1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2 /* Do not edit directly, auto-generated from: */
3 /* Documentation/netlink/specs/fou.yaml */
4 /* YNL-GEN user header */
5
6 #ifndef _LINUX_FOU_GEN_H
7 #define _LINUX_FOU_GEN_H
8
9 #include <stdlib.h>
10 #include <string.h>
11 #include <linux/types.h>
12 #include <linux/fou.h>
13
14 struct ynl_sock;
15
16 extern const struct ynl_family ynl_fou_family;
17
18 /* Enums */
19 const char *fou_op_str(int op);
20 const char *fou_encap_type_str(int value);
21
22 /* Common nested types */
23 /* ============== FOU_CMD_ADD ============== */
24 /* FOU_CMD_ADD - do */
25 struct fou_add_req {
26 struct {
27 __u32 port:1;
28 __u32 ipproto:1;
29 __u32 type:1;
30 __u32 remcsum_nopartial:1;
31 __u32 local_v4:1;
32 __u32 peer_v4:1;
33 __u32 local_v6_len;
34 __u32 peer_v6_len;
35 __u32 peer_port:1;
36 __u32 ifindex:1;
37 } _present;
38
39 __u16 port /* big-endian */;
40 __u8 ipproto;
41 __u8 type;
42 __u32 local_v4;
43 __u32 peer_v4;
44 void *local_v6;
45 void *peer_v6;
46 __u16 peer_port /* big-endian */;
47 __s32 ifindex;
48 };
49
fou_add_req_alloc(void)50 static inline struct fou_add_req *fou_add_req_alloc(void)
51 {
52 return calloc(1, sizeof(struct fou_add_req));
53 }
54 void fou_add_req_free(struct fou_add_req *req);
55
56 static inline void
fou_add_req_set_port(struct fou_add_req * req,__u16 port)57 fou_add_req_set_port(struct fou_add_req *req, __u16 port /* big-endian */)
58 {
59 req->_present.port = 1;
60 req->port = port;
61 }
62 static inline void
fou_add_req_set_ipproto(struct fou_add_req * req,__u8 ipproto)63 fou_add_req_set_ipproto(struct fou_add_req *req, __u8 ipproto)
64 {
65 req->_present.ipproto = 1;
66 req->ipproto = ipproto;
67 }
fou_add_req_set_type(struct fou_add_req * req,__u8 type)68 static inline void fou_add_req_set_type(struct fou_add_req *req, __u8 type)
69 {
70 req->_present.type = 1;
71 req->type = type;
72 }
fou_add_req_set_remcsum_nopartial(struct fou_add_req * req)73 static inline void fou_add_req_set_remcsum_nopartial(struct fou_add_req *req)
74 {
75 req->_present.remcsum_nopartial = 1;
76 }
77 static inline void
fou_add_req_set_local_v4(struct fou_add_req * req,__u32 local_v4)78 fou_add_req_set_local_v4(struct fou_add_req *req, __u32 local_v4)
79 {
80 req->_present.local_v4 = 1;
81 req->local_v4 = local_v4;
82 }
83 static inline void
fou_add_req_set_peer_v4(struct fou_add_req * req,__u32 peer_v4)84 fou_add_req_set_peer_v4(struct fou_add_req *req, __u32 peer_v4)
85 {
86 req->_present.peer_v4 = 1;
87 req->peer_v4 = peer_v4;
88 }
89 static inline void
fou_add_req_set_local_v6(struct fou_add_req * req,const void * local_v6,size_t len)90 fou_add_req_set_local_v6(struct fou_add_req *req, const void *local_v6,
91 size_t len)
92 {
93 free(req->local_v6);
94 req->_present.local_v6_len = len;
95 req->local_v6 = malloc(req->_present.local_v6_len);
96 memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
97 }
98 static inline void
fou_add_req_set_peer_v6(struct fou_add_req * req,const void * peer_v6,size_t len)99 fou_add_req_set_peer_v6(struct fou_add_req *req, const void *peer_v6,
100 size_t len)
101 {
102 free(req->peer_v6);
103 req->_present.peer_v6_len = len;
104 req->peer_v6 = malloc(req->_present.peer_v6_len);
105 memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
106 }
107 static inline void
fou_add_req_set_peer_port(struct fou_add_req * req,__u16 peer_port)108 fou_add_req_set_peer_port(struct fou_add_req *req,
109 __u16 peer_port /* big-endian */)
110 {
111 req->_present.peer_port = 1;
112 req->peer_port = peer_port;
113 }
114 static inline void
fou_add_req_set_ifindex(struct fou_add_req * req,__s32 ifindex)115 fou_add_req_set_ifindex(struct fou_add_req *req, __s32 ifindex)
116 {
117 req->_present.ifindex = 1;
118 req->ifindex = ifindex;
119 }
120
121 /*
122 * Add port.
123 */
124 int fou_add(struct ynl_sock *ys, struct fou_add_req *req);
125
126 /* ============== FOU_CMD_DEL ============== */
127 /* FOU_CMD_DEL - do */
128 struct fou_del_req {
129 struct {
130 __u32 af:1;
131 __u32 ifindex:1;
132 __u32 port:1;
133 __u32 peer_port:1;
134 __u32 local_v4:1;
135 __u32 peer_v4:1;
136 __u32 local_v6_len;
137 __u32 peer_v6_len;
138 } _present;
139
140 __u8 af;
141 __s32 ifindex;
142 __u16 port /* big-endian */;
143 __u16 peer_port /* big-endian */;
144 __u32 local_v4;
145 __u32 peer_v4;
146 void *local_v6;
147 void *peer_v6;
148 };
149
fou_del_req_alloc(void)150 static inline struct fou_del_req *fou_del_req_alloc(void)
151 {
152 return calloc(1, sizeof(struct fou_del_req));
153 }
154 void fou_del_req_free(struct fou_del_req *req);
155
fou_del_req_set_af(struct fou_del_req * req,__u8 af)156 static inline void fou_del_req_set_af(struct fou_del_req *req, __u8 af)
157 {
158 req->_present.af = 1;
159 req->af = af;
160 }
161 static inline void
fou_del_req_set_ifindex(struct fou_del_req * req,__s32 ifindex)162 fou_del_req_set_ifindex(struct fou_del_req *req, __s32 ifindex)
163 {
164 req->_present.ifindex = 1;
165 req->ifindex = ifindex;
166 }
167 static inline void
fou_del_req_set_port(struct fou_del_req * req,__u16 port)168 fou_del_req_set_port(struct fou_del_req *req, __u16 port /* big-endian */)
169 {
170 req->_present.port = 1;
171 req->port = port;
172 }
173 static inline void
fou_del_req_set_peer_port(struct fou_del_req * req,__u16 peer_port)174 fou_del_req_set_peer_port(struct fou_del_req *req,
175 __u16 peer_port /* big-endian */)
176 {
177 req->_present.peer_port = 1;
178 req->peer_port = peer_port;
179 }
180 static inline void
fou_del_req_set_local_v4(struct fou_del_req * req,__u32 local_v4)181 fou_del_req_set_local_v4(struct fou_del_req *req, __u32 local_v4)
182 {
183 req->_present.local_v4 = 1;
184 req->local_v4 = local_v4;
185 }
186 static inline void
fou_del_req_set_peer_v4(struct fou_del_req * req,__u32 peer_v4)187 fou_del_req_set_peer_v4(struct fou_del_req *req, __u32 peer_v4)
188 {
189 req->_present.peer_v4 = 1;
190 req->peer_v4 = peer_v4;
191 }
192 static inline void
fou_del_req_set_local_v6(struct fou_del_req * req,const void * local_v6,size_t len)193 fou_del_req_set_local_v6(struct fou_del_req *req, const void *local_v6,
194 size_t len)
195 {
196 free(req->local_v6);
197 req->_present.local_v6_len = len;
198 req->local_v6 = malloc(req->_present.local_v6_len);
199 memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
200 }
201 static inline void
fou_del_req_set_peer_v6(struct fou_del_req * req,const void * peer_v6,size_t len)202 fou_del_req_set_peer_v6(struct fou_del_req *req, const void *peer_v6,
203 size_t len)
204 {
205 free(req->peer_v6);
206 req->_present.peer_v6_len = len;
207 req->peer_v6 = malloc(req->_present.peer_v6_len);
208 memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
209 }
210
211 /*
212 * Delete port.
213 */
214 int fou_del(struct ynl_sock *ys, struct fou_del_req *req);
215
216 /* ============== FOU_CMD_GET ============== */
217 /* FOU_CMD_GET - do */
218 struct fou_get_req {
219 struct {
220 __u32 af:1;
221 __u32 ifindex:1;
222 __u32 port:1;
223 __u32 peer_port:1;
224 __u32 local_v4:1;
225 __u32 peer_v4:1;
226 __u32 local_v6_len;
227 __u32 peer_v6_len;
228 } _present;
229
230 __u8 af;
231 __s32 ifindex;
232 __u16 port /* big-endian */;
233 __u16 peer_port /* big-endian */;
234 __u32 local_v4;
235 __u32 peer_v4;
236 void *local_v6;
237 void *peer_v6;
238 };
239
fou_get_req_alloc(void)240 static inline struct fou_get_req *fou_get_req_alloc(void)
241 {
242 return calloc(1, sizeof(struct fou_get_req));
243 }
244 void fou_get_req_free(struct fou_get_req *req);
245
fou_get_req_set_af(struct fou_get_req * req,__u8 af)246 static inline void fou_get_req_set_af(struct fou_get_req *req, __u8 af)
247 {
248 req->_present.af = 1;
249 req->af = af;
250 }
251 static inline void
fou_get_req_set_ifindex(struct fou_get_req * req,__s32 ifindex)252 fou_get_req_set_ifindex(struct fou_get_req *req, __s32 ifindex)
253 {
254 req->_present.ifindex = 1;
255 req->ifindex = ifindex;
256 }
257 static inline void
fou_get_req_set_port(struct fou_get_req * req,__u16 port)258 fou_get_req_set_port(struct fou_get_req *req, __u16 port /* big-endian */)
259 {
260 req->_present.port = 1;
261 req->port = port;
262 }
263 static inline void
fou_get_req_set_peer_port(struct fou_get_req * req,__u16 peer_port)264 fou_get_req_set_peer_port(struct fou_get_req *req,
265 __u16 peer_port /* big-endian */)
266 {
267 req->_present.peer_port = 1;
268 req->peer_port = peer_port;
269 }
270 static inline void
fou_get_req_set_local_v4(struct fou_get_req * req,__u32 local_v4)271 fou_get_req_set_local_v4(struct fou_get_req *req, __u32 local_v4)
272 {
273 req->_present.local_v4 = 1;
274 req->local_v4 = local_v4;
275 }
276 static inline void
fou_get_req_set_peer_v4(struct fou_get_req * req,__u32 peer_v4)277 fou_get_req_set_peer_v4(struct fou_get_req *req, __u32 peer_v4)
278 {
279 req->_present.peer_v4 = 1;
280 req->peer_v4 = peer_v4;
281 }
282 static inline void
fou_get_req_set_local_v6(struct fou_get_req * req,const void * local_v6,size_t len)283 fou_get_req_set_local_v6(struct fou_get_req *req, const void *local_v6,
284 size_t len)
285 {
286 free(req->local_v6);
287 req->_present.local_v6_len = len;
288 req->local_v6 = malloc(req->_present.local_v6_len);
289 memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
290 }
291 static inline void
fou_get_req_set_peer_v6(struct fou_get_req * req,const void * peer_v6,size_t len)292 fou_get_req_set_peer_v6(struct fou_get_req *req, const void *peer_v6,
293 size_t len)
294 {
295 free(req->peer_v6);
296 req->_present.peer_v6_len = len;
297 req->peer_v6 = malloc(req->_present.peer_v6_len);
298 memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
299 }
300
301 struct fou_get_rsp {
302 struct {
303 __u32 port:1;
304 __u32 ipproto:1;
305 __u32 type:1;
306 __u32 remcsum_nopartial:1;
307 __u32 local_v4:1;
308 __u32 peer_v4:1;
309 __u32 local_v6_len;
310 __u32 peer_v6_len;
311 __u32 peer_port:1;
312 __u32 ifindex:1;
313 } _present;
314
315 __u16 port /* big-endian */;
316 __u8 ipproto;
317 __u8 type;
318 __u32 local_v4;
319 __u32 peer_v4;
320 void *local_v6;
321 void *peer_v6;
322 __u16 peer_port /* big-endian */;
323 __s32 ifindex;
324 };
325
326 void fou_get_rsp_free(struct fou_get_rsp *rsp);
327
328 /*
329 * Get tunnel info.
330 */
331 struct fou_get_rsp *fou_get(struct ynl_sock *ys, struct fou_get_req *req);
332
333 /* FOU_CMD_GET - dump */
334 struct fou_get_list {
335 struct fou_get_list *next;
336 struct fou_get_rsp obj __attribute__ ((aligned (8)));
337 };
338
339 void fou_get_list_free(struct fou_get_list *rsp);
340
341 struct fou_get_list *fou_get_dump(struct ynl_sock *ys);
342
343 #endif /* _LINUX_FOU_GEN_H */
344