Struct rtnetlink::NetlinkMessage [−][src]
pub struct NetlinkMessage { /* fields omitted */ }
Represent a netlink message.
A netlink message is made of a header (represented by
NetlinkHeader
) and message (represented by
RtnlMessage
):
0 8 16 24 32
+----------------+----------------+----------------+----------------+
| packet length (including header) | \
+----------------+----------------+----------------+----------------+ |
| message type | flags | |
+----------------+----------------+----------------+----------------+ | NetlinkHeader
| sequence number | |
+----------------+----------------+----------------+----------------+ |
| port number (formerly known as PID) | /
+----------------+----------------+----------------+----------------+
| payload | \
| (variable length) | | RtnlMessage
| | |
| | /
+----------------+----------------+----------------+----------------+
Methods
impl NetlinkMessage
[src]
impl NetlinkMessage
pub fn into_parts(self) -> (NetlinkHeader, RtnlMessage)
[src]
pub fn into_parts(self) -> (NetlinkHeader, RtnlMessage)
pub fn message(&self) -> &RtnlMessage
[src]
pub fn message(&self) -> &RtnlMessage
pub fn message_mut(&mut self) -> &mut RtnlMessage
[src]
pub fn message_mut(&mut self) -> &mut RtnlMessage
pub fn header(&self) -> &NetlinkHeader
[src]
pub fn header(&self) -> &NetlinkHeader
pub fn header_mut(&mut self) -> &mut NetlinkHeader
[src]
pub fn header_mut(&mut self) -> &mut NetlinkHeader
pub fn to_bytes(&self, buffer: &mut [u8]) -> Result<usize>
[src]
pub fn to_bytes(&self, buffer: &mut [u8]) -> Result<usize>
Safely serialize the message. Under the hood, this calls
Emitable::emit()
, but unlike emit()
, this method
does not panic if the message is malformed or if the destination buffer is too small.
Instead, an error is returned. Note that you must call finalize()
before calling this method, otherwise, Error::Malformed
is returned.
pub fn from_bytes(buffer: &[u8]) -> Result<Self>
[src]
pub fn from_bytes(buffer: &[u8]) -> Result<Self>
Try to parse a message from a buffer
pub fn is_done(&self) -> bool
[src]
pub fn is_done(&self) -> bool
Check if the payload is a NLMSG_DONE
message
(Rtnl::Done
)
pub fn is_noop(&self) -> bool
[src]
pub fn is_noop(&self) -> bool
Check if the payload is a NLMSG_NOOP
message
(Rtnl::Noop
)
pub fn is_overrun(&self) -> bool
[src]
pub fn is_overrun(&self) -> bool
Check if the payload is a NLMSG_OVERRUN
message
(Rtnl::Overrun
)
pub fn is_error(&self) -> bool
[src]
pub fn is_error(&self) -> bool
Check if the payload is a NLMSG_ERROR
message with a negative error code
(Rtnl::Error
)
pub fn is_ack(&self) -> bool
[src]
pub fn is_ack(&self) -> bool
Check if the payload is a NLMSG_ERROR
message with a non-negative error code
(Rtnl::Ack
)
pub fn is_new_link(&self) -> bool
[src]
pub fn is_new_link(&self) -> bool
Check if the payload is a RTM_NEWLINK
message
(Rtnl::NewLink
)
pub fn is_del_link(&self) -> bool
[src]
pub fn is_del_link(&self) -> bool
Check if the payload is a RTM_DELLINK
message
(Rtnl::DelLink
)
pub fn is_get_link(&self) -> bool
[src]
pub fn is_get_link(&self) -> bool
Check if the payload is a RTM_GETLINK
message
(Rtnl::GetLink
)
pub fn is_set_link(&self) -> bool
[src]
pub fn is_set_link(&self) -> bool
Check if the payload is a RTM_SETLINK
message
(Rtnl::SetLink
)
pub fn is_new_address(&self) -> bool
[src]
pub fn is_new_address(&self) -> bool
Check if the payload is a RTM_NEWADDR
message
(Rtnl::NewAddress
)
pub fn is_del_address(&self) -> bool
[src]
pub fn is_del_address(&self) -> bool
Check if the payload is a RTM_DELADDR
message
(Rtnl::DelAddress
)
pub fn is_get_address(&self) -> bool
[src]
pub fn is_get_address(&self) -> bool
Check if the payload is a RTM_GETADDR
message
(Rtnl::GetAddress
)
pub fn finalize(&mut self)
[src]
pub fn finalize(&mut self)
Ensure the header (NetlinkHeader
) is consistent with the payload (RtnlMessage
):
- compute the payload length and set the header's length field
- check the payload type and set the header's message type field accordingly
If you are not 100% sure the header is correct, this method should be called before calling
Emitable::emit()
or
to_bytes()
. emit()
could panic if the header is inconsistent with
the rest of the message, and to_bytes()
would return an error.
Trait Implementations
impl Debug for NetlinkMessage
[src]
impl Debug for NetlinkMessage
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for NetlinkMessage
[src]
impl PartialEq for NetlinkMessage
fn eq(&self, other: &NetlinkMessage) -> bool
[src]
fn eq(&self, other: &NetlinkMessage) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &NetlinkMessage) -> bool
[src]
fn ne(&self, other: &NetlinkMessage) -> bool
This method tests for !=
.
impl Eq for NetlinkMessage
[src]
impl Eq for NetlinkMessage
impl Clone for NetlinkMessage
[src]
impl Clone for NetlinkMessage
fn clone(&self) -> NetlinkMessage
[src]
fn clone(&self) -> NetlinkMessage
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl From<RtnlMessage> for NetlinkMessage
[src]
impl From<RtnlMessage> for NetlinkMessage
fn from(message: RtnlMessage) -> Self
[src]
fn from(message: RtnlMessage) -> Self
Performs the conversion.
impl<'buffer, T: AsRef<[u8]> + 'buffer> Parseable<NetlinkMessage> for NetlinkBuffer<&'buffer T>
[src]
impl<'buffer, T: AsRef<[u8]> + 'buffer> Parseable<NetlinkMessage> for NetlinkBuffer<&'buffer T>
fn parse(&self) -> Result<NetlinkMessage>
[src]
fn parse(&self) -> Result<NetlinkMessage>
Deserialize the current type.
impl Emitable for NetlinkMessage
[src]
impl Emitable for NetlinkMessage
Auto Trait Implementations
impl Send for NetlinkMessage
impl Send for NetlinkMessage
impl Sync for NetlinkMessage
impl Sync for NetlinkMessage