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 int NLMSG_ALIGN(size_t len);
12 int NLMSG_LENGTH(size_t len);
13 int NLMSG_SPACE(size_t len);
14 void *NLMSG_DATA(struct nlmsghdr *nlh);
15 struct nlmsghdr *NLMSG_NEXT(struct nlmsghdr *nlh, int len);
16 int NLMSG_OK(struct nlmsghdr *nlh, int len);
17 int NLMSG_PAYLOAD(struct nlmsghdr *nlh, int len);
18
20 <linux/netlink.h> defines several standard macros to access or create a
21 netlink datagram. They are similar in spirit to the macros defined in
22 cmsg(3) for auxiliary data. The buffer passed to and from a netlink
23 socket should be only accessed using these macros.
24
25
26 NLMSG_ALIGN
27 Round the length of a netlink message up to align it
28 properly.
29
30 NLMSG_LENGTH
31 Gets the payload length as argument and returns the
32 aligned length to store in the nlmsg_len field of the
33 nlmsghdr.
34
35
36 NLMSG_SPACE
37 Return the number of bytes a netlink message with payload
38 of the passed length would occupy.
39
40 NLMSG_DATA
41 Return a pointer to the payload associated with the
42 passed nlmsghdr.
43
44 NLMSG_NEXT
45 Get the next nlmsghdr in a multipart message. The caller
46 must check if the current nlmsghdr didn't have the
47 NLMSG_DONE set — this function doesn't return NULL on
48 end. The length parameter is an lvalue containing the
49 remaining length of the message buffer. This macro
50 decrements it by the length of the message header.
51
52 NLMSG_OK
53 Return true if the netlink message is not truncated and
54 ok to parse.
55
56 NLMSG_PAYLOAD
57 Return the length of the payload associated with the
58 nlmsghdr.
59
60
62 It is often better to use netlink via libnetlink than via the
63 low level kernel interface.
64
65
67 netlink(7)
68
69 and ftp://ftp.inr.ac.ru/ip-routing/iproute2* for libnetlink
70
71
72
73Linux Man Page 1999-05-14 NETLINK(3)