522 Commits

Author SHA1 Message Date
whitequark
7eba669281 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
deccd469fe 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
737b387f61 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
ad56bacb56 Replace EthernetInterface::new with EthernetInterfaceBuilder. 2017-12-18 13:29:29 +00:00
whitequark
54f1147d9e Trace the TCP socket acknowledging incoming segment. 2017-12-18 12:47:42 +00:00
whitequark
3f917c1adc Fix 14185a16. 2017-12-18 11:42:55 +00:00
whitequark
14185a16bb Do not fill neighbor cache with IPs not on the same network as us.
This is pointless (`route` doesn't even check the cache in that case)
and wastes cache space.
2017-12-18 11:06:26 +00:00
whitequark
42c93b99c0 Trace neighbor discovery status on a per-socket basis.
This avoids delaying the first packets for new neighbors by
(at least) the ARP cache silence time, or potentially even
indefinitely.
2017-12-18 11:06:24 +00:00
whitequark
97d262ed54 Style. NFC. 2017-12-16 21:45:24 +00:00
whitequark
b1680368fe Rework the pretty printer to avoid superfluous trailing newlines. 2017-12-16 21:42:19 +00:00
whitequark
fe94691562 Fix clocking code in the loopback example. 2017-12-15 10:20:06 +00:00
whitequark
8d0913652a Make elaborated reasons for sending a TCP packet more precise. 2017-12-15 06:31:50 +00:00
whitequark
552b770871 Log an elaborated reason for sending a TCP packet.
Otherwise, it is hard to debug e.g. ACK loops.
2017-12-15 05:24:17 +00:00
Dan Robertson
eaaf1fa4a6 Process the Icmpv4Repr in IcmpSocket::process
- Use the Icmpv4Repr in IcmpSocket::process instead of the raw payload.
 - Update the IcmpSocket tests.
2017-12-09 00:10:09 +00:00
whitequark
30012cc3b1 Make packet dumps emitted for broken packets more useful.
Before this commit, only the outermost frame (the Ethernet one)
would be shown, which is really no help at all.
2017-12-08 07:11:08 +00:00
Dan Robertson
9bae200a8f Minor doc improvements to wire::ipv6
- Add links to the Addressing Achitecture RFC where appropriate
 - Add comments to functions where appropriate
2017-11-30 19:20:42 +00:00
Dan Robertson
7727687330 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
Jeremy Soller
d8b25cdce8 Allow receiving broadcast packets via UDP sockets. 2017-11-23 07:01:35 +00:00
Dan Robertson
0772bb0044 Remove debug println in test_evict
The println's surrounding the final cache fill in test_evict that causes
PADDR_B to be evicted are not needed.
2017-11-22 08:03:39 +00:00
whitequark
7959473308 Style. NFC. 2017-11-22 07:44:03 +00:00
whitequark
9914616893 Limit the rate at which sockets will request neighbor discovery.
The rate of emission of neighbor discovery packets is already
limited at the level of the entire neighbor cache, but poll()
would uselessly spin until the answer arrives (if ever).
2017-11-22 07:20:31 +00:00
whitequark
7937011424 Extract socket handle into a new SocketMeta structure.
This paves way for adding more metadata apart from handles,
such as caches and so on.

This commit also removes SocketHandle::EMPTY in favor of
SocketHandle::default() since they are functionally identical.
2017-11-22 03:50:09 +00:00
whitequark
e0cbe22556 Add a missing feature check. 2017-11-21 12:02:25 +00:00
whitequark
6ee44a9bae Implement eviction in neighbor cache for fixed storage size. 2017-11-21 11:53:26 +00:00
whitequark
c63dd6c580 Fix a broken macro invocation. 2017-11-21 11:06:53 +00:00
whitequark
2005e77e49 Don't build on stable for now. 2017-11-21 11:06:42 +00:00
whitequark
34c3a8c905 Rewrite the ARP cache to allow for flood protection and expiration. 2017-11-21 10:53:55 +00:00
Kai Lüke
5e2ae22302 Don't panic on TCP sequence number wrapping in debug mode. 2017-11-13 18:03:36 +00:00
Egor Karavaev
907f3659a4 Make Error::Unaddressable ignored for ICMP sockets as well. 2017-11-13 14:16:03 +00:00
Egor Karavaev
752ae033db ICMP sockets don't end ICMP packets processing. 2017-11-13 14:16:03 +00:00
Kai Lüke
86ac32539f Preserve retransmission timer for Dup-ACKs
Duplicate ACKs should not replace the retransmission timer,
but if not in retransmission, still set the keep-alive timer
as normal ACKs do.
2017-11-13 06:26:26 +00:00
whitequark
9b98dfa3d0 Fix ICMP socket documentation. NFC. 2017-11-13 04:54:49 +00:00
whitequark
401d004e28 Update README. 2017-11-10 02:02:17 +00:00
whitequark
ffcd3ab80d Style. NFCI. 2017-11-09 02:07:24 +00:00
whitequark
19790720a3 Remove impl Ord/PartialOrd for Cidr.
It's not obvious that CIDRs are ordered in any particular meaningful
way.
2017-11-09 01:50:34 +00:00
Dan Robertson
ef4af850e0 Add ICMP sockets
- Add support for ICMP sockets
 - Add tests for ICMP sockets
 - Rename proto-<type> features to socket-<type>
 - Update documentation
2017-11-09 00:08:24 +00:00
Philipp Oppermann
4ae84ab36a Store plain DeviceT instead of Managed<_> in EthernetInterface 2017-11-08 09:34:35 +00:00
whitequark
f58cc4bcbb Rename proto-* features back to socket-*.
A proto-* feature does not make sense for ICMP, where the protocol
is always enabled, but sockets, not.
2017-11-06 09:51:03 +00:00
whitequark
f239e36bf3 Reimplement {RawSocket,TapInterface}::receive correctly. 2017-11-06 09:38:44 +00:00
whitequark
fd7109b2e4 Rename a few tests. NFC. 2017-11-04 02:42:51 +00:00
whitequark
32ee91da07 Add CODE_STYLE.md. 2017-11-03 23:34:12 +00:00
Philipp Oppermann
198fe239f1 Redesign the phy::Device trait to avoid Drop impls. 2017-11-03 23:15:07 +00:00
Dan Robertson
d1d80ca121 Do not send ICMPv4 responses to broadcasts
- Do not send ICMPv4 responses for packets with a broadcast destination
   address.
   - Do not send DstUnreachable with ProtoUnreachable on receipt of a
     packet with an unknown protocol with a non-unicast destination
     address.
   - Do not send DstUnreachable with PortUnreachable on receipt of a
     UDP packet when no sockets are listening on the destination port
     and the destination address is a non-unicast address.
 - Send the correct amount of the original datagram when sending Destination
   Unreachable error responses.
   - Do not assume that a ip datagram has a payload when sending a proto
     unreachable ICMPv4 error response.
 - Add tests to iface tests.
   - Ensure ICMP error responses are correctly formed when the
     datagram has no payload.
   - Ensure ICMP error responses are correctly handled for UDP packets
     when no socket is listening on the destination port.
   - Ensure the correct amount of the original payload is returned in
     Destination Unreachable responses.
2017-11-01 06:34:10 +00:00
whitequark
0091191cce Rework TcpSocket::{send,recv} to remove need for precomputing size.
Now, these functions give you the largest contiguous slice they can
grab, and you return however much you took from it.
2017-10-31 19:24:54 +00:00
whitequark
1e18c03d34 Fix Cidr::contains_addr for zero length prefixes. 2017-10-30 08:25:32 +00:00
whitequark
1e105253f9 Do not parse an empty string as an IpAddress.
This is more likely to result in downstream confusion than not.
Let downstream code decide exactly what it wants to do with
an empty string; be conservative here.
2017-10-30 07:20:55 +00:00
Dan Robertson
7a2271dfd6 Tests: Add basic interface tests
- Add tests for the following
   - ICMP error responses are not sent in response to broadcast requests
   - ARP requests are responded to and inserted into the cache
   - ARP requests for someone else are not responded to, but the sender
     is still inserted in the cache
2017-10-28 19:33:01 +00:00
whitequark
f64a99a4e6 Use a much more sensible method naming for SocketRef. 2017-10-25 02:16:23 +00:00
whitequark
42e2c04dee Expose wrapping and unwrapping of SocketRefs. 2017-10-25 01:28:59 +00:00
whitequark
475486cc6f Update README. 2017-10-25 00:30:57 +00:00