Commit 53d7d0f 1 parent 5eced2a commit 53d7d0f Copy full SHA for 53d7d0f
File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,15 @@ fn main() {
38
38
config. random_seed = rand:: random ( ) ;
39
39
let mut iface = Interface :: new ( config, & mut device, Instant :: now ( ) ) ;
40
40
41
+ // Initialize with an address so that there is something to mutate later.
42
+ // This also allows sockets made before a real address is negotiated
43
+ // via DHCP to update properly afterward.
44
+ iface. update_ip_addrs ( |addrs| {
45
+ addrs
46
+ . push ( IpCidr :: Ipv4 ( Ipv4Cidr :: new ( Ipv4Address :: UNSPECIFIED , 0 ) ) )
47
+ . unwrap ( ) ;
48
+ } ) ;
49
+
41
50
// Create sockets
42
51
let mut dhcp_socket = dhcpv4:: Socket :: new ( ) ;
43
52
@@ -86,6 +95,7 @@ fn main() {
86
95
}
87
96
}
88
97
98
+ /// Mutate the first IP address to match the one supplied
89
99
fn set_ipv4_addr ( iface : & mut Interface , cidr : Ipv4Cidr ) {
90
100
iface. update_ip_addrs ( |addrs| {
91
101
let dest = addrs. iter_mut ( ) . next ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments