浏览代码

clear addresses instead of setting unspecified

James Logan 1 年之前
父节点
当前提交
b78ab0eb20
共有 1 个文件被更改,包括 1 次插入4 次删除
  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();
             }
         }