Struct NlRouter

Source
pub struct NlRouter { /* private fields */ }
Expand description

A high-level handle for sending messages and generating a handle that validates all of the received messages.

Implementations§

Source§

impl NlRouter

Source

pub fn connect( proto: NlFamily, pid: Option<u32>, groups: Groups, ) -> Result<(Self, NlRouterReceiverHandle<u16, Genlmsghdr<u8, u16, NoUserHeader>>), RouterError<u16, Buffer>>

Equivalent of socket and bind calls.

Source

pub fn add_mcast_membership( &self, groups: Groups, ) -> Result<(), RouterError<u16, Buffer>>

Join multicast groups for a socket.

Source

pub fn drop_mcast_membership( &self, groups: Groups, ) -> Result<(), RouterError<u16, Buffer>>

Leave multicast groups for a socket.

Source

pub fn list_mcast_membership( &self, ) -> Result<NetlinkBitArray, RouterError<u16, Buffer>>

List joined groups for a socket.

Source

pub fn enable_ext_ack( &self, enable: bool, ) -> Result<(), RouterError<u16, Buffer>>

If true is passed in, enable extended ACKs for this socket. If false is passed in, disable extended ACKs for this socket.

Source

pub fn get_ext_ack_enabled(&self) -> Result<bool, RouterError<u16, Buffer>>

Return true if an extended ACK is enabled for this socket.

Source

pub fn enable_strict_checking( &self, enable: bool, ) -> Result<(), RouterError<u16, Buffer>>

If true is passed in, enable strict checking for this socket. If false is passed in, disable strict checking for for this socket. Only supported by NlFamily::Route sockets. Requires Linux >= 4.20.

Source

pub fn get_strict_checking_enabled( &self, ) -> Result<bool, RouterError<u16, Buffer>>

Return true if strict checking is enabled for this socket. Only supported by NlFamily::Route sockets. Requires Linux >= 4.20.

Source

pub fn pid(&self) -> u32

Get the PID for the current socket.

Source

pub fn send<ST, SP, RT, RP>( &self, nl_type: ST, nl_flags: NlmF, nl_payload: NlPayload<ST, SP>, ) -> Result<NlRouterReceiverHandle<RT, RP>, RouterError<ST, SP>>
where ST: NlType, SP: Size + ToBytes,

Send a message and return a handle for receiving responses from this message.

Source

pub fn resolve_genl_family( &self, family_name: &str, ) -> Result<u16, RouterError<GenlId, Genlmsghdr<CtrlCmd, CtrlAttr>>>

Convenience function for resolving a str containing the generic netlink family name to a numeric generic netlink ID.

Source

pub fn resolve_nl_mcast_group( &self, family_name: &str, mcast_name: &str, ) -> Result<u32, RouterError<GenlId, Genlmsghdr<CtrlCmd, CtrlAttr>>>

Convenience function for resolving a str containing the multicast group name to a numeric multicast group ID.

Source

pub fn lookup_id( &self, id: u32, ) -> Result<(String, String), RouterError<GenlId, Genlmsghdr<CtrlCmd, CtrlAttr>>>

Look up netlink family and multicast group name by ID.

Trait Implementations§

Source§

impl Drop for NlRouter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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.