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