188 Commits

Author SHA1 Message Date
Thibaut Vandervelden
099f5f7c2a Don't use Option for neighbor cache anymore 2023-04-04 18:54:33 +02:00
Ruben De Smet
dc3c44410b Remove extern crate calls 2023-03-07 11:07:45 +01:00
Dario Nieuwenhuis
5740b76574 iface: remove builder. 2023-01-19 14:43:15 +01:00
Dario Nieuwenhuis
b73c943eee iface: remove lifetimes. 2023-01-19 14:43:15 +01:00
Dario Nieuwenhuis
c015cc358e iface: use owned frag buffer, remove frag from builder. 2023-01-19 13:33:49 +01:00
Dario Nieuwenhuis
050731b519 iface: remove all uses of crate::{Error, Result}; 2023-01-14 21:57:36 +01:00
Dario Nieuwenhuis
0102a4b741 phy: make consume infallible, move timestamp to receive/transmit. 2023-01-14 21:57:36 +01:00
Dario Nieuwenhuis
af115a5769 packet assembler: simplify data structure and api. 2023-01-02 00:28:38 +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
Dario Nieuwenhuis
9beb57a992 iface: use heapless Vec for routes.
Lookup is O(n) now. However, it previously did 32 (or 128 for ipv6!)
map lookups. Since the route table typically doesn't have that many
routes, the new code is likely faster even if it's O(n).
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
aec718a08f Fix clippy and rustfmt errors 2022-12-20 13:21:28 +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
13cc7f83ac Clippy fixes. 2022-11-06 21:45:21 +01:00
Dario Nieuwenhuis
4300e7cc3b GAT-based Device trait.
The current `'a` lifetime in the `Device` trait is essentially a workaround for lack of GATs.
I'm just experimenting how this would look like, it'll have to wait until GATs are stable to go in.

The main benefit is structs implementing `Device` can now borrow stuff. This wasn't possible
before because the `for<'d> T: Device<'d>` bounds would essentially imply `T: 'static`.
2022-11-06 21:18:02 +01:00
Benjamin Brittain
35cea49b8a Adds DNS query type to example 2022-09-22 10:10:05 -04:00
bors[bot]
70915655b3 Merge #634
634: IPv4 fragmentation (for outgoing) r=Dirbaio a=thvdveld

Almost ready for review, just need to clean up some things 🎉 

Co-authored-by: Thibaut Vandervelden <thvdveld@vub.be>
2022-09-21 21:12:23 +00:00
Thibaut Vandervelden
fe26f462dd Better names for buffers (#653) 2022-09-21 23:11:35 +02:00
Thibaut Vandervelden
297d90b0ff IPv4 fragmentation (outgoing) 2022-09-21 23:11:35 +02:00
Johannes Draaijer
03e830b886 DHCPv4: use a Vec to store DNS server addresses instead of an array of options 2022-09-06 09:28:55 +02:00
Dario Nieuwenhuis
ecb4cbc545 Clippy fixes. 2022-08-06 00:00:19 +02:00
Thibaut Vandervelden
f04a44d6bc Update 6lowpan example 2022-06-16 15:44:09 +02:00
Thibaut Vandervelden
3065959c70 Reassemble incomming IPv4 packets. 2022-06-09 09:51:29 +02: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
Thibaut Vandervelden
f3310e63f4 refactor 6LoWPAN fragmentation 2022-06-01 12:27:11 +02:00
AntoonBeres
c11e4bb6a7 added sixlowpan fragmentation benchmark 2022-05-24 10:24:53 +02:00
Thibaut Vandervelden
adf56a1701 sixlowpan: add fragmentation logic in interface 2022-05-23 15:44:20 +02:00
Dario Nieuwenhuis
43329e696e socket/dns: add own error enums for public API. 2022-05-20 23:36:36 +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
ea0d4d7f46 dns: allow specifying name in human-friendly format. 2022-05-19 21:36:13 +02:00
Dario Nieuwenhuis
ce1f0169f8 dns: use Vec for server address list. 2022-05-19 19:54:38 +02:00
Dario Nieuwenhuis
da1a2b2df0 socket: add DNS 2022-05-19 19:13:57 +02:00
Dario Nieuwenhuis
eb41d077e0 Remove IpAddress::Unspecified, assign src addr in sockets.
This continues work started in #579, with the goal of "remove unspecified variants from wire".

"unspecified" variants are bad, they've been a source of bugs in the past. The issue with them is that
depending on the context it may or may not make sense for the value to be unspecified.
It's better to not have them, and then use Option only where the value can really be unspecified.

This removes lots of `Address::Unspecified => unreachable!()` and similar match arms, which shows the
unreachable variant was actively unwanted in many places.

This fixes the "unspecified src addr" panic:

- Picking src addr is now the resposibility of the sockets, not the interface. All sockets now emit IpReprs with properly assigned src addr.
- Removed the `assert!(!ip_repr.src_addr().is_unspecified());`. This assert is WRONG even if
  now sockets pick the source address, because there ARE cases where we indeed want to send a
  packet with zero src addr, for example in DHCP.
2022-05-19 04:38:55 +02:00
Alexandra Sandulescu
9b5abf0e88 Update dependencies: ignore those updated through caret spec
* allow logging environment overwrite by RUST_LOG
2022-01-28 18:49:18 +01:00
Alexandra Sandulescu
842c875f92 Update dependencies 2022-01-28 12:58:24 +01:00
Dario Nieuwenhuis
3644b94b82 rand: use simple PRNG owned by Interface, sockets access it through Context. 2021-11-30 18:36:17 +01: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
f67f024882 Use one PAN ID for source and destination
Also check for the correct destination PAN id when receiving a frame (as
discussed). Linux does this as well.
However, hardware implementations also can drop those packets.
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis
b74cd58036 example/6lowpan: expand readme, do not use monitor interface.
Using a raw socket on `monitor0` causes weird results: packets we receive
include FCS, packets we send are parsed as if they didn't have FCS, except
by wireshark which always expects a FCS??

Turns out the sane way is to use raw sockets on normal `wpanX` interfaces,
in which case all packets we send/receive are without FCS.
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis
68e25a29c3 Add RawHardwareAddress, use it in wire ndisc.
This avoids wire needing to know what medium we're on.
2021-10-21 01:25:13 +02:00
Thibaut Vandervelden
3d782f19cd Add support for 802.15.4 and 6LoWPAN 2021-10-21 01:25:12 +02:00
Dario Nieuwenhuis
67c3b3b7b1 Add rand module.
On `std` targets, `OsRng` is used by default. The user can supply a custom impl
by enabling the `rand-custom-impl` Cargo feature and using the `rand_custom_impl!()` macro.
Specifying a custom impl is mandatory when `std` is not enabled.
2021-10-11 20:53:04 +02:00
qiujiangkun
a4275a5966 use micros in Instant and Duration 2021-10-05 22:33:58 +02:00