Module netlink.message
Netlink wire codec shared by the netlink modules.
Builds nlmsghdr/nlattr
structures via the struct codec and parses received buffers into Lua
tables.
Functions
| attrs (attrs[, pos]) | Attribute codec: serializes a {[type] = value} table into netlink
attributes, or parses them back from a message body starting at pos. |
| encode (mtype, flags, seq, payload) | Builds a complete netlink message. |
| parse (buf) | Parses a buffer into a list of {type, flags, body} messages, where body
holds the bytes after the nlmsghdr (family header and attributes). |
Functions
- attrs (attrs[, pos])
-
Attribute codec: serializes a
{[type] = value}table into netlink attributes, or parses them back from a message body starting atpos. Anumbervalue is packed as au32; a string is used verbatim.Parameters:
- attrs table or string attribute table (serialize) or message body (parse).
- pos integer 1-based position of the first attribute (parse). (optional)
Returns:
- encode (mtype, flags, seq, payload)
-
Builds a complete netlink message.
Parameters:
- mtype integer message type.
- flags integer NLMF* flags.
- seq integer sequence number.
- payload string family header and/or attributes.
Returns:
-
string
the serialized message.
- parse (buf)
-
Parses a buffer into a list of
{type, flags, body}messages, wherebodyholds the bytes after thenlmsghdr(family header and attributes).Parameters:
- buf string received buffer.
Returns:
-
table
list of messages.