oops
[libnl.git] / include / netlink / netlink-kernel.h
1 #ifndef __LINUX_NETLINK_H
2 #define __LINUX_NETLINK_H
3
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
22
23 #define MAX_LINKS 32            
24
25 /**
26  * Netlink socket address
27  * @ingroup nl
28  */
29 struct sockaddr_nl
30 {
31         /** socket family (AF_NETLINK) */
32         sa_family_t     nl_family;
33
34         /** Padding (unused) */
35         unsigned short  nl_pad;
36
37         /** Unique process ID  */
38         uint32_t        nl_pid;
39
40         /** Multicast group subscriptions */
41         uint32_t        nl_groups;
42 };
43
44 /**
45  * Netlink message header
46  * @ingroup msg
47  */
48 struct nlmsghdr
49 {
50         /**
51          * Length of message including header.
52          */
53         uint32_t        nlmsg_len;
54
55         /**
56          * Message type (content type)
57          */
58         uint16_t        nlmsg_type;
59
60         /**
61          * Message flags
62          */
63         uint16_t        nlmsg_flags;
64
65         /**
66          * Sequence number
67          */
68         uint32_t        nlmsg_seq;
69
70         /**
71          * Netlink PID of the proccess sending the message.
72          */
73         uint32_t        nlmsg_pid;
74 };
75
76 /**
77  * @name Standard message flags
78  * @{
79  */
80
81 /**
82  * Must be set on all request messages (typically from user space to
83  * kernel space).
84  * @ingroup msg
85  */
86 #define NLM_F_REQUEST           1
87
88 /**
89  * Indicates the message is part of a multipart message terminated
90  * by NLMSG_DONE.
91  */
92 #define NLM_F_MULTI             2
93
94 /**
95  * Request for an acknowledgment on success.
96  */
97 #define NLM_F_ACK               4
98
99 /**
100  * Echo this request
101  */
102 #define NLM_F_ECHO              8
103
104 /** @} */
105
106 /**
107  * @name Additional message flags for GET requests
108  * @{
109  */
110
111 /**
112  * Return the complete table instead of a single entry.
113  * @ingroup msg
114  */
115 #define NLM_F_ROOT      0x100
116
117 /**
118  * Return all entries matching criteria passed in message content.
119  */
120 #define NLM_F_MATCH     0x200
121
122 /**
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.
126  */
127 #define NLM_F_ATOMIC    0x400
128
129 /**
130  * Dump all entries
131  */
132 #define NLM_F_DUMP      (NLM_F_ROOT|NLM_F_MATCH)
133
134 /** @} */
135
136 /**
137  * @name Additional messsage flags for NEW requests
138  * @{
139  */
140
141 /**
142  * Replace existing matching config object with this request.
143  * @ingroup msg
144  */
145 #define NLM_F_REPLACE   0x100
146
147 /**
148  * Don't replace the config object if it already exists.
149  */
150 #define NLM_F_EXCL      0x200
151
152 /**
153  * Create config object if it doesn't already exist.
154  */
155 #define NLM_F_CREATE    0x400
156
157 /**
158  * Add to the end of the object list.
159  */
160 #define NLM_F_APPEND    0x800
161
162 /** @} */
163
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)))
167
168 /**
169  * @name Standard Message types
170  * @{
171  */
172
173 /**
174  * No operation, message must be ignored
175  * @ingroup msg
176  */
177 #define NLMSG_NOOP              0x1
178
179 /**
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
182  * from FEC to CPC.
183  */
184 #define NLMSG_ERROR             0x2
185
186 /**
187  * Message terminates a multipart message.
188  */
189 #define NLMSG_DONE              0x3
190
191 /**
192  * The message signals that data got lost
193  */
194 #define NLMSG_OVERRUN           0x4
195
196 /**
197  * Lower limit of reserved message types
198  */
199 #define NLMSG_MIN_TYPE          0x10
200
201 /** @} */
202
203 /**
204  * Netlink error message
205  * @ingroup msg
206  */
207 struct nlmsgerr
208 {
209         /** Error code (errno number) */
210         int             error;
211
212         /** Original netlink message causing the error */
213         struct nlmsghdr msg;
214 };
215
216 #define NETLINK_ADD_MEMBERSHIP  1
217 #define NETLINK_DROP_MEMBERSHIP 2
218 #define NETLINK_PKTINFO         3
219
220 struct nl_pktinfo
221 {
222         __u32   group;
223 };
224
225 /**
226  * Netlink Attribute
227  * @ingroup attr
228  */
229 struct nlattr
230 {
231         /** Attribute length */
232         __u16           nla_len;
233
234         /** Attribute type */
235         __u16           nla_type;
236 };
237
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)))
241
242 #endif  /* __LINUX_NETLINK_H */