405 Commits

Author SHA1 Message Date
whitequark
bd52f9b83c Only verify checksum in pretty printers, do not bail out if invalid.
This lets us e.g. deal with checksum offload on egress packets.
2017-10-03 07:09:53 +00:00
whitequark
c8ae7bdc21 Fix insufficient length validation in IPv4 packets.
Found via cargo-fuzz.
2017-10-02 23:03:41 +00:00
whitequark
58c12b8f51 Reword checksum-related documentations.
cc @steffengy
2017-10-02 21:52:30 +00:00
whitequark
70248c5109 Formatting. NFC. 2017-10-02 21:51:43 +00:00
Steffen Butzer
d5147efb82 support hardware based checksum settings in during packet send/recv
- makes sure the checksum is zeroed when not emitted by software
  (This is required by some implementations such as STM32 to work properly)
2017-10-02 21:40:08 +00:00
Steffen Butzer
9b1b0b4bde phy: introduce hardware based checksum settings, rename DeviceLimits
this contains a rename of occurrences of
DeviceLimits -> DeviceCapabilities.
2017-10-02 21:40:08 +00:00
whitequark
a7cdcd49f4 Update CI config to not use poorly interacting feature sets. 2017-09-25 00:59:21 +00:00
whitequark
16e6e70d2f Fix many warnings. 2017-09-25 00:55:54 +00:00
whitequark
cedf66a733 Enforce some lints. 2017-09-25 00:46:53 +00:00
whitequark
a983c629b9 Allow disabling any of: raw, TCP or UDP sockets. 2017-09-25 00:20:22 +00:00
whitequark
440b6f5556 Reorganize features using namespaces, to match module hierarchy.
I'm about to add a whole lot more features, and it's going to get
quite confusing otherwise.
2017-09-24 23:51:19 +00:00
whitequark
2d31ef9665 Add some docs. 2017-09-24 23:29:42 +00:00
Egor Karavaev
0454c3f8f6 Uncomment associated constants. 2017-09-24 23:25:18 +00:00
whitequark
081851d955 Clarify README paragraph about features.
We can easily (although annoyingly) do IP fragmentation with
the assembler now, so I don't see *any* features that are apriori
impossible to implement anymore.
2017-09-24 16:07:24 +00:00
whitequark
6f5ae33501 Add a keep-alive and timeout demo to the examples. 2017-09-24 13:58:53 +00:00
whitequark
b7b4877a85 Fix an embarassing relative/absolute time mismatch in examples. 2017-09-24 13:57:35 +00:00
whitequark
7362e1a49e A few cosmetic changes to TCP socket trace messages.
No functional change.
2017-09-24 13:39:23 +00:00
whitequark
c73721aa03 Completely redo the logic of TCP socket polling.
The previous implementation made no sense. It is obvious that
poll_at() should use the same mechanisms to decide whether dispatch()
should be called as dispatch() itself uses to decide whether to send
anything.

This fixes numerous busy looping issues that arise if the return
value of poll() is used for waiting.
2017-09-24 13:20:56 +00:00
whitequark
1a810294e2 Fix two issues that may cause TCP sockets to be polled too late.
1. Apart from non-empty transmit buffer, a state which transmits
   a FIN flag should also be considerd. Otherwise, closing a socket
   with an empty transmit buffer may retransmit the FIN flag forever.
2. Timeout poll requests should only be overridden by timer poll
   requests when the latter is earlier.
2017-09-24 11:04:55 +00:00
whitequark
43cc132459 Fix a typo in documentation. 2017-09-24 08:23:46 +00:00
whitequark
bf4ddef87d Remove all remnants of the collections feature. 2017-09-22 20:40:13 +00:00
whitequark
24b6165aee Fix CI configuration after 4e8be41c. 2017-09-22 20:23:53 +00:00
whitequark
19ed1f38d8 Bump version. v0.4.0 2017-09-22 20:01:44 +00:00
whitequark
4e8be41caf Update features to reflect merge of alloc and collections crates. 2017-09-22 19:54:47 +00:00
whitequark
15bd9896f1 Update README.
Mention SACKs, don't spend many words on junk no one wants,
reword everything, and reorder the features so that the ones
with a higher cost/benefit ratio are higher up.
2017-09-22 19:49:54 +00:00
whitequark
c33aedf7c6 Update README.
We don't really care about fast open one way or another, this entry
was a misunderstanding of RFC 793's behavior wrt data in SYN packets.
2017-09-22 19:20:24 +00:00
whitequark
64369d9801 Make TCP more RFC 5681 compliant wrt immediate ACKs. 2017-09-22 18:57:47 +00:00
whitequark
fb624e5528 Clarify inline TCP documentation. 2017-09-22 18:40:23 +00:00
whitequark
546b3670ef Revert "Keep dispatching packets from a socket as long as there are any."
This reverts commit 51b2f18d1165bf7257de8894df101299cc93b094.

