Skip to main content

uefi_raw/protocol/network/
ip4.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use crate::{Boolean, Ipv4Address};
4
5#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
6#[repr(C)]
7pub struct Ip4RouteTable {
8    pub subnet_addr: Ipv4Address,
9    pub subnet_mask: Ipv4Address,
10    pub gateway_addr: Ipv4Address,
11}
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)]
16pub 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)]
47pub 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)]
56pub 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}