pub struct NlSocketHandle { /* private fields */ }Expand description
Tokio-enabled Netlink socket struct
Implementations§
Source§impl NlSocketHandle
impl NlSocketHandle
Sourcepub fn connect(
proto: NlFamily,
pid: Option<u32>,
groups: Groups,
) -> Result<Self, SocketError>
pub fn connect( proto: NlFamily, pid: Option<u32>, groups: Groups, ) -> Result<Self, SocketError>
Set up asynchronous socket handle.
Sourcepub fn add_mcast_membership(&self, groups: Groups) -> Result<(), SocketError>
pub fn add_mcast_membership(&self, groups: Groups) -> Result<(), SocketError>
Join multicast groups for a socket.
Sourcepub fn drop_mcast_membership(&self, groups: Groups) -> Result<(), SocketError>
pub fn drop_mcast_membership(&self, groups: Groups) -> Result<(), SocketError>
Leave multicast groups for a socket.
Sourcepub fn list_mcast_membership(&self) -> Result<NetlinkBitArray, SocketError>
pub fn list_mcast_membership(&self) -> Result<NetlinkBitArray, SocketError>
List joined groups for a socket.
Sourcepub async fn send<T, P>(&self, msg: &Nlmsghdr<T, P>) -> Result<(), SocketError>
pub async fn send<T, P>(&self, msg: &Nlmsghdr<T, P>) -> Result<(), SocketError>
Send a message on the socket asynchronously.
Sourcepub async fn recv<T, P>(
&self,
) -> Result<(NlBufferIter<T, P, BufferPoolGuard<'_>>, Groups), SocketError>
pub async fn recv<T, P>( &self, ) -> Result<(NlBufferIter<T, P, BufferPoolGuard<'_>>, Groups), SocketError>
Receive a message from the socket asynchronously.
Sourcepub async fn recv_all<T, P>(
&self,
) -> Result<(NlBuffer<T, P>, Groups), SocketError>
pub async fn recv_all<T, P>( &self, ) -> Result<(NlBuffer<T, P>, Groups), SocketError>
Parse all Nlmsghdr structs sent in
one network packet and return them all in a list.
Failure to parse any packet will cause the entire operation
to fail. If an error is detected at the application level,
this method will discard any non-error
Nlmsghdr structs and only return the
error. For a more granular approach, use either NlSocketHandle::recv.
Sourcepub fn set_recv_buffer_size(&self, size: usize) -> Result<(), SocketError>
pub fn set_recv_buffer_size(&self, size: usize) -> Result<(), SocketError>
Set the size of the receive buffer for the socket.
This can be useful when communicating with a service that sends a high volume of messages (especially multicast), and your application cannot process them fast enough, leading to the kernel dropping messages. A larger buffer may help mitigate this.
The value passed is a hint to the kernel to set the size of the receive buffer.
The kernel will double the value provided to account for bookkeeping overhead.
The doubled value is capped by the value in /proc/sys/net/core/rmem_max.
The default value is /proc/sys/net/core/rmem_default
See socket(7) documentation for SO_RCVBUF for more information.
Sourcepub fn enable_ext_ack(&self, enable: bool) -> Result<(), SocketError>
pub fn enable_ext_ack(&self, enable: bool) -> Result<(), SocketError>
Sourcepub fn get_ext_ack_enabled(&self) -> Result<bool, SocketError>
pub fn get_ext_ack_enabled(&self) -> Result<bool, SocketError>
Return true if an extended ACK is enabled for this socket.
Sourcepub fn enable_strict_checking(&self, enable: bool) -> Result<(), SocketError>
pub fn enable_strict_checking(&self, enable: bool) -> Result<(), SocketError>
Sourcepub fn get_strict_checking_enabled(&self) -> Result<bool, SocketError>
pub fn get_strict_checking_enabled(&self) -> Result<bool, SocketError>
Return true if strict checking is enabled for this socket.
Only supported by NlFamily::Route sockets.
Requires Linux >= 4.20.
Trait Implementations§
Source§impl AsRawFd for NlSocketHandle
impl AsRawFd for NlSocketHandle
Source§impl From<NlSocketHandle> for NlSocket
Available on crate feature async only.
impl From<NlSocketHandle> for NlSocket
async only.