WinDivert

Struct WinDivert 

Source
#[non_exhaustive]
pub struct WinDivert<L: WinDivertLayerTrait> { /* private fields */ }
Expand description

Main wrapper struct around windivert functionalities.

Implementations§

Source§

impl WinDivert<NetworkLayer>

Source

pub fn recv<'a>( &self, buffer: Option<&'a mut [u8]>, ) -> Result<WinDivertPacket<'a, NetworkLayer>, WinDivertError>

Single packet blocking recv function.

Source

pub fn recv_ex<'a>( &self, buffer: Option<&'a mut [u8]>, packet_count: usize, ) -> Result<Vec<WinDivertPacket<'a, NetworkLayer>>, WinDivertError>

Batched blocking recv function.

Source

pub fn send( &self, packet: &WinDivertPacket<'_, NetworkLayer>, ) -> Result<u32, WinDivertError>

Single packet send function.

Source

pub fn send_ex<'data, 'packets, P, I>( &self, packets: P, ) -> Result<u32, WinDivertError>
where P: IntoIterator<IntoIter = I>, I: ExactSizeIterator<Item = &'packets WinDivertPacket<'data, NetworkLayer>>, 'data: 'packets,

Batched packet send function.

Source§

impl WinDivert<ForwardLayer>

Source

pub fn recv<'a>( &self, buffer: Option<&'a mut [u8]>, ) -> Result<WinDivertPacket<'a, ForwardLayer>, WinDivertError>

Single packet blocking recv function.

Source

pub fn recv_ex<'a>( &self, buffer: Option<&'a mut [u8]>, packet_count: usize, ) -> Result<Vec<WinDivertPacket<'a, NetworkLayer>>, WinDivertError>

Batched blocking recv function.

Source

pub fn send( &self, packet: &WinDivertPacket<'_, ForwardLayer>, ) -> Result<u32, WinDivertError>

Single packet send function.

Source

pub fn send_ex<'data, 'packets, P, I>( &self, packets: P, ) -> Result<u32, WinDivertError>
where P: IntoIterator<IntoIter = I>, I: ExactSizeIterator<Item = &'packets WinDivertPacket<'data, ForwardLayer>>, 'data: 'packets,

Batched packet send function.

Source§

impl WinDivert<FlowLayer>

Source

pub fn recv<'a>( &self, buffer: Option<&'a mut [u8]>, ) -> Result<WinDivertPacket<'a, FlowLayer>, WinDivertError>

Single packet blocking recv function.

Source

pub fn recv_ex<'a>( &self, packet_count: usize, ) -> Result<Vec<WinDivertPacket<'a, FlowLayer>>, WinDivertError>

Batched blocking recv function.

Source§

impl WinDivert<SocketLayer>

Source

pub fn recv<'a>( &self, buffer: Option<&'a mut [u8]>, ) -> Result<WinDivertPacket<'a, SocketLayer>, WinDivertError>

Single packet blocking recv function.

Source

pub fn recv_ex<'a>( &self, packet_count: usize, ) -> Result<Vec<WinDivertPacket<'a, SocketLayer>>, WinDivertError>

Batched blocking recv function.

Source§

impl WinDivert<ReflectLayer>

Source

pub fn recv<'a>( &self, buffer: Option<&'a mut [u8]>, ) -> Result<WinDivertPacket<'a, ReflectLayer>, WinDivertError>

Single packet blocking recv function.

Source

pub fn recv_ex<'a>( &self, buffer: Option<&'a mut [u8]>, packet_count: usize, ) -> Result<Vec<WinDivertPacket<'a, ReflectLayer>>, WinDivertError>

Batched blocking recv function.

Source§

impl<L: WinDivertLayerTrait> WinDivert<L>

Recv implementations

Source

pub fn get_param(&self, param: WinDivertParam) -> Result<u64, WinDivertError>

Methods that allows to query the driver for parameters.

Source

pub fn set_param( &self, param: WinDivertParam, value: u64, ) -> Result<(), WinDivertError>

Method that allows setting driver parameters.

Source

pub fn close(&mut self, action: CloseAction) -> WinResult<()>

Handle close function.

Source

pub fn shutdown(&mut self, mode: WinDivertShutdownMode) -> WinResult<()>

Shutdown function.

Source§

impl WinDivert<NetworkLayer>

Source

pub fn network( filter: impl AsRef<str>, priority: i16, flags: WinDivertFlags, ) -> Result<Self, WinDivertError>

WinDivert constructor for network layer.

Source§

impl WinDivert<ForwardLayer>

Source

pub fn forward( filter: impl AsRef<str>, priority: i16, flags: WinDivertFlags, ) -> Result<Self, WinDivertError>

WinDivert constructor for forward layer.

Source§

impl WinDivert<FlowLayer>

Source

pub fn flow( filter: &str, priority: i16, flags: WinDivertFlags, ) -> Result<Self, WinDivertError>

WinDivert constructor for flow layer.

Source§

impl WinDivert<SocketLayer>

Source

pub fn socket( filter: impl AsRef<str>, priority: i16, flags: WinDivertFlags, ) -> Result<Self, WinDivertError>

WinDivert constructor for socket layer.

Source§

impl WinDivert<ReflectLayer>

Source

pub fn reflect( filter: impl AsRef<str>, priority: i16, flags: WinDivertFlags, ) -> Result<Self, WinDivertError>

WinDivert constructor for reflect layer.

Source§

impl WinDivert<()>

Source

pub const MAX_BATCH: u8 = 255u8

Maximum number of packets that can be captured/sent in a single batched operation

Source

pub fn uninstall() -> WinResult<()>

Method that tries to uninstall WinDivert driver.

Auto Trait Implementations§

§

impl<L> Freeze for WinDivert<L>

§

impl<L> RefUnwindSafe for WinDivert<L>
where L: RefUnwindSafe,

§

impl<L> Send for WinDivert<L>
where L: Send,

§

impl<L> Sync for WinDivert<L>
where L: Sync,

§

impl<L> Unpin for WinDivert<L>
where L: Unpin,

§

impl<L> UnwindSafe for WinDivert<L>
where L: UnwindSafe,

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<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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.