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).
str ([value]) Decodes a NUL-terminated string attribute value.
u32 ([value]) Decodes a u32 attribute value.


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.
str ([value])
Decodes a NUL-terminated string attribute value.

Parameters:

  • value string raw attribute payload; nil is passed through. (optional)

Returns:

    string or nil the decoded string.
u32 ([value])
Decodes a u32 attribute value.

Parameters:

  • value string raw attribute payload; nil is passed through. (optional)

Returns:

    integer or nil the decoded integer.
generated by LDoc 1.5.0 Last updated 2026-09-05 12:27:44