libnl  1.1
netlink-kernel.h
1 /**
2  * Recent linux-libc-dev changed the name of the define
3  */
4 #ifdef __LINUX_NETLINK_H
5 #define _UAPI__LINUX_NETLINK_H
6 #endif
7 
8 #ifndef _UAPI__LINUX_NETLINK_H
9 #define _UAPI__LINUX_NETLINK_H
10 
11 /**
12  * Netlink socket address
13  * @ingroup nl
14  */
16 {
17  /** socket family (AF_NETLINK) */
18  sa_family_t nl_family;
19 
20  /** Padding (unused) */
21  unsigned short nl_pad;
22 
23  /** Unique process ID */
24  uint32_t nl_pid;
25 
26  /** Multicast group subscriptions */
27  uint32_t nl_groups;
28 };
29 
30 /**
31  * Netlink message header
32  * @ingroup msg
33  */
34 struct nlmsghdr
35 {
36  /**
37  * Length of message including header.
38  */
39  uint32_t nlmsg_len;
40 
41  /**
42  * Message type (content type)
43  */
44  uint16_t nlmsg_type;
45 
46  /**
47  * Message flags
48  */
49  uint16_t nlmsg_flags;
50 
51  /**
52  * Sequence number
53  */
54  uint32_t nlmsg_seq;
55 
56  /**
57  * Netlink PID of the proccess sending the message.
58  */
59  uint32_t nlmsg_pid;
60 };
61 
62 /**
63  * @name Standard message flags
64  * @{
65  */
66 
67 /**
68  * Must be set on all request messages (typically from user space to
69  * kernel space).
70  * @ingroup msg
71  */
72 #define NLM_F_REQUEST 1
73 
74 /**
75  * Indicates the message is part of a multipart message terminated
76  * by NLMSG_DONE.
77  */
78 #define NLM_F_MULTI 2
79 
80 /**
81  * Request for an acknowledgment on success.
82  */
83 #define NLM_F_ACK 4
84 
85 /**
86  * Echo this request
87  */
88 #define NLM_F_ECHO 8
89 
90 /** @} */
91 
92 /**
93  * @name Additional message flags for GET requests
94  * @{
95  */
96 
97 /**
98  * Return the complete table instead of a single entry.
99  * @ingroup msg
100  */
101 #define NLM_F_ROOT 0x100
102 
103 /**
104  * Return all entries matching criteria passed in message content.
105  */
106 #define NLM_F_MATCH 0x200
107 
108 /**
109  * Return an atomic snapshot of the table being referenced. This
110  * may require special privileges because it has the potential to
111  * interrupt service in the FE for a longer time.
112  */
113 #define NLM_F_ATOMIC 0x400
114 
115 /**
116  * Dump all entries
117  */
118 #define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
119 
120 /** @} */
121 
122 /**
123  * @name Additional messsage flags for NEW requests
124  * @{
125  */
126 
127 /**
128  * Replace existing matching config object with this request.
129  * @ingroup msg
130  */
131 #define NLM_F_REPLACE 0x100
132 
133 /**
134  * Don't replace the config object if it already exists.
135  */
136 #define NLM_F_EXCL 0x200
137 
138 /**
139  * Create config object if it doesn't already exist.
140  */
141 #define NLM_F_CREATE 0x400
142 
143 /**
144  * Add to the end of the object list.
145  */
146 #define NLM_F_APPEND 0x800
147 
148 /** @} */
149 
150 /**
151  * @name Standard Message types
152  * @{
153  */
154 
155 /**
156  * No operation, message must be ignored
157  * @ingroup msg
158  */
159 #define NLMSG_NOOP 0x1
160 
161 /**
162  * The message signals an error and the payload contains a nlmsgerr
163  * structure. This can be looked at as a NACK and typically it is
164  * from FEC to CPC.
165  */
166 #define NLMSG_ERROR 0x2
167 
168 /**
169  * Message terminates a multipart message.
170  */
171 #define NLMSG_DONE 0x3
172 
173 /**
174  * The message signals that data got lost
175  */
176 #define NLMSG_OVERRUN 0x4
177 
178 /**
179  * Lower limit of reserved message types
180  */
181 #define NLMSG_MIN_TYPE 0x10
182 
183 /** @} */
184 
185 /**
186  * Netlink error message
187  * @ingroup msg
188  */
189 struct nlmsgerr
190 {
191  /** Error code (errno number) */
192  int error;
193 
194  /** Original netlink message causing the error */
195  struct nlmsghdr msg;
196 };
197 
199 {
200  __u32 group;
201 };
202 
203 #endif /* _UAPI__LINUX_NETLINK_H */