The Part 1 of ths Netlink socket structures discussion can be found in the below link.
The Netlink Socket Structures β Part 1
The netlink message is sent using a netlink message. The format of the netlink message is shown below
Fig Courtesy: https://people.redhat.com/nhorman/papers/netlink.pdf
The nlmsghdr is the netlink message header and is given below
Fig Courtesy: https://people.redhat.com/nhorman/papers/netlink.pdf
The parameters are described below
- nlmsg_len – length of the packet including the header
- nlmsg_type – The type of the message. Some message types are given below
- NLMSG_NOOP – message is to be ignored
- NLMSG_ERROR – error message. This is part of a structure and is provided below
Fig Courtesy: https://linux.die.net/man/7/netlink
-
- NLMSG_DONE – sent in a multi-part netlink message signalling the end
- nlmsg_flags – this is a set of logically OR’ed bit-mask which determines what action needs to be performed on the message. Some examples are provided below. For further message flags – refer (1) in the reference section
- NLM_F_REQUEST – Request message
- NLM_F_ACK – Ack to a previous packet
- NLM_F_ECHO – associated packet is echoed back to user space process
- NLM_F_MULTI – message is a multi-part message
- NLM_F_MATCH – This flag indicates only a subset of data
should be returned on a protocol specific GET request - NLM_F_ROOT – Used With various data retrieval (GET) operations
for various netlink protocols, request messages with this flag
set indicate that an entire table of data should be returned rather
than a single entry
and various other messages.
- nlmsg_seq – a unique sequence number for the message
- nlms_pid – a unique number associated with the process – can be the pid of the process using getpid () API
Reference:
- https://people.redhat.com/nhorman/papers/netlink.pdf
- https://www.infradead.org/~tgr/libnl/doc/core.html#:~:text=Message%20Format,by%20a%20stream%20of%20attributes.
- https://linux.die.net/man/7/netlink
- https://man7.org/linux/man-pages/man7/netlink.7.html
Pingback: The Netlink Socket Structures – Part 1 | Hitch Hiker's Guide to Learning
Pingback: Netlink Message Macros | Hitch Hiker's Guide to Learning