522 Commits

Author SHA1 Message Date
whitequark
08186129cd Add the packet2pcap utility. 2018-01-30 03:24:50 +00:00
Philipp Oppermann
c2d18ec071 Return specific sockets from new functions instead of Socket.
* Add Into<Socket> implementations for sockets
* Make SocketSet::add generic over Into<Socket>
2018-01-28 14:36:23 +00:00
寧靜
f0c147a5ee Gate Linux-specific platform dependencies behind a #[cfg]. 2018-01-27 12:38:47 +00:00
Dan Robertson
783a76b2d8 Add ICMPv6
Add support for ICMPv6 message types to the wire module.
2018-01-26 23:10:41 +00:00
whitequark
5a0492cc8e Allow fuzzer failures on Travis.
cargo-fuzz is broken on Travis, but the mode is still useful for
those running ./.test_like_travis.rb.
2018-01-26 20:20:37 +00:00
whitequark
938000797b Fix af26eafd. 2018-01-26 19:56:23 +00:00
whitequark
af26eafd89 Install cargo-fuzz on Travis before fuzzing. 2018-01-26 19:44:02 +00:00
whitequark
e4a53315b4 Run fuzzing on Travis. 2018-01-26 19:30:47 +00:00
Egor Karavaev
283109caca Treat unspecified IPv4/IPv6 addresses as IpAddress::Unspecified in IpRepr::lower.
Closes #127.
2018-01-26 19:26:01 +00:00
Dan Robertson
bec2435e80 Fix ICMPv4 check_len to not panic on truncated packets. 2018-01-26 18:59:11 +00:00
whitequark
96b631cee9 Add some ICMPv4 and ICMPv6 packets to fuzz corpus. 2018-01-26 18:43:39 +00:00
whitequark
b0995c13e2 Fix some overly long comments. NFC. 2018-01-26 17:48:59 +00:00
Dan Robertson
3ff7e07941 Increase required size for ICMPv4 packets
- Increase the size required in Icmpv4Packet::check_len to 8 bytes
 - Add a test
2018-01-26 16:59:37 +00:00
luozijun
3b824ca642 Add Hash trait on IpAddress/IpCidr 2018-01-26 16:35:53 +00:00
whitequark
cb5be48868 Route broadcast packets directly.
Closes #120.
2018-01-15 11:56:14 +00:00
Dan Robertson
6e877f8501 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
Herman J. Radtke III
d404beea3b Fix mistakes in README
- Fix binary path in tcpdump example
- Fix IP address in ping example
2018-01-13 18:42:17 +00:00
Dan Robertson
8fee5cee1e Implement the time module. 2018-01-13 14:51:21 +00:00
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