# `Linx.Netlink.Message`
[🔗](https://github.com/oshlabs/linx/blob/v0.2.0/lib/linx/netlink/message.ex#L1)

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.

# `t`

```elixir
@type t() :: %Linx.Netlink.Message{
  flags: 0..65535,
  payload: binary(),
  pid: non_neg_integer(),
  seq: non_neg_integer(),
  type: 0..65535
}
```

# `decode`

```elixir
@spec decode(binary()) :: [t()]
```

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.

# `encode`

```elixir
@spec encode(t()) :: binary()
```

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
