Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub mod debug;
pub mod device_path;
pub mod loaded_image;
pub mod media;
pub mod network;
pub mod pi;
pub mod rng;
pub mod shim;
36 changes: 36 additions & 0 deletions src/proto/network/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//! Network access protocols.
//!
//! These protocols can be used to interact with network resources.

pub mod pxe;

/// Represents an IPv4/v6 address.
///
/// Corresponds to the `EFI_IP_ADDRESS` type in the C API.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C, align(4))]
pub struct IpAddress(pub [u8; 16]);

impl IpAddress {
/// Construct a new IPv4 address.
pub const fn new_v4(ip_addr: [u8; 4]) -> Self {
let mut buffer = [0; 16];
buffer[0] = ip_addr[0];
buffer[1] = ip_addr[1];
buffer[2] = ip_addr[2];
buffer[3] = ip_addr[3];
Self(buffer)
}

/// Construct a new IPv6 address.
pub const fn new_v6(ip_addr: [u8; 16]) -> Self {
Self(ip_addr)
}
}

/// Represents a MAC (media access control) address.
///
/// Corresponds to the `EFI_MAC_ADDRESS` type in the C API.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C)]
pub struct MacAddress(pub [u8; 32]);
Loading