Skip to content

Commit 7878c21

Browse files
uefi-raw: Add Ip4Config2Protocol
Co-authored-by: Ben Krieger <[email protected]>
1 parent 5de89dd commit 7878c21

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed

uefi-raw/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## Added
44
- Added `Ipv4Address`, `Ipv6Address`, and `MacAddress` types.
5-
- Added `ServiceBindingProtocol` and `Dhcp4Protocol`.
5+
- Added `ServiceBindingProtocol`, `Dhcp4Protocol`, `Ip4Config2Protocol`, and
6+
related types.
67

78
# uefi-raw - 0.5.0 (2023-11-12)
89

uefi-raw/src/protocol/network/ip4.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use crate::Ipv4Address;
2+
3+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
4+
#[repr(C)]
5+
pub struct Ip4RouteTable {
6+
pub subnet_addr: Ipv4Address,
7+
pub subnet_mask: Ipv4Address,
8+
pub gateway_addr: Ipv4Address,
9+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
use crate::protocol::network::ip4::Ip4RouteTable;
2+
use crate::{guid, Char16, Event, Guid, Ipv4Address, MacAddress, Status};
3+
use core::ffi::c_void;
4+
5+
newtype_enum! {
6+
pub enum Ip4Config2DataType: i32 => {
7+
INTERFACE_INFO = 0,
8+
POLICY = 1,
9+
MANUAL_ADDRESS = 2,
10+
GATEWAY = 3,
11+
DNS_SERVER = 4,
12+
MAXIMUM = 5,
13+
}
14+
}
15+
16+
#[derive(Debug)]
17+
#[repr(C)]
18+
pub struct Ip4Config2InterfaceInfo {
19+
pub name: [Char16; 32],
20+
pub if_type: u8,
21+
pub hw_addr_size: u32,
22+
pub hw_addr: MacAddress,
23+
pub station_addr: Ipv4Address,
24+
pub subnet_mask: Ipv4Address,
25+
pub route_table_size: u32,
26+
pub route_table: *mut Ip4RouteTable,
27+
}
28+
29+
newtype_enum! {
30+
pub enum Ip4Config2Policy: i32 => {
31+
STATIC = 0,
32+
DHCP = 1,
33+
MAX = 2,
34+
}
35+
}
36+
37+
#[derive(Debug)]
38+
#[repr(C)]
39+
pub struct Ip4Config2ManualAddress {
40+
pub address: Ipv4Address,
41+
pub subnet_mask: Ipv4Address,
42+
}
43+
44+
#[derive(Debug)]
45+
#[repr(C)]
46+
pub struct Ip4Config2Protocol {
47+
pub set_data: unsafe extern "efiapi" fn(
48+
this: *mut Self,
49+
data_type: Ip4Config2DataType,
50+
data_size: usize,
51+
data: *const c_void,
52+
) -> Status,
53+
54+
pub get_data: unsafe extern "efiapi" fn(
55+
this: *mut Self,
56+
data_type: Ip4Config2DataType,
57+
data_size: *mut usize,
58+
data: *mut c_void,
59+
) -> Status,
60+
61+
pub register_data_notify: unsafe extern "efiapi" fn(
62+
this: *mut Self,
63+
data_type: Ip4Config2DataType,
64+
event: Event,
65+
) -> Status,
66+
67+
pub unregister_data_notify: unsafe extern "efiapi" fn(
68+
this: *mut Self,
69+
data_type: Ip4Config2DataType,
70+
event: Event,
71+
) -> Status,
72+
}
73+
74+
impl Ip4Config2Protocol {
75+
pub const GUID: Guid = guid!("5b446ed1-e30b-4faa-871a-3654eca36080");
76+
}

uefi-raw/src/protocol/network/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
pub mod dhcp4;
2+
pub mod ip4;
3+
pub mod ip4_config2;

0 commit comments

Comments
 (0)