Commit Graph

72 Commits (fb2d0029d8b7c9d7461db7215a3d6ed674e4c6b7)

Author SHA1 Message Date
Thibaut Vandervelden fb2d0029d8 Add support for 802.15.4 and 6LoWPAN 2021-10-21 01:25:12 +02:00
Dario Nieuwenhuis 94541ae827 socket/dhcp: add basic test 2021-10-14 23:19:30 +02:00
qiujiangkun acfa7f0b19 use micros in Instant and Duration 2021-10-05 22:33:58 +02:00
Thibaut Vandervelden 82a62327ba Fix clippy because of MSV change 2021-09-16 19:44:26 +02:00
Thibaut Vandervelden 8ce629257a Remove trailing commas in macros
This is going to become a hard error in future releases of the compiler.
2021-08-19 12:07:56 +02:00
Dario Nieuwenhuis 98fe17890a rustfmt 2021-06-27 09:31:59 +02:00
Dario Nieuwenhuis 32311b23dc Add Context struct. 2021-06-17 03:20:58 +02:00
Dario Nieuwenhuis 0d53163c55 dhcp: convert to socket 2021-04-07 19:00:36 +02:00
Dario Nieuwenhuis d64c8593f0 Add defmt logging support 2021-04-01 01:30:47 +02:00
Niclas Hoyer ad7795f996 Use #[non_exhaustive] instead of manual variant 2021-01-09 02:06:00 +01:00
Dario Nieuwenhuis c09ca370b2 Simplify Socket lifetimes 2021-01-09 01:59:02 +01:00
Dario Nieuwenhuis 2ea2b7ff6b tcp: add Delayed ACK 2021-01-07 00:21:55 +01:00
Dario Nieuwenhuis 88256dbdcf Update to Rust 2018. Fixes #271 2020-12-27 17:54:56 +01:00
Dario Nieuwenhuis 4e11070ff4 Async/await waker support. 2020-12-27 17:31:49 +01:00
Alex Crawford c9f57150a8 Dereference match expressions to clean up patterns
These were flagged by `cargo clippy`:

    warning: you don't need to add `&` to all patterns
2020-12-26 10:32:51 -08:00
Ole Martin Ruud 9533e3ac17 Update the docstrings of PollAt
Closes: #214
Approved by: whitequark
2018-05-18 00:40:47 +08:00
Ole Martin Ruud 9694949172 Add conditional compile attr to `is_ingress`
Closes: #216
Approved by: whitequark
2018-05-17 06:17:47 +08:00
Ole Martin Ruud 0c59e3f5f9 Implement new type for `poll_at`
Change return-type for `poll_at` for sockets to be a `PollAt` instead of
the former `Option<Instant>`.

Closes: #216
Approved by: whitequark
2018-05-17 06:17:47 +08:00
Valentin Lorentz 2afc538fd9 Add support for IPv6 to ICMP sockets.
Closes: #205
Approved by: whitequark
2018-05-10 07:12:33 +08:00
whitequark 3d12690009 Use storage::PacketBuffer for implementing socket::IcmpSocket.
This substantially increases its space efficiency.
2018-02-22 12:23:35 +00:00
whitequark 9353c37a62 Use storage::PacketBuffer for implementing socket::RawSocket.
This substantially increases its space efficiency.
2018-02-22 12:05:36 +00:00
whitequark c474d0c32e Factor out storage::PacketBuffer from socket::UdpSocket. 2018-02-22 11:34:58 +00:00
Philipp Oppermann ed2dcaaff9 Use separate metadata and payload buffers for UDP sockets.
Co-authored-by: Dan Robertson <danlrobertson89@gmail.com>
2018-02-22 06:33:11 +00:00
Dan Robertson 9747733dd7 Use time types in socket
Use the time types (Instant and Duration) in the socket modules instead
of a simple u64.

Closes: #141
Approved by: whitequark
2018-02-16 10:44:03 +08:00
Alex Crawford 066d42c0e0 Clean up dispatch_socket!() syntax
This modified syntax is meant to more closely resemble standard Rust.
2018-01-08 07:44:15 +00:00
Dan Robertson b653a6e421 Fix documentation warnings.
- There are several warnings that are thrown when running `cargo doc`. Fix
  these warnings.
