Browse Source

clear addresses instead of setting unspecified

James Logan 1 year ago
parent
commit
b78ab0eb20
1 changed files with 1 additions and 4 deletions
  1. 1 4
      examples/dhcp_client.rs

+ 1 - 4
examples/dhcp_client.rs

@@ -38,9 +38,6 @@ fn main() {
     config.random_seed = rand::random();
     let mut iface = Interface::new(config, &mut device, Instant::now());
 
-    // Initialize with an unspecified address
-    set_ipv4_addr(&mut iface, Ipv4Cidr::new(Ipv4Address::UNSPECIFIED, 0));
-
     // Create sockets
     let mut dhcp_socket = dhcpv4::Socket::new();
 
@@ -80,7 +77,7 @@ fn main() {
             }
             Some(dhcpv4::Event::Deconfigured) => {
                 debug!("DHCP lost config!");
-                set_ipv4_addr(&mut iface, Ipv4Cidr::new(Ipv4Address::UNSPECIFIED, 0));
+                iface.update_ip_addrs(|addrs| addrs.clear());
                 iface.routes_mut().remove_default_ipv4_route();
             }
         }