MnlSocket

Struct MnlSocket 

Source
pub struct MnlSocket { /* private fields */ }

Implementations§

Source§

impl MnlSocket

Source

pub fn mnl_socket_open(bus: i32) -> NtflRes<Self>

mnl_socket_open - open a netlink socket

§Arguments
  • bus - bus the netlink socket bus ID (see NETLINK_* constants)
§Returns

A Result is retuened which has alias NtflRes.

Source

pub fn mnl_socket_bind(&mut self, groups: u32, pid: pid_t) -> NtflRes<()>

Source

pub fn mnl_socket_get_portid(&self) -> u32

mnl_socket_get_portid - obtain Netlink PortID from netlink socket

Copypaste from libmnl: This function returns the Netlink PortID of a given netlink socket. It’s a common mistake to assume that this PortID equals the process ID which is not always true. This is the case if you open more than one socket that is binded to the same Netlink subsystem from the same process.

Source

pub fn mnl_socket_sendto(&self, buf: &[u8], len: usize) -> NtflRes<isize>

mnl_socket_sendto - send a netlink message of a certain size

§Arguments
  • buf - buffer containing the netlink message to be sent
  • len - number of bytes in the buffer that you want to send
§Result

A Result is retuened which has alias NtflRes.

Source

pub fn mnl_socket_recvfrom(&self, bufsiz: usize) -> NtflRes<Vec<u8>>

mnl_socket_recvfrom - receive a netlink message \param nl netlink socket obtained via mnl_socket_open() \param buf buffer that you want to use to store the netlink message \param bufsiz size of the buffer passed to store the netlink message

On error, it returns -1 and errno is appropriately set. If errno is set to ENOSPC, it means that the buffer that you have passed to store the netlink message is too small, so you have received a truncated message. To avoid this, you have to allocate a buffer of MNL_SOCKET_BUFFER_SIZE (which is 8KB, see linux/netlink.h for more information). Using this buffer size ensures that your buffer is big enough to store the netlink message without truncating it.

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V