Commit Graph

63 Commits (fb2d0029d8b7c9d7461db7215a3d6ed674e4c6b7)

Author SHA1 Message Date
Thibaut Vandervelden fb2d0029d8 Add support for 802.15.4 and 6LoWPAN 2021-10-21 01:25:12 +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 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 af4a1e6436 Add medium-ip, medium-ethernet feature flags. 2021-03-31 17:05:09 +02: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
Ruben De Smet eebd8e431a Add ethernet feature-gate as default.
Disable ethernet-related features and framing based on a feature gate.

Add a no-ethernet option to Travis.

notes:
- allow(unused) is added when not using ethernet feature
- Don't run pretty-print doctest, ethernet is optional.

Closes: #308
Approved by: whitequark
2019-10-04 22:49:54 +08:00
Astro a8f2725784 Implement IGMPv1/v2 processing.
Closes: #178
Approved by: whitequark
2018-08-01 10:26:51 +08:00
Astro 633d89b78e Add a few DHCP options
Closes: #255
Approved by: whitequark
2018-07-31 19:26:47 +08:00
whitequark 5bcb358eb5 Rename `new` method on Packet types to `new_checked`.
Fixes #195.

Closes: #254
Approved by: dlrobertson
2018-07-11 12:59:05 +08:00
Dan Robertson 8a214f3850 Add MLDv2 Repr support
Closes: #252
Approved by: whitequark
2018-07-11 10:47:52 +08:00
Dan Robertson 0563fdf921 Add MLDv2 packet parsing support to wire
Add the basics for parsing MLDv2 packets with the Icmpv6Packet structure
in the wire module.

Closes: #235
Approved by: whitequark
2018-06-23 10:53:10 +08:00
Dan Robertson 7462664954 iface: Begin parsing Hop-By-Hop extension headers
Begin add support for parsing extension headers.

Closes: #212
Approved by: whitequark
2018-05-27 16:14:29 +08:00
Dan Robertson be32144ba2 NDISC flags should be located in ndisc module
Closes: #212
Approved by: whitequark
2018-05-27 16:14:29 +08:00
Herman J. Radtke III 9403f1bf23 Add IPv6 Extension Routing Header
Fixes #160

Closes: #218
Approved by: whitequark
2018-05-23 05:51:21 +08:00
Valentin Lorentz 2afc538fd9 Add support for IPv6 to ICMP sockets.
Closes: #205
Approved by: whitequark
2018-05-10 07:12:33 +08:00
Dan Robertson 867eb1b7f8 NDISC: Improve the representation layer for NDISC
Each given NDISC packet type may only include one of a few options.
Instead of including the options in the NDISC repr as a &[u8] include
the packet types available options as `Option<T>`.

Closes: #194
Approved by: whitequark
2018-04-21 00:33:41 +08:00
Dan Robertson 13fe5734ec Add Repr support for NDISC packets
Add Representation layer support for NDISC packets.
2018-04-20 11:09:11 +00:00
Dan Robertson e97b50419f Add Packet support for NDISC packet types
Add packet layer support for NDISC packet types.

Closes: #180
Approved by: whitequark
2018-04-12 14:04:50 +08:00
Dan Robertson bca0ff638b Add NDISC Option Type to wire
Add support for NDISC options parsing in wire.

Closes: #167
Approved by: whitequark
2018-03-12 06:08:58 +08:00
Philipp Oppermann 745df22709 Create a DHCP wire module
Closes: #75
Approved by: whitequark
2018-03-12 02:29:21 +08:00
Andrew Cann cc8f45df40 Add EthernetRepr type 2018-03-11 18:17:20 +00:00
Astro 714602b948 Implement wire::igmp. 2018-03-11 18:08:08 +00:00
Herman J. Radtke III 8c9fc02f1d Add IPv6 Extension Fragment Header
Closes: #168
Approved by: whitequark
2018-02-22 15:19:18 +08:00
Herman J. Radtke III 785637957c Add IPv6 Extension Hop-by-Hop Options Header
Closes: #139
Approved by: whitequark
2018-02-18 06:30:21 +08:00
Dan Robertson e09e20df95 Add basic ICMPv6 reply
Add basic ICMPv6 handling

 - ICMPv6
   - Handle ICMPv6 echo requests
   - Send ICMPv6 error messages
     - When know listening UDP socket is found in process_udp
     - When the next header is not known
   - Update icmpv6 test to be more useful
 - ICMPv4
   - Handle one more case where we are sending too much data
2018-02-05 16:24:25 +00:00
Herman J. Radtke III 4e88b1f82f Implement IPv6 Extension Headers Pad1 and PadN. 2018-01-30 19:45:25 +00:00
Dan Robertson eb33e7f09f Add ICMPv6
Add support for ICMPv6 message types to the wire module.
2018-01-26 23:10:41 +00:00
Dan Robertson b653a6e421 Fix documentation warnings.
- There are several warnings that are thrown when running `cargo doc`. Fix
  these warnings.
