Skip to content

Commit aac4efe

Browse files
uefi: Convert more uses of IpAddress to uefi_raw::IpAddress in pxe::BaseCode
This is an intermediate step towards using the uefi-raw definition of the protocol.
1 parent f76595c commit aac4efe

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

uefi/src/proto/network/pxe.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ pub struct BaseCode {
5656
op_flags: UdpOpFlags,
5757
dest_ip: *const uefi_raw::IpAddress,
5858
dest_port: &u16,
59-
gateway_ip: Option<&IpAddress>,
60-
src_ip: Option<&IpAddress>,
59+
gateway_ip: *const uefi_raw::IpAddress,
60+
src_ip: *const uefi_raw::IpAddress,
6161
src_port: Option<&mut u16>,
6262
header_size: Option<&usize>,
6363
header_ptr: *const c_void,
@@ -92,8 +92,8 @@ pub struct BaseCode {
9292
) -> Status,
9393
set_station_ip: unsafe extern "efiapi" fn(
9494
this: &Self,
95-
new_station_ip: Option<&IpAddress>,
96-
new_subnet_mask: Option<&IpAddress>,
95+
new_station_ip: *const uefi_raw::IpAddress,
96+
new_subnet_mask: *const uefi_raw::IpAddress,
9797
) -> Status,
9898
set_packets: unsafe extern "efiapi" fn(
9999
this: &Self,
@@ -481,8 +481,8 @@ impl BaseCode {
481481
op_flags,
482482
dest_ip.as_raw_ptr(),
483483
&dest_port,
484-
gateway_ip,
485-
src_ip,
484+
opt_ip_addr_to_ptr(gateway_ip),
485+
opt_ip_addr_to_ptr(src_ip),
486486
src_port,
487487
header_size,
488488
header_ptr,
@@ -573,7 +573,14 @@ impl BaseCode {
573573
new_station_ip: Option<&IpAddress>,
574574
new_subnet_mask: Option<&IpAddress>,
575575
) -> Result {
576-
unsafe { (self.set_station_ip)(self, new_station_ip, new_subnet_mask) }.to_result()
576+
unsafe {
577+
(self.set_station_ip)(
578+
self,
579+
opt_ip_addr_to_ptr(new_station_ip),
580+
opt_ip_addr_to_ptr(new_subnet_mask),
581+
)
582+
}
583+
.to_result()
577584
}
578585

579586
/// Updates the contents of the cached DHCP and Discover packets.
@@ -629,6 +636,11 @@ fn opt_bool_to_ptr(arg: &Option<bool>) -> *const Boolean {
629636
.unwrap_or_else(null)
630637
}
631638

639+
/// Convert an `Option<&IpAddress>` to a `*const uefi_raw::IpAddress`.
640+
fn opt_ip_addr_to_ptr(arg: Option<&IpAddress>) -> *const uefi_raw::IpAddress {
641+
arg.map(|arg| arg.as_raw_ptr()).unwrap_or_else(null)
642+
}
643+
632644
opaque_type! {
633645
/// Opaque type that should be used to represent a pointer to a [`DiscoverInfo`] in
634646
/// foreign function interfaces. This type produces a thin pointer, unlike

0 commit comments

Comments
 (0)