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