Skip to main content

DatagramDriver

Struct DatagramDriver 

Source
pub struct DatagramDriver<E, F>{ /* private fields */ }
Available on crate features extractors and reassembler and session only.
Expand description

One DatagramParser type over a UDP capture, with an ordered SessionEvent output. The datagram sibling of SessionDriver; no reassembly is involved.

Implementations§

Source§

impl<E, F, M> DatagramDriver<E, F>
where E: FlowExtractor, E::Key: Hash + Eq + Clone, F: DatagramParserFactory<E::Key>, F::Parser: DatagramParser<Message = M>,

Source

pub fn new(extractor: E, factory: F) -> Self

Default config.

Source

pub fn with_config(extractor: E, factory: F, config: FlowTrackerConfig) -> Self

Explicit config.

Source

pub fn from_tracker(tracker: FlowTracker<E, ()>, factory: F) -> Self

Take over an existing flow table.

Source

pub fn with_emit_anomalies(self, enable: bool) -> Self

Emit SessionEvent::FlowAnomaly / SessionEvent::TrackerAnomaly (reassembly gaps, overflows, retransmits, parser poison, eviction pressure, …). Default: off.

Source

pub fn set_emit_anomalies(&mut self, enable: bool)

In-place variant of Self::with_emit_anomalies.

Source

pub fn with_dedup(self, dedup: Dedup) -> Self

Drop duplicate packets (content hash) before tracking — see crate::Dedup. Applies to the flow table and to the parser alike. Read the counts back through Self::dedup, or watch flowscope_packets_deduplicated_total (metrics feature).

Source

pub fn set_dedup(&mut self, dedup: Option<Dedup>)

In-place variant of Self::with_dedup; None removes it.

Source

pub fn dedup(&self) -> Option<&Dedup>

Borrow the dedup state; None when none is configured. crate::Dedup::dropped / crate::Dedup::seen are the counts. New in 0.25.1.

Source

pub fn with_monotonic_timestamps(self, enable: bool) -> Self

Clamp packet timestamps (and sweep times) to a running max so time never goes backwards. Default: off.

Source

pub fn set_monotonic_timestamps(&mut self, enable: bool)

In-place variant of Self::with_monotonic_timestamps.

Source

pub fn with_idle_timeout_fn<G>(self, f: G) -> Self
where G: Fn(&E::Key, Option<L4Proto>) -> Option<Duration> + Send + Sync + 'static,

Per-flow idle-timeout override (see FlowTracker::set_idle_timeout_fn). The parser’s life is bound to the flow’s, so this also decides when parser state is reset.

Source

pub fn set_config(&mut self, config: FlowTrackerConfig)

Replace the config (tracker and reassembly limits alike).

Source

pub fn config(&self) -> &FlowTrackerConfig

Current config.

Source

pub fn tracker(&self) -> &FlowTracker<E, ()>

Borrow the flow table.

Source

pub fn set_idle_timeout_fn<G>(&mut self, f: G)
where G: Fn(&E::Key, Option<L4Proto>) -> Option<Duration> + Send + Sync + 'static,

In-place variant of Self::with_idle_timeout_fn.

Source

pub fn pause_events(&mut self)

Stop emitting lifecycle events (overload shunt); the parser keeps running and flows keep being released.

Source

pub fn resume_events(&mut self)

Resume after Self::pause_events.

Source

pub fn flow_driver(&self) -> &FlowDriver<E, SegmentBufferReassemblerFactory, ()>

Borrow the underlying flow driver (reassembly state, memcap accounting).

Source

pub fn snapshot_flow_stats( &self, ) -> impl Iterator<Item = (E::Key, FlowStats)> + '_

Live (key, stats) of every tracked flow, reassembly diagnostics included.

Source

pub fn flow_stats(&self, key: &E::Key) -> Option<FlowStats>

Live stats of one flow, reassembly diagnostics included.

Source

pub fn track_into<'v>( &mut self, view: impl Into<PacketView<'v>>, out: &mut Vec<SessionEvent<E::Key, M>>, )

Track one packet, appending the resulting events to out.

Source

pub fn track<'v>( &mut self, view: impl Into<PacketView<'v>>, ) -> Vec<SessionEvent<E::Key, M>>

Track one packet and return the resulting events.

Source

pub fn sweep_into( &mut self, now: Timestamp, out: &mut Vec<SessionEvent<E::Key, M>>, )

Run the periodic hooks (on_tick, out-of-order hole deadlines) and end idle flows.

Source

pub fn sweep(&mut self, now: Timestamp) -> Vec<SessionEvent<E::Key, M>>

Self::sweep_into returning a fresh Vec.

Source

pub fn finish_into(&mut self, out: &mut Vec<SessionEvent<E::Key, M>>)

End of input: end every flow. Parsers’ on_tick sees Timestamp::MAX; output is stamped with the latest packet timestamp and the monotonic clock is left alone.

Source

pub fn finish(&mut self) -> Vec<SessionEvent<E::Key, M>>

Self::finish_into returning a fresh Vec.

Source

pub fn force_close_into( &mut self, key: &E::Key, now: Timestamp, out: &mut Vec<SessionEvent<E::Key, M>>, )

End one flow now (EndReason::ForceClosed): its last bytes reach the parser, which is flushed (fin_*) before the Closed. No-op for an unknown key.

Source

pub fn force_close( &mut self, key: &E::Key, now: Timestamp, ) -> Vec<SessionEvent<E::Key, M>>

Self::force_close_into returning a fresh Vec.

Auto Trait Implementations§

§

impl<E, F> !RefUnwindSafe for DatagramDriver<E, F>

§

impl<E, F> !UnwindSafe for DatagramDriver<E, F>

§

impl<E, F> Freeze for DatagramDriver<E, F>
where Engine<E>: Freeze, DatagramCore<<E as FlowExtractor>::Key, F>: Freeze,

§

impl<E, F> Send for DatagramDriver<E, F>
where Engine<E>: Send, DatagramCore<<E as FlowExtractor>::Key, F>: Send,

§

impl<E, F> Sync for DatagramDriver<E, F>
where Engine<E>: Sync, DatagramCore<<E as FlowExtractor>::Key, F>: Sync,

§

impl<E, F> Unpin for DatagramDriver<E, F>
where Engine<E>: Unpin, DatagramCore<<E as FlowExtractor>::Key, F>: Unpin,

§

impl<E, F> UnsafeUnpin for DatagramDriver<E, F>
where Engine<E>: UnsafeUnpin, DatagramCore<<E as FlowExtractor>::Key, F>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more