Struct ndisapi_rs::EthMRequest
source · #[repr(C)]pub struct EthMRequest<'a, const N: usize> { /* private fields */ }
Expand description
This structure represents a request for multiple Ethernet packets, containing a network adapter handle, packet number, packet success count, and an array of EthPacket
instances.
A Rust equivalent for the _ETH_M_REQUEST structure.
adapter_handle
is a handle to the network adapter associated with this request. packet_number
is the number of packets in the packets
array. packet_success
is the number of packets that have been successfully processed. packets
is an array of EthPacket
instances representing the Ethernet packets for this request.
Implementations§
source§impl<'a, const N: usize> EthMRequest<'a, N>
impl<'a, const N: usize> EthMRequest<'a, N>
Provides methods for manipulating the EthPacket
instances within an EthMRequest
.
sourcepub fn new(adapter_handle: HANDLE) -> Self
pub fn new(adapter_handle: HANDLE) -> Self
Creates a new EthMRequest
with the specified adapter handle.
All packets in the request are initialized to empty.
sourcepub fn take_packet(
&mut self,
index: usize
) -> Option<&'a mut IntermediateBuffer>
pub fn take_packet( &mut self, index: usize ) -> Option<&'a mut IntermediateBuffer>
Takes the IntermediateBuffer
from the EthPacket
at the specified index, replacing it with None
.
This is useful when you want to use the packet’s buffer elsewhere, while ensuring that the EthMRequest
no longer has access to it.
sourcepub fn put_packet(
&mut self,
index: usize,
buffer: &'a mut IntermediateBuffer
) -> Result<()>
pub fn put_packet( &mut self, index: usize, buffer: &'a mut IntermediateBuffer ) -> Result<()>
Sets the IntermediateBuffer
for the EthPacket
at the specified index.
This method allows you to associate a new buffer with the EthPacket
at the given index.
sourcepub fn get_packet_number(&self) -> u32
pub fn get_packet_number(&self) -> u32
Returns the number of packets in the packets
array.
This provides a count of all packets, regardless of whether they’ve been successfully processed.
sourcepub fn set_packet_number(&mut self, number: u32)
pub fn set_packet_number(&mut self, number: u32)
Sets the number of packets in the packets
array.
This allows you to manually set the count of packets in the request.
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets the packet number to 0.
This effectively empties the request of packets.
sourcepub fn get_packet_success(&self) -> u32
pub fn get_packet_success(&self) -> u32
Returns the number of successfully processed packets
sourcepub fn push(&mut self, packet: &'a mut IntermediateBuffer) -> Result<()>
pub fn push(&mut self, packet: &'a mut IntermediateBuffer) -> Result<()>
Adds an IntermediateBuffer
to the packets
array if there’s available space.
This effectively wraps the buffer into an EthPacket
and stores it in the array.
The packet_number
field of the EthMRequest
is automatically incremented to reflect the addition of the new packet.
If there is no available space in the array (i.e., if the packet_number
is equal to the array length N
), this method returns an error, specifically ERROR_INVALID_PARAMETER
.
This method provides an idiomatic way of adding new packets to an EthMRequest
in Rust.
Arguments
packet
- A mutable reference to theIntermediateBuffer
to be added to thepackets
array.
Returns
Ok(())
if the buffer was successfully added as a packet.Err(ERROR_INVALID_PARAMETER.into())
if thepackets
array is full.