Egor Karavaev
e927b09ba8
`IpRepr::lower` replaces unspecified src_addr in Ipv4Repr as well.
2017-06-21 03:01:15 +00:00
Egor Karavaev
c1c4ed68c5
Factor out the `RingBuffer` container.
2017-06-21 02:50:10 +00:00
Egor Karavaev
59fc0c0358
Factor out the "raw_socket" and "tap_interface" features
...
This makes it possible to build smoltcp with the "std" feature on platforms
without libc, such as redox.
2017-06-15 10:12:11 +00:00
whitequark
f29b610801
Remove accidentally committed change.
2017-05-29 17:15:35 +00:00
whitequark
5bac3e5a02
Fix no-std build.
2017-05-29 11:04:49 +00:00
whitequark
91ef5c60c3
Add packet shaping to the fault injector.
2017-05-29 10:53:30 +00:00
whitequark
73bb4b8593
Implement TCP TIME-WAIT timeouts.
2017-04-21 16:01:49 +00:00
whitequark
8087bf3755
Fix a typo in documentation.
2017-04-21 15:59:55 +00:00
whitequark
555825e49e
Clamp TCP receive window to MSS multiplied by maximum burst size.
...
This is a conservative bound; if we don't have enough buffers
to receive more than four segments, clearly we shouldn't advertise
our ability to.
It however will only work reliably with exactly one TCP connection
continuously receiving; for two, another window adjustment mechanism
will be needed for reliable reception.
2017-03-07 11:21:49 +00:00
whitequark
1d46ccf432
fn Device::mtu() -> usize → Device::limits() -> DeviceLimits
2017-03-07 11:10:26 +00:00
whitequark
c73298f01e
Improve handling of TCP ACK packets in FIN-* states.
...
Previously, sockets could get stuck in the CLOSING state, after
the sequence described in the new test_mutual_close_with_data_2.
The root cause was that some state machine transitions got
folded into ACK handling.
Now, all transitions are handled in the same match statement,
and ACK handling is broken up around it.
2017-03-07 10:17:30 +00:00
whitequark
393ebbe682
Don't put non-unicast (IP or Ethernet) addresses into ARP cache.
...
Thanks @little-dude for pointing this out--it's probably a DoS bug.
2017-03-07 06:32:18 +00:00
whitequark
b305797cb4
Trace eviction and fill in SliceArpCache.
2017-03-07 06:25:47 +00:00
Corentin Henry
0f2b05ede7
arp: increment lru when inserting a new entry
2017-03-07 06:04:40 +00:00
Corentin Henry
40d3a3ada8
arp: use valid unicast ip addresses for tests
2017-03-07 05:20:28 +00:00
whitequark
5137608aed
Follow-up to b9e79d19; always process broadcast frames.
2017-03-06 04:00:13 +00:00
whitequark
d25eebc0ef
Ignore Ethernet frames for which we aren't a destination.
2017-03-06 03:58:19 +00:00
whitequark
493a319132
Remove the `use_` prefix from feature names.
...
I haven't realized that a feature `log` with an optional crate
dependency `log` activates that dependency, and added the prefix
to avoid a "clash". This is unnecessary.
2017-03-05 05:49:38 +00:00
whitequark
0836bc949a
Fix condition for acceptable RST|ACK in TCP SYN-SENT state.
2017-03-05 05:31:12 +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
0d32fcee5b
Send an ARP request when the destination is not in cache.
2017-03-05 04:59:51 +00:00
whitequark
78d3d53a06
Use trait FromStr for the parsing code.
2017-03-05 04:48:13 +00:00
whitequark
cd894460f5
Implement the TCP SYN-SENT state.
2017-03-05 03:53:04 +00:00
whitequark
e36e05905c
Fix an incorrect tracing message.
2017-03-05 03:16:15 +00:00
whitequark
9905b3de86
Pull in macros from the log crate in tests.
2017-01-31 11:46:07 +00:00
whitequark
255d69d63b
Fix the TCP MSS calculation.
2017-01-31 11:39:33 +00:00
whitequark
da4900a02b
Fix an incorrect payload length when sending TCP MSS option.
2017-01-27 03:35:22 +00:00
whitequark
d6b7623c37
Receive the TCP MSS option and act on it.
2017-01-27 03:06:52 +00:00
whitequark
bc1d65ea89
Send the TCP MSS option.
2017-01-27 02:56:27 +00:00
whitequark
077513fda6
Add support for TCP MSS option in TCP representation.
2017-01-27 02:56:27 +00:00
whitequark
4c3f454902
Add support for TCP option parsing and emission.
2017-01-27 00:33:30 +00:00
whitequark
4267ad2635
Fix an inaccurate comment.
2017-01-26 22:04:05 +00:00
whitequark
ca1146995f
Remove TcpControl::len().
2017-01-26 21:20:48 +00:00
whitequark
a3c997f007
Also parse Ethernet addresses separated by dashes (-).
...
This is handy because we print them separated by dashes.
2017-01-26 17:28:07 +00:00
whitequark
22e5462936
Add Internet and Ethernet address parsing (from strings).
2017-01-25 19:41:02 +00:00
whitequark
9b8671ce15
Fix the TCP FIN emission with queued data rolling over TX buffer.
2017-01-25 06:20:57 +00:00
whitequark
9fbb5cfff1
Fix the TCP ACK handling in FIN-WAIT-1 state with queued data.
2017-01-25 06:01:58 +00:00
whitequark
68064c3725
Refactor the TCP ACK handling in ESTABLISHED/CLOSE-WAIT states.
2017-01-25 05:50:14 +00:00
whitequark
8b292c6dd8
Don't switch TCP state from FIN-WAIT-1 to FIN-WAIT-2 with queued data.
2017-01-25 05:36:42 +00:00
whitequark
bef01740a7
If a TCP FIN|ACK also ACKs our FIN, transition to TIME-WAIT.
2017-01-25 03:58:03 +00:00
whitequark
f6d542b739
Actually close TCP sockets with 0 references during pruning.
2017-01-25 02:45:17 +00:00
whitequark
5cb4e6f760
Trace pruning of sockets from a set.
2017-01-25 02:23:10 +00:00
whitequark
497aa5919a
Correctly treat TCP ACKs that acknowledge both data and a FIN.
2017-01-23 22:17:04 +00:00
whitequark
92fde3d18b
Don't send TCP FIN flag yet if next segment will also have data.
2017-01-23 12:07:07 +00:00
whitequark
507af2b0c3
Reset the TCP retransmit timer on valid ACK if transmit half is open.
2017-01-23 11:34:36 +00:00
whitequark
62f094d276
Fix build with no alloc or collections.
2017-01-22 20:29:45 +00:00
whitequark
34d32f67a2
Gate the really verbose log messages behind a feature.
...
Otherwise, trying to use the socket buffers instead of BufReader/
BufWriter is doomed to overwhelm the application logic.
2017-01-19 12:23:32 +00:00
whitequark
15a344f1d3
Don't respond with RST to ACKs in TCP LISTEN state.
...
These packets may have been destined for a different socket.
2017-01-17 04:43:51 +00:00
whitequark
591993014e
Reject, not accept, TCP RST packets in LISTEN state.
...
These packets may have been destined for a different socket.
2017-01-17 04:33:37 +00:00
whitequark
ac38ddd936
Add reference counting to SocketSet.
2017-01-17 02:47:14 +00:00
whitequark
74d1eb86b6
Add TcpSocket::abort().
2017-01-17 01:24:51 +00:00
whitequark
a75f7d4bf0
Reject all TCP packets in the CLOSED state.
2017-01-17 00:24:47 +00:00
whitequark
4da2598ea7
Properly document TCP state machine query methods.
2017-01-17 00:21:07 +00:00
whitequark
f126eab193
Distinguish sockets by debug identifiers (socket set indexes).
2017-01-16 23:35:21 +00:00
whitequark
40716a348d
Do not send RST in response to invalid SEQ or ACK.
2017-01-16 16:58:45 +00:00
whitequark
bd01cdef78
Always display meaningful endpoint in trace messages.
2017-01-16 16:34:24 +00:00
whitequark
51d8afe579
Fix inverted meaning of TcpSocketBuffer::empty().
2017-01-15 11:00:04 +00:00
whitequark
c0697cf37d
Add lots of sanity checking to TCP test helpers.
2017-01-14 12:56:58 +00:00
whitequark
a864157feb
Do not try to retransmit SYN as if it was in data stream.
2017-01-14 12:18:00 +00:00
whitequark
62883a6e0b
Don't display IP packet error twice when pretty-printing.
2017-01-14 12:09:30 +00:00
whitequark
578d7bce5f
Calculate IP payload length from the total length field.
...
Before this commit, IP payload length was calculated by subtracting
the IP header length from the total underlying buffer length, which
fails if the underlying buffer has padding, e.g. like Ethernet
does.
2017-01-14 11:07:06 +00:00
whitequark
9b24627d69
Pretty-print TCP and UDP representations, and verify checksums.
2017-01-14 10:08:08 +00:00
whitequark
8b04d8bebe
Try to get TCP state query methods into a saner state.
2017-01-14 09:13:25 +00:00
whitequark
f7bc7fe364
Do not use UTF-8 in net_trace!().
...
This may interact badly with other tooling.
2017-01-14 07:10:20 +00:00
whitequark
dc8809288f
Fix a bug that caused .send();.close(); to result in a lost FIN.
2017-01-14 06:59:58 +00:00
whitequark
cca835a45a
Update TcpSocket::{can,may}_{send,recv} APIs.
2017-01-14 06:59:58 +00:00
whitequark
9fb6d6f4b2
impl Debug for SocketSet.
2017-01-12 05:42:54 +00:00
whitequark
4b92c25fa3
Rework the user-facing error handling in UDP sockets.
2017-01-12 04:18:18 +00:00
whitequark
6ccc48d647
Allow copying socket set handles.
...
Trying to keep them unique was kind of a losing battle anyway.
2017-01-12 04:10:24 +00:00
whitequark
7f095f6429
Return the amount of bytes sent from UdpSocket::send_slice.
2017-01-11 06:39:27 +00:00
whitequark
f01ce30466
Add functions to check if the UDP socket buffers are empty or not.
2017-01-11 06:34:12 +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
83bb8c6ae8
Update docs.
2017-01-10 12:29:24 +00:00
whitequark
1ea9a5125b
Use ManagedSlice in SliceArpCache.
2017-01-10 11:57:14 +00:00
whitequark
0e006383f2
Use Managed/ManagedSlice for EthernetInterface.
2017-01-10 11:37:12 +00:00
whitequark
67430aa589
Use the managed crate.
2017-01-10 11:04:00 +00:00
whitequark
08ac98e4bc
Reorder type parameters of Interface.
2017-01-01 08:18:25 +00:00
whitequark
716a1cf7fe
Fix silliness in docs.
2017-01-01 08:15:38 +00:00
whitequark
c29d3c2804
Allow Managed to accept a Box<[T]>.
2016-12-31 18:12:45 +00:00
whitequark
bf3b62bb25
Examples for the phy layer!
2016-12-31 12:28:59 +00:00
whitequark
5bee008464
Examples for the wire layer!
2016-12-31 11:44:51 +00:00
whitequark
345670f618
Documentation!
2016-12-31 10:26:59 +00:00
whitequark
27ccfc1bb0
Implement TCP retransmission.
2016-12-31 08:35:46 +00:00
whitequark
818e98f47a
TCP: retransmit ACK when receiving duplicate SEQ.
2016-12-31 01:33:46 +00:00
whitequark
64a8c36118
Fix length of tx buffers returned by fault injector.
2016-12-31 01:10:46 +00:00
whitequark
e1e0c2e838
Impement fault injection.
2016-12-31 01:05:29 +00:00
whitequark
3ea9606827
Remove an unnecessary PhantomData.
2016-12-30 23:48:37 +00:00
whitequark
be68066152
#[inline(always)] → #[inline]
2016-12-30 16:55:31 +00:00
whitequark
287affb447
Implement the TCP TIME-WAIT state.
2016-12-28 05:33:12 +00:00
whitequark
94963faf12
Implement the TCP CLOSING state.
2016-12-28 04:56:49 +00:00
whitequark
3e7a1ee575
Implement the TCP FIN-WAIT-2 state.
2016-12-28 04:10:17 +00:00
whitequark
9dc931dbe2
Implement the TCP FIN-WAIT-1 state.
2016-12-28 04:02:43 +00:00
whitequark
151b3ba07b
Get rid of the #![feature(associated_consts)].
2016-12-28 00:12:15 +00:00
whitequark
71268ace88
Get rid of the #![feature(const_fn)].
2016-12-28 00:08:51 +00:00
whitequark
e043e7c496
Get rid of the #![feature(step_by)].
2016-12-28 00:08:51 +00:00
whitequark
b409eec11b
Suppress unused variable warnings in net_trace!.
2016-12-27 23:52:43 +00:00
whitequark
bba505bc90
Add a use_alloc feature.
2016-12-27 23:49:37 +00:00
whitequark
de24d635fa
Rename features: std→use_std, logging→use_log.
2016-12-27 23:45:24 +00:00
whitequark
df69303624
Fix state names in documentation.
2016-12-27 23:28:57 +00:00
whitequark
979cd4c1bf
Implement the TCP LAST-ACK state.
2016-12-27 23:27:33 +00:00
whitequark
874264503d
Implement the TCP close operation.
2016-12-27 22:43:16 +00:00
whitequark
feaef0d7c4
Fix TCP sequence number in multiple consecutive non-ACKed data packets.
2016-12-27 20:39:46 +00:00
whitequark
17f96ba929
Fix TcpSocket::can_recv().
2016-12-27 20:17:46 +00:00
whitequark
71d1b4061f
Fix ACK validation of TCP RST packets.
2016-12-27 20:17:35 +00:00
whitequark
867dda659d
Fix several TCP out-of-bounds reads from the transmit buffer.
2016-12-27 20:17:03 +00:00
whitequark
69427c9e2f
Add TcpSocket::is_connected().
2016-12-27 18:54:45 +00:00
whitequark
e6357ee79c
Correctly propagate carries in the IP checksum.
2016-12-27 18:43:49 +00:00
whitequark
6b592742fd
Use the correct wrapping operations on TCP sequence numbers.
2016-12-27 18:34:13 +00:00
whitequark
bbff907e87
Fix examples.
2016-12-27 18:04:39 +00:00
whitequark
a8fc4fd832
Improve the user-facing TCP socket API.
2016-12-27 17:49:40 +00:00
whitequark
09040f3e91
Accept TCP ACK packets in CLOSE_WAIT state.
2016-12-27 14:13:42 +00:00
whitequark
d11016b138
Simplify TCP ACK handling.
2016-12-27 14:04:30 +00:00
whitequark
751a2269c3
Add support for TCP FIN in ESTABLISHED state.
2016-12-27 13:34:48 +00:00
whitequark
79553e81d4
Fix TCP incoming sequence number check.
2016-12-26 17:24:37 +00:00
whitequark
2d562c10fa
Add support for multiple outgoing in-flight TCP packets.
2016-12-26 16:59:39 +00:00
whitequark
3917ba5836
Shrink the buffers in examples for ease of testing.
2016-12-26 16:29:33 +00:00
whitequark
a6eab874be
Parameterize tracer over the write function.
2016-12-26 15:46:30 +00:00
whitequark
a8b4ed2deb
Implement the userspace side of TCP sockets.
2016-12-26 15:05:46 +00:00
whitequark
0e20ea9205
Implement TCP data transmission.
2016-12-26 14:24:17 +00:00
whitequark
0bf822c77e
Implement TCP RST handling.
2016-12-26 13:54:26 +00:00
whitequark
83f886826f
Validate ACK for TCP RST packets.
2016-12-26 13:10:39 +00:00
whitequark
f468f47959
Validate ACK even in TCP LISTEN state.
2016-12-26 13:00:39 +00:00
whitequark
2de98aea06
Add tests for TCP error conditions.
2016-12-26 12:44:41 +00:00
whitequark
25d453447f
Generalize the TCP tests to accept multiple packets.
2016-12-26 12:38:40 +00:00
whitequark
ea78053dc1
Factor out IpRepr into the wire module.
2016-12-26 11:20:20 +00:00
whitequark
ea07e79bdf
Group IP header parts in the socket layer as struct IpRepr.
2016-12-26 10:06:49 +00:00
whitequark
b5a9917950
Implement TCP data acknowledgement.
2016-12-25 11:19:50 +00:00
whitequark
0ae27678a0
Implement TCP data reception.
2016-12-25 11:09:50 +00:00
whitequark
bdfb99ea16
Validate TCP ACKs.
2016-12-25 09:22:49 +00:00
whitequark
fa1a51b90a
Add tests for TCP state machine.
2016-12-24 23:06:42 +00:00
whitequark
f5f0b8e435
Add basic TCP three-way handshake.
2016-12-23 08:05:50 +00:00
whitequark
3c05139204
Add logging capability.
2016-12-23 07:59:38 +00:00
whitequark
f46c77bdd6
Fix autoselection of source address.
2016-12-23 07:57:54 +00:00
whitequark
6539019f19
Get rid of explicit backlog.
2016-12-23 07:34:10 +00:00
whitequark
6d8d3cb29d
Use correct sequence numbers in TCP RST packets.
2016-12-23 07:34:10 +00:00
whitequark
3bd715e1bc
Use signed integers to represent TCP sequence numbers.
2016-12-23 07:34:07 +00:00
whitequark
2f24fb263b
Populate ARP cache from incoming IP packets.
2016-12-23 07:31:42 +00:00
whitequark
1ad8f9c9bd
Implement conversion of incoming TCP connections into TCP streams.
2016-12-20 22:57:21 +00:00
whitequark
53ddc9476f
Fix no_std build.
2016-12-20 22:06:36 +00:00
whitequark
bddb5f9127
Implement TCP server sockets.
2016-12-20 19:51:52 +00:00
whitequark
5a64a87dbe
Reply with ICMP dest. unreachable or TCP RST from unused ports.
2016-12-20 19:18:35 +00:00
whitequark
a3481537d9
Add some sanity into buffer names (avoid clases with wire::*).
2016-12-20 13:56:59 +00:00
whitequark
0d9a8a417d
Add some sanity into enumeration names (avoid "*Type").
2016-12-20 13:54:11 +00:00
whitequark
c562ea784d
Fix TcpRepr field visibility.
2016-12-20 13:44:41 +00:00
whitequark
3d5f47b89f
Implement TCP representation printing.
2016-12-20 13:16:29 +00:00
whitequark
513923725e
Implement TCP representation parsing and emission.
2016-12-20 12:52:33 +00:00
whitequark
31040bf0fc
In Repr::emit, do not assume that the packet is pre-zeroed.
2016-12-20 09:41:08 +00:00
whitequark
6d2c11fb61
Fix IP checksum calculation for odd-length packets.
2016-12-20 00:17:29 +00:00
whitequark
095005a597
Empty transmit buffers before starting to receive.
2016-12-20 00:07:02 +00:00
whitequark
f86fac2223
Sort out buffer lengths.
2016-12-19 23:50:04 +00:00
whitequark
9c922d0306
Implement TCP packet support.
2016-12-18 21:42:44 +00:00
whitequark
71fc81b7c5
Implement TCP stream ring buffers.
2016-12-18 19:40:50 +00:00
whitequark
fe96ff3015
UdpBufferElem → UdpPacket
2016-12-18 19:40:02 +00:00
whitequark
2dc837be9d
Fix lifetime variance.
2016-12-17 06:39:18 +00:00
whitequark
31e44445f5
Working UDP loopback.
2016-12-17 05:12:45 +00:00
whitequark
c672b94ef7
Rethink the buffering strategy with Managed<T>.
2016-12-17 04:15:55 +00:00
whitequark
d1d910b46d
Significantly simplify buffering.
2016-12-15 17:27:17 +00:00
whitequark
3fb5f04b07
Implement network part of communication through UDP sockets.
2016-12-15 05:40:55 +00:00
whitequark
fb172ed1ed
Implement UDP sockets.
2016-12-14 17:39:44 +00:00
whitequark
2b01a3dace
Implement UDP representation parsing and emission.
2016-12-14 02:11:50 +00:00
whitequark
5a721a7b11
Implement UDP packet support.
2016-12-14 00:11:45 +00:00
whitequark
57e544cc8c
Return interior pointers more uniformly.
2016-12-13 22:37:05 +00:00
whitequark
53309f8271
Simplify checksum computation.
2016-12-13 17:31:08 +00:00
whitequark
1c616218a1
Respond with ICMP echo request data in echo reply.
2016-12-13 17:02:50 +00:00
whitequark
d587981ef5
Implement ICMPv4 echo replies.
2016-12-12 23:22:59 +00:00
whitequark
c18d6bf04d
Actually commit ARP snooping.
2016-12-12 22:41:34 +00:00
whitequark
2482117682
Implement ICMPv4 echo request/reply representation parsing and emission.
2016-12-12 22:38:13 +00:00
whitequark
9fa0bffb7a
Implement ICMPv4 echo request/reply packet support.
2016-12-12 22:11:59 +00:00
whitequark
c5bdf30458
Implement IPv4 representation parsing and emission.
2016-12-12 20:09:37 +00:00
whitequark
921ca353b4
Implement IPv4 packet support.
2016-12-12 17:26:06 +00:00
whitequark
7f1b88ef45
Implement ARP snooping.
2016-12-12 12:30:35 +00:00
whitequark
4421b2fe27
Implement ARP replies.
2016-12-12 07:19:53 +00:00
whitequark
d862512582
Implement an ARP LRU cache.
2016-12-12 02:39:46 +00:00
whitequark
2e80d69384
Naming consistency.
2016-12-11 00:50:34 +00:00
whitequark
2a438b6e8d
Factor out pretty-printing of packets.
2016-12-11 00:48:44 +00:00
whitequark
e7d6237279
Implement TAP interface support.
2016-12-11 00:30:40 +00:00
whitequark
77225b77a9
Fix tests.
2016-12-11 00:30:40 +00:00
whitequark
fb3faa9d28
Implement a trait for sending and receiving frames.
2016-12-10 19:27:07 +00:00
whitequark
683652a9a6
smoltcp::interface → smoltcp::phy.
2016-12-10 18:33:19 +00:00
whitequark
b1149e746c
Implement raw socket interface and tcpdump.
2016-12-10 16:58:30 +00:00
whitequark
32ff49a795
Move protocol-related data structures to smoltcp::wire.
2016-12-10 13:13:13 +00:00
whitequark
d966c1870b
Implement ARP representation parsing and emission.
2016-12-10 11:16:58 +00:00
whitequark
adff3c0069
Imlpement ARP packet support.
2016-12-10 10:40:46 +00:00
whitequark
c638f45373
Implement Ethernet II frame support.
2016-12-10 09:55:45 +00:00