There's no throughput difference so far as I could measure, but
this greatly increases worst-case latency. At some later point
we could perhaps pass a deadline to the poll function, but for now
reverting this is simple enough.
2017-09-22 18:09:18 +00:00
whitequark
51b2f18d11 Keep dispatching packets from a socket as long as there are any.
Typically, the poll function is used as a part of a larger RTOS.
If we only dispatch one packet per socket per poll() call,
then we have to wait for a complete scheduler roundtrip,
which is potentially a lot of time, and as a result we are
not filling the peer's window efficiently.
2017-09-22 17:55:49 +00:00
whitequark
c879b39629 Fix a warning. 2017-09-22 17:38:58 +00:00
whitequark
eff0e0b90e Handle buffer wraparound in TCP reassembly code. 2017-09-22 17:10:51 +00:00
whitequark
f65bc8aa79 Make sure all side-effectful RingBuffer methods are #[must_use].
Some of them already use Result, but the ones that can return
an empty slice (or a slice shorter than requested) also must have
their return value (at least) checked.
2017-09-22 17:08:46 +00:00
whitequark
3c74d3309b Add RingBuffer::{enqueue_allocated,dequeue_allocated}.
These should be used instead of enqueue_many because they do not
require the caller to handle wraparound explicitly.
2017-09-22 17:04:56 +00:00
whitequark
7b29dfee2e Add RingBuffer::{read_allocated,write_unallocated}. 2017-09-22 16:23:37 +00:00
whitequark
7684d50d6e Fix an issue where TCP packets would have zero IP payload length. 2017-09-22 10:14:26 +00:00
whitequark
64d306340b Fix a few warnings. 2017-09-22 10:06:40 +00:00
whitequark
394ea4d633 Implement reassembly of out-of-order TCP segments. 2017-09-22 10:06:40 +00:00
whitequark
af51f2aba9 Clean up PSH flag handling. 2017-09-22 08:15:29 +00:00
whitequark
c43446ff3a Do not clear remote_last_ts in TcpSocket::set_timeout().
After this change, if an 1s timeout is set on a socket that received
no packet for 2s, it will be instantly aborted, which seems
more reasonable. Also, this makes the `self.remote_last_ts.is_none()`
branch in TcpSocket::dispatch() actually behave as described.
2017-09-22 06:16:58 +00:00
whitequark
968255e56d Clean up and document TCP MSS calculations. 2017-09-22 06:02:03 +00:00
whitequark
30cafe3106 Implement a buffer (re)assembler. 2017-09-20 20:46:15 +00:00
whitequark
742a8f5e2b smoltcp;:parsing → smoltcp::parsers. 2017-09-20 20:18:50 +00:00
whitequark
64a82709d4 Implement TCP timeouts. 2017-09-18 11:05:40 +00:00
whitequark
a04b32441b Implement TCP keep-alive. 2017-09-16 10:54:59 +00:00
whitequark
c5deacbcb8 Fix warnings. 2017-09-15 06:05:41 +00:00
whitequark
14355e15d0 RingBuffer::{empty,full}→is_{empty,full}.
Query methods in Rust conventionally start with the "is" prefix.
2017-09-08 23:23:40 +00:00
whitequark
388e94b32a Remove Error::Rejected.
This wasn't an actual error, just a poorly designed communication
mechanism between sockets and whatever lies on the layer below them.
2017-09-08 00:59:46 +00:00
Egor Karavaev
a2c66fdd88 Factor out TcpSocket::accepts. 2017-09-08 00:57:42 +00:00
Egor Karavaev
44cf21b91b Factor out UdpSocket::accepts. 2017-09-08 00:57:19 +00:00