522 Commits

Author SHA1 Message Date
whitequark
7e4971df32 Rename Cargo features: socket-* → proto-*. 2017-10-25 00:20:40 +00:00
whitequark
2602a151e4 Fix a naming mishap. NFCI. 2017-10-24 23:55:58 +00:00
whitequark
581e7b3f6f Simplify. NFC. 2017-10-24 23:12:55 +00:00
whitequark
284db0099f Small adjustments to TTL code; style, docs, and tests. NFCI. 2017-10-24 23:12:55 +00:00
Dan Robertson
fea462837d Implement set_ttl for Tcp and Udp sockets
- Add the ttl member to the IpRepr
 - Add the ttl member along with setters and getters to the tcp and udp
   socket types
 - Add unit tests for the new set_ttl parameter
 - Update usage of IpRepr to include the ttl value
2017-10-24 23:02:18 +00:00
whitequark
7c6cd6b9a3 Dump malformed ingress packets at DEBUG log level. 2017-10-24 20:37:52 +00:00
whitequark
8ee2f7bff5 Style fixes. 2017-10-24 18:08:22 +00:00
whitequark
bbb54fe2a2 Fix a (future) syntax error in the net_log macro. 2017-10-15 10:10:08 +00:00
Egor Karavaev
096ce02ac4 Implement a SocketRef smart pointer to detect state changes. 2017-10-05 03:44:20 +00:00
whitequark
100b57aa66 Replace "socket debug identifiers" with just socket handles.
This is basically a rename that now calls an apple an apple,
except user code can no longer change it. It's not obvious if
user code getting the socket handle from the socket is very useful,
but it's not harmful either, so why not.
2017-10-05 03:02:41 +00:00
whitequark
067fb2ddc9 Fix a typo. 2017-10-04 01:54:39 +00:00
whitequark
b0fc1d9542 Explain the return value of poll(). 2017-10-03 20:41:45 +00:00
whitequark
d88ef3c8d3 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
331dc10780 Add support for IPv4 default gateway. 2017-10-03 15:17:29 +00:00
Egor Karavaev
fbfe9859db Implement wire::{IpCidr/Ipv4Cidr}. 2017-10-03 14:27:17 +00:00
whitequark
d16e0bd212 Formatting. NFC. 2017-10-03 14:27:01 +00:00
whitequark
02658d0e2f Make sure IpAddress prohibits exhaustive matches.
I forgot to ensure this.
2017-10-03 13:22:09 +00:00
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