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

Loads the program inside the kernel.

Attaches the filter on the given socket.

The returned value can be used to detach from the socket, see SocketFilter::detach.

Detaches the program.

See SocketFilter::attach.

Takes ownership of the link referenced by the provided link_id.

The link will be detached on Drop and the caller is now responsible for managing its lifetime.

Unloads the program from the kernel.

Links will be detached before unloading the program. Note that owned links obtained using take_link() will not be detached.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the RawFd of the program if it has been loaded, or None

Returns the RawFd of the program if it has been loaded, or None

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.