chiark / gitweb /
0d71a57c8a2ca38691c4c7d823d7ad7f36547c1a
[elogind.git] / src / basic / missing.h
1 #pragma once
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2010 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 /* Missing glibc definitions to access certain kernel APIs */
23
24 #include <errno.h>
25 #include <fcntl.h>
26 #include <linux/audit.h>
27 #include <linux/capability.h>
28 #include <linux/if_link.h>
29 #include <linux/input.h>
30 #include <linux/loop.h>
31 #include <linux/neighbour.h>
32 #include <linux/oom.h>
33 #include <linux/rtnetlink.h>
34 #include <net/ethernet.h>
35 #include <stdlib.h>
36 #include <sys/resource.h>
37 #include <sys/socket.h>
38 #include <sys/syscall.h>
39 #include <uchar.h>
40 #include <unistd.h>
41
42 /// Additional includes needed by elogind
43 #include "musl_missing.h"
44
45 #ifdef HAVE_AUDIT
46 #include <libaudit.h>
47 #endif
48
49 #ifdef ARCH_MIPS
50 #include <asm/sgidefs.h>
51 #endif
52
53 #ifdef HAVE_LINUX_BTRFS_H
54 #include <linux/btrfs.h>
55 #endif
56
57 #if 0 /// UNNEEDED by elogind
58 #ifdef HAVE_LINUX_VM_SOCKETS_H
59 #include <linux/vm_sockets.h>
60 #else
61 #define VMADDR_CID_ANY -1U
62 struct sockaddr_vm {
63         unsigned short svm_family;
64         unsigned short svm_reserved1;
65         unsigned int svm_port;
66         unsigned int svm_cid;
67         unsigned char svm_zero[sizeof(struct sockaddr) -
68                                sizeof(unsigned short) -
69                                sizeof(unsigned short) -
70                                sizeof(unsigned int) -
71                                sizeof(unsigned int)];
72 };
73 #endif /* !HAVE_LINUX_VM_SOCKETS_H */
74 #endif // 0
75
76 #include "macro.h"
77
78 #ifndef RLIMIT_RTTIME
79 #define RLIMIT_RTTIME 15
80 #endif
81
82 /* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
83 #define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
84
85 #ifndef F_LINUX_SPECIFIC_BASE
86 #define F_LINUX_SPECIFIC_BASE 1024
87 #endif
88
89 #ifndef F_SETPIPE_SZ
90 #define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
91 #endif
92
93 #ifndef F_GETPIPE_SZ
94 #define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
95 #endif
96
97 #ifndef F_ADD_SEALS
98 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
99 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
100
101 #define F_SEAL_SEAL     0x0001  /* prevent further seals from being set */
102 #define F_SEAL_SHRINK   0x0002  /* prevent file from shrinking */
103 #define F_SEAL_GROW     0x0004  /* prevent file from growing */
104 #define F_SEAL_WRITE    0x0008  /* prevent writes */
105 #endif
106
107 #ifndef F_OFD_GETLK
108 #define F_OFD_GETLK     36
109 #define F_OFD_SETLK     37
110 #define F_OFD_SETLKW    38
111 #endif
112
113 #ifndef MFD_ALLOW_SEALING
114 #define MFD_ALLOW_SEALING 0x0002U
115 #endif
116
117 #ifndef MFD_CLOEXEC
118 #define MFD_CLOEXEC 0x0001U
119 #endif
120
121 #ifndef IP_FREEBIND
122 #define IP_FREEBIND 15
123 #endif
124
125 #ifndef OOM_SCORE_ADJ_MIN
126 #define OOM_SCORE_ADJ_MIN (-1000)
127 #endif
128
129 #ifndef OOM_SCORE_ADJ_MAX
130 #define OOM_SCORE_ADJ_MAX 1000
131 #endif
132
133 #ifndef AUDIT_SERVICE_START
134 #define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
135 #endif
136
137 #ifndef AUDIT_SERVICE_STOP
138 #define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
139 #endif
140
141 #ifndef TIOCVHANGUP
142 #define TIOCVHANGUP 0x5437
143 #endif
144
145 #ifndef IP_TRANSPARENT
146 #define IP_TRANSPARENT 19
147 #endif
148
149 #ifndef SOL_NETLINK
150 #define SOL_NETLINK 270
151 #endif
152
153 #ifndef NETLINK_LIST_MEMBERSHIPS
154 #define NETLINK_LIST_MEMBERSHIPS 9
155 #endif
156
157 #ifndef SOL_SCTP
158 #define SOL_SCTP 132
159 #endif
160
161 #ifndef GRND_NONBLOCK
162 #define GRND_NONBLOCK 0x0001
163 #endif
164
165 #ifndef GRND_RANDOM
166 #define GRND_RANDOM 0x0002
167 #endif
168
169 #ifndef FS_NOCOW_FL
170 #define FS_NOCOW_FL 0x00800000
171 #endif
172
173 #ifndef BTRFS_IOCTL_MAGIC
174 #define BTRFS_IOCTL_MAGIC 0x94
175 #endif
176
177 #ifndef BTRFS_PATH_NAME_MAX
178 #define BTRFS_PATH_NAME_MAX 4087
179 #endif
180
181 #ifndef BTRFS_DEVICE_PATH_NAME_MAX
182 #define BTRFS_DEVICE_PATH_NAME_MAX 1024
183 #endif
184
185 #ifndef BTRFS_FSID_SIZE
186 #define BTRFS_FSID_SIZE 16
187 #endif
188
189 #ifndef BTRFS_UUID_SIZE
190 #define BTRFS_UUID_SIZE 16
191 #endif
192
193 #ifndef BTRFS_SUBVOL_RDONLY
194 #define BTRFS_SUBVOL_RDONLY (1ULL << 1)
195 #endif
196
197 #ifndef BTRFS_SUBVOL_NAME_MAX
198 #define BTRFS_SUBVOL_NAME_MAX 4039
199 #endif
200
201 #ifndef BTRFS_INO_LOOKUP_PATH_MAX
202 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
203 #endif
204
205 #ifndef BTRFS_SEARCH_ARGS_BUFSIZE
206 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
207 #endif
208
209 #ifndef BTRFS_QGROUP_LEVEL_SHIFT
210 #define BTRFS_QGROUP_LEVEL_SHIFT 48
211 #endif
212
213 #if 0 /// UNNEEDED by elogind (It can not support BTRFS at all)
214 #ifndef HAVE_LINUX_BTRFS_H
215 struct btrfs_ioctl_vol_args {
216         int64_t fd;
217         char name[BTRFS_PATH_NAME_MAX + 1];
218 };
219
220 struct btrfs_qgroup_limit {
221         __u64 flags;
222         __u64 max_rfer;
223         __u64 max_excl;
224         __u64 rsv_rfer;
225         __u64 rsv_excl;
226 };
227
228 struct btrfs_qgroup_inherit {
229         __u64 flags;
230         __u64 num_qgroups;
231         __u64 num_ref_copies;
232         __u64 num_excl_copies;
233         struct btrfs_qgroup_limit lim;
234         __u64 qgroups[0];
235 };
236
237 struct btrfs_ioctl_qgroup_limit_args {
238         __u64 qgroupid;
239         struct btrfs_qgroup_limit lim;
240 };
241
242 struct btrfs_ioctl_vol_args_v2 {
243         __s64 fd;
244         __u64 transid;
245         __u64 flags;
246         union {
247                 struct {
248                         __u64 size;
249                         struct btrfs_qgroup_inherit *qgroup_inherit;
250                 };
251                 __u64 unused[4];
252         };
253         char name[BTRFS_SUBVOL_NAME_MAX + 1];
254 };
255
256 struct btrfs_ioctl_dev_info_args {
257         uint64_t devid;                         /* in/out */
258         uint8_t uuid[BTRFS_UUID_SIZE];          /* in/out */
259         uint64_t bytes_used;                    /* out */
260         uint64_t total_bytes;                   /* out */
261         uint64_t unused[379];                   /* pad to 4k */
262         char path[BTRFS_DEVICE_PATH_NAME_MAX];  /* out */
263 };
264
265 struct btrfs_ioctl_fs_info_args {
266         uint64_t max_id;                        /* out */
267         uint64_t num_devices;                   /* out */
268         uint8_t fsid[BTRFS_FSID_SIZE];          /* out */
269         uint64_t reserved[124];                 /* pad to 1k */
270 };
271
272 struct btrfs_ioctl_ino_lookup_args {
273         __u64 treeid;
274         __u64 objectid;
275         char name[BTRFS_INO_LOOKUP_PATH_MAX];
276 };
277
278 struct btrfs_ioctl_search_key {
279         /* which root are we searching.  0 is the tree of tree roots */
280         __u64 tree_id;
281
282         /* keys returned will be >= min and <= max */
283         __u64 min_objectid;
284         __u64 max_objectid;
285
286         /* keys returned will be >= min and <= max */
287         __u64 min_offset;
288         __u64 max_offset;
289
290         /* max and min transids to search for */
291         __u64 min_transid;
292         __u64 max_transid;
293
294         /* keys returned will be >= min and <= max */
295         __u32 min_type;
296         __u32 max_type;
297
298         /*
299          * how many items did userland ask for, and how many are we
300          * returning
301          */
302         __u32 nr_items;
303
304         /* align to 64 bits */
305         __u32 unused;
306
307         /* some extra for later */
308         __u64 unused1;
309         __u64 unused2;
310         __u64 unused3;
311         __u64 unused4;
312 };
313
314 struct btrfs_ioctl_search_header {
315         __u64 transid;
316         __u64 objectid;
317         __u64 offset;
318         __u32 type;
319         __u32 len;
320 };
321
322
323 struct btrfs_ioctl_search_args {
324         struct btrfs_ioctl_search_key key;
325         char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
326 };
327
328 struct btrfs_ioctl_clone_range_args {
329         __s64 src_fd;
330         __u64 src_offset, src_length;
331         __u64 dest_offset;
332 };
333
334 #define BTRFS_QUOTA_CTL_ENABLE  1
335 #define BTRFS_QUOTA_CTL_DISABLE 2
336 #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
337 struct btrfs_ioctl_quota_ctl_args {
338         __u64 cmd;
339         __u64 status;
340 };
341 #endif
342
343 #ifndef BTRFS_IOC_DEFRAG
344 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
345                                  struct btrfs_ioctl_vol_args)
346 #endif
347
348 #ifndef BTRFS_IOC_RESIZE
349 #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
350                                  struct btrfs_ioctl_vol_args)
351 #endif
352
353 #ifndef BTRFS_IOC_CLONE
354 #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
355 #endif
356
357 #ifndef BTRFS_IOC_CLONE_RANGE
358 #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
359                                  struct btrfs_ioctl_clone_range_args)
360 #endif
361
362 #ifndef BTRFS_IOC_SUBVOL_CREATE
363 #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
364                                  struct btrfs_ioctl_vol_args)
365 #endif
366
367 #ifndef BTRFS_IOC_SNAP_DESTROY
368 #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
369                                  struct btrfs_ioctl_vol_args)
370 #endif
371
372 #ifndef BTRFS_IOC_TREE_SEARCH
373 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
374                                  struct btrfs_ioctl_search_args)
375 #endif
376
377 #ifndef BTRFS_IOC_INO_LOOKUP
378 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
379                                  struct btrfs_ioctl_ino_lookup_args)
380 #endif
381
382 #ifndef BTRFS_IOC_SNAP_CREATE_V2
383 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
384                                  struct btrfs_ioctl_vol_args_v2)
385 #endif
386
387 #ifndef BTRFS_IOC_SUBVOL_GETFLAGS
388 #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
389 #endif
390
391 #ifndef BTRFS_IOC_SUBVOL_SETFLAGS
392 #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
393 #endif
394
395 #ifndef BTRFS_IOC_DEV_INFO
396 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
397                                  struct btrfs_ioctl_dev_info_args)
398 #endif
399
400 #ifndef BTRFS_IOC_FS_INFO
401 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
402                                  struct btrfs_ioctl_fs_info_args)
403 #endif
404
405 #ifndef BTRFS_IOC_DEVICES_READY
406 #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
407                                  struct btrfs_ioctl_vol_args)
408 #endif
409
410 #ifndef BTRFS_IOC_QUOTA_CTL
411 #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
412                                struct btrfs_ioctl_quota_ctl_args)
413 #endif
414
415 #ifndef BTRFS_IOC_QGROUP_LIMIT
416 #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
417                                struct btrfs_ioctl_qgroup_limit_args)
418 #endif
419
420 #ifndef BTRFS_IOC_QUOTA_RESCAN_WAIT
421 #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
422 #endif
423
424 #ifndef BTRFS_FIRST_FREE_OBJECTID
425 #define BTRFS_FIRST_FREE_OBJECTID 256
426 #endif
427
428 #ifndef BTRFS_LAST_FREE_OBJECTID
429 #define BTRFS_LAST_FREE_OBJECTID -256ULL
430 #endif
431
432 #ifndef BTRFS_ROOT_TREE_OBJECTID
433 #define BTRFS_ROOT_TREE_OBJECTID 1
434 #endif
435
436 #ifndef BTRFS_QUOTA_TREE_OBJECTID
437 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL
438 #endif
439
440 #ifndef BTRFS_ROOT_ITEM_KEY
441 #define BTRFS_ROOT_ITEM_KEY 132
442 #endif
443
444 #ifndef BTRFS_QGROUP_STATUS_KEY
445 #define BTRFS_QGROUP_STATUS_KEY 240
446 #endif
447
448 #ifndef BTRFS_QGROUP_INFO_KEY
449 #define BTRFS_QGROUP_INFO_KEY 242
450 #endif
451
452 #ifndef BTRFS_QGROUP_LIMIT_KEY
453 #define BTRFS_QGROUP_LIMIT_KEY 244
454 #endif
455
456 #ifndef BTRFS_QGROUP_RELATION_KEY
457 #define BTRFS_QGROUP_RELATION_KEY 246
458 #endif
459
460 #ifndef BTRFS_ROOT_BACKREF_KEY
461 #define BTRFS_ROOT_BACKREF_KEY 144
462 #endif
463
464 #ifndef BTRFS_SUPER_MAGIC
465 #define BTRFS_SUPER_MAGIC 0x9123683E
466 #endif
467
468 #endif // 0
469 #ifndef CGROUP_SUPER_MAGIC
470 #define CGROUP_SUPER_MAGIC 0x27e0eb
471 #endif
472
473 #ifndef CGROUP2_SUPER_MAGIC
474 #define CGROUP2_SUPER_MAGIC 0x63677270
475 #endif
476
477 #ifndef CLONE_NEWCGROUP
478 #define CLONE_NEWCGROUP 0x02000000
479 #endif
480
481 #ifndef TMPFS_MAGIC
482 #define TMPFS_MAGIC 0x01021994
483 #endif
484
485 #ifndef MQUEUE_MAGIC
486 #define MQUEUE_MAGIC 0x19800202
487 #endif
488
489 #ifndef SECURITYFS_MAGIC
490 #define SECURITYFS_MAGIC 0x73636673
491 #endif
492
493 #ifndef TRACEFS_MAGIC
494 #define TRACEFS_MAGIC 0x74726163
495 #endif
496
497 #ifndef BPF_FS_MAGIC
498 #define BPF_FS_MAGIC 0xcafe4a11
499 #endif
500
501 #ifndef MS_MOVE
502 #define MS_MOVE 8192
503 #endif
504
505 #ifndef MS_REC
506 #define MS_REC 16384
507 #endif
508
509 #ifndef MS_PRIVATE
510 #define MS_PRIVATE      (1<<18)
511 #endif
512
513 #ifndef MS_REC
514 #define MS_REC          (1<<19)
515 #endif
516
517 #ifndef MS_SHARED
518 #define MS_SHARED       (1<<20)
519 #endif
520
521 #ifndef MS_RELATIME
522 #define MS_RELATIME     (1<<21)
523 #endif
524
525 #ifndef MS_KERNMOUNT
526 #define MS_KERNMOUNT    (1<<22)
527 #endif
528
529 #ifndef MS_I_VERSION
530 #define MS_I_VERSION    (1<<23)
531 #endif
532
533 #ifndef MS_STRICTATIME
534 #define MS_STRICTATIME  (1<<24)
535 #endif
536
537 #ifndef MS_LAZYTIME
538 #define MS_LAZYTIME     (1<<25)
539 #endif
540
541 #ifndef SCM_SECURITY
542 #define SCM_SECURITY 0x03
543 #endif
544
545 #ifndef PR_SET_NO_NEW_PRIVS
546 #define PR_SET_NO_NEW_PRIVS 38
547 #endif
548
549 #ifndef PR_SET_CHILD_SUBREAPER
550 #define PR_SET_CHILD_SUBREAPER 36
551 #endif
552
553 #ifndef MAX_HANDLE_SZ
554 #define MAX_HANDLE_SZ 128
555 #endif
556
557 #ifndef HAVE_SECURE_GETENV
558 #  ifdef HAVE___SECURE_GETENV
559 #    define secure_getenv __secure_getenv
560 #  else
561 #    error "neither secure_getenv nor __secure_getenv are available"
562 #  endif
563 #endif
564
565 #ifndef CIFS_MAGIC_NUMBER
566 #  define CIFS_MAGIC_NUMBER 0xFF534D42
567 #endif
568
569 #ifndef TFD_TIMER_CANCEL_ON_SET
570 #  define TFD_TIMER_CANCEL_ON_SET (1 << 1)
571 #endif
572
573 #ifndef SO_REUSEPORT
574 #  define SO_REUSEPORT 15
575 #endif
576
577 #ifndef EVIOCREVOKE
578 #  define EVIOCREVOKE _IOW('E', 0x91, int)
579 #endif
580
581 #ifndef DRM_IOCTL_SET_MASTER
582 #  define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
583 #endif
584
585 #ifndef DRM_IOCTL_DROP_MASTER
586 #  define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
587 #endif
588
589 /* The precise definition of __O_TMPFILE is arch specific; use the
590  * values defined by the kernel (note: some are hexa, some are octal,
591  * duplicated as-is from the kernel definitions):
592  * - alpha, parisc, sparc: each has a specific value;
593  * - others: they use the "generic" value.
594  */
595
596 #ifndef __O_TMPFILE
597 #if defined(__alpha__)
598 #define __O_TMPFILE     0100000000
599 #elif defined(__parisc__) || defined(__hppa__)
600 #define __O_TMPFILE     0400000000
601 #elif defined(__sparc__) || defined(__sparc64__)
602 #define __O_TMPFILE     0x2000000
603 #else
604 #define __O_TMPFILE     020000000
605 #endif
606
607 /* a horrid kludge trying to make sure that this will fail on old kernels */
608 #ifndef O_TMPFILE
609 #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
610 #endif
611
612 #endif
613
614 #if !HAVE_DECL_LO_FLAGS_PARTSCAN
615 #define LO_FLAGS_PARTSCAN 8
616 #endif
617
618 #ifndef LOOP_CTL_REMOVE
619 #define LOOP_CTL_REMOVE 0x4C81
620 #endif
621
622 #ifndef LOOP_CTL_GET_FREE
623 #define LOOP_CTL_GET_FREE 0x4C82
624 #endif
625
626 #if !HAVE_DECL_IFLA_INET6_ADDR_GEN_MODE
627 #define IFLA_INET6_UNSPEC 0
628 #define IFLA_INET6_FLAGS 1
629 #define IFLA_INET6_CONF 2
630 #define IFLA_INET6_STATS 3
631 #define IFLA_INET6_MCAST 4
632 #define IFLA_INET6_CACHEINFO 5
633 #define IFLA_INET6_ICMP6STATS 6
634 #define IFLA_INET6_TOKEN 7
635 #define IFLA_INET6_ADDR_GEN_MODE 8
636 #define __IFLA_INET6_MAX 9
637
638 #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
639
640 #define IN6_ADDR_GEN_MODE_EUI64 0
641 #define IN6_ADDR_GEN_MODE_NONE 1
642 #endif
643
644 #if !HAVE_DECL_IN6_ADDR_GEN_MODE_STABLE_PRIVACY
645 #define IN6_ADDR_GEN_MODE_STABLE_PRIVACY 2
646 #endif
647
648 #if !HAVE_DECL_IFLA_MACVLAN_FLAGS
649 #define IFLA_MACVLAN_UNSPEC 0
650 #define IFLA_MACVLAN_MODE 1
651 #define IFLA_MACVLAN_FLAGS 2
652 #define __IFLA_MACVLAN_MAX 3
653
654 #define IFLA_MACVLAN_MAX (__IFLA_MACVLAN_MAX - 1)
655 #endif
656
657 #if !HAVE_DECL_IFLA_IPVLAN_MODE
658 #define IFLA_IPVLAN_UNSPEC 0
659 #define IFLA_IPVLAN_MODE 1
660 #define __IFLA_IPVLAN_MAX 2
661
662 #define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1)
663
664 #define IPVLAN_MODE_L2 0
665 #define IPVLAN_MODE_L3 1
666 #define IPVLAN_MAX 2
667 #endif
668
669 #if !HAVE_DECL_IFLA_VTI_REMOTE
670 #define IFLA_VTI_UNSPEC 0
671 #define IFLA_VTI_LINK 1
672 #define IFLA_VTI_IKEY 2
673 #define IFLA_VTI_OKEY 3
674 #define IFLA_VTI_LOCAL 4
675 #define IFLA_VTI_REMOTE 5
676 #define __IFLA_VTI_MAX 6
677
678 #define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1)
679 #endif
680
681 #if !HAVE_DECL_IFLA_PHYS_PORT_ID
682 #define IFLA_EXT_MASK 29
683 #undef IFLA_PROMISCUITY
684 #define IFLA_PROMISCUITY 30
685 #define IFLA_NUM_TX_QUEUES 31
686 #define IFLA_NUM_RX_QUEUES 32
687 #define IFLA_CARRIER 33
688 #define IFLA_PHYS_PORT_ID 34
689 #define __IFLA_MAX 35
690
691 #define IFLA_MAX (__IFLA_MAX - 1)
692 #endif
693
694 #if !HAVE_DECL_IFLA_BOND_AD_INFO
695 #define IFLA_BOND_UNSPEC 0
696 #define IFLA_BOND_MODE 1
697 #define IFLA_BOND_ACTIVE_SLAVE 2
698 #define IFLA_BOND_MIIMON 3
699 #define IFLA_BOND_UPDELAY 4
700 #define IFLA_BOND_DOWNDELAY 5
701 #define IFLA_BOND_USE_CARRIER 6
702 #define IFLA_BOND_ARP_INTERVAL 7
703 #define IFLA_BOND_ARP_IP_TARGET 8
704 #define IFLA_BOND_ARP_VALIDATE 9
705 #define IFLA_BOND_ARP_ALL_TARGETS 10
706 #define IFLA_BOND_PRIMARY 11
707 #define IFLA_BOND_PRIMARY_RESELECT 12
708 #define IFLA_BOND_FAIL_OVER_MAC 13
709 #define IFLA_BOND_XMIT_HASH_POLICY 14
710 #define IFLA_BOND_RESEND_IGMP 15
711 #define IFLA_BOND_NUM_PEER_NOTIF 16
712 #define IFLA_BOND_ALL_SLAVES_ACTIVE 17
713 #define IFLA_BOND_MIN_LINKS 18
714 #define IFLA_BOND_LP_INTERVAL 19
715 #define IFLA_BOND_PACKETS_PER_SLAVE 20
716 #define IFLA_BOND_AD_LACP_RATE 21
717 #define IFLA_BOND_AD_SELECT 22
718 #define IFLA_BOND_AD_INFO 23
719 #define __IFLA_BOND_MAX 24
720
721 #define IFLA_BOND_MAX   (__IFLA_BOND_MAX - 1)
722 #endif
723
724 #if !HAVE_DECL_IFLA_VLAN_PROTOCOL
725 #define IFLA_VLAN_UNSPEC 0
726 #define IFLA_VLAN_ID 1
727 #define IFLA_VLAN_FLAGS 2
728 #define IFLA_VLAN_EGRESS_QOS 3
729 #define IFLA_VLAN_INGRESS_QOS 4
730 #define IFLA_VLAN_PROTOCOL 5
731 #define __IFLA_VLAN_MAX 6
732
733 #define IFLA_VLAN_MAX   (__IFLA_VLAN_MAX - 1)
734 #endif
735
736 #if !HAVE_DECL_IFLA_VXLAN_GPE
737 #define IFLA_VXLAN_UNSPEC 0
738 #define IFLA_VXLAN_ID 1
739 #define IFLA_VXLAN_GROUP 2
740 #define IFLA_VXLAN_LINK 3
741 #define IFLA_VXLAN_LOCAL 4
742 #define IFLA_VXLAN_TTL 5
743 #define IFLA_VXLAN_TOS 6
744 #define IFLA_VXLAN_LEARNING 7
745 #define IFLA_VXLAN_AGEING 8
746 #define IFLA_VXLAN_LIMIT 9
747 #define IFLA_VXLAN_PORT_RANGE 10
748 #define IFLA_VXLAN_PROXY 11
749 #define IFLA_VXLAN_RSC 12
750 #define IFLA_VXLAN_L2MISS 13
751 #define IFLA_VXLAN_L3MISS 14
752 #define IFLA_VXLAN_PORT 15
753 #define IFLA_VXLAN_GROUP6 16
754 #define IFLA_VXLAN_LOCAL6 17
755 #define IFLA_VXLAN_UDP_CSUM 18
756 #define IFLA_VXLAN_UDP_ZERO_CSUM6_TX 19
757 #define IFLA_VXLAN_UDP_ZERO_CSUM6_RX 20
758 #define IFLA_VXLAN_REMCSUM_TX 21
759 #define IFLA_VXLAN_REMCSUM_RX 22
760 #define IFLA_VXLAN_GBP 23
761 #define IFLA_VXLAN_REMCSUM_NOPARTIAL 24
762 #define IFLA_VXLAN_COLLECT_METADATA 25
763 #define IFLA_VXLAN_LABEL 26
764 #define IFLA_VXLAN_GPE 27
765
766 #define __IFLA_VXLAN_MAX 28
767
768 #define IFLA_VXLAN_MAX  (__IFLA_VXLAN_MAX - 1)
769 #endif
770
771 #if !HAVE_DECL_IFLA_IPTUN_ENCAP_DPORT
772 #define IFLA_IPTUN_UNSPEC 0
773 #define IFLA_IPTUN_LINK 1
774 #define IFLA_IPTUN_LOCAL 2
775 #define IFLA_IPTUN_REMOTE 3
776 #define IFLA_IPTUN_TTL 4
777 #define IFLA_IPTUN_TOS 5
778 #define IFLA_IPTUN_ENCAP_LIMIT 6
779 #define IFLA_IPTUN_FLOWINFO 7
780 #define IFLA_IPTUN_FLAGS 8
781 #define IFLA_IPTUN_PROTO 9
782 #define IFLA_IPTUN_PMTUDISC 10
783 #define IFLA_IPTUN_6RD_PREFIX 11
784 #define IFLA_IPTUN_6RD_RELAY_PREFIX 12
785 #define IFLA_IPTUN_6RD_PREFIXLEN 13
786 #define IFLA_IPTUN_6RD_RELAY_PREFIXLEN 14
787 #define IFLA_IPTUN_ENCAP_TYPE 15
788 #define IFLA_IPTUN_ENCAP_FLAGS 16
789 #define IFLA_IPTUN_ENCAP_SPORT 17
790 #define IFLA_IPTUN_ENCAP_DPORT 18
791
792 #define __IFLA_IPTUN_MAX 19
793
794 #define IFLA_IPTUN_MAX  (__IFLA_IPTUN_MAX - 1)
795 #endif
796
797 #if !HAVE_DECL_IFLA_GRE_ENCAP_DPORT
798 #define IFLA_GRE_UNSPEC 0
799 #define IFLA_GRE_LINK 1
800 #define IFLA_GRE_IFLAGS 2
801 #define IFLA_GRE_OFLAGS 3
802 #define IFLA_GRE_IKEY 4
803 #define IFLA_GRE_OKEY 5
804 #define IFLA_GRE_LOCAL 6
805 #define IFLA_GRE_REMOTE 7
806 #define IFLA_GRE_TTL 8
807 #define IFLA_GRE_TOS 9
808 #define IFLA_GRE_PMTUDISC 10
809 #define IFLA_GRE_ENCAP_LIMIT 11
810 #define IFLA_GRE_FLOWINFO 12
811 #define IFLA_GRE_FLAGS 13
812 #define IFLA_GRE_ENCAP_TYPE 14
813 #define IFLA_GRE_ENCAP_FLAGS 15
814 #define IFLA_GRE_ENCAP_SPORT 16
815 #define IFLA_GRE_ENCAP_DPORT 17
816
817 #define __IFLA_GRE_MAX 18
818
819 #define IFLA_GRE_MAX  (__IFLA_GRE_MAX - 1)
820 #endif
821
822 #if !HAVE_DECL_IFLA_BRIDGE_VLAN_INFO
823 #define IFLA_BRIDGE_FLAGS 0
824 #define IFLA_BRIDGE_MODE 1
825 #define IFLA_BRIDGE_VLAN_INFO 2
826 #define __IFLA_BRIDGE_MAX 3
827
828 #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
829 #endif
830
831 #ifndef BRIDGE_VLAN_INFO_RANGE_BEGIN
832 #define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */
833 #endif
834
835 #ifndef BRIDGE_VLAN_INFO_RANGE_END
836 #define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */
837 #endif
838
839 #if !HAVE_DECL_IFLA_BR_VLAN_DEFAULT_PVID
840 #define IFLA_BR_UNSPEC 0
841 #define IFLA_BR_FORWARD_DELAY 1
842 #define IFLA_BR_HELLO_TIME 2
843 #define IFLA_BR_MAX_AGE 3
844 #define IFLA_BR_AGEING_TIME 4
845 #define IFLA_BR_STP_STATE 5
846 #define IFLA_BR_PRIORITY 6
847 #define IFLA_BR_VLAN_FILTERING 7
848 #define IFLA_BR_VLAN_PROTOCOL 8
849 #define IFLA_BR_GROUP_FWD_MASK 9
850 #define IFLA_BR_ROOT_ID 10
851 #define IFLA_BR_BRIDGE_ID 11
852 #define IFLA_BR_ROOT_PORT 12
853 #define IFLA_BR_ROOT_PATH_COST 13
854 #define IFLA_BR_TOPOLOGY_CHANGE 14
855 #define IFLA_BR_TOPOLOGY_CHANGE_DETECTED 15
856 #define IFLA_BR_HELLO_TIMER 16
857 #define IFLA_BR_TCN_TIMER 17
858 #define IFLA_BR_TOPOLOGY_CHANGE_TIMER 18
859 #define IFLA_BR_GC_TIMER 19
860 #define IFLA_BR_GROUP_ADDR 20
861 #define IFLA_BR_FDB_FLUSH 21
862 #define IFLA_BR_MCAST_ROUTER 22
863 #define IFLA_BR_MCAST_SNOOPING 23
864 #define IFLA_BR_MCAST_QUERY_USE_IFADDR 24
865 #define IFLA_BR_MCAST_QUERIER 25
866 #define IFLA_BR_MCAST_HASH_ELASTICITY 26
867 #define IFLA_BR_MCAST_HASH_MAX 27
868 #define IFLA_BR_MCAST_LAST_MEMBER_CNT 28
869 #define IFLA_BR_MCAST_STARTUP_QUERY_CNT 29
870 #define IFLA_BR_MCAST_LAST_MEMBER_INTVL 30
871 #define IFLA_BR_MCAST_MEMBERSHIP_INTVL 31
872 #define IFLA_BR_MCAST_QUERIER_INTVL 32
873 #define IFLA_BR_MCAST_QUERY_INTVL 33
874 #define IFLA_BR_MCAST_QUERY_RESPONSE_INTVL 34
875 #define IFLA_BR_MCAST_STARTUP_QUERY_INTVL 35
876 #define IFLA_BR_NF_CALL_IPTABLES 36
877 #define IFLA_BR_NF_CALL_IP6TABLES 37
878 #define IFLA_BR_NF_CALL_ARPTABLES 38
879 #define IFLA_BR_VLAN_DEFAULT_PVID 39
880 #define __IFLA_BR_MAX 40
881
882 #define IFLA_BR_MAX (__IFLA_BR_MAX - 1)
883 #endif
884
885 #if !HAVE_DECL_IFLA_BRPORT_LEARNING_SYNC
886 #define IFLA_BRPORT_UNSPEC 0
887 #define IFLA_BRPORT_STATE 1
888 #define IFLA_BRPORT_PRIORITY 2
889 #define IFLA_BRPORT_COST 3
890 #define IFLA_BRPORT_MODE 4
891 #define IFLA_BRPORT_GUARD 5
892 #define IFLA_BRPORT_PROTECT 6
893 #define IFLA_BRPORT_FAST_LEAVE 7
894 #define IFLA_BRPORT_LEARNING 8
895 #define IFLA_BRPORT_UNICAST_FLOOD 9
896 #define IFLA_BRPORT_LEARNING_SYNC 11
897 #define __IFLA_BRPORT_MAX 12
898
899 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
900 #endif
901
902 #if !HAVE_DECL_IFLA_BRPORT_PROXYARP
903 #define IFLA_BRPORT_PROXYARP 10
904 #endif
905
906 #if !HAVE_DECL_IFLA_VRF_TABLE
907 #define IFLA_VRF_TABLE 1
908 #endif
909
910 #if !HAVE_DECL_NDA_IFINDEX
911 #define NDA_UNSPEC 0
912 #define NDA_DST 1
913 #define NDA_LLADDR 2
914 #define NDA_CACHEINFO 3
915 #define NDA_PROBES 4
916 #define NDA_VLAN 5
917 #define NDA_PORT 6
918 #define NDA_VNI 7
919 #define NDA_IFINDEX 8
920 #define __NDA_MAX 9
921
922 #define NDA_MAX (__NDA_MAX - 1)
923 #endif
924
925 #ifndef RTA_PREF
926 #define RTA_PREF 20
927 #endif
928
929 #ifndef IPV6_UNICAST_IF
930 #define IPV6_UNICAST_IF 76
931 #endif
932
933 #ifndef IPV6_MIN_MTU
934 #define IPV6_MIN_MTU 1280
935 #endif
936
937 #ifndef IFF_MULTI_QUEUE
938 #define IFF_MULTI_QUEUE 0x100
939 #endif
940
941 #ifndef IFF_LOWER_UP
942 #define IFF_LOWER_UP 0x10000
943 #endif
944
945 #ifndef IFF_DORMANT
946 #define IFF_DORMANT 0x20000
947 #endif
948
949 #ifndef BOND_XMIT_POLICY_ENCAP23
950 #define BOND_XMIT_POLICY_ENCAP23 3
951 #endif
952
953 #ifndef BOND_XMIT_POLICY_ENCAP34
954 #define BOND_XMIT_POLICY_ENCAP34 4
955 #endif
956
957 #ifndef NET_ADDR_RANDOM
958 #  define NET_ADDR_RANDOM 1
959 #endif
960
961 #ifndef NET_NAME_UNKNOWN
962 #  define NET_NAME_UNKNOWN 0
963 #endif
964
965 #ifndef NET_NAME_ENUM
966 #  define NET_NAME_ENUM 1
967 #endif
968
969 #ifndef NET_NAME_PREDICTABLE
970 #  define NET_NAME_PREDICTABLE 2
971 #endif
972
973 #ifndef NET_NAME_USER
974 #  define NET_NAME_USER 3
975 #endif
976
977 #ifndef NET_NAME_RENAMED
978 #  define NET_NAME_RENAMED 4
979 #endif
980
981 #ifndef BPF_XOR
982 #  define BPF_XOR 0xa0
983 #endif
984
985 /* Note that LOOPBACK_IFINDEX is currently not exported by the
986  * kernel/glibc, but hardcoded internally by the kernel.  However, as
987  * it is exported to userspace indirectly via rtnetlink and the
988  * ioctls, and made use of widely we define it here too, in a way that
989  * is compatible with the kernel's internal definition. */
990 #ifndef LOOPBACK_IFINDEX
991 #define LOOPBACK_IFINDEX 1
992 #endif
993
994 #if !HAVE_DECL_IFA_FLAGS
995 #define IFA_FLAGS 8
996 #endif
997
998 #ifndef IFA_F_MANAGETEMPADDR
999 #define IFA_F_MANAGETEMPADDR 0x100
1000 #endif
1001
1002 #ifndef IFA_F_NOPREFIXROUTE
1003 #define IFA_F_NOPREFIXROUTE 0x200
1004 #endif
1005
1006 #ifndef MAX_AUDIT_MESSAGE_LENGTH
1007 #define MAX_AUDIT_MESSAGE_LENGTH 8970
1008 #endif
1009
1010 #ifndef AUDIT_NLGRP_MAX
1011 #define AUDIT_NLGRP_READLOG 1
1012 #endif
1013
1014 #ifndef CAP_MAC_OVERRIDE
1015 #define CAP_MAC_OVERRIDE 32
1016 #endif
1017
1018 #ifndef CAP_MAC_ADMIN
1019 #define CAP_MAC_ADMIN 33
1020 #endif
1021
1022 #ifndef CAP_SYSLOG
1023 #define CAP_SYSLOG 34
1024 #endif
1025
1026 #ifndef CAP_WAKE_ALARM
1027 #define CAP_WAKE_ALARM 35
1028 #endif
1029
1030 #ifndef CAP_BLOCK_SUSPEND
1031 #define CAP_BLOCK_SUSPEND 36
1032 #endif
1033
1034 #ifndef CAP_AUDIT_READ
1035 #define CAP_AUDIT_READ 37
1036 #endif
1037
1038 #if 0 /// UNNEEDED by elogind
1039 #ifndef RENAME_NOREPLACE
1040 #define RENAME_NOREPLACE (1 << 0)
1041 #endif
1042
1043 #ifndef KCMP_FILE
1044 #define KCMP_FILE 0
1045 #endif
1046
1047 #ifndef INPUT_PROP_POINTING_STICK
1048 #define INPUT_PROP_POINTING_STICK 0x05
1049 #endif
1050
1051 #ifndef INPUT_PROP_ACCELEROMETER
1052 #define INPUT_PROP_ACCELEROMETER  0x06
1053 #endif
1054 #endif // 0
1055
1056 #ifndef HAVE_KEY_SERIAL_T
1057 typedef int32_t key_serial_t;
1058 #endif
1059
1060 #ifndef KEYCTL_JOIN_SESSION_KEYRING
1061 #define KEYCTL_JOIN_SESSION_KEYRING 1
1062 #endif
1063
1064 #ifndef KEYCTL_CHOWN
1065 #define KEYCTL_CHOWN 4
1066 #endif
1067
1068 #ifndef KEYCTL_SETPERM
1069 #define KEYCTL_SETPERM 5
1070 #endif
1071
1072 #ifndef KEYCTL_DESCRIBE
1073 #define KEYCTL_DESCRIBE 6
1074 #endif
1075
1076 #ifndef KEYCTL_READ
1077 #define KEYCTL_READ 11
1078 #endif
1079
1080 #ifndef KEYCTL_SET_TIMEOUT
1081 #define KEYCTL_SET_TIMEOUT 15
1082 #endif
1083
1084 #ifndef KEY_POS_VIEW
1085 #define KEY_POS_VIEW    0x01000000
1086 #define KEY_POS_READ    0x02000000
1087 #define KEY_POS_WRITE   0x04000000
1088 #define KEY_POS_SEARCH  0x08000000
1089 #define KEY_POS_LINK    0x10000000
1090 #define KEY_POS_SETATTR 0x20000000
1091
1092 #define KEY_USR_VIEW    0x00010000
1093 #define KEY_USR_READ    0x00020000
1094 #define KEY_USR_WRITE   0x00040000
1095 #define KEY_USR_SEARCH  0x00080000
1096 #define KEY_USR_LINK    0x00100000
1097 #define KEY_USR_SETATTR 0x00200000
1098
1099 #define KEY_GRP_VIEW    0x00000100
1100 #define KEY_GRP_READ    0x00000200
1101 #define KEY_GRP_WRITE   0x00000400
1102 #define KEY_GRP_SEARCH  0x00000800
1103 #define KEY_GRP_LINK    0x00001000
1104 #define KEY_GRP_SETATTR 0x00002000
1105
1106 #define KEY_OTH_VIEW    0x00000001
1107 #define KEY_OTH_READ    0x00000002
1108 #define KEY_OTH_WRITE   0x00000004
1109 #define KEY_OTH_SEARCH  0x00000008
1110 #define KEY_OTH_LINK    0x00000010
1111 #define KEY_OTH_SETATTR 0x00000020
1112 #endif
1113
1114 #ifndef KEY_SPEC_USER_KEYRING
1115 #define KEY_SPEC_USER_KEYRING -4
1116 #endif
1117
1118 #ifndef KEY_SPEC_SESSION_KEYRING
1119 #define KEY_SPEC_SESSION_KEYRING -3
1120 #endif
1121
1122 #ifndef PR_CAP_AMBIENT
1123 #define PR_CAP_AMBIENT 47
1124 #endif
1125
1126 #ifndef PR_CAP_AMBIENT_IS_SET
1127 #define PR_CAP_AMBIENT_IS_SET 1
1128 #endif
1129
1130 #ifndef PR_CAP_AMBIENT_RAISE
1131 #define PR_CAP_AMBIENT_RAISE 2
1132 #endif
1133
1134 #ifndef PR_CAP_AMBIENT_CLEAR_ALL
1135 #define PR_CAP_AMBIENT_CLEAR_ALL 4
1136 #endif
1137
1138 /* The following two defines are actually available in the kernel headers for longer, but we define them here anyway,
1139  * since that makes it easier to use them in conjunction with the glibc net/if.h header which conflicts with
1140  * linux/if.h. */
1141 #ifndef IF_OPER_UNKNOWN
1142 #define IF_OPER_UNKNOWN 0
1143 #endif
1144
1145 #ifndef IF_OPER_UP
1146 #define IF_OPER_UP 6
1147
1148 #ifndef HAVE_CHAR32_T
1149 #define char32_t uint32_t
1150 #endif
1151
1152 #ifndef HAVE_CHAR16_T
1153 #define char16_t uint16_t
1154 #endif
1155
1156 #ifndef ETHERTYPE_LLDP
1157 #define ETHERTYPE_LLDP 0x88cc
1158 #endif
1159
1160 #ifndef IFA_F_MCAUTOJOIN
1161 #define IFA_F_MCAUTOJOIN 0x400
1162 #endif
1163
1164 #if 0 /// UNNEEDED by elogind
1165 #ifndef HAVE_STRUCT_ETHTOOL_LINK_SETTINGS
1166
1167 #define ETHTOOL_GLINKSETTINGS   0x0000004c /* Get ethtool_link_settings */
1168 #define ETHTOOL_SLINKSETTINGS   0x0000004d /* Set ethtool_link_settings */
1169
1170 struct ethtool_link_settings {
1171         __u32   cmd;
1172         __u32   speed;
1173         __u8    duplex;
1174         __u8    port;
1175         __u8    phy_address;
1176         __u8    autoneg;
1177         __u8    mdio_support;
1178         __u8    eth_tp_mdix;
1179         __u8    eth_tp_mdix_ctrl;
1180         __s8    link_mode_masks_nwords;
1181         __u32   reserved[8];
1182         __u32   link_mode_masks[0];
1183         /* layout of link_mode_masks fields:
1184          * __u32 map_supported[link_mode_masks_nwords];
1185          * __u32 map_advertising[link_mode_masks_nwords];
1186          * __u32 map_lp_advertising[link_mode_masks_nwords];
1187          */
1188 };
1189
1190 #endif
1191 #endif // 0
1192
1193 #endif
1194
1195 #ifndef SOL_ALG
1196 #define SOL_ALG 279
1197 #endif
1198
1199 #ifndef AF_VSOCK
1200 #define AF_VSOCK 40
1201 #endif
1202
1203 #include "missing_syscall.h"