#[repr(transparent)]
pub struct WinDivertFlags(_);
Expand description

Flag type required by WinDivertOpen(). It follows a builder like style.

Different flags affect how the opened handle behaves. The following flags are supported:

  • sniff: This flag opens the WinDivert handle in packet sniffing mode. In packet sniffing mode the original packet is not dropped-and-diverted (the default) but copied-and-diverted. This mode is useful for implementing packet sniffing tools similar to those applications that currently use Winpcap.
  • drop: This flag indicates that the user application does not intend to read matching packets with recv() (or any of it’s variants), instead the packets should be silently dropped. This is useful for implementing simple packet filters using the WinDivert filter language.
  • recv_only: This flags forces the handle into receive only mode which effectively disables send() (and any of it’s variants). This means that it is possible to block/capture packets or events but not inject them.
  • send_only: This flags forces the handle into send only mode which effectively disables recv() (and any of it’s variants). This means that it is possible to inject packets or events, but not block/capture them.
  • no_installs: This flags causes WinDivertOpen to fail with ERROR_SERVICE_DOES_NOT_EXIST (1060) if the WinDivert driver is not already installed. This flag is useful for querying the WinDivert driver state using Reflect layer.
  • fragments: If set, the handle will capture inbound IP fragments, but not inbound reassembled IP packets. Otherwise, if not set (the default), the handle will capture inbound reassembled IP packets, but not inbound IP fragments. This flag only affects inbound packets at the Network layer, else the flag is ignored. Note that any combination of (snif | drop) or (recv_only | send_only) are considered invalid.

Some layers have mandatory flags:

Implementations§

source§

impl WinDivertFlags

WinDivertFlags builder methods.

source

pub const fn new() -> Self

Creates a new flag field with all options unset.

source

pub const fn set_sniff(self) -> Self

Sets sniff flag.

source

pub const fn unset_sniff(self) -> Self

Unsets sniff flag.

source

pub fn set_sniff_value(&mut self, value: bool)

Sets sniff flag to value.

source

pub const fn set_drop(self) -> Self

Sets drop flag.

source

pub const fn unset_drop(self) -> Self

Unsets drop flag.

source

pub fn set_drop_value(&mut self, value: bool)

Sets drop flag to value.

source

pub const fn set_recv_only(self) -> Self

Sets recv_only flag

source

pub const fn unset_recv_only(self) -> Self

Unsets recv_only flag

source

pub fn set_recv_only_value(&mut self, value: bool)

Sets recv_only flag to value.

source

pub const fn set_send_only(self) -> Self

Sets send_only flag.

source

pub const fn unset_send_only(self) -> Self

Unsets send_only flag.

source

pub fn set_send_only_value(&mut self, value: bool)

Sets send_only flag to value.

source

pub const fn set_no_installs(self) -> Self

Sets no_installs flag.

source

pub const fn unset_no_installs(self) -> Self

Unsets no_installs flag.

source

pub fn set_no_installs_value(&mut self, value: bool)

Sets no_installs flag to value.

source

pub const fn set_fragments(self) -> Self

Sets fragments flag.

source

pub const fn unset_fragments(self) -> Self

Unsets fragments flag.

source

pub fn set_fragments_value(&mut self, value: bool)

Sets fragments flag to value.

Trait Implementations§

source§

impl Clone for WinDivertFlags

source§

fn clone(&self) -> WinDivertFlags

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WinDivertFlags

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for WinDivertFlags

source§

fn default() -> WinDivertFlags

Returns the “default value” for a type. Read more
source§

impl From<WinDivertFlags> for u64

source§

fn from(flags: WinDivertFlags) -> Self

Converts to this type from the input type.
source§

impl Copy for WinDivertFlags

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.