504 Commits

Author SHA1 Message Date
Herman J. Radtke III
07b78a8d50 Handle parsing and display of IPv4 mapped IPv6 addresses.
* The IPv6 address parser now handles IPv4 mapped IPv6 addresses which
  take on the form ::ffff:x.x.x.x.
* Implement Display for IPv4 mapped IPv6 addresses
* Implement From<IPv4Address> for IPv6Address

Fixes #86
2018-01-13 08:49:24 +00:00
Dan Robertson
8d908127d3 Support IPv6 raw sockets
- Add support for IPv6 raw sockets.
 - Update tests.
2018-01-13 03:07:10 +00:00
Alex Crawford
3b4d6b5e09 Clean up dispatch_socket!() syntax
This modified syntax is meant to more closely resemble standard Rust.
2018-01-08 07:44:15 +00:00
whitequark
888b1d2403 Bump managed dependency to 0.5. 2018-01-05 22:44:25 +00:00
whitequark
fcffa6a5b1 Disregard TCP FIN flag if it arrives in a segment not at window start.
Fixes #111.
2018-01-05 21:06:20 +00:00
Dan Robertson
4d918e4406 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
793227fd46 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
寧靜
d1ac62c2a2 Update examples/tcpdump.rs. 2017-12-28 04:48:23 +00:00
whitequark
8928851665 Simplify. NFC. 2017-12-27 00:09:50 +00:00
Dan Robertson
da8e7dceb8 Add bench tests
- Add basic infrastructure for bench tests
 - Add bench tests for
   - TcpRepr::emit
   - UdpRepr::emit
   - Ipv4Repr::emit
   - Ipv6Repr::emit
2017-12-24 22:40:00 +00:00
Dan Robertson
507d2fe0ea Add the proto-ipv4 feature. 2017-12-24 13:28:59 +00:00
Herman J. Radtke III
ea953fbf19 Implement FromStr for IpEndpoint
Fixes #81
2017-12-24 12:08:16 +00:00
Josh Gangloff
56ddb0c206 Make IP checksum loop use larger chunks to ease autovectorization. 2017-12-23 22:26:16 +00:00
whitequark
275eb90785 Unswitch the IP checksum loop for 30% improvement in performance. 2017-12-23 12:17:39 +00:00
whitequark
ba1d5ed576 Convert the stress.rs example into a simple benchmark.
There are no more bugs exposed by stress.rs as far as I can tell,
so let's make it do something more useful.
2017-12-22 20:59:30 +00:00
whitequark
1e0f92fad7 Convert all assert!s not documented as panics into debug_assert!s.
Document the rest.
2017-12-22 20:38:54 +00:00
whitequark
826764c961 Build release testsuite binaries with complete debug information. 2017-12-22 19:38:17 +00:00
whitequark
b247f6498e Correctly handle retransmission of lost-received-lost TCP segments.
Thanks @pothos for initial analysis of the issue.
2017-12-22 19:31:04 +00:00
whitequark
46365af7bc Fix a few documentation issues. NFC. 2017-12-22 13:13:43 +00:00
whitequark
62bd94dedc TcpSocket::recv_impl should have never been public, oops. 2017-12-22 13:11:11 +00:00
whitequark
35619edb8b EthernetInterface::set_ipv4_gateway should panic on non-unicast addrs. 2017-12-22 13:07:11 +00:00
whitequark
3868dcdb14 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
d5f11159d8 Make the log crate properly optional. 2017-12-22 09:57:38 +00:00
whitequark
44db954f8e Add a stress test.
Run it without the `log` feature and in release mode:
  $ cargo run --release \
    --no-default-features \
    --features std,phy-tap_interface,socket-tcp \
    --example stress tap0 \
    [reader|writer]

There are currently two bugs exposed by it:
  * a crash in the reader mode,
  * slow-down in the writer mode.
2017-12-22 09:43:00 +00:00
whitequark
31cb0c627d Oops, don't make examples depend on a nonexistent feature.
It's a Cargo bug that this is not an error (and thus went unnoticed).
2017-12-22 09:29:56 +00:00
whitequark
ecf6bf291f Add a script to run every test Travis would run locally. 2017-12-22 09:07:57 +00:00
whitequark
62fb0fc8cd Clean up our feature story and more aggressively test features. 2017-12-22 08:54:58 +00:00
whitequark
d1e229261f Panic on an attempt of subtracting sequence numbers with underflow.
This would result in results near usize::MAX, and is indicative of
a bug. A panic is always used instead of a debug_assert!() because
debug builds are easily slow enough so that the underlying bugs
are not tripped.

Related to #62.
2017-12-21 12:35:15 +00:00
whitequark
3347bbe60b Use a more specific log message for keep-alive or probe TCP packets. 2017-12-21 10:39:54 +00:00
whitequark
960b0012a0 Unbreak cargo test --no-default-features --features default.
I'm not sure why is this needed, but it broke CI.
2017-12-18 15:10:50 +00:00
whitequark
e052e5195f Fix accidental conversion of a slice to owned.
This broke #![no_std] builds.
2017-12-18 15:03:38 +00:00
whitequark
a7d289eac1 Add an HTTP client example. 2017-12-18 14:53:09 +00:00
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