Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/netif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl EspNetif {
};

if let Some(dns) = dns {
netif.set_dns(dns);
netif.set_dns(dns)?;

if dhcps {
#[cfg(esp_idf_version_major = "4")]
Expand All @@ -398,7 +398,7 @@ impl EspNetif {
}

if let Some(secondary_dns) = secondary_dns {
netif.set_secondary_dns(secondary_dns);
netif.set_secondary_dns(secondary_dns)?;
}

if let Some(hostname) = hostname {
Expand Down Expand Up @@ -479,7 +479,7 @@ impl EspNetif {
}
}

fn set_dns(&mut self, dns: ipv4::Ipv4Addr) {
pub fn set_dns(&mut self, dns: ipv4::Ipv4Addr) -> Result<(), EspError> {
let mut dns_info: esp_netif_dns_info_t = Default::default();

unsafe {
Expand All @@ -489,8 +489,8 @@ impl EspNetif {
self.handle,
esp_netif_dns_type_t_ESP_NETIF_DNS_MAIN,
&mut dns_info
))
.unwrap();
))?;
Ok(())
}
}

Expand All @@ -509,7 +509,7 @@ impl EspNetif {
}
}

fn set_secondary_dns(&mut self, secondary_dns: ipv4::Ipv4Addr) {
pub fn set_secondary_dns(&mut self, secondary_dns: ipv4::Ipv4Addr) -> Result<(), EspError> {
let mut dns_info: esp_netif_dns_info_t = Default::default();

unsafe {
Expand All @@ -519,8 +519,8 @@ impl EspNetif {
self.handle,
esp_netif_dns_type_t_ESP_NETIF_DNS_BACKUP,
&mut dns_info
))
.unwrap();
))?;
Ok(())
}
}

Expand All @@ -531,7 +531,7 @@ impl EspNetif {
Ok(unsafe { from_cstr_ptr(ptr) }.try_into().unwrap())
}

fn set_hostname(&mut self, hostname: &str) -> Result<(), EspError> {
pub fn set_hostname(&mut self, hostname: &str) -> Result<(), EspError> {
let hostname = to_cstring_arg(hostname)?;

esp!(unsafe { esp_netif_set_hostname(self.handle, hostname.as_ptr() as *const _) })?;
Expand Down