Commit Graph

837 Commits (master)

Author SHA1 Message Date
Gerd Zellweger e4d487d5fb Fix unused extern crate warning with certain build flags. 2021-06-14 15:16:15 -07:00
Gerd Zellweger bae279c3a8 Also import alloc crate for std. 2021-06-14 13:39:33 -07:00
Gerd Zellweger 4210fe5e60 Update loopback.rs 2021-06-14 13:33:16 -07:00
Ryan Summers 9f7bf5dc68 Adding support for retrieving socket handle from DHCP sockets 2021-06-14 10:53:27 +02:00
Dario Nieuwenhuis 0754a7703c tcp: use nonzero initial sequence number. 2021-06-11 22:36:26 +02:00
Dario Nieuwenhuis caad8929d5 tcp: fix substract with overflow when receiving a SYNACK with unincremented ACK number. 2021-06-11 22:17:59 +02:00
Dario Nieuwenhuis f1b0a04599 tcp: extract ack_min, ack_max vars 2021-06-11 22:17:24 +02:00
Dario Nieuwenhuis de950ef823 Fix "subtract sequence numbers with underflow" on remote window shrink.
Fixes #489
2021-06-11 11:25:30 +02:00
Ryan Summers 06a52a7de9 Merge branch 'master' into rs/issue-475/udp-rebinding 2021-06-09 16:27:04 +02:00
Ryan Summers a6dbd18574 Merge branch 'master' into rs/issue-281/ethernet-dos 2021-06-09 11:38:40 +02:00
Ryan Summers 57604a4d4c Sanitizing log macro to allow usage in match arm directly 2021-06-09 11:36:28 +02:00
Ryan Summers 421870ee75 Restructuring to allow-unused 2021-06-09 11:30:02 +02:00
Ryan Summers 2fb5880628 Fixing feature flag 2021-06-09 11:13:56 +02:00
qiujiangkun 0be1a76bc3 add std::error::Error to smoltcp::Error 2021-06-08 14:34:38 +08:00
Ryan Summers 84866f8f69 Updating packet buffer clear to be UDP-only 2021-05-31 18:07:19 +02:00
Ryan Summers fa77ddd836 Updating UDP close to clear RX/TX buffers 2021-05-31 18:04:02 +02:00
Ryan Summers e27e3254f4 Fixing clippy 2021-05-31 17:58:20 +02:00
Ryan Summers 0bb9fc90f0 Simplifying loop logic 2021-05-31 17:42:01 +02:00
Ryan Summers 44add57e8e Removing unneeded changes 2021-05-31 17:39:30 +02:00
Ryan Summers f790f59088 Reverting phy changes 2021-05-31 17:36:26 +02:00
Ryan Summers 8474a1b1e4 cleaning up implementation 2021-05-31 17:33:52 +02:00
Ryan Summers 95829934db Fail-free ingress 2021-05-31 17:30:45 +02:00
Ryan Summers 8d4e255090 Adding prototype fix for fail-free ingress 2021-05-31 17:25:04 +02:00
Ryan Summers 108543a2f6 Adding UDP socket close funcionality 2021-05-31 14:25:52 +02:00
Dario Nieuwenhuis b9477f25bc wire/dhcp: Simplify how options are emitted. 2021-05-29 01:44:27 +02:00
Dario Nieuwenhuis ea8d2ae7f4 Fix u32::MAX 2021-05-29 01:32:17 +02:00
Anton Romanov 7b6b70d058 Account for lease time, router and subnet options in DhcpRepr::buffer_len 2021-05-29 01:32:17 +02:00
Dario Nieuwenhuis a5b9461275 tcp: LastAck should only change to Closed on ack of fin.
Fixes #470
2021-05-28 21:09:36 +02:00
Dario Nieuwenhuis 383d2426cb tcp rtte: fix "attempt to multiply with overflow". Fixes #468 2021-05-28 21:02:31 +02:00
Dario Nieuwenhuis a81f2fef56 dhcp: convert port check to hard assert. 2021-05-28 18:43:52 +02:00
Dario Nieuwenhuis 07c3a402a3 Remove unused macro_use 2021-05-28 18:26:08 +02:00
Dario Nieuwenhuis 743f9de039 dhcp: address review comments. 2021-05-28 18:23:50 +02:00
Dario Nieuwenhuis 284f5bc834 wire/udp: clearer HEADER_LEN usage 2021-05-28 17:47:02 +02:00
Dario Nieuwenhuis a916888ab8 dhcp: add max_lease_duration option 2021-04-13 20:23:28 +02:00
Dario Nieuwenhuis 53b62cfbad dhcp: remove 0.0.0.0s from the DNS serevr list.
tp-link routers pad the DNS server list with 0.0.0.0 to a fixed size :(
2021-04-13 18:43:23 +02:00
Dario Nieuwenhuis b1f2bcb678 dhcp: retry REQUEST slower and with exponential backoff. Fixes #464 2021-04-07 21:52:26 +02:00
Dario Nieuwenhuis cb075bfc16 dhcp: handle NAK packets 2021-04-07 19:00:36 +02:00
Dario Nieuwenhuis 0d53163c55 dhcp: convert to socket 2021-04-07 19:00:36 +02:00
Dario Nieuwenhuis ef58fc67a4 route: add remove_default_ipvX_route 2021-04-07 14:49:46 +02:00
Dario Nieuwenhuis ab47db24e0 udp: do not include payload in UdpRepr
This makes UdpRepr work like IpRepr, where it only emits the header, and the user
must emit the payload.

This makes it easier to emit UDP packets with payloads that come from protocol-specific
reprs, like DHCP and in the future DNS.
2021-04-07 14:49:46 +02:00
Dario Nieuwenhuis 68d60a202b phy: fix FaultInjector returning a too big buffer when simulating a drop on tx 2021-04-07 02:40:32 +02:00
Dario Nieuwenhuis 1d19ff8d91 dhcp: Clear expiration time on reset. 2021-04-07 02:32:46 +02:00
Dario Nieuwenhuis 562f12ffed dhcp: always send parameter_request_list. Fixes #445. 2021-04-07 02:32:46 +02:00
Dario Nieuwenhuis c043897327 iface: check for ipv4 subnet broadcast addrs everywhere 2021-04-07 02:23:19 +02:00
Dario Nieuwenhuis 77c46220a6 Document MSRV with the defmt exception, don't test defmt with 1.40 2021-04-01 02:15:35 +02:00
Dario Nieuwenhuis d64c8593f0 Add defmt logging support 2021-04-01 01:30:47 +02:00
Dario Nieuwenhuis 6e8c2a8455 Add IP medium support to PcapWriter and Tracer. 2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis 9e3b373e36 Add support for TUN interfaces. 2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis b6220a04c8 Do not use DeviceCapabilities in sockets.
DeviceCapabilities contains the `medium` field, so tests had to give it a value
even if it was unused. This is impossible to do with no `medium-*` enabled, because
it makes `Medium` uninhabited (empty enum).
2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis af4a1e6436 Add medium-ip, medium-ethernet feature flags. 2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis 9ac2cac075 Add support for IP mediums.
- Add `medium` in `DeviceCapabilities`.
- Rename EthernetInterface to Interface.
- Add support to Interface for both Ethernet and IP mediums. The medium to use is detected from `device.capabilities().medium`.
- Ethernet-only features are gated behind the "ethernet" feature, as before.
- IP features are always enabled for now.
2021-03-31 17:05:09 +02:00
Dario Nieuwenhuis 1a1741660a Fix "leftover tokens" macro error 2021-03-25 00:06:35 +01:00
Dario Nieuwenhuis f6259f8113 Merge branch 'master' into feature/dhcp-lease-updates 2021-03-24 03:26:42 +01:00
Dario Nieuwenhuis 79dfc7e97e Merge branch 'master' into fix-phywait 2021-03-24 03:13:13 +01:00
Dario Nieuwenhuis a576389340 Fix timeval in phy_wait for times greater than 1 second 2021-03-24 02:58:51 +01:00
Dario Nieuwenhuis 067eee1681 Merge branch 'master' into feature/dhcp-lease-updates 2021-03-24 02:56:21 +01:00
Dario Nieuwenhuis 8e86318a13 Fix feature-related compilation issues. 2021-03-24 02:28:55 +01:00
Dario Nieuwenhuis e40b1442ce Remove support table from docs. Fixes #361
The table is no longer very informative since it's all "yes" now.
2021-03-24 02:21:12 +01:00
Ryan Summers 881123f849 Removing lease expiration on reset - the lease does not expire 2021-03-18 16:26:44 +01:00
Ryan Summers 2851a135df Adding parsing test with lease time 2021-03-12 17:36:43 +01:00
Ryan Summers 39c3e7ef1f Updating control logic 2021-03-12 17:28:00 +01:00
Ryan Summers c491962b3f Refactoring retry mechanism 2021-03-12 16:14:44 +01:00
Ryan Summers 647e27ed2b Adding DHCP lease management 2021-03-12 14:03:51 +01:00
whitequark b1db516b10 Enable all Linux `phy` components for Android as well.
Fixes #433.
2021-03-12 06:31:05 +00:00
whitequark 9f0213765c Simplify enum_with_unknown! macro. 2021-03-12 06:15:34 +00:00
Dario Nieuwenhuis 4933a0a19f Merge pull request #431 from dnadlinger/patch-2
socket/tcp: Fix missing ` in doc comment
2021-03-07 07:58:04 +01:00
David Nadlinger b5eca87885 socket/tcp: Fix missing ` in doc comment 2021-03-07 04:14:10 +00:00
David Nadlinger 3fb05f0857 socket/tcp: Fix is_active comment typo 2021-03-07 04:09:44 +00:00
Nathan K. Zhinn 4ac265fb46 Fix BPF header length on OpenBSD.
The actual header length may be larger than the bpf_hdr struct due to aligning:
37ecb4d066/sys/net/bpf.c (L1649)
8f02f2a044/bsd/net/bpf.c (L3580)

Tests are only valid for 32 and 64 bit architectures. I did not bother
guarding them with additional cfg flags.
2021-03-01 04:37:37 +00:00
Dario Nieuwenhuis 5388ef1f1d Merge pull request #419 from vkrasnov/vlad/solicit_dst
Ask for dst_addr in neighbor solicitation request
2021-02-20 13:03:47 +01:00
whitequark 9f51548f4d Merge pull request #421 from pk-j-xyz/openbsd-bpf
Fix bpf ffi and add OpenBSD bpf cfg
2021-02-18 01:30:12 +00:00
Nathan K. Zhinn 019653b0cf Fix bpf ffi and add OpenBSD bpf cfg
This fixes the ordering that was causing a dealloc before the FFI call
to libc open.
2021-02-17 15:11:56 +00:00
Ben Stabler 335099aa26 Silence clippy lint for const assert work-around, remove const where using features not yet stable in 1.40 2021-02-11 23:10:35 -08:00
Ben Stabler 851d26aaa6 Make wire/ipv4 functions const where possible. 2021-02-11 22:49:33 -08:00
Vlad Krasnov c6f7163638 Ask for dst_addr in neighbor solicitation request 2021-02-09 14:07:57 -05:00
Dario Nieuwenhuis 857c012f14 Fix build when with no socket features 2021-02-01 16:45:32 +01:00
Dario Nieuwenhuis 8da202ff7f Simplify EthernetInterface lifetimes. 2021-01-19 22:59:52 +01:00
Dario Nieuwenhuis 02a80a6000 Simplify SocketSet lifetimes 2021-01-19 22:45:15 +01:00
Dario Nieuwenhuis af2eb5a454 Clarify docs of DeviceCapabilities MTU. Fixes #392 2021-01-19 22:20:40 +01:00
Scott Mabin 47d27472b9 subnet_broadcasts
Adds `is_subnet_broadcast` to the ethernet interface which checks for
subnet broadcasts, which are discussed on page 8 in
https://tools.ietf.org/html/rfc917. The subnet broadcast addresses are
derived from the interfaces ipv4 addresses.
2021-01-16 15:36:27 +00:00
Alex Crawford 0cf0a7e386 Clean up clippy warnings about if-else blocks
This de-duplicates and (hopefully) simplifies a few if-else blocks. The
others were given an exception because I thought they were more readable
as is. I've verified that these changes don't result in larger binaries.
2021-01-10 14:30:31 -08:00
Alex Crawford 06d128ad22 Use #[non_exhaustive] on structs as well
This builds on 633e7c25, adding the #[non_exhaustive] attribute to
applicable struct definitions.
2021-01-10 13:54:29 -08:00
Niclas Hoyer ad7795f996 Use #[non_exhaustive] instead of manual variant 2021-01-09 02:06:00 +01:00
Dario Nieuwenhuis c09ca370b2 Simplify Socket lifetimes 2021-01-09 01:59:02 +01:00
Dario Nieuwenhuis 2ea2b7ff6b tcp: add Delayed ACK 2021-01-07 00:21:55 +01:00
Alex Crawford cb66f9f036 Allow DeviceCapabilities to be initialized
This was flagged by `cargo clippy`:

    warning: field assignment outside of initializer for an instance
             created with Default::default()

This changes the visibility of the dummy field to be public, but only to
the crate.
2021-01-04 10:39:33 -08:00
Alex Crawford 6b524dc74d Various cleanups
These were flagged by `cargo clippy`:

    warning: using `clone` on a `Copy` type
    warning: passing a unit value to a function
    warning: redundant closure found
    warning: called `iter().cloned().collect()` on a slice to create a
             `Vec`. Calling `to_vec()` is both faster and more readable
2021-01-04 10:39:06 -08:00
Dario Nieuwenhuis bb891ce7c1 tcp: Add RTT estimation. 2021-01-04 03:26:55 +01:00
Dario Nieuwenhuis 0752945161 Make some time funcs const. 2021-01-04 01:37:06 +01:00
Dario Nieuwenhuis 45df367d7e More clippy fixes. 2021-01-04 01:19:20 +01:00
Alex Crawford bc957da1ea Collapse redundant closure
This was flagged by `cargo clippy`:

    warning: redundant closure found
2020-12-28 23:31:17 -08:00
Alex Crawford 039a55e1bf Remove unnecessary clones
These were flagged by `cargo clippy`:

    warning: using `clone` on a `Copy` type
2020-12-28 23:20:21 -08:00
Alex Crawford 0e21e8524f Silence warning about mapping to unit type
This was flagged by `cargo clippy`:

    warning: called `map(f)` on an `Option` value where `f` is a closure
             that returns the unit type `()`

I decided to disable this because it was suggesting changes like the
following and I prefer the original:

    @@ -1 +1 @@
    -self.waker.take().map(|w| w.wake());
    +if let Some(w) = self.waker.take() { w.wake() }
2020-12-28 23:10:05 -08:00
Alex Crawford 27232041e7 Silence a few warnings from clippy
These were flagged by `cargo clippy`:

    warning: the operation is ineffective. Consider reducing it to `number`
    warning: this function has too many arguments (8/7)
    warning: you should consider adding a `Default` implementation for
             `phy::loopback::Loopback`

I like the code better as it is.
2020-12-28 23:09:53 -08:00
Alex Crawford 8a961b7d7c Use iterators instead of manually looping
These were flagged by `cargo clippy`:

    warning: the loop variable is used to index

I've verified that this doesn't increase the size of consuming binaries.
Pretty impressive. I tested this with a project that uses the following
features: ethernet, proto-dhcpv4, socket-tcp.
2020-12-28 22:28:07 -08:00
Alex Crawford 20c82238df Remove some unneeded imports and a variable
These were flagged by `cargo clippy`:

    warning: returning the result of a `let` binding from a block
    warning: this import is redundant
2020-12-28 22:28:06 -08:00
Alex Crawford fff5926210 Clean up a couple of if-blocks
These were flagged by `cargo clippy`:

    warning: this `else { if .. }` block can be collapsed
2020-12-28 22:27:24 -08:00
Alex Crawford e27f6cb564 Remove redundant field names from structs
These were flagged by `cargo clippy`:

    warning: redundant field names in struct initialization

There are plenty more redundant field names, but I only changed the ones
where the initialization was a single line of code. I still prefer the
redundant style for multi-line initializations (and I'm under the
impression that others agree), so I've also disabled the warning.
2020-12-28 22:27:24 -08:00
Dario Nieuwenhuis adce62a795 Merge pull request #398 from smoltcp-rs/simultaneous-close
tcp: fix racey simultaneous close not sending FIN.
2020-12-28 14:49:13 +01:00
Dario Nieuwenhuis f67097cf3f Merge pull request #399 from smoltcp-rs/medium-ip-part1
Add IP medium support, part 1
2020-12-28 14:31:33 +01:00
Alex Crawford e78c9576b2 Clean up iterator chains
These were flagged by `cargo clippy`:

    warning: called `is_some()` after searching an `Iterator` with find.
             This is more succinctly expressed by calling `any()`.
    warning: this `.into_iter()` call is equivalent to `.iter_mut()` and
             will not consume the `BTreeMap`
    warning: called `skip_while(p).next()` on an `Iterator`

The skip_while conversion is a little tricky. Clippy notes that:

    warning: called `skip_while(p).next()` on an `Iterator`
    help: this is more succinctly expressed by calling `.find(!p)` instead

So the condition of the skip_while is inverted and then simplified using
De Morgan's laws.
2020-12-27 17:00:03 -08:00
Alex Crawford 81ddfe734f Remove some redundant closures
These were flagged by `cargo clippy`:

    warning: redundant closure found
2020-12-27 17:00:03 -08:00
Alex Crawford 737fdf7bbf Use subsec_millis where possible
These were flagged by `cargo clippy`:

    warning: calling `subsec_millis()` is more concise than this
             calculation
2020-12-27 17:00:03 -08:00
Alex Crawford ec5c924d88 Prefer elided lifetimes
These were flagged by `cargo clippy`:

    warning: explicit lifetimes given in parameter types where they
             could be elided (or replaced with `'_` if needed by type
             declaration)
2020-12-27 17:00:03 -08:00
Alex Crawford d2b557e01c Prefer assignment operators
These were flagged by `cargo clippy`:

    warning: manual implementation of an assign operation
2020-12-27 17:00:03 -08:00
Alex Crawford a73c90ad08 Silence warning about matches macro
These were flagged by `cargo clippy`:

    warning: match expression looks like `matches!` macro

The matches! macro isn't stabilized until Rust 1.42.
2020-12-27 17:00:02 -08:00
Alex Crawford 79e81bf97f Silence warning about is_empty method
These were flagged by `cargo clippy`:

    warning: item has a public `len` method but no corresponding
             `is_empty` method
2020-12-27 16:59:39 -08:00
Alex Crawford 1a1861721b Silence warning about non-exhaustive pattern
These were flagged by `cargo clippy`:

    warning: this seems like a manual implementation of the
             non-exhaustive pattern

The non_exhaustive attribute isn't available until we increase the
minimum Rust version to 1.40, so we should just silence these warnings
in the meantime.
2020-12-27 16:59:30 -08:00
Alex Crawford 752e81489e Dereference match expressions to clean up patterns
These were flagged by `cargo clippy`:

    warning: you don't need to add `&` to all patterns

This should have happened in ac830e8b, but I guess I missed it.
2020-12-27 15:20:16 -08:00
Alex Crawford 321998eb66 Prefer if-let syntax over single-pattern match
These were flagged by `cargo clippy`:

    warning: you seem to be trying to use match for destructuring a
             single pattern. Consider using `if let`

This also silences a few cases where the match couldn't be replaced with
an if because of the following error:

    error: attributes are not yet allowed on `if` expressions

Once we increase the minimum Rust version to 1.43, these can be updated
as well.
2020-12-27 15:20:14 -08:00
Alex Crawford b2c04416c2 Use is_empty instead of length comparison
These were flagged by `cargo clippy`:

    warning: length comparison to zero
2020-12-27 15:18:51 -08:00
Dario Nieuwenhuis 708be1ccb5 Split Packet into EthernetPacket and IpPacket.
Functions that only deal with IP packets take/return IpPacket's. IpPacket's
are wrapped into EthernetPacket's as late as possible.

This will later allow generalizing Interface to handle both Ethernet
and pure-IP mediums.
2020-12-27 19:57:18 +01:00
Dario Nieuwenhuis 2d7b150984 Remove "None" variant from Packet, use Option<Packet> instead. 2020-12-27 19:25:25 +01:00
Dario Nieuwenhuis 2c8b780702 tcp: fix racey simultaneous close not sending FIN. 2020-12-27 19:11:52 +01:00
Dario Nieuwenhuis 88256dbdcf Update to Rust 2018. Fixes #271 2020-12-27 17:54:56 +01:00
Dario Nieuwenhuis 4e11070ff4 Async/await waker support. 2020-12-27 17:31:49 +01:00
Dario Nieuwenhuis 29cc59c89d Merge pull request #395 from crawford/clippy
Various cleanup suggested by cargo clippy
2020-12-26 23:53:25 +01:00
Alex Crawford c9f57150a8 Dereference match expressions to clean up patterns
These were flagged by `cargo clippy`:

    warning: you don't need to add `&` to all patterns
2020-12-26 10:32:51 -08:00
Alex Crawford 0c7cdbb4ef Remove unnecessary returns
These were flagged by `cargo clippy`:

    warning: unneeded `return` statement
2020-12-26 10:32:51 -08:00
Alex Crawford c58711e11b Use newline variants of write macro
These were flagged by `cargo clippy`:

    warning: using `println!("")`
    warning: using `write!()` with a format string that ends in a single
             newline
2020-12-26 10:32:42 -08: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 a7d3f604a3 Don't use matches! macro, for Rust 1.36 support 2020-12-26 03:12:48 +01:00
Dario Nieuwenhuis 67e03b34b6 Fix seq_to_transmit incorrectly returning true when a FIN was enqueued.
If there's data queued that doesn't fit into the remote window, we can't
send the FIN either, so seq_to_transmit should return false.
2020-12-26 03:04:17 +01:00
Dario Nieuwenhuis 12f2e0f7e2 Merge pull request #372 from JOE1994/null_terminator
add null terminator to c-string passed to 'libc::open'
2020-12-26 00:24:27 +01:00
JOE1994 e12f4abaa0 add null terminator to c-string passed to libc API 2020-12-26 00:07:14 +01:00
Dario Nieuwenhuis 273f4d60b6 Fix MTU of RawSocket and TapInterface.
Linux's MTU is the IP MTU, while smoltcp's is the Ethernet MTU.
Therefore we have to add the ethernet header size to it.
2020-12-25 23:57:54 +01:00
Dario Nieuwenhuis f89d240c29 tcp: don't send data outside the remote window 2020-12-19 03:23:44 +00:00
Dario Nieuwenhuis 42dc04852b tcp: allow sending ACKs in FinWait2 state. 2020-12-19 01:13:59 +00:00
mustermeiszer 7b4997d5c7 Taking into account TCP and IP header
The MTU consists of TCP header, IP header and the payload.
In the former fix, this was not taken into account.
2020-10-23 15:13:18 +02:00
mustermeiszer d2aa3edbb7 Fixes unused MTU settings at TcpSocket dispatch
This commit fixes a small bug, where the TcpSocket computed the maximum
size per payload in a tx_buffer without taking into account the MTU
defined by the underlying network device.
2020-10-23 14:12:20 +02:00
Sam Jones d32c72aafd Changed Dhcpv4Client to use device checksum capabilities 2020-10-22 10:31:36 +00:00
whitequark 3e22502f61 Merge branch 'master' into dhcpv4-use-requested_ip 2020-10-22 09:53:38 +00:00
Dario Nieuwenhuis bc1f718589 igmp: centisecs are really decisecs 2020-10-22 03:48:19 +00:00
Ryan Summers 1ae400acaa Return RST to unexpected ACK in SYN-SENT state.
Before this commit, the socket got stuck in an unusable state.
2020-08-17 05:44:58 +00:00
whitequark f35057c19f Fix test that relied on matching panic messages.
The panic message for copy_from_slice changed in Rust 1.47.
2020-08-17 05:19:09 +00:00
Thales Fragoso 88d01234a8 Match silent_until behavior of NeighborState and Cache 2020-08-17 04:44:58 +00:00
Thales Fragoso 561708c34f Merge lookup and lookup_pure methods 2020-08-17 04:44:58 +00:00
Thales Fragoso 1e5de8d42c Only limit the neighbor cache rate after sending a request packet
Prior to this change, the neighbor cache would get limited even when the
device failed to process our arp packet, which could put the socket in
the waiting state in the next poll.

This change only limits the cache rate if the device successfully
consumed our packet.
2020-08-17 04:44:58 +00:00
whitequark 548a019991 Update src/socket/meta.rs 2020-08-11 16:26:53 +00:00
Thales Fragoso 24e4868761 Allow for ARP retry during egress 2020-08-10 22:06:06 -03:00
whitequark 6a38ace62c Improve docs for `DeviceCapabilities.checksum`. 2020-07-15 05:06:35 +00:00
Dario Nieuwenhuis 4cfe8dafdb Do not send window updates in states that shouldn't do so.
Previously, the window update was sent anytime it changed. This is
not desirable for 2 reasons:

- It would send window updates in TimeWait or Closed states, which is incorrect.
- It would send window updates in states where we've already received the
  remote side's FIN, such as CloseWait. This is not necessarily incorrect, but
  is useless, since the remote side is not going to send us more data, therefore
  it's not interested in our window size anymore.
2020-06-25 04:06:29 +00:00
YOUNGSUK KIM f6a55fa3c7 replace deprecated item 'mem::uninitialized'
This commit replaces the use of deprecated item 'mem::uninitialized'
with 'mem::MaybeUninit'.

Thank you for reviewing :)
2020-06-22 14:46:56 +00:00
Lucas Zanela d5c44a37d5 Fix overly strict lifetime in TcpSocket. 2020-06-15 12:39:06 +00:00
Dario Nieuwenhuis d1e614516a Remove now-redundant `remote_last_ack` update. 2020-06-12 18:49:33 +00:00
Dario Nieuwenhuis 544b3789d0 Document `Error::Finished` in `recv()`. 2020-06-12 09:43:44 +00:00
Dario Nieuwenhuis a176641192 Return `Error::Finished` in `recv()` on graceful close.
This allows applications to distinguish whether the remote end has
gracefully closed the connection with a FIN (in which case it has
received all the data intact), or the connection has failed due to e.g. a
RST or a timeout (in which case the received data may be truncated).
2020-06-12 09:43:44 +00:00
Dario Nieuwenhuis efbd3ec23d Add `Finished` error. 2020-06-12 09:43:44 +00:00
Dario Nieuwenhuis 0d31e0a134 Always send updated ack number in `ack_reply()`.
Previously, `ack_reply()` was sending the ack number present in `remote_last_ack`,
which is only updated by `dispatch`. This means the ack replies could contain
a wrong, old ack number.

Most of the time this simply caused wasting an extra roundtrip until the socket state
settles down, but in extreme cases it could lead to an infinite loop of packets, such
as in https://github.com/smoltcp-rs/smoltcp/issues/338

Fixes #338
2020-06-11 23:24:24 +00:00
Dario Nieuwenhuis ffcaa83502 Accept data packets in FIN_WAIT_2 state.
Previously, data packets were never accepted in FIN_WAIT_2. The missing
match case was dropping them as "unexpected packet"s.
2020-06-11 20:19:44 +00:00