- Convert all module documentation to use /*! for consistency.
2018-01-05 19:38:23 +00:00
Dan Robertson 22b048c225 Ensure ICMPv4 error replies comply with size requirements
- Add MIN_MTU constants to the IP version modules.
 - Ensure that ICMPv4 error replies comply with the size requirements
   specified in RFC 1812 § 4.3.2.3.
2018-01-05 19:21:45 +00:00
Dan Robertson 439e0a2cc1 Add the proto-ipv4 feature. 2017-12-24 13:28:59 +00:00
Dan Robertson c5c2264cdc Use hop limit instead of ttl
Use hop limit instead of ttl for method and member names.
2017-12-18 13:47:34 +00:00
Dan Robertson ee60efefd3 Add Ipv6Repr and Ipv6Packet to wire
- Add the Ipv6Repr and Ipv6Packet structures to the wire module
 - Add basic tests for the new structures
 - Update IpRepr to include the Ipv6 variant
2017-12-18 13:47:34 +00:00
whitequark 16b59eefad Style. NFC. 2017-12-16 21:45:24 +00:00
Dan Robertson b97c592671 Add IPv6 address and cidr to wire
- Add the ipv6 feature
   - Ensure a travis build with the ipv6 feature enabled.
 - Add the necessary infrastructure to wire for ipv6 support.
   - Ipv6Address
   - Ipv6Cidr
 - Add Ipv6 Address and Cidr parsing to parsers
 - Add basic tests.
2017-11-29 12:57:22 +00:00
whitequark e495544a85 Fix a naming mishap. NFCI. 2017-10-24 23:55:58 +00:00
Dan Robertson eef65d2676 Implement set_ttl for Tcp and Udp sockets
- Add the ttl member to the IpRepr
 - Add the ttl member along with setters and getters to the tcp and udp
   socket types
 - Add unit tests for the new set_ttl parameter
 - Update usage of IpRepr to include the ttl value
2017-10-24 23:02:18 +00:00
Egor Karavaev f57de10625 Implement wire::{IpCidr/Ipv4Cidr}. 2017-10-03 14:27:17 +00:00
Steffen Butzer 61cb64406d support hardware based checksum settings in during packet send/recv
- makes sure the checksum is zeroed when not emitted by software
  (This is required by some implementations such as STM32 to work properly)
2017-10-02 21:40:08 +00:00
whitequark fe6fb087e5 Move macros into their own module.
This allows us to use `enum_with_unknown` in `phy`.
2017-07-23 07:54:36 +00:00
whitequark 8b27330c8b Do not attempt to validate length of packets being emitted.
This is a form of an uninitialized read bug; although safe it caused
panics. In short, transmit buffers received from the network stack
should be considered uninitialized (in practice they will often
contain previously transmitted packets or parts thereof). Wrapping
them with the only method we had (e.g. Ipv4Packet) treated the buffer
as if it contained a valid incoming packet, which can easily fail
with Error::Truncated.

This commit splits every `fn new(buffer: T) -> Result<Self, Error>`
method on a `Packet` into three smaller ones:
  * `fn check_len(&self) -> Result<(), Error>`, purely a validator;
  * `fn new(T) -> Self`, purely a wrapper;
  * `fn new_checked(T) -> Result<Self, Error>`, a validating wrapper.

This makes it easy to process ingress packets (using `new_checked`),
egress packets (using `new`), and, if needed, maintain the invariants
at any point during packet construction (using `check_len`).

Fixes #17.
2017-06-24 11:42:32 +00:00
Egor Karavaev ca56baca65 Add `RawSocket`. 2017-06-21 03:29:31 +00:00
whitequark 4c3f454902 Add support for TCP option parsing and emission. 2017-01-27 00:33:30 +00:00
whitequark 578d7bce5f Calculate IP payload length from the total length field.
Before this commit, IP payload length was calculated by subtracting
the IP header length from the total underlying buffer length, which
fails if the underlying buffer has padding, e.g. like Ethernet
does.
2017-01-14 11:07:06 +00:00
whitequark 716a1cf7fe Fix silliness in docs. 2017-01-01 08:15:38 +00:00
whitequark bf3b62bb25 Examples for the phy layer! 2016-12-31 12:28:59 +00:00
whitequark 5bee008464 Examples for the wire layer! 2016-12-31 11:44:51 +00:00
whitequark 6b592742fd Use the correct wrapping operations on TCP sequence numbers. 2016-12-27 18:34:13 +00:00
whitequark ea78053dc1 Factor out IpRepr into the wire module. 2016-12-26 11:20:20 +00:00