xref: /openbmc/linux/tools/net/ynl/generated/fou-user.h (revision 9134211f)
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 
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
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
63 fou_add_req_set_ipproto(struct fou_add_req *req, __u8 ipproto)
64 {
65 	req->_present.ipproto = 1;
66 	req->ipproto = ipproto;
67 }
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 }
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
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
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
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->local_v6 = malloc(req->_present.local_v6_len);
95 	memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
96 }
97 static inline void
98 fou_add_req_set_peer_v6(struct fou_add_req *req, const void *peer_v6,
99 			size_t len)
100 {
101 	free(req->peer_v6);
102 	req->peer_v6 = malloc(req->_present.peer_v6_len);
103 	memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
104 }
105 static inline void
106 fou_add_req_set_peer_port(struct fou_add_req *req,
107 			  __u16 peer_port /* big-endian */)
108 {
109 	req->_present.peer_port = 1;
110 	req->peer_port = peer_port;
111 }
112 static inline void
113 fou_add_req_set_ifindex(struct fou_add_req *req, __s32 ifindex)
114 {
115 	req->_present.ifindex = 1;
116 	req->ifindex = ifindex;
117 }
118 
119 /*
120  * Add port.
121  */
122 int fou_add(struct ynl_sock *ys, struct fou_add_req *req);
123 
124 /* ============== FOU_CMD_DEL ============== */
125 /* FOU_CMD_DEL - do */
126 struct fou_del_req {
127 	struct {
128 		__u32 af:1;
129 		__u32 ifindex:1;
130 		__u32 port:1;
131 		__u32 peer_port:1;
132 		__u32 local_v4:1;
133 		__u32 peer_v4:1;
134 		__u32 local_v6_len;
135 		__u32 peer_v6_len;
136 	} _present;
137 
138 	__u8 af;
139 	__s32 ifindex;
140 	__u16 port /* big-endian */;
141 	__u16 peer_port /* big-endian */;
142 	__u32 local_v4;
143 	__u32 peer_v4;
144 	void *local_v6;
145 	void *peer_v6;
146 };
147 
148 static inline struct fou_del_req *fou_del_req_alloc(void)
149 {
150 	return calloc(1, sizeof(struct fou_del_req));
151 }
152 void fou_del_req_free(struct fou_del_req *req);
153 
154 static inline void fou_del_req_set_af(struct fou_del_req *req, __u8 af)
155 {
156 	req->_present.af = 1;
157 	req->af = af;
158 }
159 static inline void
160 fou_del_req_set_ifindex(struct fou_del_req *req, __s32 ifindex)
161 {
162 	req->_present.ifindex = 1;
163 	req->ifindex = ifindex;
164 }
165 static inline void
166 fou_del_req_set_port(struct fou_del_req *req, __u16 port /* big-endian */)
167 {
168 	req->_present.port = 1;
169 	req->port = port;
170 }
171 static inline void
172 fou_del_req_set_peer_port(struct fou_del_req *req,
173 			  __u16 peer_port /* big-endian */)
174 {
175 	req->_present.peer_port = 1;
176 	req->peer_port = peer_port;
177 }
178 static inline void
179 fou_del_req_set_local_v4(struct fou_del_req *req, __u32 local_v4)
180 {
181 	req->_present.local_v4 = 1;
182 	req->local_v4 = local_v4;
183 }
184 static inline void
185 fou_del_req_set_peer_v4(struct fou_del_req *req, __u32 peer_v4)
186 {
187 	req->_present.peer_v4 = 1;
188 	req->peer_v4 = peer_v4;
189 }
190 static inline void
191 fou_del_req_set_local_v6(struct fou_del_req *req, const void *local_v6,
192 			 size_t len)
193 {
194 	free(req->local_v6);
195 	req->local_v6 = malloc(req->_present.local_v6_len);
196 	memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
197 }
198 static inline void
199 fou_del_req_set_peer_v6(struct fou_del_req *req, const void *peer_v6,
200 			size_t len)
201 {
202 	free(req->peer_v6);
203 	req->peer_v6 = malloc(req->_present.peer_v6_len);
204 	memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
205 }
206 
207 /*
208  * Delete port.
209  */
210 int fou_del(struct ynl_sock *ys, struct fou_del_req *req);
211 
212 /* ============== FOU_CMD_GET ============== */
213 /* FOU_CMD_GET - do */
214 struct fou_get_req {
215 	struct {
216 		__u32 af:1;
217 		__u32 ifindex:1;
218 		__u32 port:1;
219 		__u32 peer_port:1;
220 		__u32 local_v4:1;
221 		__u32 peer_v4:1;
222 		__u32 local_v6_len;
223 		__u32 peer_v6_len;
224 	} _present;
225 
226 	__u8 af;
227 	__s32 ifindex;
228 	__u16 port /* big-endian */;
229 	__u16 peer_port /* big-endian */;
230 	__u32 local_v4;
231 	__u32 peer_v4;
232 	void *local_v6;
233 	void *peer_v6;
234 };
235 
236 static inline struct fou_get_req *fou_get_req_alloc(void)
237 {
238 	return calloc(1, sizeof(struct fou_get_req));
239 }
240 void fou_get_req_free(struct fou_get_req *req);
241 
242 static inline void fou_get_req_set_af(struct fou_get_req *req, __u8 af)
243 {
244 	req->_present.af = 1;
245 	req->af = af;
246 }
247 static inline void
248 fou_get_req_set_ifindex(struct fou_get_req *req, __s32 ifindex)
249 {
250 	req->_present.ifindex = 1;
251 	req->ifindex = ifindex;
252 }
253 static inline void
254 fou_get_req_set_port(struct fou_get_req *req, __u16 port /* big-endian */)
255 {
256 	req->_present.port = 1;
257 	req->port = port;
258 }
259 static inline void
260 fou_get_req_set_peer_port(struct fou_get_req *req,
261 			  __u16 peer_port /* big-endian */)
262 {
263 	req->_present.peer_port = 1;
264 	req->peer_port = peer_port;
265 }
266 static inline void
267 fou_get_req_set_local_v4(struct fou_get_req *req, __u32 local_v4)
268 {
269 	req->_present.local_v4 = 1;
270 	req->local_v4 = local_v4;
271 }
272 static inline void
273 fou_get_req_set_peer_v4(struct fou_get_req *req, __u32 peer_v4)
274 {
275 	req->_present.peer_v4 = 1;
276 	req->peer_v4 = peer_v4;
277 }
278 static inline void
279 fou_get_req_set_local_v6(struct fou_get_req *req, const void *local_v6,
280 			 size_t len)
281 {
282 	free(req->local_v6);
283 	req->local_v6 = malloc(req->_present.local_v6_len);
284 	memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
285 }
286 static inline void
287 fou_get_req_set_peer_v6(struct fou_get_req *req, const void *peer_v6,
288 			size_t len)
289 {
290 	free(req->peer_v6);
291 	req->peer_v6 = malloc(req->_present.peer_v6_len);
292 	memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
293 }
294 
295 struct fou_get_rsp {
296 	struct {
297 		__u32 port:1;
298 		__u32 ipproto:1;
299 		__u32 type:1;
300 		__u32 remcsum_nopartial:1;
301 		__u32 local_v4:1;
302 		__u32 peer_v4:1;
303 		__u32 local_v6_len;
304 		__u32 peer_v6_len;
305 		__u32 peer_port:1;
306 		__u32 ifindex:1;
307 	} _present;
308 
309 	__u16 port /* big-endian */;
310 	__u8 ipproto;
311 	__u8 type;
312 	__u32 local_v4;
313 	__u32 peer_v4;
314 	void *local_v6;
315 	void *peer_v6;
316 	__u16 peer_port /* big-endian */;
317 	__s32 ifindex;
318 };
319 
320 void fou_get_rsp_free(struct fou_get_rsp *rsp);
321 
322 /*
323  * Get tunnel info.
324  */
325 struct fou_get_rsp *fou_get(struct ynl_sock *ys, struct fou_get_req *req);
326 
327 /* FOU_CMD_GET - dump */
328 struct fou_get_list {
329 	struct fou_get_list *next;
330 	struct fou_get_rsp obj __attribute__ ((aligned (8)));
331 };
332 
333 void fou_get_list_free(struct fou_get_list *rsp);
334 
335 struct fou_get_list *fou_get_dump(struct ynl_sock *ys);
336 
337 #endif /* _LINUX_FOU_GEN_H */
338