Skip to content

Commit cbc9664

Browse files
committed
uefi: ip4config2: use core::net-types in public API
1 parent 72af12b commit cbc9664

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

uefi/src/proto/network/ip4config2.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
use alloc::vec;
88
use alloc::vec::Vec;
99
use core::ffi::c_void;
10+
use core::net::Ipv4Addr;
1011
use core::time::Duration;
1112

1213
use uefi::boot::ScopedProtocol;
1314
use uefi::prelude::*;
1415
use uefi::proto::unsafe_protocol;
1516
use uefi::{print, println};
16-
use uefi_raw::Ipv4Address;
1717
use uefi_raw::protocol::network::ip4_config2::{
1818
Ip4Config2DataType, Ip4Config2InterfaceInfo, Ip4Config2Policy, Ip4Config2Protocol,
1919
};
@@ -102,29 +102,19 @@ impl Ip4Config2 {
102102
})
103103
}
104104

105-
fn print_info(info: &Ip4Config2InterfaceInfo) {
106-
println!(
107-
"addr v4: {}.{}.{}.{}",
108-
info.station_addr.0[0],
109-
info.station_addr.0[1],
110-
info.station_addr.0[2],
111-
info.station_addr.0[3],
112-
);
113-
}
114-
115105
/// Bring up network interface. Does nothing in case the network
116106
/// is already set up. Otherwise turns on DHCP and waits until an
117107
/// IPv4 address has been assigned. Reports progress on the
118108
/// console if verbose is set to true. Returns TIMEOUT error in
119109
/// case DHCP configuration does not finish within 30 seconds.
120110
pub fn ifup(&mut self, verbose: bool) -> uefi::Result<()> {
121-
let no_address = Ipv4Address::default();
111+
let no_address = Ipv4Addr::from_bits(0);
122112

123113
let info = self.get_interface_info()?;
124-
if info.station_addr != no_address {
114+
if info.station_addr != no_address.into() {
125115
if verbose {
126116
print!("Network is already up: ");
127-
Self::print_info(&info);
117+
println!("addr v4: {}", info.station_addr);
128118
}
129119
return Ok(());
130120
}
@@ -140,10 +130,10 @@ impl Ip4Config2 {
140130
}
141131
boot::stall(Duration::from_secs(1));
142132
let info = self.get_interface_info()?;
143-
if info.station_addr != no_address {
133+
if info.station_addr != no_address.into() {
144134
if verbose {
145135
print!(" OK: ");
146-
Self::print_info(&info);
136+
println!("addr v4: {}", info.station_addr);
147137
}
148138
return Ok(());
149139
}

0 commit comments

Comments
 (0)