@@ -13,10 +13,10 @@ use smoltcp::socket::dhcpv4;
13
13
use smoltcp:: socket:: dns;
14
14
use smoltcp:: time:: Instant ;
15
15
#[ cfg( not( feature = "dhcpv4" ) ) ]
16
+ use smoltcp:: wire:: IpCidr ;
17
+ #[ cfg( not( feature = "dhcpv4" ) ) ]
16
18
use smoltcp:: wire:: Ipv4Address ;
17
19
use smoltcp:: wire:: { EthernetAddress , HardwareAddress } ;
18
- #[ cfg( not( feature = "dhcpv4" ) ) ]
19
- use smoltcp:: wire:: { IpAddress , IpCidr } ;
20
20
21
21
use super :: network:: { NetworkInterface , NetworkState } ;
22
22
use crate :: arch;
@@ -135,15 +135,7 @@ impl<'a> NetworkInterface<'a> {
135
135
136
136
let ethernet_addr = EthernetAddress ( mac) ;
137
137
let hardware_addr = HardwareAddress :: Ethernet ( ethernet_addr) ;
138
- let ip_addrs = [ IpCidr :: new (
139
- IpAddress :: v4 (
140
- myip. octets ( ) [ 0 ] ,
141
- myip. octets ( ) [ 1 ] ,
142
- myip. octets ( ) [ 2 ] ,
143
- myip. octets ( ) [ 3 ] ,
144
- ) ,
145
- prefix_len,
146
- ) ] ;
138
+ let ip_addrs = [ IpCidr :: new ( myip. into ( ) , prefix_len) ] ;
147
139
148
140
info ! ( "MAC address {hardware_addr}" ) ;
149
141
info ! ( "Configure network interface with address {}" , ip_addrs[ 0 ] ) ;
@@ -160,17 +152,7 @@ impl<'a> NetworkInterface<'a> {
160
152
161
153
let mut iface = Interface :: new ( config, & mut device, crate :: executor:: network:: now ( ) ) ;
162
154
iface. update_ip_addrs ( |ip_addrs| {
163
- ip_addrs
164
- . push ( IpCidr :: new (
165
- IpAddress :: v4 (
166
- myip. octets ( ) [ 0 ] ,
167
- myip. octets ( ) [ 1 ] ,
168
- myip. octets ( ) [ 2 ] ,
169
- myip. octets ( ) [ 3 ] ,
170
- ) ,
171
- prefix_len,
172
- ) )
173
- . unwrap ( ) ;
155
+ ip_addrs. push ( IpCidr :: new ( myip. into ( ) , prefix_len) ) . unwrap ( ) ;
174
156
} ) ;
175
157
iface. routes_mut ( ) . add_default_ipv4_route ( mygw) . unwrap ( ) ;
176
158
0 commit comments