If the length field indicates a lenght bigger than the actual data that
it is carying, then the packet is just wrong. Emitting such a packet is
also not allowed. We now also parse the IPv6 header in an NDISC
redirected packet and check that the length is correct.
Signed-off-by: Thibaut Vandervelden <thvdveld@vub.be>
This brings the code to a more modern Rust style.
- Dstructuring is not so necessary nowadays, with the borrow checker being smarter, especially around partial captures in closures.
- "ref" is barely needed anymore, with [match ergonomics](https://rust-lang.github.io/rfcs/2005-match-ergonomics.html).
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`.
Because IEEE802.15.4 uses a lot of compression in its frame, fuzzing it
is maybe a good idea. Adding this fuzz target showed that some frame
methods were panicking. `check_len` now checks if accessors will panic
or not.
I ran the fuzzer for about 15 minutes and nothing showed up.
- 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.