diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-10-06 23:47:43 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-10-07 00:22:44 +0200 |
| commit | f6155cf735678fa1e297baa4ace992af3a871ae7 (patch) | |
| tree | 21c8d87ca763471360fef1c4c8ea448784ccb4e6 /embassy-net | |
| parent | 631fec8d092b247b02d4279b8087cceb49146575 (diff) | |
Update smoltcp, embedded-nal-async to use the `core::net` IP addr types.
Diffstat (limited to 'embassy-net')
| -rw-r--r-- | embassy-net/Cargo.toml | 4 | ||||
| -rw-r--r-- | embassy-net/src/dns.rs | 17 | ||||
| -rw-r--r-- | embassy-net/src/tcp.rs | 12 |
3 files changed, 14 insertions, 19 deletions
diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 2e21b4231..a33c693fc 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml | |||
| @@ -68,7 +68,7 @@ multicast = ["smoltcp/multicast"] | |||
| 68 | defmt = { version = "0.3", optional = true } | 68 | defmt = { version = "0.3", optional = true } |
| 69 | log = { version = "0.4.14", optional = true } | 69 | log = { version = "0.4.14", optional = true } |
| 70 | 70 | ||
| 71 | smoltcp = { git="https://github.com/smoltcp-rs/smoltcp", rev="dd43c8f189178b0ab3bda798ed8578b5b0a6f094", default-features = false, features = [ | 71 | smoltcp = { git="https://github.com/smoltcp-rs/smoltcp", rev="b65e1b64dc9b66fa984a2ad34e90685cb0b606de", default-features = false, features = [ |
| 72 | "socket", | 72 | "socket", |
| 73 | "async", | 73 | "async", |
| 74 | ] } | 74 | ] } |
| @@ -80,5 +80,5 @@ embedded-io-async = { version = "0.6.1" } | |||
| 80 | 80 | ||
| 81 | managed = { version = "0.8.0", default-features = false, features = [ "map" ] } | 81 | managed = { version = "0.8.0", default-features = false, features = [ "map" ] } |
| 82 | heapless = { version = "0.8", default-features = false } | 82 | heapless = { version = "0.8", default-features = false } |
| 83 | embedded-nal-async = { version = "0.7.1" } | 83 | embedded-nal-async = "0.8.0" |
| 84 | document-features = "0.2.7" | 84 | document-features = "0.2.7" |
diff --git a/embassy-net/src/dns.rs b/embassy-net/src/dns.rs index 1fbaea4f0..dbe73776c 100644 --- a/embassy-net/src/dns.rs +++ b/embassy-net/src/dns.rs | |||
| @@ -73,8 +73,11 @@ impl<'a> embedded_nal_async::Dns for DnsSocket<'a> { | |||
| 73 | &self, | 73 | &self, |
| 74 | host: &str, | 74 | host: &str, |
| 75 | addr_type: embedded_nal_async::AddrType, | 75 | addr_type: embedded_nal_async::AddrType, |
| 76 | ) -> Result<embedded_nal_async::IpAddr, Self::Error> { | 76 | ) -> Result<core::net::IpAddr, Self::Error> { |
| 77 | use embedded_nal_async::{AddrType, IpAddr}; | 77 | use core::net::IpAddr; |
| 78 | |||
| 79 | use embedded_nal_async::AddrType; | ||
| 80 | |||
| 78 | let (qtype, secondary_qtype) = match addr_type { | 81 | let (qtype, secondary_qtype) = match addr_type { |
| 79 | AddrType::IPv4 => (DnsQueryType::A, None), | 82 | AddrType::IPv4 => (DnsQueryType::A, None), |
| 80 | AddrType::IPv6 => (DnsQueryType::Aaaa, None), | 83 | AddrType::IPv6 => (DnsQueryType::Aaaa, None), |
| @@ -98,20 +101,16 @@ impl<'a> embedded_nal_async::Dns for DnsSocket<'a> { | |||
| 98 | if let Some(first) = addrs.get(0) { | 101 | if let Some(first) = addrs.get(0) { |
| 99 | Ok(match first { | 102 | Ok(match first { |
| 100 | #[cfg(feature = "proto-ipv4")] | 103 | #[cfg(feature = "proto-ipv4")] |
| 101 | IpAddress::Ipv4(addr) => IpAddr::V4(addr.0.into()), | 104 | IpAddress::Ipv4(addr) => IpAddr::V4(*addr), |
| 102 | #[cfg(feature = "proto-ipv6")] | 105 | #[cfg(feature = "proto-ipv6")] |
| 103 | IpAddress::Ipv6(addr) => IpAddr::V6(addr.0.into()), | 106 | IpAddress::Ipv6(addr) => IpAddr::V6(*addr), |
| 104 | }) | 107 | }) |
| 105 | } else { | 108 | } else { |
| 106 | Err(Error::Failed) | 109 | Err(Error::Failed) |
| 107 | } | 110 | } |
| 108 | } | 111 | } |
| 109 | 112 | ||
| 110 | async fn get_host_by_address( | 113 | async fn get_host_by_address(&self, _addr: core::net::IpAddr, _result: &mut [u8]) -> Result<usize, Self::Error> { |
| 111 | &self, | ||
| 112 | _addr: embedded_nal_async::IpAddr, | ||
| 113 | _result: &mut [u8], | ||
| 114 | ) -> Result<usize, Self::Error> { | ||
| 115 | todo!() | 114 | todo!() |
| 116 | } | 115 | } |
| 117 | } | 116 | } |
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index bcddbc95b..1bd582b65 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -675,10 +675,9 @@ mod embedded_io_impls { | |||
| 675 | pub mod client { | 675 | pub mod client { |
| 676 | use core::cell::{Cell, UnsafeCell}; | 676 | use core::cell::{Cell, UnsafeCell}; |
| 677 | use core::mem::MaybeUninit; | 677 | use core::mem::MaybeUninit; |
| 678 | use core::net::IpAddr; | ||
| 678 | use core::ptr::NonNull; | 679 | use core::ptr::NonNull; |
| 679 | 680 | ||
| 680 | use embedded_nal_async::IpAddr; | ||
| 681 | |||
| 682 | use super::*; | 681 | use super::*; |
| 683 | 682 | ||
| 684 | /// TCP client connection pool compatible with `embedded-nal-async` traits. | 683 | /// TCP client connection pool compatible with `embedded-nal-async` traits. |
| @@ -715,17 +714,14 @@ pub mod client { | |||
| 715 | type Error = Error; | 714 | type Error = Error; |
| 716 | type Connection<'m> = TcpConnection<'m, N, TX_SZ, RX_SZ> where Self: 'm; | 715 | type Connection<'m> = TcpConnection<'m, N, TX_SZ, RX_SZ> where Self: 'm; |
| 717 | 716 | ||
| 718 | async fn connect<'a>( | 717 | async fn connect<'a>(&'a self, remote: core::net::SocketAddr) -> Result<Self::Connection<'a>, Self::Error> { |
| 719 | &'a self, | ||
| 720 | remote: embedded_nal_async::SocketAddr, | ||
| 721 | ) -> Result<Self::Connection<'a>, Self::Error> { | ||
| 722 | let addr: crate::IpAddress = match remote.ip() { | 718 | let addr: crate::IpAddress = match remote.ip() { |
| 723 | #[cfg(feature = "proto-ipv4")] | 719 | #[cfg(feature = "proto-ipv4")] |
| 724 | IpAddr::V4(addr) => crate::IpAddress::Ipv4(crate::Ipv4Address::from_bytes(&addr.octets())), | 720 | IpAddr::V4(addr) => crate::IpAddress::Ipv4(addr), |
| 725 | #[cfg(not(feature = "proto-ipv4"))] | 721 | #[cfg(not(feature = "proto-ipv4"))] |
| 726 | IpAddr::V4(_) => panic!("ipv4 support not enabled"), | 722 | IpAddr::V4(_) => panic!("ipv4 support not enabled"), |
| 727 | #[cfg(feature = "proto-ipv6")] | 723 | #[cfg(feature = "proto-ipv6")] |
| 728 | IpAddr::V6(addr) => crate::IpAddress::Ipv6(crate::Ipv6Address::from_bytes(&addr.octets())), | 724 | IpAddr::V6(addr) => crate::IpAddress::Ipv6(addr), |
| 729 | #[cfg(not(feature = "proto-ipv6"))] | 725 | #[cfg(not(feature = "proto-ipv6"))] |
| 730 | IpAddr::V6(_) => panic!("ipv6 support not enabled"), | 726 | IpAddr::V6(_) => panic!("ipv6 support not enabled"), |
| 731 | }; | 727 | }; |
