Struct aya::programs::SocketFilter
source · [−]pub struct SocketFilter { /* private fields */ }
Expand description
A program used to inspect and filter incoming packets on a socket.
SocketFilter
programs are attached on sockets and can be used to inspect
and filter incoming packets.
Minimum kernel version
The minimum kernel version required to use this feature is 4.0.
Examples
use std::convert::TryInto;
use std::net::TcpStream;
use std::os::unix::io::AsRawFd;
use aya::programs::SocketFilter;
let mut client = TcpStream::connect("127.0.0.1:1234")?;
let prog: &mut SocketFilter = bpf.program_mut("filter_packets").unwrap().try_into()?;
prog.load()?;
prog.attach(client.as_raw_fd())?;
Implementations
sourceimpl SocketFilter
impl SocketFilter
sourcepub fn load(&mut self) -> Result<(), ProgramError>
pub fn load(&mut self) -> Result<(), ProgramError>
Loads the program inside the kernel.
See also Program::load
.
Trait Implementations
sourceimpl Debug for SocketFilter
impl Debug for SocketFilter
sourceimpl ProgramFd for SocketFilter
impl ProgramFd for SocketFilter
sourceimpl ProgramFd for &mut SocketFilter
impl ProgramFd for &mut SocketFilter
sourceimpl<'a> TryFrom<&'a Program> for &'a SocketFilter
impl<'a> TryFrom<&'a Program> for &'a SocketFilter
type Error = ProgramError
type Error = ProgramError
The type returned in the event of a conversion error.
sourcefn try_from(program: &'a Program) -> Result<&'a SocketFilter, ProgramError>
fn try_from(program: &'a Program) -> Result<&'a SocketFilter, ProgramError>
Performs the conversion.
sourceimpl<'a> TryFrom<&'a mut Program> for &'a mut SocketFilter
impl<'a> TryFrom<&'a mut Program> for &'a mut SocketFilter
type Error = ProgramError
type Error = ProgramError
The type returned in the event of a conversion error.
sourcefn try_from(
program: &'a mut Program
) -> Result<&'a mut SocketFilter, ProgramError>
fn try_from(
program: &'a mut Program
) -> Result<&'a mut SocketFilter, ProgramError>
Performs the conversion.
Auto Trait Implementations
impl !RefUnwindSafe for SocketFilter
impl !Send for SocketFilter
impl !Sync for SocketFilter
impl Unpin for SocketFilter
impl !UnwindSafe for SocketFilter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more