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>
impl<const N: usize> BpfFilters<N>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new BpfFilters.
Sourcepub fn filters(&self) -> &[sock_filter]
pub fn filters(&self) -> &[sock_filter]
Gets a reference to the list of sock_filters.
Sourcepub fn bpf_stmt(&mut self, i: &mut usize, code: u16, data: u32) -> Result<()>
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
Sourcepub fn bpf_jmp(
&mut self,
i: &mut usize,
code: u16,
data: u32,
jt: u8,
jf: u8,
) -> Result<()>
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
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Gets the length of set socket filters in the BpfFilters.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Gets whether the BpfFilters has any set socket filters.
Sourcepub fn as_sock_fprog(&mut self) -> sock_fprog
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more