Skip to content

Commit e90b3bc

Browse files
authored
Merge pull request #3329 from embassy-rs/net-deinit
net: refactor to simplify lifetimes/generics.
2 parents a23f56b + 73aa40a commit e90b3bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+506
-609
lines changed

Diff for: ci.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cargo batch \
4747
--- build --release --manifest-path embassy-sync/Cargo.toml --target thumbv6m-none-eabi --features defmt \
4848
--- build --release --manifest-path embassy-time/Cargo.toml --target thumbv6m-none-eabi --features defmt,defmt-timestamp-uptime,generic-queue-8,mock-driver \
4949
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,medium-ethernet,packet-trace \
50-
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,igmp,medium-ethernet \
50+
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,multicast,medium-ethernet \
5151
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet \
5252
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,dhcpv4-hostname \
5353
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet \
@@ -290,8 +290,9 @@ cargo batch \
290290
$BUILD_EXTRA
291291

292292

293-
# temporarily disabled, bluepill board got bricked
293+
# temporarily disabled, these boards are dead.
294294
rm -rf out/tests/stm32f103c8
295+
rm -rf out/tests/nrf52840-dk
295296

296297
rm out/tests/stm32wb55rg/wpan_mac
297298
rm out/tests/stm32wb55rg/wpan_ble

Diff for: embassy-net/Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ categories = [
1616
[package.metadata.embassy_docs]
1717
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/"
1818
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/"
19-
features = ["defmt", "tcp", "udp", "raw", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "igmp", "dhcpv4-hostname"]
19+
features = ["defmt", "tcp", "udp", "raw", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "multicast", "dhcpv4-hostname"]
2020
target = "thumbv7em-none-eabi"
2121

2222
[package.metadata.docs.rs]
23-
features = ["defmt", "tcp", "udp", "raw", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "igmp", "dhcpv4-hostname"]
23+
features = ["defmt", "tcp", "udp", "raw", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "multicast", "dhcpv4-hostname"]
2424

2525
[features]
2626
default = []
@@ -60,15 +60,15 @@ medium-ethernet = ["smoltcp/medium-ethernet"]
6060
medium-ip = ["smoltcp/medium-ip"]
6161
## Enable the IEEE 802.15.4 medium
6262
medium-ieee802154 = ["smoltcp/medium-ieee802154"]
63-
## Enable IGMP support
64-
igmp = ["smoltcp/proto-igmp"]
63+
## Enable multicast support (for both ipv4 and/or ipv6 if enabled)
64+
multicast = ["smoltcp/multicast"]
6565

6666
[dependencies]
6767

6868
defmt = { version = "0.3", optional = true }
6969
log = { version = "0.4.14", optional = true }
7070

71-
smoltcp = { version = "0.11.0", default-features = false, features = [
71+
smoltcp = { git="https://github.com/smoltcp-rs/smoltcp", rev="dd43c8f189178b0ab3bda798ed8578b5b0a6f094", default-features = false, features = [
7272
"socket",
7373
"async",
7474
] }

Diff for: embassy-net/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ memory management designed to work well for embedded systems, aiming for a more
1010

1111
- IPv4, IPv6
1212
- Ethernet and bare-IP mediums.
13-
- TCP, UDP, DNS, DHCPv4, IGMPv4
13+
- TCP, UDP, DNS, DHCPv4
1414
- TCP sockets implement the `embedded-io` async traits.
15+
- Multicast
1516

1617
See the [`smoltcp`](https://github.com/smoltcp-rs/smoltcp) README for a detailed list of implemented and
1718
unimplemented features of the network protocols.

Diff for: embassy-net/src/dns.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub use smoltcp::socket::dns::{DnsQuery, Socket};
99
pub(crate) use smoltcp::socket::dns::{GetQueryResultError, StartQueryError};
1010
pub use smoltcp::wire::{DnsQueryType, IpAddress};
1111

12-
use crate::{Driver, Stack};
12+
use crate::Stack;
1313

1414
/// Errors returned by DnsSocket.
1515
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
@@ -44,21 +44,15 @@ impl From<StartQueryError> for Error {
4444
/// This exists only for compatibility with crates that use `embedded-nal-async`.
4545
/// Prefer using [`Stack::dns_query`](crate::Stack::dns_query) directly if you're
4646
/// not using `embedded-nal-async`.
47-
pub struct DnsSocket<'a, D>
48-
where
49-
D: Driver + 'static,
50-
{
51-
stack: &'a Stack<D>,
47+
pub struct DnsSocket<'a> {
48+
stack: Stack<'a>,
5249
}
5350

54-
impl<'a, D> DnsSocket<'a, D>
55-
where
56-
D: Driver + 'static,
57-
{
51+
impl<'a> DnsSocket<'a> {
5852
/// Create a new DNS socket using the provided stack.
5953
///
6054
/// NOTE: If using DHCP, make sure it has reconfigured the stack to ensure the DNS servers are updated.
61-
pub fn new(stack: &'a Stack<D>) -> Self {
55+
pub fn new(stack: Stack<'a>) -> Self {
6256
Self { stack }
6357
}
6458

@@ -72,10 +66,7 @@ where
7266
}
7367
}
7468

75-
impl<'a, D> embedded_nal_async::Dns for DnsSocket<'a, D>
76-
where
77-
D: Driver + 'static,
78-
{
69+
impl<'a> embedded_nal_async::Dns for DnsSocket<'a> {
7970
type Error = Error;
8071

8172
async fn get_host_by_name(
@@ -124,3 +115,7 @@ where
124115
todo!()
125116
}
126117
}
118+
119+
fn _assert_covariant<'a, 'b: 'a>(x: DnsSocket<'b>) -> DnsSocket<'a> {
120+
x
121+
}

Diff for: embassy-net/src/device.rs renamed to embassy-net/src/driver_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ where
7474
{
7575
fn consume<R, F>(self, f: F) -> R
7676
where
77-
F: FnOnce(&mut [u8]) -> R,
77+
F: FnOnce(&[u8]) -> R,
7878
{
7979
self.0.consume(|buf| {
8080
#[cfg(feature = "packet-trace")]

0 commit comments

Comments
 (0)