[][src]Struct neli::socket::NlSocket

pub struct NlSocket { /* fields omitted */ }

Handle for the socket file descriptor

Methods

impl NlSocket[src]

pub fn new(proto: NlFamily, track_seq: bool) -> Result<Self, Error>[src]

Wrapper around socket() syscall filling in the netlink-specific information

pub fn increment_seq(&mut self)[src]

Manually increment sequence number

pub fn block(&mut self) -> Result<&mut Self, Error>[src]

Set underlying socket file descriptor to be blocking

pub fn nonblock(&mut self) -> Result<&mut Self, Error>[src]

Set underlying socket file descriptor to be non blocking

pub fn is_blocking(&self) -> Result<bool, Error>[src]

Determines if underlying file descriptor is blocking - Stream feature will throw an error if this function returns false

pub fn bind(
    &mut self,
    pid: Option<u32>,
    groups: Option<Vec<u32>>
) -> Result<(), Error>
[src]

Use this function to bind to a netlink ID and subscribe to groups. See netlink(7) man pages for more information on netlink IDs and groups.

The pid parameter sets PID checking.

  • None means checking is off.
  • Some(0) turns checking on, but takes the PID from the first received message.
  • Some(pid) uses the given PID.

pub fn set_mcast_groups(&mut self, groups: Vec<u32>) -> Result<(), Error>[src]

Set multicast groups for socket

pub fn send<B>(&self, buf: B, flags: i32) -> Result<size_t, Error> where
    B: AsRef<[u8]>, 
[src]

Send message encoded as byte slice to the netlink ID specified in the netlink header (neli::nl::Nlmsghdr)

pub fn recv<B>(&self, buf: B, flags: i32) -> Result<size_t, Error> where
    B: AsMut<[u8]>, 
[src]

Receive message encoded as byte slice from the netlink socket

pub fn connect(
    proto: NlFamily,
    pid: Option<u32>,
    groups: Option<Vec<u32>>,
    track_seq: bool
) -> Result<Self, Error>
[src]

Equivalent of socket and bind calls.

pub fn resolve_genl_family(&mut self, family_name: &str) -> Result<u16, NlError>[src]

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

pub fn resolve_nl_mcast_group(
    &mut self,
    family_name: &str,
    mcast_name: &str
) -> Result<u32, NlError>
[src]

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

pub fn send_nl<T, P>(&mut self, msg: Nlmsghdr<T, P>) -> Result<(), NlError> where
    T: Nl + NlType + Debug,
    P: Nl + Debug
[src]

Convenience function to send an Nlmsghdr struct

pub fn recv_nl<T, P>(
    &mut self,
    buf_sz: Option<usize>
) -> Result<Nlmsghdr<T, P>, NlError> where
    T: Nl + NlType + Debug,
    P: Nl + Debug
[src]

Convenience function to begin receiving a stream of Nlmsghdr structs

pub fn recv_ack(&mut self) -> Result<(), NlError>[src]

Consume an ACK and return an error if an ACK is not found

pub fn iter<T, P>(&mut self) -> NlMessageIter<T, P> where
    T: NlType,
    P: Nl
[src]

Return an iterator object

Trait Implementations

impl AsRawFd for NlSocket[src]

impl Drop for NlSocket[src]

fn drop(&mut self)[src]

Closes underlying file descriptor to avoid file descriptor leaks.

impl FromRawFd for NlSocket[src]

impl IntoRawFd for NlSocket[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.