diff options
| author | Ulf Lilleengen <[email protected]> | 2023-02-10 18:20:50 +0100 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2023-02-10 18:20:50 +0100 |
| commit | 7ae47cb1d81d5112fdc42ceaec470350aab5c372 (patch) | |
| tree | 89b6f40545dd3e3b5ecf5b6bdf661ee2e6936032 /embassy-net | |
| parent | cd440a49d677f7dfc09e405d99b87a49fba9ba31 (diff) | |
Expose api on Stack and add doc
Make it work with smoltcp 0.9
Diffstat (limited to 'embassy-net')
| -rw-r--r-- | embassy-net/src/dns.rs | 8 | ||||
| -rw-r--r-- | embassy-net/src/lib.rs | 7 |
2 files changed, 5 insertions, 10 deletions
diff --git a/embassy-net/src/dns.rs b/embassy-net/src/dns.rs index 1815d258f..9b1b936c4 100644 --- a/embassy-net/src/dns.rs +++ b/embassy-net/src/dns.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! DNS socket with async support. | 1 | //! DNS socket with async support. |
| 2 | use heapless::Vec; | 2 | use heapless::Vec; |
| 3 | pub use smoltcp::socket::dns::{DnsQuery, Socket, MAX_ADDRESS_COUNT}; | 3 | pub use smoltcp::socket::dns::{DnsQuery, Socket}; |
| 4 | pub(crate) use smoltcp::socket::dns::{GetQueryResultError, StartQueryError}; | 4 | pub(crate) use smoltcp::socket::dns::{GetQueryResultError, StartQueryError}; |
| 5 | pub use smoltcp::wire::{DnsQueryType, IpAddress}; | 5 | pub use smoltcp::wire::{DnsQueryType, IpAddress}; |
| 6 | 6 | ||
| @@ -48,9 +48,7 @@ impl<'a, D> DnsSocket<'a, D> | |||
| 48 | where | 48 | where |
| 49 | D: Driver + 'static, | 49 | D: Driver + 'static, |
| 50 | { | 50 | { |
| 51 | /// Create a new DNS socket using the provided stack and query storage. | 51 | /// Create a new DNS socket using the provided stack. |
| 52 | /// | ||
| 53 | /// DNS servers are derived from the stack configuration. | ||
| 54 | /// | 52 | /// |
| 55 | /// NOTE: If using DHCP, make sure it has reconfigured the stack to ensure the DNS servers are updated. | 53 | /// NOTE: If using DHCP, make sure it has reconfigured the stack to ensure the DNS servers are updated. |
| 56 | pub fn new(stack: &'a Stack<D>) -> Self { | 54 | pub fn new(stack: &'a Stack<D>) -> Self { |
| @@ -58,7 +56,7 @@ where | |||
| 58 | } | 56 | } |
| 59 | 57 | ||
| 60 | /// Make a query for a given name and return the corresponding IP addresses. | 58 | /// Make a query for a given name and return the corresponding IP addresses. |
| 61 | pub async fn query(&self, name: &str, qtype: DnsQueryType) -> Result<Vec<IpAddress, MAX_ADDRESS_COUNT>, Error> { | 59 | pub async fn query(&self, name: &str, qtype: DnsQueryType) -> Result<Vec<IpAddress, 1>, Error> { |
| 62 | self.stack.dns_query(name, qtype).await | 60 | self.stack.dns_query(name, qtype).await |
| 63 | } | 61 | } |
| 64 | } | 62 | } |
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index b63aa83df..5b6ab0e3a 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -231,12 +231,9 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 231 | unreachable!() | 231 | unreachable!() |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | /// Make a query for a given name and return the corresponding IP addresses. | ||
| 234 | #[cfg(feature = "dns")] | 235 | #[cfg(feature = "dns")] |
| 235 | async fn dns_query( | 236 | pub async fn dns_query(&self, name: &str, qtype: dns::DnsQueryType) -> Result<Vec<IpAddress, 1>, dns::Error> { |
| 236 | &self, | ||
| 237 | name: &str, | ||
| 238 | qtype: dns::DnsQueryType, | ||
| 239 | ) -> Result<Vec<IpAddress, { dns::MAX_ADDRESS_COUNT }>, dns::Error> { | ||
| 240 | let query = self.with_mut(|s, i| { | 237 | let query = self.with_mut(|s, i| { |
| 241 | if let Some(dns_handle) = i.dns_socket { | 238 | if let Some(dns_handle) = i.dns_socket { |
| 242 | let socket = s.sockets.get_mut::<dns::Socket>(dns_handle); | 239 | let socket = s.sockets.get_mut::<dns::Socket>(dns_handle); |
