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]

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.

Try to parse a message from a buffer

Check if the payload is a NLMSG_DONE message (Rtnl::Done)

Check if the payload is a NLMSG_NOOP message (Rtnl::Noop)

Check if the payload is a NLMSG_OVERRUN message (Rtnl::Overrun)

Check if the payload is a NLMSG_ERROR message with a negative error code (Rtnl::Error)

Check if the payload is a NLMSG_ERROR message with a non-negative error code (Rtnl::Ack)

Check if the payload is a RTM_NEWLINK message (Rtnl::NewLink)

Check if the payload is a RTM_DELLINK message (Rtnl::DelLink)

Check if the payload is a RTM_GETLINK message (Rtnl::GetLink)

Check if the payload is a RTM_SETLINK message (Rtnl::SetLink)

Check if the payload is a RTM_NEWADDR message (Rtnl::NewAddress)

Check if the payload is a RTM_DELADDR message (Rtnl::DelAddress)

Check if the payload is a RTM_GETADDR message (Rtnl::GetAddress)

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]

Formats the value using the given formatter. Read more

impl PartialEq for NetlinkMessage
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for NetlinkMessage
[src]

impl Clone for NetlinkMessage
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl From<RtnlMessage> for NetlinkMessage
[src]

Performs the conversion.

impl<'buffer, T: AsRef<[u8]> + 'buffer> Parseable<NetlinkMessage> for NetlinkBuffer<&'buffer T>
[src]

Deserialize the current type.

impl Emitable for NetlinkMessage
[src]

Return the length of the serialized data.

Serialize this types and write the serialized data into the given buffer. Read more

Auto Trait Implementations