26 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
e6b9a9ca2a wire: use core::net::Ipv4Addr as the ipv4 address type. 2024-10-06 22:12:49 +02:00
Dario Nieuwenhuis
34b1fa505b iface: do not require device and timestamp for multicast join/leave.
Instead of eagerly sending the join/leave packet when the user calls join/leave,
we update internal state and send the packet when the interface is polled.

Advantages:
- If the device is exhausted, the packet gets sent later instead of just failing and returning an error to the user.
- Makes the API consistent with everything else in smoltcp: operations only update internal state, poll is what sends/receives packets.
- Enables wrappers to offer simpler APIs with less generics. See https://github.com/embassy-rs/embassy/pull/3329 for an example, which is my original motivation.
2024-09-12 15:53:33 +02:00
Thibaut Vandervelden
533f103a95
pass the now time when creating the iface
Signed-off-by: Thibaut Vandervelden <thvdveld@vub.be>
2023-06-12 16:31:38 +02:00
Thibaut Vandervelden
099f5f7c2a Don't use Option for neighbor cache anymore 2023-04-04 18:54:33 +02:00
Dario Nieuwenhuis
5740b76574 iface: remove builder. 2023-01-19 14:43:15 +01:00
Dario Nieuwenhuis
050731b519 iface: remove all uses of crate::{Error, Result}; 2023-01-14 21:57:36 +01:00
Dario Nieuwenhuis
3a080d818b Clippy fixes 2023-01-02 00:20:05 +01:00
Dario Nieuwenhuis
94a52d8baf iface: use heapless LinearMap for ipv4_multicast_groups 2022-12-23 18:23:06 +01:00
Dario Nieuwenhuis
4eb49b808a iface: use heapless LinearMap for neighbor cache. 2022-12-23 18:13:03 +01:00
Davide Della Giustina
4ddb96b1b2
Increased max number of IPs from 4 to 5 because some test use 5 2022-12-20 14:04:24 +00:00
Davide Della Giustina
8cf7625cc2
ip_addrs field of an interface is now a heapless::Vec (one test still failing) 2022-12-20 12:02:10 +00:00
Dario Nieuwenhuis
9e18ca127e socket_set: add get_mut, make get immutable. 2022-06-06 02:26:45 +02:00
Dario Nieuwenhuis
d703a66d1d iface: borrow the device instead of owning it. 2022-06-06 02:26:45 +02:00
Dario Nieuwenhuis
b71ffcb6cc iface: borrow the SocketSet instead of owning. 2022-06-06 01:14:53 +02:00
Dario Nieuwenhuis
72a9ee46ce socket: reorganize module structure, with one module per protocol. 2022-05-20 02:18:00 +02:00
Dario Nieuwenhuis
78f92bcea6 wire: use own Error type. 2022-05-20 01:37:34 +02:00
Dario Nieuwenhuis
9a2093e39e Remove braces that were previously needed to workaround SocketRef borrow issues. 2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis
ef213fa772 socket: remove SocketRef.
The intent was to run custom code after the user is done modifying the socket,
for example to update a (not yet existing) port->socket map in SocketSet. However
this wouldn't work, since the SocketRef would have to borrow the SocketSet at
the same time as the Socket to be able to notify the SocketSet.

I believe such indexing can be achieved by setting a "dirty" bit *before* giving
the socket to the user, then on poll() reindexing all dirty sockets. This could
even be faster: if user gets a socket multiple times between polls, it'd be reindexed
only once.
2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis
bde881d2f9 iface: own the SocketSet instead of borrowing it 2021-11-03 23:32:32 +01:00
Thibaut Vandervelden
3d782f19cd Add support for 802.15.4 and 6LoWPAN 2021-10-21 01:25:12 +02:00
Dario Nieuwenhuis
2cb407d62a rustfmt 2021-06-27 09:31:59 +02:00
Dario Nieuwenhuis
b869449b31 Add support for TUN interfaces. 2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis
d352e151f6 Add support for IP mediums.
- Add `medium` in `DeviceCapabilities`.
- Rename EthernetInterface to Interface.
- Add support to Interface for both Ethernet and IP mediums. The medium to use is detected from `device.capabilities().medium`.
- Ethernet-only features are gated behind the "ethernet" feature, as before.
- IP features are always enabled for now.
2021-03-31 17:05:09 +02:00
Alex Crawford
1cbc38d0ea Clean up examples
These were flagged by `cargo clippy`:

    warning: you seem to be trying to use match for destructuring a
             single pattern. Consider using `if let`
    warning: called `.nth(0)` on a `std::iter::Iterator`, when `.next()`
             is equivalent
    warning: using `write!()` with a format string that ends in a single
             newline
    warning: useless conversion to the same type:
             `smoltcp::wire::Ipv4Address`
    warning: called `map(f)` on an `Option` value where `f` is a closure
             that returns the unit type `()`
    warning: returning the result of a `let` binding from a block
    warning: use of `unwrap_or` followed by a function call
2021-01-04 10:39:27 -08:00
Dario Nieuwenhuis
1e40b934bf Update to Rust 2018. Fixes #271 2020-12-27 17:54:56 +01:00
Astro
58a54730db Implement IGMPv1/v2 processing.
Closes: #178
Approved by: whitequark
2018-08-01 10:26:51 +08:00