Skip to content

Commit

Permalink
update dhcp example to work in the case where we do not already have …
Browse files Browse the repository at this point in the history
…an ip address from some other source
  • Loading branch information
jlogan03 committed Feb 4, 2024
1 parent 5eced2a commit dc771ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/dhcp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fn main() {
}
Some(dhcpv4::Event::Deconfigured) => {
debug!("DHCP lost config!");
iface.update_ip_addrs(|addrs| addrs.clear());
set_ipv4_addr(&mut iface, Ipv4Cidr::new(Ipv4Address::UNSPECIFIED, 0));
iface.routes_mut().remove_default_ipv4_route();
}
Expand All @@ -88,7 +89,6 @@ fn main() {

fn set_ipv4_addr(iface: &mut Interface, cidr: Ipv4Cidr) {
iface.update_ip_addrs(|addrs| {
let dest = addrs.iter_mut().next().unwrap();
*dest = IpCidr::Ipv4(cidr);
addrs.push(IpCidr::Ipv4(cidr)).unwrap();
});
}

0 comments on commit dc771ec

Please sign in to comment.