Skip to content

uefi: SNP transmit: document parameters #1664

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

Merged
merged 1 commit into from
May 19, 2025
Merged
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
31 changes: 28 additions & 3 deletions uefi/src/proto/network/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,38 @@ impl SimpleNetwork {
status.to_result_with_val(|| NonNull::new(tx_buf.cast()))
}

/// Place a packet in the transmit queue of a network interface.
/// Place a packet in the transmit queue of the network interface.
///
/// The packet structure varies based on the type of network interface. In
/// typical scenarios, the protocol is implemented for Ethernet devices,
/// meaning this function transmits Ethernet frames.
///
/// The header of the packet can be filled by the function with the given
/// parameters, but the buffer must already reserve the space for the
/// header.
///
/// # Arguments
/// - `header_size`: The size in bytes of the media header to be filled by
/// the `transmit()` function. If this is `0`, the (ethernet frame) header
/// will not be filled by the function and taken as-is from the buffer.
/// If it is nonzero, then it must be equal to `media_header_size` of
/// the corresponding [`NetworkMode`] and the `dst_addr` and `protocol`
/// parameters must not be `None`.
/// - `buffer`: The buffer containing the whole network packet with all
/// its payload including the header for the medium.
/// - `src_addr`: The optional source address.
/// - `dst_addr`: The optional destination address.
/// - `protocol`: Ether Type as of RFC 3232. See
/// [IANA IEEE 802 Numbers][ethertype] for examples. Typically, this is
/// `0x0800` (IPv4) or `0x0806` (ARP).
///
/// [ethertype]: https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml#ieee-802-numbers-1
pub fn transmit(
&self,
header_size: usize,
buffer: &[u8],
src_addr: Option<MacAddress>,
dest_addr: Option<MacAddress>,
dst_addr: Option<MacAddress>,
protocol: Option<u16>,
) -> Result {
unsafe {
Expand All @@ -202,7 +227,7 @@ impl SimpleNetwork {
buffer.len(),
buffer.as_ptr().cast(),
src_addr.as_ref().map(ptr::from_ref).unwrap_or(ptr::null()),
dest_addr.as_ref().map(ptr::from_ref).unwrap_or(ptr::null()),
dst_addr.as_ref().map(ptr::from_ref).unwrap_or(ptr::null()),
protocol.as_ref().map(ptr::from_ref).unwrap_or(ptr::null()),
)
}
Expand Down