Skip to content

Commit c866f4a

Browse files
uefi: Convert uses of Packet to PxeBaseCodePacket in pxe::BaseCode
This is an intermediate step towards using the uefi-raw definition of the protocol.
1 parent 17c6e6b commit c866f4a

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

uefi/src/proto/network/pxe.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::iter::from_fn;
1414
use core::mem::MaybeUninit;
1515
use core::ptr::{self, null, null_mut};
1616
use ptr_meta::Pointee;
17-
use uefi_raw::protocol::network::pxe::PxeBaseCodeTftpOpcode;
17+
use uefi_raw::protocol::network::pxe::{PxeBaseCodePacket, PxeBaseCodeTftpOpcode};
1818
use uefi_raw::{Boolean, Char8};
1919

2020
pub use uefi_raw::protocol::network::pxe::{
@@ -103,12 +103,12 @@ pub struct BaseCode {
103103
new_pxe_discover_valid: *const Boolean,
104104
new_pxe_reply_received: *const Boolean,
105105
new_pxe_bis_reply_received: *const Boolean,
106-
new_dhcp_discover: Option<&Packet>,
107-
new_dhcp_ack: Option<&Packet>,
108-
new_proxy_offer: Option<&Packet>,
109-
new_pxe_discover: Option<&Packet>,
110-
new_pxe_reply: Option<&Packet>,
111-
new_pxe_bis_reply: Option<&Packet>,
106+
new_dhcp_discover: *const PxeBaseCodePacket,
107+
new_dhcp_ack: *const PxeBaseCodePacket,
108+
new_proxy_offer: *const PxeBaseCodePacket,
109+
new_pxe_discover: *const PxeBaseCodePacket,
110+
new_pxe_reply: *const PxeBaseCodePacket,
111+
new_pxe_bis_reply: *const PxeBaseCodePacket,
112112
) -> Status,
113113
mode: *const Mode,
114114
}
@@ -609,12 +609,12 @@ impl BaseCode {
609609
opt_bool_to_ptr(&new_pxe_discover_valid),
610610
opt_bool_to_ptr(&new_pxe_reply_received),
611611
opt_bool_to_ptr(&new_pxe_bis_reply_received),
612-
new_dhcp_discover,
613-
new_dhcp_ack,
614-
new_proxy_offer,
615-
new_pxe_discover,
616-
new_pxe_reply,
617-
new_pxe_bis_reply,
612+
opt_packet_to_ptr(new_dhcp_discover),
613+
opt_packet_to_ptr(new_dhcp_ack),
614+
opt_packet_to_ptr(new_proxy_offer),
615+
opt_packet_to_ptr(new_pxe_discover),
616+
opt_packet_to_ptr(new_pxe_reply),
617+
opt_packet_to_ptr(new_pxe_bis_reply),
618618
)
619619
}
620620
.to_result()
@@ -651,6 +651,11 @@ fn opt_ip_addr_to_ptr_mut(arg: Option<&mut IpAddress>) -> *mut uefi_raw::IpAddre
651651
arg.map(|arg| arg.as_raw_ptr_mut()).unwrap_or_else(null_mut)
652652
}
653653

654+
/// Convert an `Option<&Packet>` to a `*const PxeBaseCodePacket`.
655+
fn opt_packet_to_ptr(arg: Option<&Packet>) -> *const PxeBaseCodePacket {
656+
arg.map(|p| ptr::from_ref(p).cast()).unwrap_or_else(null)
657+
}
658+
654659
opaque_type! {
655660
/// Opaque type that should be used to represent a pointer to a [`DiscoverInfo`] in
656661
/// foreign function interfaces. This type produces a thin pointer, unlike

0 commit comments

Comments
 (0)