pub struct Packet<'a> { /* private fields */ }Implementations§
Source§impl<'a> Packet<'a>
impl<'a> Packet<'a>
Sourcepub fn from_bytes(
buf: &'a [u8],
link_type: LinkType,
mode: ParseMode,
) -> Result<Self, PacketHeaderError>
pub fn from_bytes( buf: &'a [u8], link_type: LinkType, mode: ParseMode, ) -> Result<Self, PacketHeaderError>
Parse a packet from raw bytes using the specified link type and parse mode.
This method directly parses all protocol layers without using an iterator,
collecting them into a structured Packet.
§Arguments
buf- The raw packet byteslink_type- The link layer type of the packetmode- Parse mode:Outermostignores tunnels,Innermostparses through them
Sourcepub fn arp(&self) -> Option<&ArpHeaderFull<'a>>
pub fn arp(&self) -> Option<&ArpHeaderFull<'a>>
Returns a reference to the ARP header, if present.
Sourcepub fn network(&self) -> Option<&NetworkLayer<'a>>
pub fn network(&self) -> Option<&NetworkLayer<'a>>
Returns a reference to the network layer header, if present.
Sourcepub fn transport(&self) -> Option<&TransportLayer<'a>>
pub fn transport(&self) -> Option<&TransportLayer<'a>>
Returns a reference to the transport layer header, if present.
Sourcepub fn tunnels(&self) -> &[NetworkTunnelLayer<'a>]
pub fn tunnels(&self) -> &[NetworkTunnelLayer<'a>]
Returns a slice of IP tunnel layer headers.
Trait Implementations§
Source§impl TryFrom<&Packet<'_>> for SmallVec<[VniLayer; 4]>
Convert a Packet to a VNI layer stack
impl TryFrom<&Packet<'_>> for SmallVec<[VniLayer; 4]>
Convert a Packet to a VNI layer stack
This efficiently extracts VNI information from:
- Link layer (VLAN tags) - produces SmallVec<[VniLayer; 2]>
- Tunnel layers - each NetworkTunnelLayer converted to VniLayer
The result is the concatenation of link VNI layers followed by tunnel VNI layers. This operation may fail (returning Err(())) if any tunnel layer cannot be converted.
Auto Trait Implementations§
impl<'a> Freeze for Packet<'a>
impl<'a> RefUnwindSafe for Packet<'a>
impl<'a> Send for Packet<'a>
impl<'a> Sync for Packet<'a>
impl<'a> Unpin for Packet<'a>
impl<'a> UnsafeUnpin for Packet<'a>
impl<'a> UnwindSafe for Packet<'a>
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