BpfFilters

Struct BpfFilters 

Source
pub struct BpfFilters<const N: usize>(/* private fields */);
Expand description

Collection of BPF socket filters for kernel events.

Implementations§

Source§

impl<const N: usize> BpfFilters<N>

Source

pub const fn new() -> Self

Creates a new BpfFilters.

Source

pub fn filters(&self) -> &[sock_filter]

Gets a reference to the list of sock_filters.

Source

pub fn bpf_stmt(&mut self, i: &mut usize, code: u16, data: u32) -> Result<()>

Sets the code and data in the BPF socket filter.

Increments the filter index on success.

Returns: Err(Error) if the index is out-of-bounds

Source

pub fn bpf_jmp( &mut self, i: &mut usize, code: u16, data: u32, jt: u8, jf: u8, ) -> Result<()>

Sets all the fields in the BPF socket filter.

Increments the filter index on success.

Returns: Err(Error) if the index is out-of-bounds

Source

pub fn len(&self) -> usize

Gets the length of set socket filters in the BpfFilters.

Source

pub fn is_empty(&self) -> bool

Gets whether the BpfFilters has any set socket filters.

Source

pub fn as_sock_fprog(&mut self) -> sock_fprog

Gets the BpfFilters as a sock_fprog FFI object.

SAFETY: the resulting sock_fprog contains a mutable pointer that should not be accessed directly. The result is meant to be passed to Linux API functions that require sock_fprog.

Trait Implementations§

Source§

impl<const N: usize> Default for BpfFilters<N>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<const N: usize> Freeze for BpfFilters<N>

§

impl<const N: usize> RefUnwindSafe for BpfFilters<N>

§

impl<const N: usize> Send for BpfFilters<N>

§

impl<const N: usize> Sync for BpfFilters<N>

§

impl<const N: usize> Unpin for BpfFilters<N>

§

impl<const N: usize> UnwindSafe for BpfFilters<N>

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.