- Convert all module documentation to use /*! for consistency.
2018-01-05 19:38:23 +00:00
Dan Robertson 439e0a2cc1 Add the proto-ipv4 feature. 2017-12-24 13:28:59 +00:00
whitequark 8dd9bdeaad Trace neighbor discovery status on a per-socket basis.
This avoids delaying the first packets for new neighbors by
(at least) the ARP cache silence time, or potentially even
indefinitely.
2017-12-18 11:06:24 +00:00
whitequark 98a3ec8c3a Limit the rate at which sockets will request neighbor discovery.
The rate of emission of neighbor discovery packets is already
limited at the level of the entire neighbor cache, but poll()
would uselessly spin until the answer arrives (if ever).
2017-11-22 07:20:31 +00:00
whitequark 6c83936872 Extract socket handle into a new SocketMeta structure.
This paves way for adding more metadata apart from handles,
such as caches and so on.

This commit also removes SocketHandle::EMPTY in favor of
SocketHandle::default() since they are functionally identical.
2017-11-22 03:50:09 +00:00
Dan Robertson adb5014780 Add ICMP sockets
- Add support for ICMP sockets
 - Add tests for ICMP sockets
 - Rename proto-<type> features to socket-<type>
 - Update documentation
2017-11-09 00:08:24 +00:00
whitequark d9fa7f6bc6 Rename proto-* features back to socket-*.
A proto-* feature does not make sense for ICMP, where the protocol
is always enabled, but sockets, not.
2017-11-06 09:51:03 +00:00
whitequark d37f4ef254 Use a much more sensible method naming for SocketRef. 2017-10-25 02:16:23 +00:00
whitequark 103fff9233 Expose wrapping and unwrapping of SocketRefs. 2017-10-25 01:28:59 +00:00
whitequark a9a00baa49 Rename Cargo features: socket-* → proto-*. 2017-10-25 00:20:40 +00:00
Egor Karavaev 19b1b764ed Implement a SocketRef smart pointer to detect state changes. 2017-10-05 03:44:20 +00:00
whitequark 52600cd521 Replace "socket debug identifiers" with just socket handles.
This is basically a rename that now calls an apple an apple,
except user code can no longer change it. It's not obvious if
user code getting the socket handle from the socket is very useful,
but it's not harmful either, so why not.
2017-10-05 03:02:41 +00:00
whitequark 4826d37c45 Allow disabling any of: raw, TCP or UDP sockets. 2017-09-25 00:20:22 +00:00
whitequark 996389d653 Compute soft deadline in poll() and use nonblocking sockets.
Before this commit, anything that touched RawSocket or TapInterface
worked partly by accident and partly because of a horrible crutch
that resulted in massive latencies as well as inevitable packet loss
every time an ARP request had to be issued. Also, there was no way
to use poll() other than by continuously calling it in a busy loop.

After this commit, poll() indicates when the earliest timer expires,
and so the caller can sleep until that moment (or until packets
arrive).

Note that there is a subtle problem remaining: every time poll()
is called, every socket with a pending outbound packet whose
IP address doesn't correspond to a MAC address will send a new
ARP request, resulting in potentially a whole lot of such requests.
ARP rate limiting is a separate topic though.
2017-08-29 19:47:11 +00:00
whitequark 379bc60924 Get rid of unused arguments in Socket::{process,dispatch}.
I've left those "for consistency" but it just implies data
dependencies where there are none, and bloats signatures.
2017-08-28 04:14:25 +00:00
whitequark 760174048d Get rid of IpPayload and indirection in Socket::dispatch.
This was just completely pointless, and only served to obfuscate
the data path and make testing harder.
2017-08-28 03:56:34 +00:00
whitequark 1d01189278 Use FnOnce, not FnMut, in Socket::dispatch() functions.
There was never any reason to use FnMut and this significantly
simplifies the job of the borrow checker.
2017-08-28 00:59:33 +00:00
whitequark be0854127a Remove unused imports. 2017-07-30 01:09:14 +00:00
whitequark 8d8a4ea583 Get rid of Result<_, ()>.
The use of this type has several drawbacks:
  * It does not allow distinguishing between different error
    conditions. In fact, we wrongly conflated some of them
    before this commit.
  * It does not allow propagation via ? and requires manual use
    of map_err, which is especially tiresome for downstream code.
  * It prevents us from expanding the set of error conditions
    even if right now we have only one.
  * It prevents us from blanket using Result<T> everywhere
    (a nitpick at most).

Instead, use Result<T, Error> everywhere, and differentiate error
conditions where applicable.
2017-07-27 13:55:47 +00:00
whitequark 83c41fd760 Simplify impls of AsSocket. 2017-07-24 17:00:00 +00:00
whitequark 2c1e234b91 Remove Socket::{process,dispatch} from public interface.
These no longer have to be public, since our required Rust version
has pub(crate). In addition Socket::process is not used at all.
2017-06-29 15:56:03 +00:00
whitequark adc51fab7f Actually export socket::SocketSetItem publicly.
It was unintentionally left unnameable. Fixes #14.
2017-06-21 03:57:13 +00:00
Egor Karavaev ca56baca65 Add `RawSocket`. 2017-06-21 03:29:31 +00:00
whitequark 1d46ccf432 fn Device::mtu() -> usize → Device::limits() -> DeviceLimits 2017-03-07 11:10:26 +00:00
whitequark bc1d65ea89 Send the TCP MSS option. 2017-01-27 02:56:27 +00:00