Skip to main content

Chain

Struct Chain 

Source
pub struct Chain<'a> { /* private fields */ }
Expand description

Abstraction of a nftnl_chain. Chains reside inside Tables and they hold Rules.

There are two types of chains, “base chain” and “regular chain”. See set_hook for more details.

Implementations§

Source§

impl<'a> Chain<'a>

Source

pub fn new<T: AsRef<CStr>>(name: T, table: &'a Table) -> Chain<'a>

Creates a new chain instance inside the given Table and with the given name.

Source

pub fn set_hook(&mut self, hook: Hook, priority: Priority)

Sets the hook and priority for this chain. Without calling this method the chain well become a “regular chain” without any hook and will thus not receive any traffic unless some rule forward packets to it via goto or jump verdicts.

By calling set_hook with a hook the chain that is created will be registered with that hook and is thus a “base chain”. A “base chain” is an entry point for packets from the networking stack.

Source

pub fn set_type(&mut self, chain_type: ChainType)

Set the type of a base chain. This only applies if the chain has been registered with a hook by calling set_hook.

Source

pub fn set_policy(&mut self, policy: Policy)

Sets the default policy for this chain. That means what action netfilter will apply to packets processed by this chain, but that did not match any rules in it.

Source

pub fn set_device<T: AsRef<CStr>>(&mut self, device: T)

Sets the device for this chain. This only applies if the chain has been registered with an ingress hook by calling set_hook.

Source

pub fn get_name(&self) -> &CStr

Returns the name of this chain.

Source

pub fn get_table(&self) -> &Table

Returns a reference to the Table this chain belongs to

Trait Implementations§

Source§

impl Debug for Chain<'_>

Source§

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

Return a string representation of the chain.

Source§

impl Drop for Chain<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl NlMsg for Chain<'_>

Source§

unsafe fn write(&self, buf: *mut c_void, seq: u32, msg_type: MsgType)

Serializes the Netlink message to the buffer at buf. buf must have space for at least nft_nlmsg_maxsize() bytes. This is not checked by the compiler, which is why this method is unsafe. Read more
Source§

impl Send for Chain<'_>

Source§

impl Sync for Chain<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for Chain<'a>

§

impl<'a> RefUnwindSafe for Chain<'a>

§

impl<'a> Unpin for Chain<'a>

§

impl<'a> UnsafeUnpin for Chain<'a>

§

impl<'a> UnwindSafe for Chain<'a>

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.