1 #ifndef __NETLINK_KERNEL_H_
2 #define __NETLINK_KERNEL_H_
7 * FIXME: Goal is to preseve the documentation but make it simple
8 * to keep linux/netlink.h in sync. Maybe use named documentation
13 * Netlink socket address
18 /** socket family (AF_NETLINK) */
19 sa_family_t nl_family;
21 /** Padding (unused) */
22 unsigned short nl_pad;
24 /** Unique process ID */
27 /** Multicast group subscriptions */
38 * Netlink message header
42 /** Length of message including header and padding. */
45 /** Message type (content type) */
51 /** Sequence number of message \see core_sk_seq_num. */
59 * @name Standard message flags
64 * Must be set on all request messages (typically from user space to
67 #define NLM_F_REQUEST 1
70 * Indicates the message is part of a multipart message terminated
76 * Request for an acknowledgment on success.
88 * @name Additional message flags for GET requests
93 * Return the complete table instead of a single entry.
95 #define NLM_F_ROOT 0x100
98 * Return all entries matching criteria passed in message content.
100 #define NLM_F_MATCH 0x200
103 * Return an atomic snapshot of the table being referenced. This
104 * may require special privileges because it has the potential to
105 * interrupt service in the FE for a longer time.
107 #define NLM_F_ATOMIC 0x400
112 #define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
117 * @name Additional messsage flags for NEW requests
122 * Replace existing matching config object with this request.
124 #define NLM_F_REPLACE 0x100
127 * Don't replace the config object if it already exists.
129 #define NLM_F_EXCL 0x200
132 * Create config object if it doesn't already exist.
134 #define NLM_F_CREATE 0x400
137 * Add to the end of the object list.
139 #define NLM_F_APPEND 0x800
144 * @name Standard Message types
149 * No operation, message must be ignored
151 #define NLMSG_NOOP 0x1
154 * The message signals an error and the payload contains a nlmsgerr
155 * structure. This can be looked at as a NACK and typically it is
158 #define NLMSG_ERROR 0x2
161 * Message terminates a multipart message.
163 #define NLMSG_DONE 0x3
166 * The message signals that data got lost
168 #define NLMSG_OVERRUN 0x4
171 * Lower limit of reserved message types
173 #define NLMSG_MIN_TYPE 0x10
178 * Netlink error message header
182 /** Error code (errno number) */
185 /** Original netlink message causing the error */
195 * Netlink alignment constant, all boundries within messages must be align to this.
197 * See \ref core_msg_fmt_align for more information on message alignment.
199 #define NLMSG_ALIGNTO 4
202 * Returns \p len properly aligned to NLMSG_ALIGNTO.
204 * See \ref core_msg_fmt_align for more information on message alignment.
206 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
209 * Length of a netlink message header including padding.
211 * See \ref core_msg_fmt_align for more information on message alignment.
213 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
226 * Netlink attribute structure
229 * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->
230 * +---------------------+- - -+- - - - - - - - - -+- - -+
231 * | Header | Pad | Payload | Pad |
232 * | (struct nlattr) | ing | | ing |
233 * +---------------------+- - -+- - - - - - - - - -+- - -+
234 * <-------------- nlattr->nla_len -------------->
239 * Attribute length in bytes including header
244 * Netlink attribute type
250 * @name Attribute Type Flags
254 * +---+---+-------------------------------+
255 * | N | O | Attribute Type |
256 * +---+---+-------------------------------+
257 * N := Carries nested attributes
258 * O := Payload stored in network byte order
261 * @note The N and O flag are mutually exclusive.
268 #define NLA_F_NESTED (1 << 15)
269 #define NLA_F_NET_BYTEORDER (1 << 14)
270 #define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
274 #define NLA_ALIGNTO 4
277 * Returns \p len properly aligned to NLA_ALIGNTO.
279 * See \ref core_msg_fmt_align for more information on message alignment.
281 #define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
284 * Length of a netlink attribute header including padding.
286 * See \ref core_msg_fmt_align for more information on message alignment.
288 #define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
293 #endif /* __LINUX_NETLINK_H */