pub struct PacketParser { /* private fields */ }Expand description
Packet parser with a refreshable snapshot of the host’s local addresses.
Implementations§
Source§impl PacketParser
impl PacketParser
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new packet parser with default configuration Automatically detects local IP addresses from network interfaces
pub fn with_config(config: ParserConfig) -> Self
Sourcepub fn with_oui_lookup(self, oui_lookup: impl Into<Arc<OuiLookup>>) -> Self
pub fn with_oui_lookup(self, oui_lookup: impl Into<Arc<OuiLookup>>) -> Self
Set the OUI lookup for MAC vendor resolution. Accepts either an owned
OuiLookup or an Arc<OuiLookup>, so the ~3 MB vendor table can be
shared between processor threads instead of cloned.
Sourcepub fn with_linktype(self, linktype: i32) -> Self
pub fn with_linktype(self, linktype: i32) -> Self
Set the linktype for this parser (needed for PKTAP detection)
Sourcepub fn refresh_local_ips(&mut self) -> bool
pub fn refresh_local_ips(&mut self) -> bool
Refresh the local-address snapshot from the operating system.
Returns true when the set changed. Capture workers call this
periodically so DHCP renewals, VPN interfaces, and IPv6 privacy-address
rotation do not leave endpoint orientation stale for the lifetime of
the process.
Sourcepub fn refresh_local_ips_if_due(&mut self, interval: Duration) -> bool
pub fn refresh_local_ips_if_due(&mut self, interval: Duration) -> bool
Refresh the local-address snapshot once interval has elapsed.
Sourcepub fn parse_packet_with_refresh(&mut self, data: &[u8]) -> Option<ParsedPacket>
pub fn parse_packet_with_refresh(&mut self, data: &[u8]) -> Option<ParsedPacket>
Parse a packet and retry once after refreshing local addresses when neither unicast endpoint is known to be local.
This self-heals the first packet observed after an address is added, rather than waiting for the periodic refresh. Refresh attempts caused by unrelated forwarded traffic are rate-limited with exponential backoff while they keep observing no change.
Sourcepub fn parse_packet(&self, data: &[u8]) -> Option<ParsedPacket>
pub fn parse_packet(&self, data: &[u8]) -> Option<ParsedPacket>
Parse a raw packet and stamp both endpoint address kinds.
The kinds are stamped here, at the single chokepoint every link-layer path funnels through, because subnet-broadcast detection needs this parser’s interface snapshot.
Sourcepub fn parse_ipv4_packet_inner(
&self,
data: &[u8],
offset: usize,
process_name: Option<String>,
process_id: Option<u32>,
) -> Option<ParsedPacket>
pub fn parse_ipv4_packet_inner( &self, data: &[u8], offset: usize, process_name: Option<String>, process_id: Option<u32>, ) -> Option<ParsedPacket>
Parse an IPv4 packet from link-layer frame data
(data includes the link-layer header of offset bytes)
Sourcepub fn parse_ipv6_packet_inner(
&self,
data: &[u8],
offset: usize,
process_name: Option<String>,
process_id: Option<u32>,
) -> Option<ParsedPacket>
pub fn parse_ipv6_packet_inner( &self, data: &[u8], offset: usize, process_name: Option<String>, process_id: Option<u32>, ) -> Option<ParsedPacket>
Parse an IPv6 packet from link-layer frame data
(data includes the link-layer header of offset bytes)
Sourcepub fn parse_arp_packet_with_offset(
&self,
data: &[u8],
header_len: usize,
process_name: Option<String>,
process_id: Option<u32>,
) -> Option<ParsedPacket>
pub fn parse_arp_packet_with_offset( &self, data: &[u8], header_len: usize, process_name: Option<String>, process_id: Option<u32>, ) -> Option<ParsedPacket>
Parse an ARP packet from link-layer frame data
(data includes the link-layer header of header_len bytes)
Sourcepub fn parse_raw_ipv4_packet(
&self,
data: &[u8],
process_name: Option<String>,
process_id: Option<u32>,
) -> Option<ParsedPacket>
pub fn parse_raw_ipv4_packet( &self, data: &[u8], process_name: Option<String>, process_id: Option<u32>, ) -> Option<ParsedPacket>
Parse a raw IPv4 packet (no link-layer header) Used by TUN devices, PKTAP DLT_RAW, and Linux Cooked Capture
Sourcepub fn parse_raw_ipv6_packet(
&self,
data: &[u8],
process_name: Option<String>,
process_id: Option<u32>,
) -> Option<ParsedPacket>
pub fn parse_raw_ipv6_packet( &self, data: &[u8], process_name: Option<String>, process_id: Option<u32>, ) -> Option<ParsedPacket>
Parse a raw IPv6 packet (no link-layer header) Used by TUN devices, PKTAP DLT_RAW, and Linux Cooked Capture