1NETLINK(3) Linux Programmer's Manual NETLINK(3)
2
3
4
6 netlink - Netlink macros
7
9 #include <asm/types.h>
10 #include <linux/netlink.h>
11
12 int NLMSG_ALIGN(size_t len);
13 int NLMSG_LENGTH(size_t len);
14 int NLMSG_SPACE(size_t len);
15 void *NLMSG_DATA(struct nlmsghdr *nlh);
16 struct nlmsghdr *NLMSG_NEXT(struct nlmsghdr *nlh, int len);
17 int NLMSG_OK(struct nlmsghdr *nlh, int len);
18 int NLMSG_PAYLOAD(struct nlmsghdr *nlh, int len);
19
21 <linux/netlink.h> defines several standard macros to access or create a
22 netlink datagram. They are similar in spirit to the macros defined in
23 cmsg(3) for auxiliary data. The buffer passed to and from a netlink
24 socket should be accessed using only these macros.
25
26 NLMSG_ALIGN()
27 Round the length of a netlink message up to align it properly.
28
29 NLMSG_LENGTH()
30 Given the payload length, len, this macro returns the aligned
31 length to store in the nlmsg_len field of the nlmsghdr.
32
33 NLMSG_SPACE()
34 Return the number of bytes that a netlink message with payload
35 of len would occupy.
36
37 NLMSG_DATA()
38 Return a pointer to the payload associated with the passed nlms‐
39 ghdr.
40
41 NLMSG_NEXT()
42 Get the next nlmsghdr in a multipart message. The caller must
43 check if the current nlmsghdr didn't have the NLMSG_DONE set—
44 this function doesn't return NULL on end. The len argument is
45 an lvalue containing the remaining length of the message buffer.
46 This macro decrements it by the length of the message header.
47
48 NLMSG_OK()
49 Return true if the netlink message is not truncated and is in a
50 form suitable for parsing.
51
52 NLMSG_PAYLOAD()
53 Return the length of the payload associated with the nlmsghdr.
54
56 These macros are nonstandard Linux extensions.
57
59 It is often better to use netlink via libnetlink than via the low-level
60 kernel interface.
61
63 libnetlink(3), netlink(7)
64
66 This page is part of release 5.12 of the Linux man-pages project. A
67 description of the project, information about reporting bugs, and the
68 latest version of this page, can be found at
69 https://www.kernel.org/doc/man-pages/.
70
71
72
73GNU 2014-03-20 NETLINK(3)