Commit Graph

42 Commits (8c43fdd4433a90370b14d4f91e000b9f36b194a5)

Author SHA1 Message Date
Dario Nieuwenhuis 8c43fdd443 Remove braces that were previously needed to workaround SocketRef borrow issues. 2021-11-03 23:32:32 +01:00
Dario Nieuwenhuis f8cc1eacbe 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 c08dd8dcf6 iface: own the SocketSet instead of borrowing it 2021-11-03 23:32:32 +01:00
Dean Li 1ce91fc206 arp: flush neighbor cache after IP update
Related to #543
2021-10-31 11:42:18 +08:00
Dario Nieuwenhuis 8922895a8b Fix some comments. 2021-10-21 01:31:15 +02:00
Thibaut Vandervelden 19d9cd46ca ieee802154: log when we drop a frame 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden ce9145dd62 ieee802154: Correct filtering of PAN id 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 91d73273d8 ieee802154: ignore frames with types other than Data 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden ecc45dbeef Remove IpRepr::Sixlowpan 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 80ba5a2e2d Send ICMP unreachable when no UDP socket is found 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden b068a856e5 Use `net_debug` and drop instead of `todo!` 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 1154390307 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 7c35a061a4 ieee80154: process packets without the FCS.
We assume the FCS is checked by lower layers or by hardware.

- Makes it consistent with Ethernet mediums, where we don't handle the FCS either.
- Linux ieee802154 raw sockets send/receive packets without the FCS.
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis c9712939fb 6lowpan: do not fill neighbor cache from random packets
Equivalent of 6210612be047ee706ac729015cdbc2581e6ae9a3 for 6lowpan
2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis 3269ce6124 wire: remove HardwareAddress::BROADCAST 2021-10-21 01:25:13 +02:00
Dario Nieuwenhuis b4764e4973 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 fb2d0029d8 Add support for 802.15.4 and 6LoWPAN 2021-10-21 01:25:12 +02:00
Dario Nieuwenhuis b4d7819769 arp: ignore ARP packets that are not REQUEST or RESPONSE. 2021-10-06 04:12:33 +02:00
Dario Nieuwenhuis 975ae59eab arp; reject packets with source address not in our network.
Fixes #536
2021-10-06 04:12:20 +02:00
Dario Nieuwenhuis 271ec5d26b arp: fill cache only for ARP packets directed at us.
- Mirrors what Linux does, so will hopefully reduce problems in broken networks.
- it can actually increase performance: for small ARP caches, it'll reduce the
  amount of entries that we're not going to use, increasing the chances of the
  ones that we actually use to stay in the cache.

Fixes #537
2021-10-06 04:12:17 +02:00
Dario Nieuwenhuis f98a89ba61 arp: Do not fill cache from random packets.
On paper this looks great, and in a sane network it should work.
However the world out there is full of horribly broken, screwed up
networks, which *of course* ruin this.

I've seen a customer's network where the router is IP 192.168.1.1,
MAC addr xx:03. However, every 1 minute the router broadcasts some
"mikrotik discovery" UDP garbage with source IP 192.168.1.1, source MAC
addr xx:02 (one less!). This accidentally poisons smoltcp's ARP cache,
which then sends all traffic for the default gateway to xx:02, which
unsurprisingly blackholes it.

And, of course, the broadcast is every 1min and the ARP cache lifetime
is 1min. This means the cache is almsot all the time poisoned, and the
smoltcp device barely works. Fantastic.

Screw you mikrotik.
2021-10-06 03:12:53 +02:00
Dario Nieuwenhuis 7e4180b503 Fix assert with any_ip + broadcast dst_addr. Fixes #533 2021-09-26 21:45:46 +02:00
Thibaut Vandervelden 82a62327ba Fix clippy because of MSV change 2021-09-16 19:44:26 +02:00
Thibaut Vandervelden 8adbd1b875 cargo fmt 2021-08-18 16:05:50 +02:00
Thibaut Vandervelden 6a27136047 Fix clippy lints 2021-08-18 16:05:50 +02:00
qiujiangkun 2a574fbca6 various clippy fix 2021-06-27 10:45:57 +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
Ryan Summers e27e3254f4 Fixing clippy 2021-05-31 17:58:20 +02:00
Ryan Summers 0bb9fc90f0 Simplifying loop logic 2021-05-31 17:42:01 +02:00
Ryan Summers 44add57e8e Removing unneeded changes 2021-05-31 17:39:30 +02:00
Ryan Summers f790f59088 Reverting phy changes 2021-05-31 17:36:26 +02:00
Ryan Summers 8474a1b1e4 cleaning up implementation 2021-05-31 17:33:52 +02:00
Ryan Summers 95829934db Fail-free ingress 2021-05-31 17:30:45 +02:00
Ryan Summers 8d4e255090 Adding prototype fix for fail-free ingress 2021-05-31 17:25:04 +02:00
Dario Nieuwenhuis 0d53163c55 dhcp: convert to socket 2021-04-07 19:00:36 +02:00
Dario Nieuwenhuis ab47db24e0 udp: do not include payload in UdpRepr
This makes UdpRepr work like IpRepr, where it only emits the header, and the user
must emit the payload.

This makes it easier to emit UDP packets with payloads that come from protocol-specific
reprs, like DHCP and in the future DNS.
2021-04-07 14:49:46 +02:00
Dario Nieuwenhuis c043897327 iface: check for ipv4 subnet broadcast addrs everywhere 2021-04-07 02:23:19 +02:00
Dario Nieuwenhuis d64c8593f0 Add defmt logging support 2021-04-01 01:30:47 +02:00
Dario Nieuwenhuis b6220a04c8 Do not use DeviceCapabilities in sockets.
DeviceCapabilities contains the `medium` field, so tests had to give it a value
even if it was unused. This is impossible to do with no `medium-*` enabled, because
it makes `Medium` uninhabited (empty enum).
2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis af4a1e6436 Add medium-ip, medium-ethernet feature flags. 2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis 9ac2cac075 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