Skip to content

Commit 16f7f18

Browse files
authored
Add PXE Base Code protocol (#417)
1 parent d351f24 commit 16f7f18

File tree

9 files changed

+1448
-0
lines changed

9 files changed

+1448
-0
lines changed

src/proto/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ pub mod debug;
6969
pub mod device_path;
7070
pub mod loaded_image;
7171
pub mod media;
72+
pub mod network;
7273
pub mod pi;
7374
pub mod rng;
7475
pub mod shim;

src/proto/network/mod.rs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//! Network access protocols.
2+
//!
3+
//! These protocols can be used to interact with network resources.
4+
5+
pub mod pxe;
6+
7+
/// Represents an IPv4/v6 address.
8+
///
9+
/// Corresponds to the `EFI_IP_ADDRESS` type in the C API.
10+
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
11+
#[repr(C, align(4))]
12+
pub struct IpAddress(pub [u8; 16]);
13+
14+
impl IpAddress {
15+
/// Construct a new IPv4 address.
16+
pub const fn new_v4(ip_addr: [u8; 4]) -> Self {
17+
let mut buffer = [0; 16];
18+
buffer[0] = ip_addr[0];
19+
buffer[1] = ip_addr[1];
20+
buffer[2] = ip_addr[2];
21+
buffer[3] = ip_addr[3];
22+
Self(buffer)
23+
}
24+
25+
/// Construct a new IPv6 address.
26+
pub const fn new_v6(ip_addr: [u8; 16]) -> Self {
27+
Self(ip_addr)
28+
}
29+
}
30+
31+
/// Represents a MAC (media access control) address.
32+
///
33+
/// Corresponds to the `EFI_MAC_ADDRESS` type in the C API.
34+
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
35+
#[repr(C)]
36+
pub struct MacAddress(pub [u8; 32]);

0 commit comments

Comments
 (0)