pub struct PacketRing { /* private fields */ }Expand description
Mmap’d PACKET_RX_RING + PACKET_TX_RING for zero-copy packet I/O.
Implementations§
Source§impl PacketRing
impl PacketRing
Sourcepub fn try_pop_rx(&self) -> Option<Bytes>
pub fn try_pop_rx(&self) -> Option<Bytes>
Try to dequeue one packet from the RX ring.
Sourcepub fn try_pop_rx_with_source(&self) -> Option<(Bytes, MacAddr)>
pub fn try_pop_rx_with_source(&self) -> Option<(Bytes, MacAddr)>
Try to dequeue one packet from the RX ring, also returning the source MAC.
In a TPACKET_V2 frame the kernel embeds a sockaddr_ll immediately after
the aligned tpacket2_hdr. For received frames the kernel fills in
sll_addr / sll_halen with the source Ethernet address, giving us the
peer MAC without any extra syscall.
Sourcepub fn try_push_tx(&self, data: &[u8]) -> bool
pub fn try_push_tx(&self, data: &[u8]) -> bool
Try to enqueue one packet into the TX ring.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PacketRing
impl RefUnwindSafe for PacketRing
impl Unpin for PacketRing
impl UnwindSafe for PacketRing
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more