A netlink message — the nlmsghdr header (include/uapi/linux/netlink.h)
and its payload — and the framing codec for it.
Every netlink message, of every protocol family, has the same 16-byte header:
0 4 6 8 12 16
+-------+------+------+------------+------------+----- ... -----+
| len | type | flags| seq | pid | payload |
+-------+------+------+------------+------------+----- ... -----+All fields are in native byte order; len covers the header and payload.
This module frames a message for sending and splits a received buffer back
into messages. It does not interpret type — that is a protocol family's
job — beyond using each message's len to find the next one.
A single receive can carry several messages — notably a multipart dump
batch — so decode/1 returns a list.
Summary
Functions
Decodes a received buffer into its list of messages, in order.
Encodes a message into its on-the-wire binary, computing nlmsg_len.
Types
@type t() :: %Linx.Netlink.Message{ flags: 0..65535, payload: binary(), pid: non_neg_integer(), seq: non_neg_integer(), type: 0..65535 }
Functions
Decodes a received buffer into its list of messages, in order.
A trailing run too short to form a header is ignored (alignment padding).
Raises ArgumentError if a message's nlmsg_len overruns the buffer.
Encodes a message into its on-the-wire binary, computing nlmsg_len.
The result is padded to the 4-byte alignment boundary, so encoded messages concatenate into a valid multi-message buffer.