#[repr(C)]pub union IpAddress {
pub addr: [u32; 4],
pub v4: Ipv4Address,
pub v6: Ipv6Address,
}Expand description
An IPv4 or IPv6 internet protocol address that is ABI compatible with EFI.
Corresponds to the EFI_IP_ADDRESS type in the UEFI specification. This
type is defined in the same way as edk2 for compatibility with C code. Note
that this is an untagged union, so there’s no way to tell which type of
address an IpAddress value contains without additional context.
§Conversions and Relation to core::net
The following From implementations exist:
[u8; 4]->IpAddress[u8; 16]->IpAddresscore::net::Ipv4Addr->IpAddresscore::net::Ipv6Addr->IpAddresscore::net::IpAddr->IpAddress
Fields§
§addr: [u32; 4]This member serves to align the whole type to a 4 bytes as required by
the spec. Note that this is slightly different from repr(align(4)),
which would prevent placing this type in a packed structure.
v4: Ipv4AddressAn IPv4 internet protocol address.
v6: Ipv6AddressAn IPv6 internet protocol address.
Implementations§
Source§impl IpAddress
impl IpAddress
Sourcepub const fn new_v4(octets: [u8; 4]) -> Self
pub const fn new_v4(octets: [u8; 4]) -> Self
Construct a new IPv4 address.
The type won’t know that it is an IPv6 address and additional context is needed.
§Safety
The constructor only initializes the bytes needed for IPv4 addresses.
Sourcepub const fn new_v6(octets: [u8; 16]) -> Self
pub const fn new_v6(octets: [u8; 16]) -> Self
Construct a new IPv6 address.
The type won’t know that it is an IPv6 address and additional context is needed.
Sourcepub unsafe fn into_core_addr(self, is_ipv6: bool) -> IpAddr
pub unsafe fn into_core_addr(self, is_ipv6: bool) -> IpAddr
Transforms this EFI type to the Rust standard library’s type
core::net::IpAddr.
§Arguments
is_ipv6: Whether the internal data should be interpreted as IPv6 or IPv4 address.
§Safety
Callers must ensure that the v4 field is valid if is_ipv6 is false,
and that the v6 field is valid if is_ipv6 is true