Commit Graph

162 Commits (88256dbdcfc3b284f5533e5aa2969bf5061db22a)

Author SHA1 Message Date
Dario Nieuwenhuis 88256dbdcf Update to Rust 2018. Fixes #271 2020-12-27 17:54:56 +01:00
Alex Crawford c9f57150a8 Dereference match expressions to clean up patterns
These were flagged by `cargo clippy`:

    warning: you don't need to add `&` to all patterns
2020-12-26 10:32:51 -08:00
Alex Crawford d217c81e5d Remove explicit calls to as_ref/as_mut
These were flagged by `cargo clippy`:

    warning: this call to `as_ref` does nothing
    warning: this call to `as_mut` does nothing
2020-12-26 10:27:32 -08:00
Thales Fragoso 561708c34f Merge lookup and lookup_pure methods 2020-08-17 04:44:58 +00:00
Thales Fragoso 1e5de8d42c Only limit the neighbor cache rate after sending a request packet
Prior to this change, the neighbor cache would get limited even when the
device failed to process our arp packet, which could put the socket in
the waiting state in the next poll.

This change only limits the cache rate if the device successfully
consumed our packet.
2020-08-17 04:44:58 +00:00
Thales Fragoso 24e4868761 Allow for ARP retry during egress 2020-08-10 22:06:06 -03:00
Scott Mabin 287e4f2814 raw_socket: gracefully handle packet truncation errors 2019-10-08 23:55:48 +00:00
Astro 49f638e2d2 Implement DHCPv4 client + example.
Closes: #186
Approved by: whitequark
2019-05-14 00:37:43 +08:00
Astro 69bc2de64c process_ipv4(): stub handled_by_raw_socket in absence of feature="socket-raw"
Closes: #295
Approved by: whitequark
2019-05-09 03:45:07 +08:00
Astro 1276234e98 Partially revert "Suppress ICMP error replies […]", still allow reception by other sockets.
This reverts commit f56666a26722c4f4f962937119d71792b51c396e.

Adds another test case.

Closes: #295
Approved by: whitequark
2019-05-09 03:45:07 +08:00
Astro a009e0ad9d Suppress ICMP error replies for packets that are accepted by raw sockets.
Closes: #293
Approved by: whitequark
2019-05-01 10:22:52 +08:00
Astro ebf449340b test_icmp_reply_size: fix for ipv4-only case
Closes: #292
Approved by: whitequark
2019-05-01 10:11:50 +08:00
Andreas Molzer 8c3bdf907b Allow access to phy-device in ethernet
Adds accessor functions to the device implementing the phy::Device trait
within an ethernet interface. The intent is to allow access to read-only
methods such as gathering of device statistics or other diagnostics
while the interface is running. The interface does not hold any internal
invariants on the device, so that a mutable accessor can be added as
well.

Closes: #289
Approved by: whitequark
2019-04-26 20:30:20 +08:00
Adam Greig 59f5cbbe64 Fix IPv4 broadcast handling
A regression meant broadcast IPv4 packets were ignored. Restore
handling those packets and also reply to broadcast ICMPv4 echo requests.

Closes #287.

Closes: #288
Approved by: whitequark
2019-04-15 01:57:17 +08:00
Chris Branch 8ef6637b0b Implement Any-IP feature
Any-IP is the capability to accept packets locally even when the
destination address is not configured on any interface. This lets
a service bind to an entire subnet of addresses and is particularly
useful in anycast deployments.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4465b469008bc03b98a1b8df4e9ae501b6c69d4b
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ab79ad14a2d51e95f0ac3cef7cd116a57089ba82

This feature is not available for IPv6 as it would be a nop: the current
IPv6 handler doesn't filter packets by the interface's IP address(es).

Closes: #276
Approved by: whitequark
2019-03-19 05:47:29 +08:00
Astro a8f2725784 Implement IGMPv1/v2 processing.
Closes: #178
Approved by: whitequark
2018-08-01 10:26:51 +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 82f822930c Move more iface tests to test ipv6
Closes: #249
Approved by: whitequark
2018-06-24 15:24:37 +08:00
jD91mZM2 3d141489a2 Fix impossible lifetime bounds
Using Routes<'static> used to make these functions impossible because it created a reference that needed to be valid for the static lifetime

Closes: #243
Approved by: dlrobertson
2018-06-19 21:14:20 +08:00
Valentin Lorentz 728ae3fbb5 Add support for arbitrarily many routes instead of only gateways.
Closes: #219
Approved by: whitequark
2018-06-10 05:31:08 +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
Ole Martin Ruud 0c59e3f5f9 Implement new type for `poll_at`
Change return-type for `poll_at` for sockets to be a `PollAt` instead of
the former `Option<Instant>`.

Closes: #216
Approved by: whitequark
2018-05-17 06:17:47 +08:00
Valentin Lorentz 2d716883b6 Add support for IPv6 gateways.
Closes: #207
Approved by: dlrobertson
2018-05-14 09:39:39 +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 bed3d8bd4b Add Address Resolution for IPv6
Add Address Resolution via NDISC for IPv6.

