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