Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bitflags definitions from uefi-raw in uefi's pxe module #1548

Merged
merged 4 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions uefi-raw/src/protocol/network/pxe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,28 @@ pub struct PxeBaseCodeMtftpInfo {
}

bitflags! {
/// Flags for UDP read and write operations.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct PxeBaseCodeUdpOpFlags: u16 {
/// Receive a packet sent from any IP address in UDP read operations.
const ANY_SRC_IP = 0x0001;

/// Receive a packet sent from any UDP port in UDP read operations. If
/// the source port is not specified in UDP write operations, the
/// source port will be automatically selected.
const ANY_SRC_PORT = 0x0002;

/// Receive a packet sent to any IP address in UDP read operations.
const ANY_DEST_IP = 0x0004;

/// Receive a packet sent to any UDP port in UDP read operations.
const ANY_DEST_PORT = 0x0008;

/// The software filter is used in UDP read operations.
const USE_FILTER = 0x0010;

/// If required, a UDP write operation may be broken up across multiple packets.
const MAY_FRAGMENT = 0x0020;
}
}
Expand Down Expand Up @@ -280,12 +294,20 @@ pub struct PxeBaseCodeIpFilter {
}

bitflags! {
/// IP receive filters.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct PxeBaseCodeIpFilterFlags: u8 {
/// Enable the Station IP address.
const STATION_IP = 0x01;

/// Enable IPv4 broadcast addresses.
const BROADCAST = 0x02;

/// Enable all addresses.
const PROMISCUOUS = 0x04;

/// Enable all multicast addresses.
const PROMISCUOUS_MULTICAST = 0x08;
}
}
Expand Down
43 changes: 4 additions & 39 deletions uefi/src/proto/network/pxe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ use crate::{CStr8, Char8, Result, Status, StatusExt};

use super::{IpAddress, MacAddress};

pub use uefi_raw::protocol::network::pxe::{
PxeBaseCodeIpFilterFlags as IpFilters, PxeBaseCodeUdpOpFlags as UdpOpFlags,
};

/// PXE Base Code protocol
#[derive(Debug)]
#[repr(C)]
Expand Down Expand Up @@ -829,29 +833,6 @@ pub struct MtftpInfo {
pub transmit_timeout: u16,
}

// No corresponding type in the UEFI spec, it just uses UINT16.
bitflags! {
/// Flags for UDP read and write operations.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
#[repr(transparent)]
pub struct UdpOpFlags: u16 {
/// Receive a packet sent from any IP address in UDP read operations.
const ANY_SRC_IP = 0x0001;
/// Receive a packet sent from any UDP port in UDP read operations. If
/// the source port is no specified in UDP write operations, the
/// source port will be automatically selected.
const ANY_SRC_PORT = 0x0002;
/// Receive a packet sent to any IP address in UDP read operations.
const ANY_DEST_IP = 0x0004;
/// Receive a packet sent to any UDP port in UDP read operations.
const ANY_DEST_PORT = 0x0008;
/// The software filter is used in UDP read operations.
const USE_FILTER = 0x0010;
/// If required, a UDP write operation may be broken up across multiple packets.
const MAY_FRAGMENT = 0x0020;
}
}

/// IP receive filter settings
///
/// Corresponds to the `EFI_PXE_BASE_CODE_IP_FILTER` type in the C API.
Expand Down Expand Up @@ -895,22 +876,6 @@ impl IpFilter {
}
}

bitflags! {
/// IP receive filters.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
#[repr(transparent)]
pub struct IpFilters: u8 {
/// Enable the Station IP address.
const STATION_IP = 0x01;
/// Enable IPv4 broadcast addresses.
const BROADCAST = 0x02;
/// Enable all addresses.
const PROMISCUOUS = 0x04;
/// Enable all multicast addresses.
const PROMISCUOUS_MULTICAST = 0x08;
}
}

/// A network packet.
///
/// Corresponds to the `EFI_PXE_BASE_CODE_PACKET` type in the C API.
Expand Down