pub struct NetlinkMessage { /* private fields */ }
Expand description

Represent a netlink message.

A netlink message is made of a header (represented by NetlinkHeader) and message (represented by NetlinkPayload):

0                8                16              24               32
+----------------+----------------+----------------+----------------+
|                 packet length (including header)                  |   \
+----------------+----------------+----------------+----------------+    |
|          message type           |              flags              |    |
+----------------+----------------+----------------+----------------+    | NetlinkHeader
|                           sequence number                         |    |
+----------------+----------------+----------------+----------------+    |
|                   port number (formerly known as PID)             |   /
+----------------+----------------+----------------+----------------+   
|                               payload                             |   \
|                          (variable length)                        |    |  NetlinkPayload
|                                                                   |    |
|                                                                   |   /
+----------------+----------------+----------------+----------------+

Implementations§

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.

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)

Ensure the header (NetlinkHeader) is consistent with the payload (NetlinkPayload):

  • 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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Return the length of the serialized data.
Serialize this types and write the serialized data into the given buffer. Read more
Converts to this type from the input type.
Deserialize the current type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.