Commit Graph

49 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 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
Dario Nieuwenhuis 7782b24427 Fix crash in server example due to returning length bigger than received buffer. 2020-04-16 07:39:11 +00:00
whitequark 06c7e6eb54 examples: remove the remaining panics on poll error. 2018-07-31 13:58:00 +00:00
Michal Podhradsky 6249f69bd9 Log and print poll errors instead of crashing the server
Closes: #228
Approved by: dlrobertson
2018-06-06 06:30:18 +08:00
Dan Robertson 3a3ac474f6 Fix server example
Make the IPv6 address used in the server example the same as the IPv6
address used in the others.

Closes: #217
Approved by: dlrobertson
2018-05-19 04:34:02 +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
whitequark 485b46a5e6 fn PacketMetadata::empty() → const PacketMetadata::EMPTY.
Fixes #181.
2018-03-24 03:23:37 +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 20d1dd8a4a Update examples to use time types
Closes: #141
Approved by: whitequark
2018-02-16 10:44:02 +08: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
Dan Robertson 4a98190f9b Replace EthernetInterface::new with EthernetInterfaceBuilder. 2017-12-18 13:29:29 +00:00
whitequark eaa50d0003 Rewrite the ARP cache to allow for flood protection and expiration. 2017-11-21 10:53:55 +00:00
Philipp Oppermann c3e07dad9a Store plain DeviceT instead of Managed<_> in EthernetInterface 2017-11-08 09:34:35 +00:00
whitequark fe6b04a29a 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
Egor Karavaev 19b1b764ed Implement a SocketRef smart pointer to detect state changes. 2017-10-05 03:44:20 +00:00
whitequark bf9584555c Drop the pretense that anyone cares about non-IP over Ethernet.
To be precise, I'm talking about IPX, AppleTalk and DECnet here,
not things like PPPoE, ATAoE, FCoE, or PTP, which make sense
to implement on top of EthernetInterface but do not work on
the same level on top of it as IP.
2017-10-03 15:17:29 +00:00
Egor Karavaev 5be76b8dc1 Add support for IPv4 default gateway. 2017-10-03 15:17:29 +00:00
whitequark 42b3a71f72 Add a keep-alive and timeout demo to the examples. 2017-09-24 13:58:53 +00:00
whitequark cfcbcea4eb Fix an embarassing relative/absolute time mismatch in examples. 2017-09-24 13:57:35 +00:00
whitequark 9a5d056d7f Add a TCP data source endpoint to the server example. 2017-08-31 09:09:16 +00:00
whitequark 996389d653 Compute soft deadline in poll() and use nonblocking sockets.
Before this commit, anything that touched RawSocket or TapInterface
worked partly by accident and partly because of a horrible crutch
that resulted in massive latencies as well as inevitable packet loss
every time an ARP request had to be issued. Also, there was no way
to use poll() other than by continuously calling it in a busy loop.

After this commit, poll() indicates when the earliest timer expires,
and so the caller can sleep until that moment (or until packets
arrive).

Note that there is a subtle problem remaining: every time poll()
is called, every socket with a pending outbound packet whose
IP address doesn't correspond to a MAC address will send a new
ARP request, resulting in potentially a whole lot of such requests.
ARP rate limiting is a separate topic though.
2017-08-29 19:47:11 +00:00
whitequark 8724157b54 Fix warnings. 2017-07-31 07:59:01 +00:00
whitequark 7825bc6070 Implement fmt::Write for TcpSocket. 2017-07-30 06:59:01 +00:00
whitequark ae903e8841 Add UdpSocket::is_open, similar to TcpSocket::is_open in function.
Fixes #31.
2017-07-30 01:17:58 +00:00
whitequark ad12573f62 Rework and test UDP sockets.
Before, errors such as packets not fitting into a buffer would have
resulted in panics, and errors such as unbound sockets were
simply ignored.
2017-07-27 22:30:01 +00:00
whitequark 8a2432dcd7 Rework error handling in TcpSocket::connect. 2017-07-27 12:27:33 +00:00
whitequark a89e57b128 Add --pcap option to all our examples.
Also, generally reorganize and clean up option handling.
2017-07-23 14:57:04 +00:00
whitequark 53be7a7747 Add a sinkhole to the server example. 2017-05-29 16:54:51 +00:00
whitequark cc67e1f753 Don't block forever in TapInterface.
Ideally Devices should be non-blocking, but that would be really
annoying to implement, so for now, to get the examples working,
I'm using this hack.
2017-03-05 05:30:03 +00:00
whitequark f49723bbf9 Add a TCP client example. 2017-03-05 04:47:45 +00:00
whitequark d20c98f870 Factor out common code from examples. 2017-03-05 04:19:19 +00:00
TÖRÖK Attila 4d8b4c09e9 examples/server: fix outdated/misleading variable name. 2017-01-26 16:59:12 +00:00
whitequark 8b04d8bebe Try to get TCP state query methods into a saner state. 2017-01-14 09:13:25 +00:00
whitequark cca835a45a Update TcpSocket::{can,may}_{send,recv} APIs. 2017-01-14 06:59:58 +00:00
whitequark 4b92c25fa3 Rework the user-facing error handling in UDP sockets. 2017-01-12 04:18:18 +00:00
whitequark 7f095f6429 Return the amount of bytes sent from UdpSocket::send_slice. 2017-01-11 06:39:27 +00:00
whitequark 3b18727032 Swap the data and endpoint in UdpSocket methods.
This is to match libstd.
2017-01-11 06:23:17 +00:00
whitequark 362c954624 Make interfaces not own the sockets. 2017-01-11 05:25:54 +00:00
whitequark 83b70b12af Make binding the UDP socket an explicit operation. 2017-01-11 04:44:42 +00:00
whitequark 234e5ef29e Implement socket sets. 2017-01-11 04:05:41 +00:00
whitequark 0e006383f2 Use Managed/ManagedSlice for EthernetInterface. 2017-01-10 11:37:12 +00:00
whitequark 08ac98e4bc Reorder type parameters of Interface. 2017-01-01 08:18:25 +00:00
whitequark 27ccfc1bb0 Implement TCP retransmission. 2016-12-31 08:35:46 +00:00
whitequark e1e0c2e838 Impement fault injection. 2016-12-31 01:05:29 +00:00
whitequark 287affb447 Implement the TCP TIME-WAIT state. 2016-12-28 05:33:12 +00:00
whitequark 22b0406c59 More sensible naming for examples. 2016-12-28 00:18:10 +00:00