Commit Graph

261 Commits (master)

Author SHA1 Message Date
Emil Fresk 089443674b Support defmt version 0.3 with new MSRV 2021-11-16 08:32:27 +01:00
Thibaut Vandervelden a9925b5957 Add fuzz tests for 6LoWPAN_IPHC and 6LoWPAN_UDP
Adding fuzz tests for 6LoWPAN_IPHC and 6LoWPAN_UDP.
Some bugs were found.

Ran for 10 minutes.
2021-11-05 10:05:12 +01:00
Thibaut Vandervelden 76f1b81182 Add fuzzing for IEEE802.15.4
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.
2021-11-04 12:01:03 +01:00
Alexandra Sandulescu d14d238422 fuzz: DHCP header parser 2021-10-28 10:37:57 +02:00
Thibaut Vandervelden e9ec0aefa8 ieee802154: add getters for security features 2021-10-26 16:58:45 +02:00
Thibaut Vandervelden 6a08f958b2 ieee802154: remove unused CRC 2021-10-26 16:16:24 +02:00
Thibaut Vandervelden be14fbb2a6 ieee802154: update documentation 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 ecc45dbeef Remove IpRepr::Sixlowpan 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 4b9d39706c Set flags to zero, because buffer could be reused. 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden bff2330309 Remove some more todos 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 061fcf880f Defmt for RawHardwareAddress 2021-10-21 01:25:13 +02:00
Thibaut Vandervelden 6e63433ab3 Set HardwareAddress behind feature flag
When there is no medium in the feature flags, then there is no
HardwareAddress.
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
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 a0b9fb6ebc ipv6: fix Solicited Node address calculation 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
Marc-André Lureau aa10b5250a wire: add From<Address> for ::std::net::IpAddr
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-10-19 02:27:49 +02:00
Dario Nieuwenhuis 6d37633353 wire/dhcp: use bitflags for the FLAGS field. 2021-10-14 14:02:27 +02:00
Dario Nieuwenhuis fc5559069c wire/dhcp: BROADCAST flag is MSB (0x8000), not LSB (0x0001).
This fixes DHCP on Linksys WRT1900AC. With 0x0001, it would not reply to
DISCOVERs at all, probably because seeing an unknown reserved flag being set.
With 0x8000, it works fine.
2021-10-14 13:59:16 +02:00
Thibaut Vandervelden 82a62327ba Fix clippy because of MSV change 2021-09-16 19:44:26 +02:00
Thibaut Vandervelden 6a27136047 Fix clippy lints 2021-08-18 16:05:50 +02:00
Anton Romanov 7a83e7d69b dhcpv4: Emit DNS servers in repr 2021-06-28 20:03:39 +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 60a299bcc2 tcp: add Nagle's Algorithm. 2021-06-17 04:44:13 +02:00
Dario Nieuwenhuis b9477f25bc wire/dhcp: Simplify how options are emitted. 2021-05-29 01:44:27 +02:00
Dario Nieuwenhuis ea8d2ae7f4 Fix u32::MAX 2021-05-29 01:32:17 +02:00
Anton Romanov 7b6b70d058 Account for lease time, router and subnet options in DhcpRepr::buffer_len 2021-05-29 01:32:17 +02:00
Dario Nieuwenhuis 284f5bc834 wire/udp: clearer HEADER_LEN usage 2021-05-28 17:47:02 +02:00
Dario Nieuwenhuis 53b62cfbad dhcp: remove 0.0.0.0s from the DNS serevr list.
tp-link routers pad the DNS server list with 0.0.0.0 to a fixed size :(
2021-04-13 18:43:23 +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 d64c8593f0 Add defmt logging support 2021-04-01 01:30:47 +02:00
Dario Nieuwenhuis af4a1e6436 Add medium-ip, medium-ethernet feature flags. 2021-03-31 17:05:09 +02:00
Ryan Summers 2851a135df Adding parsing test with lease time 2021-03-12 17:36:43 +01:00
Ryan Summers 39c3e7ef1f Updating control logic 2021-03-12 17:28:00 +01:00
Ryan Summers 647e27ed2b Adding DHCP lease management 2021-03-12 14:03:51 +01:00
whitequark 9f0213765c Simplify enum_with_unknown! macro. 2021-03-12 06:15:34 +00:00
Nathan K. Zhinn 4ac265fb46 Fix BPF header length on OpenBSD.
The actual header length may be larger than the bpf_hdr struct due to aligning:
37ecb4d066/sys/net/bpf.c (L1649)
8f02f2a044/bsd/net/bpf.c (L3580)

Tests are only valid for 32 and 64 bit architectures. I did not bother
guarding them with additional cfg flags.
2021-03-01 04:37:37 +00:00
Ben Stabler 335099aa26 Silence clippy lint for const assert work-around, remove const where using features not yet stable in 1.40 2021-02-11 23:10:35 -08:00
Ben Stabler 851d26aaa6 Make wire/ipv4 functions const where possible. 2021-02-11 22:49:33 -08:00
Alex Crawford 0cf0a7e386 Clean up clippy warnings about if-else blocks
This de-duplicates and (hopefully) simplifies a few if-else blocks. The
others were given an exception because I thought they were more readable
as is. I've verified that these changes don't result in larger binaries.
2021-01-10 14:30:31 -08:00
Niclas Hoyer ad7795f996 Use #[non_exhaustive] instead of manual variant 2021-01-09 02:06:00 +01:00
Dario Nieuwenhuis 45df367d7e More clippy fixes. 2021-01-04 01:19:20 +01:00
Alex Crawford 27232041e7 Silence a few warnings from clippy
These were flagged by `cargo clippy`:

    warning: the operation is ineffective. Consider reducing it to `number`
    warning: this function has too many arguments (8/7)
    warning: you should consider adding a `Default` implementation for
             `phy::loopback::Loopback`

I like the code better as it is.
2020-12-28 23:09:53 -08:00
Alex Crawford 8a961b7d7c Use iterators instead of manually looping
These were flagged by `cargo clippy`:

    warning: the loop variable is used to index

I've verified that this doesn't increase the size of consuming binaries.
Pretty impressive. I tested this with a project that uses the following
features: ethernet, proto-dhcpv4, socket-tcp.
2020-12-28 22:28:07 -08:00
Alex Crawford fff5926210 Clean up a couple of if-blocks
These were flagged by `cargo clippy`:

    warning: this `else { if .. }` block can be collapsed
2020-12-28 22:27:24 -08:00