pub struct ParseContext {
pub link_type: u16,
pub parent_protocol: Option<&'static str>,
pub hints: SmallVec<[HintEntry; 4]>,
pub offset: usize,
pub encap_depth: u8,
pub tunnel_stack: SmallVec<[TunnelLayer; 4]>,
}Expand description
Context passed through the parsing chain.
Fields§
§link_type: u16Link type from PCAP header (e.g., 1 = Ethernet).
parent_protocol: Option<&'static str>Parent protocol that identified this protocol.
hints: SmallVec<[HintEntry; 4]>Protocol-specific hints (e.g., ethertype, IP protocol number). Uses SmallVec for consistency with ParseResult. Typically 2-4 entries.
offset: usizeOffset into the original packet where this protocol’s data starts.
encap_depth: u8Current encapsulation depth (0 = outer/no tunnel, 1+ = inside tunnel).
tunnel_stack: SmallVec<[TunnelLayer; 4]>Stack of enclosing tunnel layers (innermost last). Typical tunneled traffic has 1-2 layers; SmallVec<4> handles deeper nesting.
Implementations§
Source§impl ParseContext
impl ParseContext
Sourcepub fn new(link_type: u16) -> Self
pub fn new(link_type: u16) -> Self
Create a new parse context for a packet with the given link type.
Sourcepub fn push_tunnel(&mut self, tunnel_type: TunnelType, tunnel_id: Option<u64>)
pub fn push_tunnel(&mut self, tunnel_type: TunnelType, tunnel_id: Option<u64>)
Push a new tunnel layer onto the stack and increment encap_depth.
Sourcepub fn current_tunnel(&self) -> Option<&TunnelLayer>
pub fn current_tunnel(&self) -> Option<&TunnelLayer>
Get the innermost (current) tunnel layer, if any.
Sourcepub fn current_tunnel_type(&self) -> TunnelType
pub fn current_tunnel_type(&self) -> TunnelType
Get the innermost tunnel type, if inside a tunnel.
Sourcepub fn current_tunnel_id(&self) -> Option<u64>
pub fn current_tunnel_id(&self) -> Option<u64>
Get the innermost tunnel ID, if inside a tunnel with an ID.
Sourcepub fn hint(&self, key: &str) -> Option<u64>
pub fn hint(&self, key: &str) -> Option<u64>
Get a hint value by key (linear search, but N is small).
Sourcepub fn insert_hint(&mut self, key: &'static str, value: u64)
pub fn insert_hint(&mut self, key: &'static str, value: u64)
Insert a hint value (appends, may create duplicates).
Use set_hint() if you need to update an existing hint.
Sourcepub fn set_hint(&mut self, key: &'static str, value: u64)
pub fn set_hint(&mut self, key: &'static str, value: u64)
Set a hint value (updates existing or appends).
Sourcepub fn clear_hints(&mut self)
pub fn clear_hints(&mut self)
Clear all hints (for context reuse).
Trait Implementations§
Source§impl Clone for ParseContext
impl Clone for ParseContext
Source§fn clone(&self) -> ParseContext
fn clone(&self) -> ParseContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more