Skip to content

Commit bbe1c5a

Browse files
authored
Merge pull request #1797 from JayKickliter/jsk/uefi-raw/add-tcpv4
uefi-raw: add Tcp4 protocol type definitions
2 parents 9fec9cc + 5966f94 commit bbe1c5a

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

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)