Skip to content

Commit 074ff74

Browse files
committed
uefi-raw: add tcpv4 protocol definitions
1 parent 2fc1b45 commit 074ff74

File tree

5 files changed

+517
-2
lines changed

5 files changed

+517
-2
lines changed

.typos.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ extend-exclude = [
99
[default]
1010
extend-ignore-identifiers-re = [
1111
# uefi-raw/src/protocol/device_path.rs
12-
"PnP"
12+
"PnP",
13+
# uefi-raw/src/protocol/network/tcpv4.rs
14+
"ANDed"
1315
]
1416

1517
[default.extend-words]

uefi-raw/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# uefi-raw - [Unreleased]
22

33
## Added
4+
- Added `Tcpv4Protocol`.
45

56
## Changed
67

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT OR Apache-2.0
22

3-
use crate::Ipv4Address;
3+
use crate::{Boolean, Ipv4Address};
44

55
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
66
#[repr(C)]
@@ -9,3 +9,78 @@ pub struct Ip4RouteTable {
99
pub subnet_mask: Ipv4Address,
1010
pub gateway_addr: Ipv4Address,
1111
}
12+
13+
/// Defined in [UEFI Specification, Section 28.3.5](https://uefi.org/specs/UEFI/2.11/28_Network_Protocols_TCP_IP_and_Configuration.html#efi-ip4-protocol-getmodedata)
14+
#[derive(Debug)]
15+
#[repr(C)]
16+
pub struct Ip4ModeData {
17+
/// Set to `TRUE` after this [`Tcp4Protocol`] instance has been
18+
/// successfully configured.
19+
pub is_started: Boolean,
20+
/// The maximum packet size, in bytes, of the packet which the
21+
/// upper layer driver could feed.
22+
pub max_packet_size: u32,
23+
/// Current configuration settings.
24+
pub config_data: Ip4ConfigData,
25+
/// Set to `TRUE` when the [`Tcp4Protocol`] instance has a
26+
/// station address and subnet mask.
27+
pub is_configured: Boolean,
28+
/// Number of joined multicast groups.
29+
pub group_count: u32,
30+
/// List of joined multicast group addresses.
31+
pub group_table: *const Ipv4Address,
32+
/// Number of entries in the routing table.
33+
pub route_count: u32,
34+
/// Routing table entries.
35+
pub route_table: *const Ip4RouteTable,
36+
/// Number of entries in the supported ICMP types list.
37+
pub icmp_type_count: u32,
38+
/// Array of ICMP types and codes that are supported.
39+
pub icmp_type_list: *const Ip4IcmpType,
40+
}
41+
42+
/// Defined in [UEFI Specification, Section 28.3.5](https://uefi.org/specs/UEFI/2.11/28_Network_Protocols_TCP_IP_and_Configuration.html#efi-ip4-protocol-getmodedata)
43+
#[derive(Debug)]
44+
#[repr(C)]
45+
pub struct Ip4IcmpType {
46+
/// ICMP message type.
47+
pub type_: u8,
48+
/// ICMP message code.
49+
pub code: u8,
50+
}
51+
52+
#[derive(Debug)]
53+
#[repr(C)]
54+
pub struct Ip4ConfigData {
55+
/// Default protocol to be used.
56+
///
57+
/// See <https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml>.
58+
pub default_protocol: u8,
59+
/// Set to `TRUE` to receive all IPv4 packets.
60+
pub accept_any_protocol: Boolean,
61+
/// Set to `TRUE` to receive ICMP error packets.
62+
pub accept_icmp_errors: Boolean,
63+
/// Set to `TRUE` to receive broadcast IPv4 packets.
64+
pub accept_broadcast: Boolean,
65+
/// Set to `TRUE` to receive all IPv4 packets in promiscuous mode.
66+
pub accept_promiscuous: Boolean,
67+
/// Set to `TRUE` to use the default IPv4 address and routing
68+
/// table.
69+
pub use_default_address: Boolean,
70+
/// Station IPv4 address.
71+
pub station_address: Ipv4Address,
72+
/// Subnet mask for the station address.
73+
pub subnet_mask: Ipv4Address,
74+
/// Type of service field in transmitted IPv4 packets.
75+
pub type_of_service: u8,
76+
/// Time to live field in transmitted IPv4 packets.
77+
pub time_to_live: u8,
78+
/// Set to `TRUE` to disable fragmentation.
79+
pub do_not_fragment: Boolean,
80+
/// Set to `TRUE` to enable raw data mode.
81+
pub raw_data: Boolean,
82+
/// Receive timeout in milliseconds.
83+
pub receive_timeout: u32,
84+
/// Transmit timeout in milliseconds.
85+
pub transmit_timeout: u32,
86+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ pub mod ip4;
66
pub mod ip4_config2;
77
pub mod pxe;
88
pub mod snp;
9+
pub mod tcp4;
910
pub mod tls;

0 commit comments

Comments
 (0)