1 #ifndef __LINUX_NETLINK_H
2 #define __LINUX_NETLINK_H
4 #define NETLINK_ROUTE 0 /* Routing/device hook */
5 #define NETLINK_W1 1 /* 1-wire subsystem */
6 #define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */
7 #define NETLINK_FIREWALL 3 /* Firewalling hook */
8 #define NETLINK_INET_DIAG 4 /* INET socket monitoring */
9 #define NETLINK_TCPDIAG NETLINK_INET_DIAG
10 #define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */
11 #define NETLINK_XFRM 6 /* ipsec */
12 #define NETLINK_SELINUX 7 /* SELinux event notifications */
13 #define NETLINK_ISCSI 8 /* Open-iSCSI */
14 #define NETLINK_AUDIT 9 /* auditing */
15 #define NETLINK_FIB_LOOKUP 10
16 #define NETLINK_CONNECTOR 11
17 #define NETLINK_NETFILTER 12
18 #define NETLINK_IP6_FW 13
19 #define NETLINK_DNRTMSG 14 /* DECnet routing messages */
20 #define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */
21 #define NETLINK_GENERIC 16
26 * Netlink socket address
31 /** socket family (AF_NETLINK) */
32 sa_family_t nl_family;
34 /** Padding (unused) */
35 unsigned short nl_pad;
37 /** Unique process ID */
40 /** Multicast group subscriptions */
45 * Netlink message header
51 * Length of message including header.
56 * Message type (content type)
71 * Netlink PID of the proccess sending the message.
77 * @name Standard message flags
82 * Must be set on all request messages (typically from user space to
86 #define NLM_F_REQUEST 1
89 * Indicates the message is part of a multipart message terminated
95 * Request for an acknowledgment on success.
107 * @name Additional message flags for GET requests
112 * Return the complete table instead of a single entry.
115 #define NLM_F_ROOT 0x100
118 * Return all entries matching criteria passed in message content.
120 #define NLM_F_MATCH 0x200
123 * Return an atomic snapshot of the table being referenced. This
124 * may require special privileges because it has the potential to
125 * interrupt service in the FE for a longer time.
127 #define NLM_F_ATOMIC 0x400
132 #define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
137 * @name Additional messsage flags for NEW requests
142 * Replace existing matching config object with this request.
145 #define NLM_F_REPLACE 0x100
148 * Don't replace the config object if it already exists.
150 #define NLM_F_EXCL 0x200
153 * Create config object if it doesn't already exist.
155 #define NLM_F_CREATE 0x400
158 * Add to the end of the object list.
160 #define NLM_F_APPEND 0x800
164 #define NLMSG_ALIGNTO 4
165 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
166 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
169 * @name Standard Message types
174 * No operation, message must be ignored
177 #define NLMSG_NOOP 0x1
180 * The message signals an error and the payload contains a nlmsgerr
181 * structure. This can be looked at as a NACK and typically it is
184 #define NLMSG_ERROR 0x2
187 * Message terminates a multipart message.
189 #define NLMSG_DONE 0x3
192 * The message signals that data got lost
194 #define NLMSG_OVERRUN 0x4
197 * Lower limit of reserved message types
199 #define NLMSG_MIN_TYPE 0x10
204 * Netlink error message
209 /** Error code (errno number) */
212 /** Original netlink message causing the error */
216 #define NETLINK_ADD_MEMBERSHIP 1
217 #define NETLINK_DROP_MEMBERSHIP 2
218 #define NETLINK_PKTINFO 3
231 /** Attribute length */
234 /** Attribute type */
238 #define NLA_ALIGNTO 4
239 #define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
240 #define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
242 #endif /* __LINUX_NETLINK_H */