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 at pos. A number value is packed as a u32; 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:

    string or table the serialized attributes, or the parsed table.
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, where body holds the bytes after the nlmsghdr (family header and attributes).

Parameters:

Returns:

    table list of messages.
generated by LDoc 1.5.0 Last updated 2026-07-04 13:06:33