Closes: #196
Approved by: whitequark
2018-05-07 23:49:56 +08:00
Dan Robertson 010e55beed Fix ICMPv6 checksum function
The ICMPv6 checksum calculation requires the pseudo header.

Closes: #196
Approved by: whitequark
2018-05-07 23:49:56 +08:00
whitequark 485b46a5e6 fn PacketMetadata::empty() → const PacketMetadata::EMPTY.
Fixes #181.
2018-03-24 03:23:37 +00:00
Dan Robertson 826ba29b72 Add has_solicited_node to EthernetInterface
- Add a function to EthernetInterface useful for determining if a
   received packet with the source address being a solicited node
   address is the solicited node address for an IPv6 address assigned
   to the interface.
 - Add SOLICITED_NODES_PREFIX to Ipv6Cidr
 - Fix some nits

Closes: #175
Approved by: whitequark
2018-03-04 03:23:12 +08:00
Astro e3e9d9d4c5 Allow broadcast/multicast traffic to UDP sockets
Closes: #173
Approved by: whitequark
2018-03-03 06:16:40 +08:00
Astro cd00d63c51 Add multicast capability to lookup_hardware_addr()
Closes: #172
Approved by: whitequark
2018-03-02 08:33:37 +08:00
whitequark 3d12690009 Use storage::PacketBuffer for implementing socket::IcmpSocket.
This substantially increases its space efficiency.
2018-02-22 12:23:35 +00:00
whitequark c474d0c32e Factor out storage::PacketBuffer from socket::UdpSocket. 2018-02-22 11:34:58 +00:00
Philipp Oppermann ed2dcaaff9 Use separate metadata and payload buffers for UDP sockets.
Co-authored-by: Dan Robertson <danlrobertson89@gmail.com>
2018-02-22 06:33:11 +00:00
Dan Robertson 9747733dd7 Use time types in socket
Use the time types (Instant and Duration) in the socket modules instead
of a simple u64.

Closes: #141
Approved by: whitequark
2018-02-16 10:44:03 +08:00
Dan Robertson e0b48caca3 Update phy mod to use new time types
Update everything but the socket types to use the new time types instead
of a basic u64

Closes: #141
Approved by: whitequark
2018-02-16 10:44:03 +08:00
Dan Robertson 1f9e14de71 Update iface and phy_wait to use new time types
Update the EthernetInterface poll functions to use Instant and Duration
instead of a simple u64 value.

Closes: #141
Approved by: whitequark
2018-02-16 10:44:02 +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
whitequark 0ddd4c9001 Route broadcast packets directly.
Closes #120.
2018-01-15 11:56:14 +00:00
Dan Robertson 4a78b02fcf Add process_ipv6 to EthernetInterface
- Add `process_ipv6` to `EthernetInterface`
 - Add basic test for `process_ipv6`
 - Add `deny(unused)` if either proto-ipv4 or proto-ipv6 is enabled
 - Add `cfg`s where needed to avoid compile time errors due to the above
2018-01-15 11:54:26 +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
whitequark 7c0bae7d36 Simplify. NFC. 2017-12-27 00:09:50 +00:00
Dan Robertson 439e0a2cc1 Add the proto-ipv4 feature. 2017-12-24 13:28:59 +00:00
whitequark 85487bf3bc EthernetInterface::set_ipv4_gateway should panic on non-unicast addrs. 2017-12-22 13:07:11 +00:00
whitequark f1a7fbe973 Split `poll_at`/`poll_delay` out of `poll`.
The previous model was flawed. Consider the following case:
  * The main loop looks as follows (pseudocode):
      loop {
        let _ = (tcp:1234).read_all()
        wait(iface.poll())
      }
  * The remote end is continuously transmitting data and at some
    point fills the window of (tcp:1234), stopping the transmission
    afterwards.
  * The local end processes the packets and, as a part of egress
    routine, emits an ACK. That also updates the window, and
    the socket's poll_at() routine returns None, since there is
    nothing to transmit or retransmit.
  * The local end now waits indefinitely even though it can start
    processing the data in the socket buffers right now.
2017-12-22 12:59:52 +00:00
whitequark 8b6050f711 Clean up our feature story and more aggressively test features. 2017-12-22 08:54:58 +00:00
whitequark bf53b73e09 Fix accidental conversion of a slice to owned.
This broke #![no_std] builds.
2017-12-18 15:03:38 +00:00
whitequark 946376897e Make EthernetInterfaceBuilder::ip_addrs optional.
It's perfectly reasonable to have an interface with no addresses
assigned to it.
2017-12-18 13:53:27 +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
Dan Robertson 4a98190f9b Replace EthernetInterface::new with EthernetInterfaceBuilder. 2017-12-18 13:29:29 +00:00