libc/unix/linux_like/linux/
mod.rs

1//! Linux-specific definitions for linux-like values
2use crate::prelude::*;
3use crate::{
4    sock_filter,
5    _IO,
6    _IOR,
7    _IOW,
8    _IOWR,
9};
10
11pub type dev_t = u64;
12pub type socklen_t = u32;
13pub type mode_t = u32;
14pub type ino64_t = u64;
15pub type off64_t = i64;
16pub type blkcnt64_t = i64;
17pub type rlim64_t = u64;
18pub type mqd_t = c_int;
19pub type nfds_t = c_ulong;
20pub type nl_item = c_int;
21pub type idtype_t = c_uint;
22pub type loff_t = c_longlong;
23pub type pthread_key_t = c_uint;
24pub type pthread_once_t = c_int;
25pub type pthread_spinlock_t = c_int;
26pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t;
27pub type __kernel_clockid_t = c_int;
28
29pub type __u8 = c_uchar;
30pub type __u16 = c_ushort;
31pub type __s16 = c_short;
32pub type __u32 = c_uint;
33pub type __s32 = c_int;
34
35// linux/sctp.h
36pub type sctp_assoc_t = __s32;
37
38pub type eventfd_t = u64;
39
40e! {
41    #[repr(u32)]
42    pub enum tpacket_versions {
43        TPACKET_V1,
44        TPACKET_V2,
45        TPACKET_V3,
46    }
47}
48
49c_enum! {
50    pub enum pid_type {
51        pub PIDTYPE_PID,
52        pub PIDTYPE_TGID,
53        pub PIDTYPE_PGID,
54        pub PIDTYPE_SID,
55        pub PIDTYPE_MAX,
56    }
57}
58
59s! {
60    pub struct dqblk {
61        pub dqb_bhardlimit: u64,
62        pub dqb_bsoftlimit: u64,
63        pub dqb_curspace: u64,
64        pub dqb_ihardlimit: u64,
65        pub dqb_isoftlimit: u64,
66        pub dqb_curinodes: u64,
67        pub dqb_btime: u64,
68        pub dqb_itime: u64,
69        pub dqb_valid: u32,
70    }
71
72    pub struct signalfd_siginfo {
73        pub ssi_signo: u32,
74        pub ssi_errno: i32,
75        pub ssi_code: i32,
76        pub ssi_pid: u32,
77        pub ssi_uid: u32,
78        pub ssi_fd: i32,
79        pub ssi_tid: u32,
80        pub ssi_band: u32,
81        pub ssi_overrun: u32,
82        pub ssi_trapno: u32,
83        pub ssi_status: i32,
84        pub ssi_int: i32,
85        pub ssi_ptr: u64,
86        pub ssi_utime: u64,
87        pub ssi_stime: u64,
88        pub ssi_addr: u64,
89        pub ssi_addr_lsb: u16,
90        _pad2: Padding<u16>,
91        pub ssi_syscall: i32,
92        pub ssi_call_addr: u64,
93        pub ssi_arch: u32,
94        _pad: Padding<[u8; 28]>,
95    }
96
97    pub struct fanout_args {
98        #[cfg(target_endian = "little")]
99        pub id: __u16,
100        pub type_flags: __u16,
101        #[cfg(target_endian = "big")]
102        pub id: __u16,
103        pub max_num_members: __u32,
104    }
105
106    #[deprecated(since = "0.2.70", note = "sockaddr_ll type must be used instead")]
107    pub struct sockaddr_pkt {
108        pub spkt_family: c_ushort,
109        pub spkt_device: [c_uchar; 14],
110        pub spkt_protocol: c_ushort,
111    }
112
113    pub struct tpacket_auxdata {
114        pub tp_status: __u32,
115        pub tp_len: __u32,
116        pub tp_snaplen: __u32,
117        pub tp_mac: __u16,
118        pub tp_net: __u16,
119        pub tp_vlan_tci: __u16,
120        pub tp_vlan_tpid: __u16,
121    }
122
123    pub struct tpacket_hdr {
124        pub tp_status: c_ulong,
125        pub tp_len: c_uint,
126        pub tp_snaplen: c_uint,
127        pub tp_mac: c_ushort,
128        pub tp_net: c_ushort,
129        pub tp_sec: c_uint,
130        pub tp_usec: c_uint,
131    }
132
133    pub struct tpacket_hdr_variant1 {
134        pub tp_rxhash: __u32,
135        pub tp_vlan_tci: __u32,
136        pub tp_vlan_tpid: __u16,
137        pub tp_padding: __u16,
138    }
139
140    pub struct tpacket2_hdr {
141        pub tp_status: __u32,
142        pub tp_len: __u32,
143        pub tp_snaplen: __u32,
144        pub tp_mac: __u16,
145        pub tp_net: __u16,
146        pub tp_sec: __u32,
147        pub tp_nsec: __u32,
148        pub tp_vlan_tci: __u16,
149        pub tp_vlan_tpid: __u16,
150        pub tp_padding: [__u8; 4],
151    }
152
153    pub struct tpacket_req {
154        pub tp_block_size: c_uint,
155        pub tp_block_nr: c_uint,
156        pub tp_frame_size: c_uint,
157        pub tp_frame_nr: c_uint,
158    }
159
160    pub struct tpacket_req3 {
161        pub tp_block_size: c_uint,
162        pub tp_block_nr: c_uint,
163        pub tp_frame_size: c_uint,
164        pub tp_frame_nr: c_uint,
165        pub tp_retire_blk_tov: c_uint,
166        pub tp_sizeof_priv: c_uint,
167        pub tp_feature_req_word: c_uint,
168    }
169
170    #[repr(align(8))]
171    pub struct tpacket_rollover_stats {
172        pub tp_all: crate::__u64,
173        pub tp_huge: crate::__u64,
174        pub tp_failed: crate::__u64,
175    }
176
177    pub struct tpacket_stats {
178        pub tp_packets: c_uint,
179        pub tp_drops: c_uint,
180    }
181
182    pub struct tpacket_stats_v3 {
183        pub tp_packets: c_uint,
184        pub tp_drops: c_uint,
185        pub tp_freeze_q_cnt: c_uint,
186    }
187
188    pub struct tpacket3_hdr {
189        pub tp_next_offset: __u32,
190        pub tp_sec: __u32,
191        pub tp_nsec: __u32,
192        pub tp_snaplen: __u32,
193        pub tp_len: __u32,
194        pub tp_status: __u32,
195        pub tp_mac: __u16,
196        pub tp_net: __u16,
197        pub hv1: crate::tpacket_hdr_variant1,
198        pub tp_padding: [__u8; 8],
199    }
200
201    pub struct tpacket_bd_ts {
202        pub ts_sec: c_uint,
203        pub ts_usec: c_uint,
204    }
205
206    #[repr(align(8))]
207    pub struct tpacket_hdr_v1 {
208        pub block_status: __u32,
209        pub num_pkts: __u32,
210        pub offset_to_first_pkt: __u32,
211        pub blk_len: __u32,
212        pub seq_num: crate::__u64,
213        pub ts_first_pkt: crate::tpacket_bd_ts,
214        pub ts_last_pkt: crate::tpacket_bd_ts,
215    }
216
217    // System V IPC
218    pub struct msginfo {
219        pub msgpool: c_int,
220        pub msgmap: c_int,
221        pub msgmax: c_int,
222        pub msgmnb: c_int,
223        pub msgmni: c_int,
224        pub msgssz: c_int,
225        pub msgtql: c_int,
226        pub msgseg: c_ushort,
227    }
228
229    pub struct input_event {
230        // FIXME(1.0): Change to the commented variant, see https://github.com/rust-lang/libc/pull/4148#discussion_r1857511742
231        #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))]
232        pub time: crate::timeval,
233        // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))]
234        // pub input_event_sec: time_t,
235        // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))]
236        // pub input_event_usec: suseconds_t,
237        // #[cfg(target_arch = "sparc64")]
238        // _pad1: c_int,
239        #[cfg(all(target_pointer_width = "32", linux_time_bits64))]
240        pub input_event_sec: c_ulong,
241
242        #[cfg(all(target_pointer_width = "32", linux_time_bits64))]
243        pub input_event_usec: c_ulong,
244
245        pub type_: __u16,
246        pub code: __u16,
247        pub value: __s32,
248    }
249
250    pub struct input_id {
251        pub bustype: __u16,
252        pub vendor: __u16,
253        pub product: __u16,
254        pub version: __u16,
255    }
256
257    pub struct input_absinfo {
258        pub value: __s32,
259        pub minimum: __s32,
260        pub maximum: __s32,
261        pub fuzz: __s32,
262        pub flat: __s32,
263        pub resolution: __s32,
264    }
265
266    pub struct input_keymap_entry {
267        pub flags: __u8,
268        pub len: __u8,
269        pub index: __u16,
270        pub keycode: __u32,
271        pub scancode: [__u8; 32],
272    }
273
274    pub struct input_mask {
275        pub type_: __u32,
276        pub codes_size: __u32,
277        pub codes_ptr: crate::__u64,
278    }
279
280    pub struct ff_replay {
281        pub length: __u16,
282        pub delay: __u16,
283    }
284
285    pub struct ff_trigger {
286        pub button: __u16,
287        pub interval: __u16,
288    }
289
290    pub struct ff_envelope {
291        pub attack_length: __u16,
292        pub attack_level: __u16,
293        pub fade_length: __u16,
294        pub fade_level: __u16,
295    }
296
297    pub struct ff_constant_effect {
298        pub level: __s16,
299        pub envelope: ff_envelope,
300    }
301
302    pub struct ff_ramp_effect {
303        pub start_level: __s16,
304        pub end_level: __s16,
305        pub envelope: ff_envelope,
306    }
307
308    pub struct ff_condition_effect {
309        pub right_saturation: __u16,
310        pub left_saturation: __u16,
311
312        pub right_coeff: __s16,
313        pub left_coeff: __s16,
314
315        pub deadband: __u16,
316        pub center: __s16,
317    }
318
319    pub struct ff_periodic_effect {
320        pub waveform: __u16,
321        pub period: __u16,
322        pub magnitude: __s16,
323        pub offset: __s16,
324        pub phase: __u16,
325
326        pub envelope: ff_envelope,
327
328        pub custom_len: __u32,
329        pub custom_data: *mut __s16,
330    }
331
332    pub struct ff_rumble_effect {
333        pub strong_magnitude: __u16,
334        pub weak_magnitude: __u16,
335    }
336
337    pub struct ff_effect {
338        pub type_: __u16,
339        pub id: __s16,
340        pub direction: __u16,
341        pub trigger: ff_trigger,
342        pub replay: ff_replay,
343        // FIXME(1.0): this is actually a union
344        #[cfg(target_pointer_width = "64")]
345        pub u: [u64; 4],
346        #[cfg(target_pointer_width = "32")]
347        pub u: [u32; 7],
348    }
349
350    pub struct uinput_ff_upload {
351        pub request_id: __u32,
352        pub retval: __s32,
353        pub effect: ff_effect,
354        pub old: ff_effect,
355    }
356
357    pub struct uinput_ff_erase {
358        pub request_id: __u32,
359        pub retval: __s32,
360        pub effect_id: __u32,
361    }
362
363    pub struct uinput_abs_setup {
364        pub code: __u16,
365        pub absinfo: input_absinfo,
366    }
367
368    pub struct __c_anonymous__kernel_fsid_t {
369        pub val: [c_int; 2],
370    }
371
372    pub struct posix_spawn_file_actions_t {
373        __allocated: c_int,
374        __used: c_int,
375        __actions: *mut c_int,
376        __pad: Padding<[c_int; 16]>,
377    }
378
379    pub struct posix_spawnattr_t {
380        __flags: c_short,
381        __pgrp: crate::pid_t,
382        __sd: crate::sigset_t,
383        __ss: crate::sigset_t,
384        #[cfg(any(target_env = "musl", target_env = "ohos"))]
385        __prio: c_int,
386        #[cfg(not(any(target_env = "musl", target_env = "ohos")))]
387        __sp: crate::sched_param,
388        __policy: c_int,
389        __pad: Padding<[c_int; 16]>,
390    }
391
392    pub struct genlmsghdr {
393        pub cmd: u8,
394        pub version: u8,
395        pub reserved: u16,
396    }
397
398    pub struct inotify_event {
399        pub wd: c_int,
400        pub mask: u32,
401        pub cookie: u32,
402        pub len: u32,
403    }
404
405    pub struct fanotify_response {
406        pub fd: c_int,
407        pub response: __u32,
408    }
409
410    pub struct fanotify_event_info_header {
411        pub info_type: __u8,
412        pub pad: __u8,
413        pub len: __u16,
414    }
415
416    pub struct fanotify_event_info_fid {
417        pub hdr: fanotify_event_info_header,
418        pub fsid: __kernel_fsid_t,
419        pub handle: [c_uchar; 0],
420    }
421
422    pub struct sockaddr_vm {
423        pub svm_family: crate::sa_family_t,
424        pub svm_reserved1: c_ushort,
425        pub svm_port: c_uint,
426        pub svm_cid: c_uint,
427        pub svm_zero: [u8; 4],
428    }
429
430    pub struct sock_extended_err {
431        pub ee_errno: u32,
432        pub ee_origin: u8,
433        pub ee_type: u8,
434        pub ee_code: u8,
435        pub ee_pad: u8,
436        pub ee_info: u32,
437        pub ee_data: u32,
438    }
439
440    // linux/seccomp.h
441    pub struct seccomp_data {
442        pub nr: c_int,
443        pub arch: __u32,
444        pub instruction_pointer: crate::__u64,
445        pub args: [crate::__u64; 6],
446    }
447
448    pub struct seccomp_notif_sizes {
449        pub seccomp_notif: __u16,
450        pub seccomp_notif_resp: __u16,
451        pub seccomp_data: __u16,
452    }
453
454    pub struct seccomp_notif {
455        pub id: crate::__u64,
456        pub pid: __u32,
457        pub flags: __u32,
458        pub data: seccomp_data,
459    }
460
461    pub struct seccomp_notif_resp {
462        pub id: crate::__u64,
463        pub val: crate::__s64,
464        pub error: __s32,
465        pub flags: __u32,
466    }
467
468    pub struct seccomp_notif_addfd {
469        pub id: crate::__u64,
470        pub flags: __u32,
471        pub srcfd: __u32,
472        pub newfd: __u32,
473        pub newfd_flags: __u32,
474    }
475
476    pub struct in6_ifreq {
477        pub ifr6_addr: crate::in6_addr,
478        pub ifr6_prefixlen: u32,
479        pub ifr6_ifindex: c_int,
480    }
481
482    // linux/openat2.h
483    #[non_exhaustive]
484    pub struct open_how {
485        pub flags: crate::__u64,
486        pub mode: crate::__u64,
487        pub resolve: crate::__u64,
488    }
489
490    // linux/ptp_clock.h
491    pub struct ptp_clock_time {
492        pub sec: crate::__s64,
493        pub nsec: __u32,
494        pub reserved: __u32,
495    }
496
497    pub struct ptp_extts_request {
498        pub index: c_uint,
499        pub flags: c_uint,
500        pub rsv: [c_uint; 2],
501    }
502
503    pub struct ptp_sys_offset_extended {
504        pub n_samples: c_uint,
505        pub clockid: __kernel_clockid_t,
506        pub rsv: [c_uint; 2],
507        pub ts: [[ptp_clock_time; 3]; PTP_MAX_SAMPLES as usize],
508    }
509
510    pub struct ptp_sys_offset_precise {
511        pub device: ptp_clock_time,
512        pub sys_realtime: ptp_clock_time,
513        pub sys_monoraw: ptp_clock_time,
514        pub rsv: [c_uint; 4],
515    }
516
517    pub struct ptp_extts_event {
518        pub t: ptp_clock_time,
519        index: c_uint,
520        flags: c_uint,
521        rsv: [c_uint; 2],
522    }
523
524    // linux/sctp.h
525
526    pub struct sctp_initmsg {
527        pub sinit_num_ostreams: __u16,
528        pub sinit_max_instreams: __u16,
529        pub sinit_max_attempts: __u16,
530        pub sinit_max_init_timeo: __u16,
531    }
532
533    pub struct sctp_sndrcvinfo {
534        pub sinfo_stream: __u16,
535        pub sinfo_ssn: __u16,
536        pub sinfo_flags: __u16,
537        pub sinfo_ppid: __u32,
538        pub sinfo_context: __u32,
539        pub sinfo_timetolive: __u32,
540        pub sinfo_tsn: __u32,
541        pub sinfo_cumtsn: __u32,
542        pub sinfo_assoc_id: crate::sctp_assoc_t,
543    }
544
545    pub struct sctp_sndinfo {
546        pub snd_sid: __u16,
547        pub snd_flags: __u16,
548        pub snd_ppid: __u32,
549        pub snd_context: __u32,
550        pub snd_assoc_id: crate::sctp_assoc_t,
551    }
552
553    pub struct sctp_rcvinfo {
554        pub rcv_sid: __u16,
555        pub rcv_ssn: __u16,
556        pub rcv_flags: __u16,
557        pub rcv_ppid: __u32,
558        pub rcv_tsn: __u32,
559        pub rcv_cumtsn: __u32,
560        pub rcv_context: __u32,
561        pub rcv_assoc_id: crate::sctp_assoc_t,
562    }
563
564    pub struct sctp_nxtinfo {
565        pub nxt_sid: __u16,
566        pub nxt_flags: __u16,
567        pub nxt_ppid: __u32,
568        pub nxt_length: __u32,
569        pub nxt_assoc_id: crate::sctp_assoc_t,
570    }
571
572    pub struct sctp_prinfo {
573        pub pr_policy: __u16,
574        pub pr_value: __u32,
575    }
576
577    pub struct sctp_authinfo {
578        pub auth_keynumber: __u16,
579    }
580
581    // linux/tls.h
582
583    pub struct tls_crypto_info {
584        pub version: __u16,
585        pub cipher_type: __u16,
586    }
587
588    pub struct tls12_crypto_info_aes_gcm_128 {
589        pub info: tls_crypto_info,
590        pub iv: [c_uchar; TLS_CIPHER_AES_GCM_128_IV_SIZE],
591        pub key: [c_uchar; TLS_CIPHER_AES_GCM_128_KEY_SIZE],
592        pub salt: [c_uchar; TLS_CIPHER_AES_GCM_128_SALT_SIZE],
593        pub rec_seq: [c_uchar; TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE],
594    }
595
596    pub struct tls12_crypto_info_aes_gcm_256 {
597        pub info: tls_crypto_info,
598        pub iv: [c_uchar; TLS_CIPHER_AES_GCM_256_IV_SIZE],
599        pub key: [c_uchar; TLS_CIPHER_AES_GCM_256_KEY_SIZE],
600        pub salt: [c_uchar; TLS_CIPHER_AES_GCM_256_SALT_SIZE],
601        pub rec_seq: [c_uchar; TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE],
602    }
603
604    pub struct tls12_crypto_info_aes_ccm_128 {
605        pub info: tls_crypto_info,
606        pub iv: [c_uchar; TLS_CIPHER_AES_CCM_128_IV_SIZE],
607        pub key: [c_uchar; TLS_CIPHER_AES_CCM_128_KEY_SIZE],
608        pub salt: [c_uchar; TLS_CIPHER_AES_CCM_128_SALT_SIZE],
609        pub rec_seq: [c_uchar; TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE],
610    }
611
612    pub struct tls12_crypto_info_chacha20_poly1305 {
613        pub info: tls_crypto_info,
614        pub iv: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE],
615        pub key: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE],
616        pub salt: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE],
617        pub rec_seq: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE],
618    }
619
620    pub struct tls12_crypto_info_sm4_gcm {
621        pub info: tls_crypto_info,
622        pub iv: [c_uchar; TLS_CIPHER_SM4_GCM_IV_SIZE],
623        pub key: [c_uchar; TLS_CIPHER_SM4_GCM_KEY_SIZE],
624        pub salt: [c_uchar; TLS_CIPHER_SM4_GCM_SALT_SIZE],
625        pub rec_seq: [c_uchar; TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE],
626    }
627
628    pub struct tls12_crypto_info_sm4_ccm {
629        pub info: tls_crypto_info,
630        pub iv: [c_uchar; TLS_CIPHER_SM4_CCM_IV_SIZE],
631        pub key: [c_uchar; TLS_CIPHER_SM4_CCM_KEY_SIZE],
632        pub salt: [c_uchar; TLS_CIPHER_SM4_CCM_SALT_SIZE],
633        pub rec_seq: [c_uchar; TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE],
634    }
635
636    pub struct tls12_crypto_info_aria_gcm_128 {
637        pub info: tls_crypto_info,
638        pub iv: [c_uchar; TLS_CIPHER_ARIA_GCM_128_IV_SIZE],
639        pub key: [c_uchar; TLS_CIPHER_ARIA_GCM_128_KEY_SIZE],
640        pub salt: [c_uchar; TLS_CIPHER_ARIA_GCM_128_SALT_SIZE],
641        pub rec_seq: [c_uchar; TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE],
642    }
643
644    pub struct tls12_crypto_info_aria_gcm_256 {
645        pub info: tls_crypto_info,
646        pub iv: [c_uchar; TLS_CIPHER_ARIA_GCM_256_IV_SIZE],
647        pub key: [c_uchar; TLS_CIPHER_ARIA_GCM_256_KEY_SIZE],
648        pub salt: [c_uchar; TLS_CIPHER_ARIA_GCM_256_SALT_SIZE],
649        pub rec_seq: [c_uchar; TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE],
650    }
651
652    // linux/wireless.h
653
654    pub struct iw_param {
655        pub value: __s32,
656        pub fixed: __u8,
657        pub disabled: __u8,
658        pub flags: __u16,
659    }
660
661    pub struct iw_point {
662        pub pointer: *mut c_void,
663        pub length: __u16,
664        pub flags: __u16,
665    }
666
667    pub struct iw_freq {
668        pub m: __s32,
669        pub e: __s16,
670        pub i: __u8,
671        pub flags: __u8,
672    }
673
674    pub struct iw_quality {
675        pub qual: __u8,
676        pub level: __u8,
677        pub noise: __u8,
678        pub updated: __u8,
679    }
680
681    pub struct iw_discarded {
682        pub nwid: __u32,
683        pub code: __u32,
684        pub fragment: __u32,
685        pub retries: __u32,
686        pubmisc: __u32,
687    }
688
689    pub struct iw_missed {
690        pub beacon: __u32,
691    }
692
693    pub struct iw_scan_req {
694        pub scan_type: __u8,
695        pub essid_len: __u8,
696        pub num_channels: __u8,
697        pub flags: __u8,
698        pub bssid: crate::sockaddr,
699        pub essid: [__u8; IW_ESSID_MAX_SIZE],
700        pub min_channel_time: __u32,
701        pub max_channel_time: __u32,
702        pub channel_list: [iw_freq; IW_MAX_FREQUENCIES],
703    }
704
705    pub struct iw_encode_ext {
706        pub ext_flags: __u32,
707        pub tx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
708        pub rx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
709        pub addr: crate::sockaddr,
710        pub alg: __u16,
711        pub key_len: __u16,
712        pub key: [__u8; 0],
713    }
714
715    pub struct iw_pmksa {
716        pub cmd: __u32,
717        pub bssid: crate::sockaddr,
718        pub pmkid: [__u8; IW_PMKID_LEN],
719    }
720
721    pub struct iw_pmkid_cand {
722        pub flags: __u32,
723        pub index: __u32,
724        pub bssid: crate::sockaddr,
725    }
726
727    pub struct iw_statistics {
728        pub status: __u16,
729        pub qual: iw_quality,
730        pub discard: iw_discarded,
731        pub miss: iw_missed,
732    }
733
734    pub struct iw_range {
735        pub throughput: __u32,
736        pub min_nwid: __u32,
737        pub max_nwid: __u32,
738        pub old_num_channels: __u16,
739        pub old_num_frequency: __u8,
740        pub scan_capa: __u8,
741        pub event_capa: [__u32; 6],
742        pub sensitivity: __s32,
743        pub max_qual: iw_quality,
744        pub avg_qual: iw_quality,
745        pub num_bitrates: __u8,
746        pub bitrate: [__s32; IW_MAX_BITRATES],
747        pub min_rts: __s32,
748        pub max_rts: __s32,
749        pub min_frag: __s32,
750        pub max_frag: __s32,
751        pub min_pmp: __s32,
752        pub max_pmp: __s32,
753        pub min_pmt: __s32,
754        pub max_pmt: __s32,
755        pub pmp_flags: __u16,
756        pub pmt_flags: __u16,
757        pub pm_capa: __u16,
758        pub encoding_size: [__u16; IW_MAX_ENCODING_SIZES],
759        pub num_encoding_sizes: __u8,
760        pub max_encoding_tokens: __u8,
761        pub encoding_login_index: __u8,
762        pub txpower_capa: __u16,
763        pub num_txpower: __u8,
764        pub txpower: [__s32; IW_MAX_TXPOWER],
765        pub we_version_compiled: __u8,
766        pub we_version_source: __u8,
767        pub retry_capa: __u16,
768        pub retry_flags: __u16,
769        pub r_time_flags: __u16,
770        pub min_retry: __s32,
771        pub max_retry: __s32,
772        pub min_r_time: __s32,
773        pub max_r_time: __s32,
774        pub num_channels: __u16,
775        pub num_frequency: __u8,
776        pub freq: [iw_freq; IW_MAX_FREQUENCIES],
777        pub enc_capa: __u32,
778    }
779
780    pub struct iw_priv_args {
781        pub cmd: __u32,
782        pub set_args: __u16,
783        pub get_args: __u16,
784        pub name: [c_char; crate::IFNAMSIZ],
785    }
786
787    // #include <linux/eventpoll.h>
788
789    pub struct epoll_params {
790        pub busy_poll_usecs: u32,
791        pub busy_poll_budget: u16,
792        pub prefer_busy_poll: u8,
793        pub __pad: u8, // Must be zero
794    }
795
796    #[cfg_attr(
797        any(
798            target_pointer_width = "32",
799            target_arch = "x86_64",
800            target_arch = "powerpc64",
801            target_arch = "mips64",
802            target_arch = "mips64r6",
803            target_arch = "s390x",
804            target_arch = "sparc64",
805            target_arch = "aarch64",
806            target_arch = "riscv64",
807            target_arch = "riscv32",
808            target_arch = "loongarch64"
809        ),
810        repr(align(4))
811    )]
812    #[cfg_attr(
813        not(any(
814            target_pointer_width = "32",
815            target_arch = "x86_64",
816            target_arch = "powerpc64",
817            target_arch = "mips64",
818            target_arch = "mips64r6",
819            target_arch = "s390x",
820            target_arch = "sparc64",
821            target_arch = "aarch64",
822            target_arch = "riscv64",
823            target_arch = "riscv32",
824            target_arch = "loongarch64"
825        )),
826        repr(align(8))
827    )]
828    pub struct pthread_mutexattr_t {
829        #[doc(hidden)]
830        size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T],
831    }
832
833    #[cfg_attr(
834        any(
835            target_env = "musl",
836            target_env = "ohos",
837            target_env = "uclibc",
838            target_pointer_width = "32"
839        ),
840        repr(align(4))
841    )]
842    #[cfg_attr(
843        all(
844            not(target_env = "musl"),
845            not(target_env = "ohos"),
846            not(target_env = "uclibc"),
847            target_pointer_width = "64"
848        ),
849        repr(align(8))
850    )]
851    pub struct pthread_rwlockattr_t {
852        #[doc(hidden)]
853        size: [u8; crate::__SIZEOF_PTHREAD_RWLOCKATTR_T],
854    }
855
856    #[repr(align(4))]
857    pub struct pthread_condattr_t {
858        #[doc(hidden)]
859        size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T],
860    }
861
862    #[repr(align(4))]
863    pub struct pthread_barrierattr_t {
864        #[doc(hidden)]
865        size: [u8; crate::__SIZEOF_PTHREAD_BARRIERATTR_T],
866    }
867
868    #[cfg(not(any(target_env = "musl", target_env = "ohos")))]
869    #[repr(align(8))]
870    pub struct fanotify_event_metadata {
871        pub event_len: __u32,
872        pub vers: __u8,
873        pub reserved: __u8,
874        pub metadata_len: __u16,
875        pub mask: __u64,
876        pub fd: c_int,
877        pub pid: c_int,
878    }
879
880    // linux/ptp_clock.h
881
882    pub struct ptp_sys_offset {
883        pub n_samples: c_uint,
884        pub rsv: [c_uint; 3],
885        // FIXME(garando): replace length with `2 * PTP_MAX_SAMPLES + 1` when supported
886        pub ts: [ptp_clock_time; 51],
887    }
888
889    pub struct ptp_pin_desc {
890        pub name: [c_char; 64],
891        pub index: c_uint,
892        pub func: c_uint,
893        pub chan: c_uint,
894        pub rsv: [c_uint; 5],
895    }
896
897    pub struct ptp_clock_caps {
898        pub max_adj: c_int,
899        pub n_alarm: c_int,
900        pub n_ext_ts: c_int,
901        pub n_per_out: c_int,
902        pub pps: c_int,
903        pub n_pins: c_int,
904        pub cross_timestamping: c_int,
905        pub adjust_phase: c_int,
906        pub max_phase_adj: c_int,
907        pub rsv: [c_int; 11],
908    }
909
910    // linux/if_xdp.h
911
912    pub struct sockaddr_xdp {
913        pub sxdp_family: crate::__u16,
914        pub sxdp_flags: crate::__u16,
915        pub sxdp_ifindex: crate::__u32,
916        pub sxdp_queue_id: crate::__u32,
917        pub sxdp_shared_umem_fd: crate::__u32,
918    }
919
920    pub struct xdp_ring_offset {
921        pub producer: crate::__u64,
922        pub consumer: crate::__u64,
923        pub desc: crate::__u64,
924        pub flags: crate::__u64,
925    }
926
927    pub struct xdp_mmap_offsets {
928        pub rx: xdp_ring_offset,
929        pub tx: xdp_ring_offset,
930        pub fr: xdp_ring_offset,
931        pub cr: xdp_ring_offset,
932    }
933
934    pub struct xdp_ring_offset_v1 {
935        pub producer: crate::__u64,
936        pub consumer: crate::__u64,
937        pub desc: crate::__u64,
938    }
939
940    pub struct xdp_mmap_offsets_v1 {
941        pub rx: xdp_ring_offset_v1,
942        pub tx: xdp_ring_offset_v1,
943        pub fr: xdp_ring_offset_v1,
944        pub cr: xdp_ring_offset_v1,
945    }
946
947    pub struct xdp_umem_reg {
948        pub addr: crate::__u64,
949        pub len: crate::__u64,
950        pub chunk_size: crate::__u32,
951        pub headroom: crate::__u32,
952        pub flags: crate::__u32,
953        pub tx_metadata_len: crate::__u32,
954    }
955
956    pub struct xdp_umem_reg_v1 {
957        pub addr: crate::__u64,
958        pub len: crate::__u64,
959        pub chunk_size: crate::__u32,
960        pub headroom: crate::__u32,
961    }
962
963    pub struct xdp_statistics {
964        pub rx_dropped: crate::__u64,
965        pub rx_invalid_descs: crate::__u64,
966        pub tx_invalid_descs: crate::__u64,
967        pub rx_ring_full: crate::__u64,
968        pub rx_fill_ring_empty_descs: crate::__u64,
969        pub tx_ring_empty_descs: crate::__u64,
970    }
971
972    pub struct xdp_statistics_v1 {
973        pub rx_dropped: crate::__u64,
974        pub rx_invalid_descs: crate::__u64,
975        pub tx_invalid_descs: crate::__u64,
976    }
977
978    pub struct xdp_options {
979        pub flags: crate::__u32,
980    }
981
982    pub struct xdp_desc {
983        pub addr: crate::__u64,
984        pub len: crate::__u32,
985        pub options: crate::__u32,
986    }
987
988    pub struct xsk_tx_metadata_completion {
989        pub tx_timestamp: crate::__u64,
990    }
991
992    pub struct xsk_tx_metadata_request {
993        pub csum_start: __u16,
994        pub csum_offset: __u16,
995    }
996
997    // linux/mount.h
998
999    pub struct mount_attr {
1000        pub attr_set: crate::__u64,
1001        pub attr_clr: crate::__u64,
1002        pub propagation: crate::__u64,
1003        pub userns_fd: crate::__u64,
1004    }
1005
1006    // linux/nsfs.h
1007    pub struct mnt_ns_info {
1008        pub size: crate::__u32,
1009        pub nr_mounts: crate::__u32,
1010        pub mnt_ns_id: crate::__u64,
1011    }
1012
1013    // linux/pidfd.h
1014
1015    // linux/uio.h
1016
1017    pub struct dmabuf_cmsg {
1018        pub frag_offset: crate::__u64,
1019        pub frag_size: crate::__u32,
1020        pub frag_token: crate::__u32,
1021        pub dmabuf_id: crate::__u32,
1022        pub flags: crate::__u32,
1023    }
1024
1025    pub struct dmabuf_token {
1026        pub token_start: crate::__u32,
1027        pub token_count: crate::__u32,
1028    }
1029
1030    pub struct sockaddr_alg {
1031        pub salg_family: crate::sa_family_t,
1032        pub salg_type: [c_uchar; 14],
1033        pub salg_feat: u32,
1034        pub salg_mask: u32,
1035        pub salg_name: [c_uchar; 64],
1036    }
1037
1038    #[cfg_attr(
1039        all(
1040            any(target_env = "musl", target_env = "ohos"),
1041            target_pointer_width = "32"
1042        ),
1043        repr(align(4))
1044    )]
1045    #[cfg_attr(
1046        all(
1047            any(target_env = "musl", target_env = "ohos"),
1048            target_pointer_width = "64"
1049        ),
1050        repr(align(8))
1051    )]
1052    #[cfg_attr(
1053        all(
1054            not(any(target_env = "musl", target_env = "ohos")),
1055            target_arch = "x86"
1056        ),
1057        repr(align(4))
1058    )]
1059    #[cfg_attr(
1060        all(
1061            not(any(target_env = "musl", target_env = "ohos")),
1062            not(target_arch = "x86")
1063        ),
1064        repr(align(8))
1065    )]
1066    pub struct pthread_cond_t {
1067        #[doc(hidden)]
1068        size: [u8; crate::__SIZEOF_PTHREAD_COND_T],
1069    }
1070
1071    #[cfg_attr(
1072        all(
1073            target_pointer_width = "32",
1074            any(
1075                target_arch = "mips",
1076                target_arch = "mips32r6",
1077                target_arch = "arm",
1078                target_arch = "hexagon",
1079                target_arch = "m68k",
1080                target_arch = "csky",
1081                target_arch = "powerpc",
1082                target_arch = "sparc",
1083                target_arch = "x86_64",
1084                target_arch = "x86",
1085            )
1086        ),
1087        repr(align(4))
1088    )]
1089    #[cfg_attr(
1090        any(
1091            target_pointer_width = "64",
1092            not(any(
1093                target_arch = "mips",
1094                target_arch = "mips32r6",
1095                target_arch = "arm",
1096                target_arch = "hexagon",
1097                target_arch = "m68k",
1098                target_arch = "csky",
1099                target_arch = "powerpc",
1100                target_arch = "sparc",
1101                target_arch = "x86_64",
1102                target_arch = "x86",
1103            ))
1104        ),
1105        repr(align(8))
1106    )]
1107    pub struct pthread_mutex_t {
1108        #[doc(hidden)]
1109        size: [c_char; crate::__SIZEOF_PTHREAD_MUTEX_T],
1110    }
1111
1112    #[cfg_attr(
1113        all(
1114            target_pointer_width = "32",
1115            any(
1116                target_arch = "mips",
1117                target_arch = "mips32r6",
1118                target_arch = "arm",
1119                target_arch = "hexagon",
1120                target_arch = "m68k",
1121                target_arch = "csky",
1122                target_arch = "powerpc",
1123                target_arch = "sparc",
1124                target_arch = "x86_64",
1125                target_arch = "x86"
1126            )
1127        ),
1128        repr(align(4))
1129    )]
1130    #[cfg_attr(
1131        any(
1132            target_pointer_width = "64",
1133            not(any(
1134                target_arch = "mips",
1135                target_arch = "mips32r6",
1136                target_arch = "arm",
1137                target_arch = "hexagon",
1138                target_arch = "m68k",
1139                target_arch = "powerpc",
1140                target_arch = "sparc",
1141                target_arch = "x86_64",
1142                target_arch = "x86"
1143            ))
1144        ),
1145        repr(align(8))
1146    )]
1147    pub struct pthread_rwlock_t {
1148        size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T],
1149    }
1150
1151    #[cfg_attr(
1152        all(
1153            target_pointer_width = "32",
1154            any(
1155                target_arch = "mips",
1156                target_arch = "mips32r6",
1157                target_arch = "arm",
1158                target_arch = "hexagon",
1159                target_arch = "m68k",
1160                target_arch = "csky",
1161                target_arch = "powerpc",
1162                target_arch = "sparc",
1163                target_arch = "x86_64",
1164                target_arch = "x86"
1165            )
1166        ),
1167        repr(align(4))
1168    )]
1169    #[cfg_attr(
1170        any(
1171            target_pointer_width = "64",
1172            not(any(
1173                target_arch = "mips",
1174                target_arch = "mips32r6",
1175                target_arch = "arm",
1176                target_arch = "hexagon",
1177                target_arch = "m68k",
1178                target_arch = "csky",
1179                target_arch = "powerpc",
1180                target_arch = "sparc",
1181                target_arch = "x86_64",
1182                target_arch = "x86"
1183            ))
1184        ),
1185        repr(align(8))
1186    )]
1187    pub struct pthread_barrier_t {
1188        size: [u8; crate::__SIZEOF_PTHREAD_BARRIER_T],
1189    }
1190
1191    pub struct uinput_setup {
1192        pub id: input_id,
1193        pub name: [c_char; UINPUT_MAX_NAME_SIZE],
1194        pub ff_effects_max: __u32,
1195    }
1196
1197    pub struct uinput_user_dev {
1198        pub name: [c_char; UINPUT_MAX_NAME_SIZE],
1199        pub id: input_id,
1200        pub ff_effects_max: __u32,
1201        pub absmax: [__s32; ABS_CNT],
1202        pub absmin: [__s32; ABS_CNT],
1203        pub absfuzz: [__s32; ABS_CNT],
1204        pub absflat: [__s32; ABS_CNT],
1205    }
1206
1207    // x32 compatibility
1208    // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279
1209    pub struct mq_attr {
1210        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1211        pub mq_flags: i64,
1212        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1213        pub mq_maxmsg: i64,
1214        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1215        pub mq_msgsize: i64,
1216        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1217        pub mq_curmsgs: i64,
1218        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1219        pad: Padding<[i64; 4]>,
1220
1221        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1222        pub mq_flags: c_long,
1223        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1224        pub mq_maxmsg: c_long,
1225        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1226        pub mq_msgsize: c_long,
1227        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1228        pub mq_curmsgs: c_long,
1229        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1230        pad: Padding<[c_long; 4]>,
1231    }
1232
1233    pub struct hwtstamp_config {
1234        pub flags: c_int,
1235        pub tx_type: c_int,
1236        pub rx_filter: c_int,
1237    }
1238
1239    pub struct sched_attr {
1240        pub size: __u32,
1241        pub sched_policy: __u32,
1242        pub sched_flags: crate::__u64,
1243        pub sched_nice: __s32,
1244        pub sched_priority: __u32,
1245        pub sched_runtime: crate::__u64,
1246        pub sched_deadline: crate::__u64,
1247        pub sched_period: crate::__u64,
1248    }
1249
1250    // linux/fcntl.h
1251
1252    pub struct file_handle {
1253        pub handle_bytes: c_uint,
1254        pub handle_type: c_int,
1255        pub f_handle: [c_uchar; 0],
1256    }
1257}
1258
1259cfg_if! {
1260    if #[cfg(not(target_arch = "sparc64"))] {
1261        s! {
1262            pub struct iw_thrspy {
1263                pub addr: crate::sockaddr,
1264                pub qual: iw_quality,
1265                pub low: iw_quality,
1266                pub high: iw_quality,
1267            }
1268
1269            pub struct iw_mlme {
1270                pub cmd: __u16,
1271                pub reason_code: __u16,
1272                pub addr: crate::sockaddr,
1273            }
1274
1275            pub struct iw_michaelmicfailure {
1276                pub flags: __u32,
1277                pub src_addr: crate::sockaddr,
1278                pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
1279            }
1280        }
1281    }
1282}
1283
1284s_no_extra_traits! {
1285    /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this
1286    /// type are unsound and will be removed in the future.
1287    #[deprecated(
1288        note = "this struct has unsafe trait implementations that will be \
1289                removed in the future",
1290        since = "0.2.80"
1291    )]
1292    pub struct af_alg_iv {
1293        pub ivlen: u32,
1294        pub iv: [c_uchar; 0],
1295    }
1296
1297    pub union tpacket_req_u {
1298        pub req: crate::tpacket_req,
1299        pub req3: crate::tpacket_req3,
1300    }
1301
1302    pub union tpacket_bd_header_u {
1303        pub bh1: crate::tpacket_hdr_v1,
1304    }
1305
1306    pub struct tpacket_block_desc {
1307        pub version: __u32,
1308        pub offset_to_priv: __u32,
1309        pub hdr: crate::tpacket_bd_header_u,
1310    }
1311
1312    // linux/net_tstamp.h
1313    pub struct sock_txtime {
1314        pub clockid: crate::clockid_t,
1315        pub flags: __u32,
1316    }
1317
1318    // linux/wireless.h
1319    pub union iwreq_data {
1320        pub name: [c_char; crate::IFNAMSIZ],
1321        pub essid: iw_point,
1322        pub nwid: iw_param,
1323        pub freq: iw_freq,
1324        pub sens: iw_param,
1325        pub bitrate: iw_param,
1326        pub txpower: iw_param,
1327        pub rts: iw_param,
1328        pub frag: iw_param,
1329        pub mode: __u32,
1330        pub retry: iw_param,
1331        pub encoding: iw_point,
1332        pub power: iw_param,
1333        pub qual: iw_quality,
1334        pub ap_addr: crate::sockaddr,
1335        pub addr: crate::sockaddr,
1336        pub param: iw_param,
1337        pub data: iw_point,
1338    }
1339
1340    pub struct iw_event {
1341        pub len: __u16,
1342        pub cmd: __u16,
1343        pub u: iwreq_data,
1344    }
1345
1346    pub union __c_anonymous_iwreq {
1347        pub ifrn_name: [c_char; crate::IFNAMSIZ],
1348    }
1349
1350    pub struct iwreq {
1351        pub ifr_ifrn: __c_anonymous_iwreq,
1352        pub u: iwreq_data,
1353    }
1354
1355    // linux/ptp_clock.h
1356    pub union __c_anonymous_ptp_perout_request_1 {
1357        pub start: ptp_clock_time,
1358        pub phase: ptp_clock_time,
1359    }
1360
1361    pub union __c_anonymous_ptp_perout_request_2 {
1362        pub on: ptp_clock_time,
1363        pub rsv: [c_uint; 4],
1364    }
1365
1366    pub struct ptp_perout_request {
1367        pub anonymous_1: __c_anonymous_ptp_perout_request_1,
1368        pub period: ptp_clock_time,
1369        pub index: c_uint,
1370        pub flags: c_uint,
1371        pub anonymous_2: __c_anonymous_ptp_perout_request_2,
1372    }
1373
1374    // linux/if_xdp.h
1375    pub struct xsk_tx_metadata {
1376        pub flags: crate::__u64,
1377        pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union,
1378    }
1379
1380    pub union __c_anonymous_xsk_tx_metadata_union {
1381        pub request: xsk_tx_metadata_request,
1382        pub completion: xsk_tx_metadata_completion,
1383    }
1384}
1385
1386cfg_if! {
1387    if #[cfg(feature = "extra_traits")] {
1388        #[allow(deprecated)]
1389        impl af_alg_iv {
1390            fn as_slice(&self) -> &[u8] {
1391                unsafe { ::core::slice::from_raw_parts(self.iv.as_ptr(), self.ivlen as usize) }
1392            }
1393        }
1394
1395        #[allow(deprecated)]
1396        impl PartialEq for af_alg_iv {
1397            fn eq(&self, other: &af_alg_iv) -> bool {
1398                *self.as_slice() == *other.as_slice()
1399            }
1400        }
1401
1402        #[allow(deprecated)]
1403        impl Eq for af_alg_iv {}
1404
1405        #[allow(deprecated)]
1406        impl hash::Hash for af_alg_iv {
1407            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1408                self.as_slice().hash(state);
1409            }
1410        }
1411    }
1412}
1413
1414pub const POSIX_SPAWN_USEVFORK: c_int = 64;
1415pub const POSIX_SPAWN_SETSID: c_int = 128;
1416
1417pub const F_SEAL_FUTURE_WRITE: c_int = 0x0010;
1418pub const F_SEAL_EXEC: c_int = 0x0020;
1419
1420pub const IFF_LOWER_UP: c_int = 0x10000;
1421pub const IFF_DORMANT: c_int = 0x20000;
1422pub const IFF_ECHO: c_int = 0x40000;
1423
1424// linux/fcntl.h
1425pub const AT_EXECVE_CHECK: c_int = 0x10000;
1426
1427pub const MAX_HANDLE_SZ: c_int = 128;
1428pub const AT_HANDLE_FID: c_int = 0x200;
1429pub const AT_HANDLE_MNT_ID_UNIQUE: c_int = 0x001;
1430pub const AT_HANDLE_CONNECTABLE: c_int = 0x002;
1431
1432// linux/if_addr.h
1433pub const IFA_UNSPEC: c_ushort = 0;
1434pub const IFA_ADDRESS: c_ushort = 1;
1435pub const IFA_LOCAL: c_ushort = 2;
1436pub const IFA_LABEL: c_ushort = 3;
1437pub const IFA_BROADCAST: c_ushort = 4;
1438pub const IFA_ANYCAST: c_ushort = 5;
1439pub const IFA_CACHEINFO: c_ushort = 6;
1440pub const IFA_MULTICAST: c_ushort = 7;
1441pub const IFA_FLAGS: c_ushort = 8;
1442
1443pub const IFA_F_SECONDARY: u32 = 0x01;
1444pub const IFA_F_TEMPORARY: u32 = 0x01;
1445pub const IFA_F_NODAD: u32 = 0x02;
1446pub const IFA_F_OPTIMISTIC: u32 = 0x04;
1447pub const IFA_F_DADFAILED: u32 = 0x08;
1448pub const IFA_F_HOMEADDRESS: u32 = 0x10;
1449pub const IFA_F_DEPRECATED: u32 = 0x20;
1450pub const IFA_F_TENTATIVE: u32 = 0x40;
1451pub const IFA_F_PERMANENT: u32 = 0x80;
1452pub const IFA_F_MANAGETEMPADDR: u32 = 0x100;
1453pub const IFA_F_NOPREFIXROUTE: u32 = 0x200;
1454pub const IFA_F_MCAUTOJOIN: u32 = 0x400;
1455pub const IFA_F_STABLE_PRIVACY: u32 = 0x800;
1456
1457// linux/fs.h
1458
1459// Flags for preadv2/pwritev2
1460pub const RWF_HIPRI: c_int = 0x00000001;
1461pub const RWF_DSYNC: c_int = 0x00000002;
1462pub const RWF_SYNC: c_int = 0x00000004;
1463pub const RWF_NOWAIT: c_int = 0x00000008;
1464pub const RWF_APPEND: c_int = 0x00000010;
1465pub const RWF_NOAPPEND: c_int = 0x00000020;
1466pub const RWF_ATOMIC: c_int = 0x00000040;
1467pub const RWF_DONTCACHE: c_int = 0x00000080;
1468
1469// linux/if_link.h
1470pub const IFLA_UNSPEC: c_ushort = 0;
1471pub const IFLA_ADDRESS: c_ushort = 1;
1472pub const IFLA_BROADCAST: c_ushort = 2;
1473pub const IFLA_IFNAME: c_ushort = 3;
1474pub const IFLA_MTU: c_ushort = 4;
1475pub const IFLA_LINK: c_ushort = 5;
1476pub const IFLA_QDISC: c_ushort = 6;
1477pub const IFLA_STATS: c_ushort = 7;
1478pub const IFLA_COST: c_ushort = 8;
1479pub const IFLA_PRIORITY: c_ushort = 9;
1480pub const IFLA_MASTER: c_ushort = 10;
1481pub const IFLA_WIRELESS: c_ushort = 11;
1482pub const IFLA_PROTINFO: c_ushort = 12;
1483pub const IFLA_TXQLEN: c_ushort = 13;
1484pub const IFLA_MAP: c_ushort = 14;
1485pub const IFLA_WEIGHT: c_ushort = 15;
1486pub const IFLA_OPERSTATE: c_ushort = 16;
1487pub const IFLA_LINKMODE: c_ushort = 17;
1488pub const IFLA_LINKINFO: c_ushort = 18;
1489pub const IFLA_NET_NS_PID: c_ushort = 19;
1490pub const IFLA_IFALIAS: c_ushort = 20;
1491pub const IFLA_NUM_VF: c_ushort = 21;
1492pub const IFLA_VFINFO_LIST: c_ushort = 22;
1493pub const IFLA_STATS64: c_ushort = 23;
1494pub const IFLA_VF_PORTS: c_ushort = 24;
1495pub const IFLA_PORT_SELF: c_ushort = 25;
1496pub const IFLA_AF_SPEC: c_ushort = 26;
1497pub const IFLA_GROUP: c_ushort = 27;
1498pub const IFLA_NET_NS_FD: c_ushort = 28;
1499pub const IFLA_EXT_MASK: c_ushort = 29;
1500pub const IFLA_PROMISCUITY: c_ushort = 30;
1501pub const IFLA_NUM_TX_QUEUES: c_ushort = 31;
1502pub const IFLA_NUM_RX_QUEUES: c_ushort = 32;
1503pub const IFLA_CARRIER: c_ushort = 33;
1504pub const IFLA_PHYS_PORT_ID: c_ushort = 34;
1505pub const IFLA_CARRIER_CHANGES: c_ushort = 35;
1506pub const IFLA_PHYS_SWITCH_ID: c_ushort = 36;
1507pub const IFLA_LINK_NETNSID: c_ushort = 37;
1508pub const IFLA_PHYS_PORT_NAME: c_ushort = 38;
1509pub const IFLA_PROTO_DOWN: c_ushort = 39;
1510pub const IFLA_GSO_MAX_SEGS: c_ushort = 40;
1511pub const IFLA_GSO_MAX_SIZE: c_ushort = 41;
1512pub const IFLA_PAD: c_ushort = 42;
1513pub const IFLA_XDP: c_ushort = 43;
1514pub const IFLA_EVENT: c_ushort = 44;
1515pub const IFLA_NEW_NETNSID: c_ushort = 45;
1516pub const IFLA_IF_NETNSID: c_ushort = 46;
1517pub const IFLA_TARGET_NETNSID: c_ushort = IFLA_IF_NETNSID;
1518pub const IFLA_CARRIER_UP_COUNT: c_ushort = 47;
1519pub const IFLA_CARRIER_DOWN_COUNT: c_ushort = 48;
1520pub const IFLA_NEW_IFINDEX: c_ushort = 49;
1521pub const IFLA_MIN_MTU: c_ushort = 50;
1522pub const IFLA_MAX_MTU: c_ushort = 51;
1523pub const IFLA_PROP_LIST: c_ushort = 52;
1524pub const IFLA_ALT_IFNAME: c_ushort = 53;
1525pub const IFLA_PERM_ADDRESS: c_ushort = 54;
1526pub const IFLA_PROTO_DOWN_REASON: c_ushort = 55;
1527pub const IFLA_PARENT_DEV_NAME: c_ushort = 56;
1528pub const IFLA_PARENT_DEV_BUS_NAME: c_ushort = 57;
1529pub const IFLA_GRO_MAX_SIZE: c_ushort = 58;
1530pub const IFLA_TSO_MAX_SIZE: c_ushort = 59;
1531pub const IFLA_TSO_MAX_SEGS: c_ushort = 60;
1532pub const IFLA_ALLMULTI: c_ushort = 61;
1533
1534pub const IFLA_INFO_UNSPEC: c_ushort = 0;
1535pub const IFLA_INFO_KIND: c_ushort = 1;
1536pub const IFLA_INFO_DATA: c_ushort = 2;
1537pub const IFLA_INFO_XSTATS: c_ushort = 3;
1538pub const IFLA_INFO_SLAVE_KIND: c_ushort = 4;
1539pub const IFLA_INFO_SLAVE_DATA: c_ushort = 5;
1540
1541// Since Linux 3.1
1542pub const SEEK_DATA: c_int = 3;
1543pub const SEEK_HOLE: c_int = 4;
1544
1545// linux/mempolicy.h
1546pub const MPOL_DEFAULT: c_int = 0;
1547pub const MPOL_PREFERRED: c_int = 1;
1548pub const MPOL_BIND: c_int = 2;
1549pub const MPOL_INTERLEAVE: c_int = 3;
1550pub const MPOL_LOCAL: c_int = 4;
1551pub const MPOL_F_NUMA_BALANCING: c_int = 1 << 13;
1552pub const MPOL_F_RELATIVE_NODES: c_int = 1 << 14;
1553pub const MPOL_F_STATIC_NODES: c_int = 1 << 15;
1554
1555pub const PTHREAD_MUTEX_INITIALIZER: crate::pthread_mutex_t = crate::pthread_mutex_t {
1556    size: [0; crate::__SIZEOF_PTHREAD_MUTEX_T],
1557};
1558pub const PTHREAD_COND_INITIALIZER: crate::pthread_cond_t = crate::pthread_cond_t {
1559    size: [0; crate::__SIZEOF_PTHREAD_COND_T],
1560};
1561pub const PTHREAD_RWLOCK_INITIALIZER: crate::pthread_rwlock_t = crate::pthread_rwlock_t {
1562    size: [0; crate::__SIZEOF_PTHREAD_RWLOCK_T],
1563};
1564
1565pub const RENAME_NOREPLACE: c_uint = 1;
1566pub const RENAME_EXCHANGE: c_uint = 2;
1567pub const RENAME_WHITEOUT: c_uint = 4;
1568
1569pub const MSG_STAT: c_int = 11 | (crate::IPC_STAT & 0x100);
1570pub const MSG_INFO: c_int = 12;
1571pub const MSG_NOTIFICATION: c_int = 0x8000;
1572
1573pub const MSG_NOERROR: c_int = 0o10000;
1574pub const MSG_EXCEPT: c_int = 0o20000;
1575pub const MSG_ZEROCOPY: c_int = 0x4000000;
1576
1577pub const SEM_UNDO: c_int = 0x1000;
1578
1579pub const GETPID: c_int = 11;
1580pub const GETVAL: c_int = 12;
1581pub const GETALL: c_int = 13;
1582pub const GETNCNT: c_int = 14;
1583pub const GETZCNT: c_int = 15;
1584pub const SETVAL: c_int = 16;
1585pub const SETALL: c_int = 17;
1586pub const SEM_STAT: c_int = 18 | (crate::IPC_STAT & 0x100);
1587pub const SEM_INFO: c_int = 19;
1588pub const SEM_STAT_ANY: c_int = 20 | (crate::IPC_STAT & 0x100);
1589
1590pub const QFMT_VFS_OLD: c_int = 1;
1591pub const QFMT_VFS_V0: c_int = 2;
1592pub const QFMT_VFS_V1: c_int = 4;
1593
1594pub const EFD_SEMAPHORE: c_int = 0x1;
1595
1596pub const RB_AUTOBOOT: c_int = 0x01234567u32 as i32;
1597pub const RB_HALT_SYSTEM: c_int = 0xcdef0123u32 as i32;
1598pub const RB_ENABLE_CAD: c_int = 0x89abcdefu32 as i32;
1599pub const RB_DISABLE_CAD: c_int = 0x00000000u32 as i32;
1600pub const RB_POWER_OFF: c_int = 0x4321fedcu32 as i32;
1601pub const RB_SW_SUSPEND: c_int = 0xd000fce2u32 as i32;
1602pub const RB_KEXEC: c_int = 0x45584543u32 as i32;
1603
1604pub const SYNC_FILE_RANGE_WAIT_BEFORE: c_uint = 1;
1605pub const SYNC_FILE_RANGE_WRITE: c_uint = 2;
1606pub const SYNC_FILE_RANGE_WAIT_AFTER: c_uint = 4;
1607
1608pub const MREMAP_MAYMOVE: c_int = 1;
1609pub const MREMAP_FIXED: c_int = 2;
1610pub const MREMAP_DONTUNMAP: c_int = 4;
1611
1612// linux/nsfs.h
1613const NSIO: c_uint = 0xb7;
1614
1615pub const NS_GET_USERNS: Ioctl = _IO(NSIO, 0x1);
1616pub const NS_GET_PARENT: Ioctl = _IO(NSIO, 0x2);
1617pub const NS_GET_NSTYPE: Ioctl = _IO(NSIO, 0x3);
1618pub const NS_GET_OWNER_UID: Ioctl = _IO(NSIO, 0x4);
1619
1620pub const NS_GET_MNTNS_ID: Ioctl = _IOR::<__u64>(NSIO, 0x5);
1621
1622pub const NS_GET_PID_FROM_PIDNS: Ioctl = _IOR::<c_int>(NSIO, 0x6);
1623pub const NS_GET_TGID_FROM_PIDNS: Ioctl = _IOR::<c_int>(NSIO, 0x7);
1624pub const NS_GET_PID_IN_PIDNS: Ioctl = _IOR::<c_int>(NSIO, 0x8);
1625pub const NS_GET_TGID_IN_PIDNS: Ioctl = _IOR::<c_int>(NSIO, 0x9);
1626
1627pub const MNT_NS_INFO_SIZE_VER0: Ioctl = 16;
1628
1629pub const NS_MNT_GET_INFO: Ioctl = _IOR::<mnt_ns_info>(NSIO, 10);
1630pub const NS_MNT_GET_NEXT: Ioctl = _IOR::<mnt_ns_info>(NSIO, 11);
1631pub const NS_MNT_GET_PREV: Ioctl = _IOR::<mnt_ns_info>(NSIO, 12);
1632
1633pub const PR_SET_MDWE: c_int = 65;
1634pub const PR_GET_MDWE: c_int = 66;
1635pub const PR_MDWE_REFUSE_EXEC_GAIN: c_uint = 1 << 0;
1636pub const PR_MDWE_NO_INHERIT: c_uint = 1 << 1;
1637
1638pub const GRND_NONBLOCK: c_uint = 0x0001;
1639pub const GRND_RANDOM: c_uint = 0x0002;
1640pub const GRND_INSECURE: c_uint = 0x0004;
1641
1642// <linux/seccomp.h>
1643pub const SECCOMP_MODE_DISABLED: c_uint = 0;
1644pub const SECCOMP_MODE_STRICT: c_uint = 1;
1645pub const SECCOMP_MODE_FILTER: c_uint = 2;
1646
1647pub const SECCOMP_SET_MODE_STRICT: c_uint = 0;
1648pub const SECCOMP_SET_MODE_FILTER: c_uint = 1;
1649pub const SECCOMP_GET_ACTION_AVAIL: c_uint = 2;
1650pub const SECCOMP_GET_NOTIF_SIZES: c_uint = 3;
1651
1652pub const SECCOMP_FILTER_FLAG_TSYNC: c_ulong = 1 << 0;
1653pub const SECCOMP_FILTER_FLAG_LOG: c_ulong = 1 << 1;
1654pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: c_ulong = 1 << 2;
1655pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: c_ulong = 1 << 3;
1656pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: c_ulong = 1 << 4;
1657pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: c_ulong = 1 << 5;
1658
1659pub const SECCOMP_RET_KILL_PROCESS: c_uint = 0x80000000;
1660pub const SECCOMP_RET_KILL_THREAD: c_uint = 0x00000000;
1661pub const SECCOMP_RET_KILL: c_uint = SECCOMP_RET_KILL_THREAD;
1662pub const SECCOMP_RET_TRAP: c_uint = 0x00030000;
1663pub const SECCOMP_RET_ERRNO: c_uint = 0x00050000;
1664pub const SECCOMP_RET_USER_NOTIF: c_uint = 0x7fc00000;
1665pub const SECCOMP_RET_TRACE: c_uint = 0x7ff00000;
1666pub const SECCOMP_RET_LOG: c_uint = 0x7ffc0000;
1667pub const SECCOMP_RET_ALLOW: c_uint = 0x7fff0000;
1668
1669pub const SECCOMP_RET_ACTION_FULL: c_uint = 0xffff0000;
1670pub const SECCOMP_RET_ACTION: c_uint = 0x7fff0000;
1671pub const SECCOMP_RET_DATA: c_uint = 0x0000ffff;
1672
1673pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: c_ulong = 1;
1674
1675pub const SECCOMP_ADDFD_FLAG_SETFD: c_ulong = 1;
1676pub const SECCOMP_ADDFD_FLAG_SEND: c_ulong = 2;
1677
1678pub const TFD_CLOEXEC: c_int = O_CLOEXEC;
1679pub const TFD_NONBLOCK: c_int = O_NONBLOCK;
1680pub const TFD_TIMER_ABSTIME: c_int = 1;
1681pub const TFD_TIMER_CANCEL_ON_SET: c_int = 2;
1682
1683pub const FALLOC_FL_KEEP_SIZE: c_int = 0x01;
1684pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x02;
1685pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x08;
1686pub const FALLOC_FL_ZERO_RANGE: c_int = 0x10;
1687pub const FALLOC_FL_INSERT_RANGE: c_int = 0x20;
1688pub const FALLOC_FL_UNSHARE_RANGE: c_int = 0x40;
1689
1690#[deprecated(
1691    since = "0.2.55",
1692    note = "ENOATTR is not available on Linux; use ENODATA instead"
1693)]
1694pub const ENOATTR: c_int = crate::ENODATA;
1695
1696pub const SO_ORIGINAL_DST: c_int = 80;
1697
1698pub const IP_RECVFRAGSIZE: c_int = 25;
1699
1700pub const IPV6_FLOWINFO: c_int = 11;
1701pub const IPV6_FLOWLABEL_MGR: c_int = 32;
1702pub const IPV6_FLOWINFO_SEND: c_int = 33;
1703pub const IPV6_RECVFRAGSIZE: c_int = 77;
1704pub const IPV6_FREEBIND: c_int = 78;
1705pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x000fffff;
1706pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0ff00000;
1707
1708// SO_MEMINFO offsets
1709pub const SK_MEMINFO_RMEM_ALLOC: c_int = 0;
1710pub const SK_MEMINFO_RCVBUF: c_int = 1;
1711pub const SK_MEMINFO_WMEM_ALLOC: c_int = 2;
1712pub const SK_MEMINFO_SNDBUF: c_int = 3;
1713pub const SK_MEMINFO_FWD_ALLOC: c_int = 4;
1714pub const SK_MEMINFO_WMEM_QUEUED: c_int = 5;
1715pub const SK_MEMINFO_OPTMEM: c_int = 6;
1716pub const SK_MEMINFO_BACKLOG: c_int = 7;
1717pub const SK_MEMINFO_DROPS: c_int = 8;
1718
1719// linux/close_range.h
1720pub const CLOSE_RANGE_UNSHARE: c_uint = 1 << 1;
1721pub const CLOSE_RANGE_CLOEXEC: c_uint = 1 << 2;
1722
1723// linux/filter.h
1724pub const SKF_AD_OFF: c_int = -0x1000;
1725pub const SKF_AD_PROTOCOL: c_int = 0;
1726pub const SKF_AD_PKTTYPE: c_int = 4;
1727pub const SKF_AD_IFINDEX: c_int = 8;
1728pub const SKF_AD_NLATTR: c_int = 12;
1729pub const SKF_AD_NLATTR_NEST: c_int = 16;
1730pub const SKF_AD_MARK: c_int = 20;
1731pub const SKF_AD_QUEUE: c_int = 24;
1732pub const SKF_AD_HATYPE: c_int = 28;
1733pub const SKF_AD_RXHASH: c_int = 32;
1734pub const SKF_AD_CPU: c_int = 36;
1735pub const SKF_AD_ALU_XOR_X: c_int = 40;
1736pub const SKF_AD_VLAN_TAG: c_int = 44;
1737pub const SKF_AD_VLAN_TAG_PRESENT: c_int = 48;
1738pub const SKF_AD_PAY_OFFSET: c_int = 52;
1739pub const SKF_AD_RANDOM: c_int = 56;
1740pub const SKF_AD_VLAN_TPID: c_int = 60;
1741pub const SKF_AD_MAX: c_int = 64;
1742pub const SKF_NET_OFF: c_int = -0x100000;
1743pub const SKF_LL_OFF: c_int = -0x200000;
1744pub const BPF_NET_OFF: c_int = SKF_NET_OFF;
1745pub const BPF_LL_OFF: c_int = SKF_LL_OFF;
1746pub const BPF_MEMWORDS: c_int = 16;
1747pub const BPF_MAXINSNS: c_int = 4096;
1748
1749// linux/bpf_common.h
1750pub const BPF_LD: __u32 = 0x00;
1751pub const BPF_LDX: __u32 = 0x01;
1752pub const BPF_ST: __u32 = 0x02;
1753pub const BPF_STX: __u32 = 0x03;
1754pub const BPF_ALU: __u32 = 0x04;
1755pub const BPF_JMP: __u32 = 0x05;
1756pub const BPF_RET: __u32 = 0x06;
1757pub const BPF_MISC: __u32 = 0x07;
1758pub const BPF_W: __u32 = 0x00;
1759pub const BPF_H: __u32 = 0x08;
1760pub const BPF_B: __u32 = 0x10;
1761pub const BPF_IMM: __u32 = 0x00;
1762pub const BPF_ABS: __u32 = 0x20;
1763pub const BPF_IND: __u32 = 0x40;
1764pub const BPF_MEM: __u32 = 0x60;
1765pub const BPF_LEN: __u32 = 0x80;
1766pub const BPF_MSH: __u32 = 0xa0;
1767pub const BPF_ADD: __u32 = 0x00;
1768pub const BPF_SUB: __u32 = 0x10;
1769pub const BPF_MUL: __u32 = 0x20;
1770pub const BPF_DIV: __u32 = 0x30;
1771pub const BPF_OR: __u32 = 0x40;
1772pub const BPF_AND: __u32 = 0x50;
1773pub const BPF_LSH: __u32 = 0x60;
1774pub const BPF_RSH: __u32 = 0x70;
1775pub const BPF_NEG: __u32 = 0x80;
1776pub const BPF_MOD: __u32 = 0x90;
1777pub const BPF_XOR: __u32 = 0xa0;
1778pub const BPF_JA: __u32 = 0x00;
1779pub const BPF_JEQ: __u32 = 0x10;
1780pub const BPF_JGT: __u32 = 0x20;
1781pub const BPF_JGE: __u32 = 0x30;
1782pub const BPF_JSET: __u32 = 0x40;
1783pub const BPF_K: __u32 = 0x00;
1784pub const BPF_X: __u32 = 0x08;
1785
1786// linux/filter.h
1787
1788pub const BPF_A: __u32 = 0x10;
1789pub const BPF_TAX: __u32 = 0x00;
1790pub const BPF_TXA: __u32 = 0x80;
1791
1792// linux/openat2.h
1793pub const RESOLVE_NO_XDEV: crate::__u64 = 0x01;
1794pub const RESOLVE_NO_MAGICLINKS: crate::__u64 = 0x02;
1795pub const RESOLVE_NO_SYMLINKS: crate::__u64 = 0x04;
1796pub const RESOLVE_BENEATH: crate::__u64 = 0x08;
1797pub const RESOLVE_IN_ROOT: crate::__u64 = 0x10;
1798pub const RESOLVE_CACHED: crate::__u64 = 0x20;
1799
1800// linux/if_ether.h
1801pub const ETH_ALEN: c_int = 6;
1802pub const ETH_HLEN: c_int = 14;
1803pub const ETH_ZLEN: c_int = 60;
1804pub const ETH_DATA_LEN: c_int = 1500;
1805pub const ETH_FRAME_LEN: c_int = 1514;
1806pub const ETH_FCS_LEN: c_int = 4;
1807
1808// These are the defined Ethernet Protocol ID's.
1809pub const ETH_P_LOOP: c_int = 0x0060;
1810pub const ETH_P_PUP: c_int = 0x0200;
1811pub const ETH_P_PUPAT: c_int = 0x0201;
1812pub const ETH_P_IP: c_int = 0x0800;
1813pub const ETH_P_X25: c_int = 0x0805;
1814pub const ETH_P_ARP: c_int = 0x0806;
1815pub const ETH_P_BPQ: c_int = 0x08FF;
1816pub const ETH_P_IEEEPUP: c_int = 0x0a00;
1817pub const ETH_P_IEEEPUPAT: c_int = 0x0a01;
1818pub const ETH_P_BATMAN: c_int = 0x4305;
1819pub const ETH_P_DEC: c_int = 0x6000;
1820pub const ETH_P_DNA_DL: c_int = 0x6001;
1821pub const ETH_P_DNA_RC: c_int = 0x6002;
1822pub const ETH_P_DNA_RT: c_int = 0x6003;
1823pub const ETH_P_LAT: c_int = 0x6004;
1824pub const ETH_P_DIAG: c_int = 0x6005;
1825pub const ETH_P_CUST: c_int = 0x6006;
1826pub const ETH_P_SCA: c_int = 0x6007;
1827pub const ETH_P_TEB: c_int = 0x6558;
1828pub const ETH_P_RARP: c_int = 0x8035;
1829pub const ETH_P_ATALK: c_int = 0x809B;
1830pub const ETH_P_AARP: c_int = 0x80F3;
1831pub const ETH_P_8021Q: c_int = 0x8100;
1832pub const ETH_P_IPX: c_int = 0x8137;
1833pub const ETH_P_IPV6: c_int = 0x86DD;
1834pub const ETH_P_PAUSE: c_int = 0x8808;
1835pub const ETH_P_SLOW: c_int = 0x8809;
1836pub const ETH_P_WCCP: c_int = 0x883E;
1837pub const ETH_P_MPLS_UC: c_int = 0x8847;
1838pub const ETH_P_MPLS_MC: c_int = 0x8848;
1839pub const ETH_P_ATMMPOA: c_int = 0x884c;
1840pub const ETH_P_PPP_DISC: c_int = 0x8863;
1841pub const ETH_P_PPP_SES: c_int = 0x8864;
1842pub const ETH_P_LINK_CTL: c_int = 0x886c;
1843pub const ETH_P_ATMFATE: c_int = 0x8884;
1844pub const ETH_P_PAE: c_int = 0x888E;
1845pub const ETH_P_AOE: c_int = 0x88A2;
1846pub const ETH_P_8021AD: c_int = 0x88A8;
1847pub const ETH_P_802_EX1: c_int = 0x88B5;
1848pub const ETH_P_TIPC: c_int = 0x88CA;
1849pub const ETH_P_MACSEC: c_int = 0x88E5;
1850pub const ETH_P_8021AH: c_int = 0x88E7;
1851pub const ETH_P_MVRP: c_int = 0x88F5;
1852pub const ETH_P_1588: c_int = 0x88F7;
1853pub const ETH_P_PRP: c_int = 0x88FB;
1854pub const ETH_P_FCOE: c_int = 0x8906;
1855pub const ETH_P_TDLS: c_int = 0x890D;
1856pub const ETH_P_FIP: c_int = 0x8914;
1857pub const ETH_P_80221: c_int = 0x8917;
1858pub const ETH_P_LOOPBACK: c_int = 0x9000;
1859pub const ETH_P_QINQ1: c_int = 0x9100;
1860pub const ETH_P_QINQ2: c_int = 0x9200;
1861pub const ETH_P_QINQ3: c_int = 0x9300;
1862pub const ETH_P_EDSA: c_int = 0xDADA;
1863pub const ETH_P_AF_IUCV: c_int = 0xFBFB;
1864
1865pub const ETH_P_802_3_MIN: c_int = 0x0600;
1866
1867// Non DIX types. Won't clash for 1500 types.
1868pub const ETH_P_802_3: c_int = 0x0001;
1869pub const ETH_P_AX25: c_int = 0x0002;
1870pub const ETH_P_ALL: c_int = 0x0003;
1871pub const ETH_P_802_2: c_int = 0x0004;
1872pub const ETH_P_SNAP: c_int = 0x0005;
1873pub const ETH_P_DDCMP: c_int = 0x0006;
1874pub const ETH_P_WAN_PPP: c_int = 0x0007;
1875pub const ETH_P_PPP_MP: c_int = 0x0008;
1876pub const ETH_P_LOCALTALK: c_int = 0x0009;
1877pub const ETH_P_CANFD: c_int = 0x000D;
1878pub const ETH_P_PPPTALK: c_int = 0x0010;
1879pub const ETH_P_TR_802_2: c_int = 0x0011;
1880pub const ETH_P_MOBITEX: c_int = 0x0015;
1881pub const ETH_P_CONTROL: c_int = 0x0016;
1882pub const ETH_P_IRDA: c_int = 0x0017;
1883pub const ETH_P_ECONET: c_int = 0x0018;
1884pub const ETH_P_HDLC: c_int = 0x0019;
1885pub const ETH_P_ARCNET: c_int = 0x001A;
1886pub const ETH_P_DSA: c_int = 0x001B;
1887pub const ETH_P_TRAILER: c_int = 0x001C;
1888pub const ETH_P_PHONET: c_int = 0x00F5;
1889pub const ETH_P_IEEE802154: c_int = 0x00F6;
1890pub const ETH_P_CAIF: c_int = 0x00F7;
1891
1892// DIFF(main): changed to `c_short` in f62eb023ab
1893pub const POSIX_SPAWN_RESETIDS: c_int = 0x01;
1894pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02;
1895pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x04;
1896pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x08;
1897pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x10;
1898pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x20;
1899
1900// linux/netfilter/nfnetlink.h
1901pub const NFNLGRP_NONE: c_int = 0;
1902pub const NFNLGRP_CONNTRACK_NEW: c_int = 1;
1903pub const NFNLGRP_CONNTRACK_UPDATE: c_int = 2;
1904pub const NFNLGRP_CONNTRACK_DESTROY: c_int = 3;
1905pub const NFNLGRP_CONNTRACK_EXP_NEW: c_int = 4;
1906pub const NFNLGRP_CONNTRACK_EXP_UPDATE: c_int = 5;
1907pub const NFNLGRP_CONNTRACK_EXP_DESTROY: c_int = 6;
1908pub const NFNLGRP_NFTABLES: c_int = 7;
1909pub const NFNLGRP_ACCT_QUOTA: c_int = 8;
1910pub const NFNLGRP_NFTRACE: c_int = 9;
1911
1912pub const NFNETLINK_V0: c_int = 0;
1913
1914pub const NFNL_SUBSYS_NONE: c_int = 0;
1915pub const NFNL_SUBSYS_CTNETLINK: c_int = 1;
1916pub const NFNL_SUBSYS_CTNETLINK_EXP: c_int = 2;
1917pub const NFNL_SUBSYS_QUEUE: c_int = 3;
1918pub const NFNL_SUBSYS_ULOG: c_int = 4;
1919pub const NFNL_SUBSYS_OSF: c_int = 5;
1920pub const NFNL_SUBSYS_IPSET: c_int = 6;
1921pub const NFNL_SUBSYS_ACCT: c_int = 7;
1922pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: c_int = 8;
1923pub const NFNL_SUBSYS_CTHELPER: c_int = 9;
1924pub const NFNL_SUBSYS_NFTABLES: c_int = 10;
1925pub const NFNL_SUBSYS_NFT_COMPAT: c_int = 11;
1926pub const NFNL_SUBSYS_HOOK: c_int = 12;
1927pub const NFNL_SUBSYS_COUNT: c_int = 13;
1928
1929pub const NFNL_MSG_BATCH_BEGIN: c_int = crate::NLMSG_MIN_TYPE;
1930pub const NFNL_MSG_BATCH_END: c_int = crate::NLMSG_MIN_TYPE + 1;
1931
1932pub const NFNL_BATCH_UNSPEC: c_int = 0;
1933pub const NFNL_BATCH_GENID: c_int = 1;
1934
1935// linux/netfilter/nfnetlink_log.h
1936pub const NFULNL_MSG_PACKET: c_int = 0;
1937pub const NFULNL_MSG_CONFIG: c_int = 1;
1938
1939pub const NFULA_VLAN_UNSPEC: c_int = 0;
1940pub const NFULA_VLAN_PROTO: c_int = 1;
1941pub const NFULA_VLAN_TCI: c_int = 2;
1942
1943pub const NFULA_UNSPEC: c_int = 0;
1944pub const NFULA_PACKET_HDR: c_int = 1;
1945pub const NFULA_MARK: c_int = 2;
1946pub const NFULA_TIMESTAMP: c_int = 3;
1947pub const NFULA_IFINDEX_INDEV: c_int = 4;
1948pub const NFULA_IFINDEX_OUTDEV: c_int = 5;
1949pub const NFULA_IFINDEX_PHYSINDEV: c_int = 6;
1950pub const NFULA_IFINDEX_PHYSOUTDEV: c_int = 7;
1951pub const NFULA_HWADDR: c_int = 8;
1952pub const NFULA_PAYLOAD: c_int = 9;
1953pub const NFULA_PREFIX: c_int = 10;
1954pub const NFULA_UID: c_int = 11;
1955pub const NFULA_SEQ: c_int = 12;
1956pub const NFULA_SEQ_GLOBAL: c_int = 13;
1957pub const NFULA_GID: c_int = 14;
1958pub const NFULA_HWTYPE: c_int = 15;
1959pub const NFULA_HWHEADER: c_int = 16;
1960pub const NFULA_HWLEN: c_int = 17;
1961pub const NFULA_CT: c_int = 18;
1962pub const NFULA_CT_INFO: c_int = 19;
1963pub const NFULA_VLAN: c_int = 20;
1964pub const NFULA_L2HDR: c_int = 21;
1965
1966pub const NFULNL_CFG_CMD_NONE: c_int = 0;
1967pub const NFULNL_CFG_CMD_BIND: c_int = 1;
1968pub const NFULNL_CFG_CMD_UNBIND: c_int = 2;
1969pub const NFULNL_CFG_CMD_PF_BIND: c_int = 3;
1970pub const NFULNL_CFG_CMD_PF_UNBIND: c_int = 4;
1971
1972pub const NFULA_CFG_UNSPEC: c_int = 0;
1973pub const NFULA_CFG_CMD: c_int = 1;
1974pub const NFULA_CFG_MODE: c_int = 2;
1975pub const NFULA_CFG_NLBUFSIZ: c_int = 3;
1976pub const NFULA_CFG_TIMEOUT: c_int = 4;
1977pub const NFULA_CFG_QTHRESH: c_int = 5;
1978pub const NFULA_CFG_FLAGS: c_int = 6;
1979
1980pub const NFULNL_COPY_NONE: c_int = 0x00;
1981pub const NFULNL_COPY_META: c_int = 0x01;
1982pub const NFULNL_COPY_PACKET: c_int = 0x02;
1983
1984pub const NFULNL_CFG_F_SEQ: c_int = 0x0001;
1985pub const NFULNL_CFG_F_SEQ_GLOBAL: c_int = 0x0002;
1986pub const NFULNL_CFG_F_CONNTRACK: c_int = 0x0004;
1987
1988// linux/netfilter/nfnetlink_queue.h
1989pub const NFQNL_MSG_PACKET: c_int = 0;
1990pub const NFQNL_MSG_VERDICT: c_int = 1;
1991pub const NFQNL_MSG_CONFIG: c_int = 2;
1992pub const NFQNL_MSG_VERDICT_BATCH: c_int = 3;
1993
1994pub const NFQA_UNSPEC: c_int = 0;
1995pub const NFQA_PACKET_HDR: c_int = 1;
1996pub const NFQA_VERDICT_HDR: c_int = 2;
1997pub const NFQA_MARK: c_int = 3;
1998pub const NFQA_TIMESTAMP: c_int = 4;
1999pub const NFQA_IFINDEX_INDEV: c_int = 5;
2000pub const NFQA_IFINDEX_OUTDEV: c_int = 6;
2001pub const NFQA_IFINDEX_PHYSINDEV: c_int = 7;
2002pub const NFQA_IFINDEX_PHYSOUTDEV: c_int = 8;
2003pub const NFQA_HWADDR: c_int = 9;
2004pub const NFQA_PAYLOAD: c_int = 10;
2005pub const NFQA_CT: c_int = 11;
2006pub const NFQA_CT_INFO: c_int = 12;
2007pub const NFQA_CAP_LEN: c_int = 13;
2008pub const NFQA_SKB_INFO: c_int = 14;
2009pub const NFQA_EXP: c_int = 15;
2010pub const NFQA_UID: c_int = 16;
2011pub const NFQA_GID: c_int = 17;
2012pub const NFQA_SECCTX: c_int = 18;
2013pub const NFQA_VLAN: c_int = 19;
2014pub const NFQA_L2HDR: c_int = 20;
2015pub const NFQA_PRIORITY: c_int = 21;
2016
2017pub const NFQA_VLAN_UNSPEC: c_int = 0;
2018pub const NFQA_VLAN_PROTO: c_int = 1;
2019pub const NFQA_VLAN_TCI: c_int = 2;
2020
2021pub const NFQNL_CFG_CMD_NONE: c_int = 0;
2022pub const NFQNL_CFG_CMD_BIND: c_int = 1;
2023pub const NFQNL_CFG_CMD_UNBIND: c_int = 2;
2024pub const NFQNL_CFG_CMD_PF_BIND: c_int = 3;
2025pub const NFQNL_CFG_CMD_PF_UNBIND: c_int = 4;
2026
2027pub const NFQNL_COPY_NONE: c_int = 0;
2028pub const NFQNL_COPY_META: c_int = 1;
2029pub const NFQNL_COPY_PACKET: c_int = 2;
2030
2031pub const NFQA_CFG_UNSPEC: c_int = 0;
2032pub const NFQA_CFG_CMD: c_int = 1;
2033pub const NFQA_CFG_PARAMS: c_int = 2;
2034pub const NFQA_CFG_QUEUE_MAXLEN: c_int = 3;
2035pub const NFQA_CFG_MASK: c_int = 4;
2036pub const NFQA_CFG_FLAGS: c_int = 5;
2037
2038pub const NFQA_CFG_F_FAIL_OPEN: c_int = 0x0001;
2039pub const NFQA_CFG_F_CONNTRACK: c_int = 0x0002;
2040pub const NFQA_CFG_F_GSO: c_int = 0x0004;
2041pub const NFQA_CFG_F_UID_GID: c_int = 0x0008;
2042pub const NFQA_CFG_F_SECCTX: c_int = 0x0010;
2043pub const NFQA_CFG_F_MAX: c_int = 0x0020;
2044
2045pub const NFQA_SKB_CSUMNOTREADY: c_int = 0x0001;
2046pub const NFQA_SKB_GSO: c_int = 0x0002;
2047pub const NFQA_SKB_CSUM_NOTVERIFIED: c_int = 0x0004;
2048
2049// linux/genetlink.h
2050
2051pub const GENL_NAMSIZ: c_int = 16;
2052
2053pub const GENL_MIN_ID: c_int = crate::NLMSG_MIN_TYPE;
2054pub const GENL_MAX_ID: c_int = 1023;
2055
2056pub const GENL_ADMIN_PERM: c_int = 0x01;
2057pub const GENL_CMD_CAP_DO: c_int = 0x02;
2058pub const GENL_CMD_CAP_DUMP: c_int = 0x04;
2059pub const GENL_CMD_CAP_HASPOL: c_int = 0x08;
2060
2061pub const GENL_ID_CTRL: c_int = crate::NLMSG_MIN_TYPE;
2062
2063pub const CTRL_CMD_UNSPEC: c_int = 0;
2064pub const CTRL_CMD_NEWFAMILY: c_int = 1;
2065pub const CTRL_CMD_DELFAMILY: c_int = 2;
2066pub const CTRL_CMD_GETFAMILY: c_int = 3;
2067pub const CTRL_CMD_NEWOPS: c_int = 4;
2068pub const CTRL_CMD_DELOPS: c_int = 5;
2069pub const CTRL_CMD_GETOPS: c_int = 6;
2070pub const CTRL_CMD_NEWMCAST_GRP: c_int = 7;
2071pub const CTRL_CMD_DELMCAST_GRP: c_int = 8;
2072pub const CTRL_CMD_GETMCAST_GRP: c_int = 9;
2073
2074pub const CTRL_ATTR_UNSPEC: c_int = 0;
2075pub const CTRL_ATTR_FAMILY_ID: c_int = 1;
2076pub const CTRL_ATTR_FAMILY_NAME: c_int = 2;
2077pub const CTRL_ATTR_VERSION: c_int = 3;
2078pub const CTRL_ATTR_HDRSIZE: c_int = 4;
2079pub const CTRL_ATTR_MAXATTR: c_int = 5;
2080pub const CTRL_ATTR_OPS: c_int = 6;
2081pub const CTRL_ATTR_MCAST_GROUPS: c_int = 7;
2082
2083pub const CTRL_ATTR_OP_UNSPEC: c_int = 0;
2084pub const CTRL_ATTR_OP_ID: c_int = 1;
2085pub const CTRL_ATTR_OP_FLAGS: c_int = 2;
2086
2087pub const CTRL_ATTR_MCAST_GRP_UNSPEC: c_int = 0;
2088pub const CTRL_ATTR_MCAST_GRP_NAME: c_int = 1;
2089pub const CTRL_ATTR_MCAST_GRP_ID: c_int = 2;
2090
2091pub const PACKET_FANOUT: c_int = 18;
2092pub const PACKET_TX_HAS_OFF: c_int = 19;
2093pub const PACKET_QDISC_BYPASS: c_int = 20;
2094pub const PACKET_ROLLOVER_STATS: c_int = 21;
2095pub const PACKET_FANOUT_DATA: c_int = 22;
2096pub const PACKET_IGNORE_OUTGOING: c_int = 23;
2097pub const PACKET_VNET_HDR_SZ: c_int = 24;
2098
2099pub const PACKET_FANOUT_HASH: c_uint = 0;
2100pub const PACKET_FANOUT_LB: c_uint = 1;
2101pub const PACKET_FANOUT_CPU: c_uint = 2;
2102pub const PACKET_FANOUT_ROLLOVER: c_uint = 3;
2103pub const PACKET_FANOUT_RND: c_uint = 4;
2104pub const PACKET_FANOUT_QM: c_uint = 5;
2105pub const PACKET_FANOUT_CBPF: c_uint = 6;
2106pub const PACKET_FANOUT_EBPF: c_uint = 7;
2107pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000;
2108pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000;
2109pub const PACKET_FANOUT_FLAG_IGNORE_OUTGOING: c_uint = 0x4000;
2110pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000;
2111
2112pub const TP_STATUS_KERNEL: __u32 = 0;
2113pub const TP_STATUS_USER: __u32 = 1 << 0;
2114pub const TP_STATUS_COPY: __u32 = 1 << 1;
2115pub const TP_STATUS_LOSING: __u32 = 1 << 2;
2116pub const TP_STATUS_CSUMNOTREADY: __u32 = 1 << 3;
2117pub const TP_STATUS_VLAN_VALID: __u32 = 1 << 4;
2118pub const TP_STATUS_BLK_TMO: __u32 = 1 << 5;
2119pub const TP_STATUS_VLAN_TPID_VALID: __u32 = 1 << 6;
2120pub const TP_STATUS_CSUM_VALID: __u32 = 1 << 7;
2121
2122pub const TP_STATUS_AVAILABLE: __u32 = 0;
2123pub const TP_STATUS_SEND_REQUEST: __u32 = 1 << 0;
2124pub const TP_STATUS_SENDING: __u32 = 1 << 1;
2125pub const TP_STATUS_WRONG_FORMAT: __u32 = 1 << 2;
2126
2127pub const TP_STATUS_TS_SOFTWARE: __u32 = 1 << 29;
2128pub const TP_STATUS_TS_SYS_HARDWARE: __u32 = 1 << 30;
2129pub const TP_STATUS_TS_RAW_HARDWARE: __u32 = 1 << 31;
2130
2131pub const TP_FT_REQ_FILL_RXHASH: __u32 = 1;
2132
2133pub const TPACKET_ALIGNMENT: usize = 16;
2134
2135pub const TPACKET_HDRLEN: usize = ((size_of::<crate::tpacket_hdr>() + TPACKET_ALIGNMENT - 1)
2136    & !(TPACKET_ALIGNMENT - 1))
2137    + size_of::<crate::sockaddr_ll>();
2138pub const TPACKET2_HDRLEN: usize = ((size_of::<crate::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1)
2139    & !(TPACKET_ALIGNMENT - 1))
2140    + size_of::<crate::sockaddr_ll>();
2141pub const TPACKET3_HDRLEN: usize = ((size_of::<crate::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1)
2142    & !(TPACKET_ALIGNMENT - 1))
2143    + size_of::<crate::sockaddr_ll>();
2144
2145// linux/netfilter.h
2146pub const NF_DROP: c_int = 0;
2147pub const NF_ACCEPT: c_int = 1;
2148pub const NF_STOLEN: c_int = 2;
2149pub const NF_QUEUE: c_int = 3;
2150pub const NF_REPEAT: c_int = 4;
2151pub const NF_STOP: c_int = 5;
2152pub const NF_MAX_VERDICT: c_int = NF_STOP;
2153
2154pub const NF_VERDICT_MASK: c_int = 0x000000ff;
2155pub const NF_VERDICT_FLAG_QUEUE_BYPASS: c_int = 0x00008000;
2156
2157pub const NF_VERDICT_QMASK: c_int = 0xffff0000;
2158pub const NF_VERDICT_QBITS: c_int = 16;
2159
2160pub const NF_VERDICT_BITS: c_int = 16;
2161
2162pub const NF_INET_PRE_ROUTING: c_int = 0;
2163pub const NF_INET_LOCAL_IN: c_int = 1;
2164pub const NF_INET_FORWARD: c_int = 2;
2165pub const NF_INET_LOCAL_OUT: c_int = 3;
2166pub const NF_INET_POST_ROUTING: c_int = 4;
2167pub const NF_INET_NUMHOOKS: c_int = 5;
2168pub const NF_INET_INGRESS: c_int = NF_INET_NUMHOOKS;
2169
2170pub const NF_NETDEV_INGRESS: c_int = 0;
2171pub const NF_NETDEV_EGRESS: c_int = 1;
2172pub const NF_NETDEV_NUMHOOKS: c_int = 2;
2173
2174// Some NFPROTO are not compatible with musl and are defined in submodules.
2175pub const NFPROTO_UNSPEC: c_int = 0;
2176pub const NFPROTO_INET: c_int = 1;
2177pub const NFPROTO_IPV4: c_int = 2;
2178pub const NFPROTO_ARP: c_int = 3;
2179pub const NFPROTO_NETDEV: c_int = 5;
2180pub const NFPROTO_BRIDGE: c_int = 7;
2181pub const NFPROTO_IPV6: c_int = 10;
2182pub const NFPROTO_DECNET: c_int = 12;
2183pub const NFPROTO_NUMPROTO: c_int = 13;
2184
2185// linux/netfilter_arp.h
2186pub const NF_ARP: c_int = 0;
2187pub const NF_ARP_IN: c_int = 0;
2188pub const NF_ARP_OUT: c_int = 1;
2189pub const NF_ARP_FORWARD: c_int = 2;
2190pub const NF_ARP_NUMHOOKS: c_int = 3;
2191
2192// linux/netfilter_bridge.h
2193pub const NF_BR_PRE_ROUTING: c_int = 0;
2194pub const NF_BR_LOCAL_IN: c_int = 1;
2195pub const NF_BR_FORWARD: c_int = 2;
2196pub const NF_BR_LOCAL_OUT: c_int = 3;
2197pub const NF_BR_POST_ROUTING: c_int = 4;
2198pub const NF_BR_BROUTING: c_int = 5;
2199pub const NF_BR_NUMHOOKS: c_int = 6;
2200
2201pub const NF_BR_PRI_FIRST: c_int = crate::INT_MIN;
2202pub const NF_BR_PRI_NAT_DST_BRIDGED: c_int = -300;
2203pub const NF_BR_PRI_FILTER_BRIDGED: c_int = -200;
2204pub const NF_BR_PRI_BRNF: c_int = 0;
2205pub const NF_BR_PRI_NAT_DST_OTHER: c_int = 100;
2206pub const NF_BR_PRI_FILTER_OTHER: c_int = 200;
2207pub const NF_BR_PRI_NAT_SRC: c_int = 300;
2208pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX;
2209
2210// linux/netfilter_ipv4.h
2211pub const NF_IP_PRE_ROUTING: c_int = 0;
2212pub const NF_IP_LOCAL_IN: c_int = 1;
2213pub const NF_IP_FORWARD: c_int = 2;
2214pub const NF_IP_LOCAL_OUT: c_int = 3;
2215pub const NF_IP_POST_ROUTING: c_int = 4;
2216pub const NF_IP_NUMHOOKS: c_int = 5;
2217
2218pub const NF_IP_PRI_FIRST: c_int = crate::INT_MIN;
2219pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: c_int = -450;
2220pub const NF_IP_PRI_CONNTRACK_DEFRAG: c_int = -400;
2221pub const NF_IP_PRI_RAW: c_int = -300;
2222pub const NF_IP_PRI_SELINUX_FIRST: c_int = -225;
2223pub const NF_IP_PRI_CONNTRACK: c_int = -200;
2224pub const NF_IP_PRI_MANGLE: c_int = -150;
2225pub const NF_IP_PRI_NAT_DST: c_int = -100;
2226pub const NF_IP_PRI_FILTER: c_int = 0;
2227pub const NF_IP_PRI_SECURITY: c_int = 50;
2228pub const NF_IP_PRI_NAT_SRC: c_int = 100;
2229pub const NF_IP_PRI_SELINUX_LAST: c_int = 225;
2230pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300;
2231pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX;
2232pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX;
2233
2234// linux/netfilter_ipv6.h
2235pub const NF_IP6_PRE_ROUTING: c_int = 0;
2236pub const NF_IP6_LOCAL_IN: c_int = 1;
2237pub const NF_IP6_FORWARD: c_int = 2;
2238pub const NF_IP6_LOCAL_OUT: c_int = 3;
2239pub const NF_IP6_POST_ROUTING: c_int = 4;
2240pub const NF_IP6_NUMHOOKS: c_int = 5;
2241
2242pub const NF_IP6_PRI_FIRST: c_int = crate::INT_MIN;
2243pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: c_int = -450;
2244pub const NF_IP6_PRI_CONNTRACK_DEFRAG: c_int = -400;
2245pub const NF_IP6_PRI_RAW: c_int = -300;
2246pub const NF_IP6_PRI_SELINUX_FIRST: c_int = -225;
2247pub const NF_IP6_PRI_CONNTRACK: c_int = -200;
2248pub const NF_IP6_PRI_MANGLE: c_int = -150;
2249pub const NF_IP6_PRI_NAT_DST: c_int = -100;
2250pub const NF_IP6_PRI_FILTER: c_int = 0;
2251pub const NF_IP6_PRI_SECURITY: c_int = 50;
2252pub const NF_IP6_PRI_NAT_SRC: c_int = 100;
2253pub const NF_IP6_PRI_SELINUX_LAST: c_int = 225;
2254pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300;
2255pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX;
2256
2257// linux/netfilter_ipv6/ip6_tables.h
2258pub const IP6T_SO_ORIGINAL_DST: c_int = 80;
2259
2260pub const SIOCSHWTSTAMP: c_ulong = 0x000089b0;
2261pub const SIOCGHWTSTAMP: c_ulong = 0x000089b1;
2262
2263// wireless.h
2264pub const WIRELESS_EXT: c_ulong = 0x16;
2265
2266pub const SIOCSIWCOMMIT: c_ulong = 0x8B00;
2267pub const SIOCGIWNAME: c_ulong = 0x8B01;
2268
2269pub const SIOCSIWNWID: c_ulong = 0x8B02;
2270pub const SIOCGIWNWID: c_ulong = 0x8B03;
2271pub const SIOCSIWFREQ: c_ulong = 0x8B04;
2272pub const SIOCGIWFREQ: c_ulong = 0x8B05;
2273pub const SIOCSIWMODE: c_ulong = 0x8B06;
2274pub const SIOCGIWMODE: c_ulong = 0x8B07;
2275pub const SIOCSIWSENS: c_ulong = 0x8B08;
2276pub const SIOCGIWSENS: c_ulong = 0x8B09;
2277
2278pub const SIOCSIWRANGE: c_ulong = 0x8B0A;
2279pub const SIOCGIWRANGE: c_ulong = 0x8B0B;
2280pub const SIOCSIWPRIV: c_ulong = 0x8B0C;
2281pub const SIOCGIWPRIV: c_ulong = 0x8B0D;
2282pub const SIOCSIWSTATS: c_ulong = 0x8B0E;
2283pub const SIOCGIWSTATS: c_ulong = 0x8B0F;
2284
2285pub const SIOCSIWSPY: c_ulong = 0x8B10;
2286pub const SIOCGIWSPY: c_ulong = 0x8B11;
2287pub const SIOCSIWTHRSPY: c_ulong = 0x8B12;
2288pub const SIOCGIWTHRSPY: c_ulong = 0x8B13;
2289
2290pub const SIOCSIWAP: c_ulong = 0x8B14;
2291pub const SIOCGIWAP: c_ulong = 0x8B15;
2292pub const SIOCGIWAPLIST: c_ulong = 0x8B17;
2293pub const SIOCSIWSCAN: c_ulong = 0x8B18;
2294pub const SIOCGIWSCAN: c_ulong = 0x8B19;
2295
2296pub const SIOCSIWESSID: c_ulong = 0x8B1A;
2297pub const SIOCGIWESSID: c_ulong = 0x8B1B;
2298pub const SIOCSIWNICKN: c_ulong = 0x8B1C;
2299pub const SIOCGIWNICKN: c_ulong = 0x8B1D;
2300
2301pub const SIOCSIWRATE: c_ulong = 0x8B20;
2302pub const SIOCGIWRATE: c_ulong = 0x8B21;
2303pub const SIOCSIWRTS: c_ulong = 0x8B22;
2304pub const SIOCGIWRTS: c_ulong = 0x8B23;
2305pub const SIOCSIWFRAG: c_ulong = 0x8B24;
2306pub const SIOCGIWFRAG: c_ulong = 0x8B25;
2307pub const SIOCSIWTXPOW: c_ulong = 0x8B26;
2308pub const SIOCGIWTXPOW: c_ulong = 0x8B27;
2309pub const SIOCSIWRETRY: c_ulong = 0x8B28;
2310pub const SIOCGIWRETRY: c_ulong = 0x8B29;
2311
2312pub const SIOCSIWENCODE: c_ulong = 0x8B2A;
2313pub const SIOCGIWENCODE: c_ulong = 0x8B2B;
2314
2315pub const SIOCSIWPOWER: c_ulong = 0x8B2C;
2316pub const SIOCGIWPOWER: c_ulong = 0x8B2D;
2317
2318pub const SIOCSIWGENIE: c_ulong = 0x8B30;
2319pub const SIOCGIWGENIE: c_ulong = 0x8B31;
2320
2321pub const SIOCSIWMLME: c_ulong = 0x8B16;
2322
2323pub const SIOCSIWAUTH: c_ulong = 0x8B32;
2324pub const SIOCGIWAUTH: c_ulong = 0x8B33;
2325
2326pub const SIOCSIWENCODEEXT: c_ulong = 0x8B34;
2327pub const SIOCGIWENCODEEXT: c_ulong = 0x8B35;
2328
2329pub const SIOCSIWPMKSA: c_ulong = 0x8B36;
2330
2331pub const SIOCIWFIRSTPRIV: c_ulong = 0x8BE0;
2332pub const SIOCIWLASTPRIV: c_ulong = 0x8BFF;
2333
2334pub const SIOCIWFIRST: c_ulong = 0x8B00;
2335pub const SIOCIWLAST: c_ulong = SIOCIWLASTPRIV;
2336
2337pub const IWEVTXDROP: c_ulong = 0x8C00;
2338pub const IWEVQUAL: c_ulong = 0x8C01;
2339pub const IWEVCUSTOM: c_ulong = 0x8C02;
2340pub const IWEVREGISTERED: c_ulong = 0x8C03;
2341pub const IWEVEXPIRED: c_ulong = 0x8C04;
2342pub const IWEVGENIE: c_ulong = 0x8C05;
2343pub const IWEVMICHAELMICFAILURE: c_ulong = 0x8C06;
2344pub const IWEVASSOCREQIE: c_ulong = 0x8C07;
2345pub const IWEVASSOCRESPIE: c_ulong = 0x8C08;
2346pub const IWEVPMKIDCAND: c_ulong = 0x8C09;
2347pub const IWEVFIRST: c_ulong = 0x8C00;
2348
2349pub const IW_PRIV_TYPE_MASK: c_ulong = 0x7000;
2350pub const IW_PRIV_TYPE_NONE: c_ulong = 0x0000;
2351pub const IW_PRIV_TYPE_BYTE: c_ulong = 0x1000;
2352pub const IW_PRIV_TYPE_CHAR: c_ulong = 0x2000;
2353pub const IW_PRIV_TYPE_INT: c_ulong = 0x4000;
2354pub const IW_PRIV_TYPE_FLOAT: c_ulong = 0x5000;
2355pub const IW_PRIV_TYPE_ADDR: c_ulong = 0x6000;
2356
2357pub const IW_PRIV_SIZE_FIXED: c_ulong = 0x0800;
2358
2359pub const IW_PRIV_SIZE_MASK: c_ulong = 0x07FF;
2360
2361pub const IW_MAX_FREQUENCIES: usize = 32;
2362pub const IW_MAX_BITRATES: usize = 32;
2363pub const IW_MAX_TXPOWER: usize = 8;
2364pub const IW_MAX_SPY: usize = 8;
2365pub const IW_MAX_AP: usize = 64;
2366pub const IW_ESSID_MAX_SIZE: usize = 32;
2367
2368pub const IW_MODE_AUTO: usize = 0;
2369pub const IW_MODE_ADHOC: usize = 1;
2370pub const IW_MODE_INFRA: usize = 2;
2371pub const IW_MODE_MASTER: usize = 3;
2372pub const IW_MODE_REPEAT: usize = 4;
2373pub const IW_MODE_SECOND: usize = 5;
2374pub const IW_MODE_MONITOR: usize = 6;
2375pub const IW_MODE_MESH: usize = 7;
2376
2377pub const IW_QUAL_QUAL_UPDATED: c_ulong = 0x01;
2378pub const IW_QUAL_LEVEL_UPDATED: c_ulong = 0x02;
2379pub const IW_QUAL_NOISE_UPDATED: c_ulong = 0x04;
2380pub const IW_QUAL_ALL_UPDATED: c_ulong = 0x07;
2381pub const IW_QUAL_DBM: c_ulong = 0x08;
2382pub const IW_QUAL_QUAL_INVALID: c_ulong = 0x10;
2383pub const IW_QUAL_LEVEL_INVALID: c_ulong = 0x20;
2384pub const IW_QUAL_NOISE_INVALID: c_ulong = 0x40;
2385pub const IW_QUAL_RCPI: c_ulong = 0x80;
2386pub const IW_QUAL_ALL_INVALID: c_ulong = 0x70;
2387
2388pub const IW_FREQ_AUTO: c_ulong = 0x00;
2389pub const IW_FREQ_FIXED: c_ulong = 0x01;
2390
2391pub const IW_MAX_ENCODING_SIZES: usize = 8;
2392pub const IW_ENCODING_TOKEN_MAX: usize = 64;
2393
2394pub const IW_ENCODE_INDEX: c_ulong = 0x00FF;
2395pub const IW_ENCODE_FLAGS: c_ulong = 0xFF00;
2396pub const IW_ENCODE_MODE: c_ulong = 0xF000;
2397pub const IW_ENCODE_DISABLED: c_ulong = 0x8000;
2398pub const IW_ENCODE_ENABLED: c_ulong = 0x0000;
2399pub const IW_ENCODE_RESTRICTED: c_ulong = 0x4000;
2400pub const IW_ENCODE_OPEN: c_ulong = 0x2000;
2401pub const IW_ENCODE_NOKEY: c_ulong = 0x0800;
2402pub const IW_ENCODE_TEMP: c_ulong = 0x0400;
2403
2404pub const IW_POWER_ON: c_ulong = 0x0000;
2405pub const IW_POWER_TYPE: c_ulong = 0xF000;
2406pub const IW_POWER_PERIOD: c_ulong = 0x1000;
2407pub const IW_POWER_TIMEOUT: c_ulong = 0x2000;
2408pub const IW_POWER_MODE: c_ulong = 0x0F00;
2409pub const IW_POWER_UNICAST_R: c_ulong = 0x0100;
2410pub const IW_POWER_MULTICAST_R: c_ulong = 0x0200;
2411pub const IW_POWER_ALL_R: c_ulong = 0x0300;
2412pub const IW_POWER_FORCE_S: c_ulong = 0x0400;
2413pub const IW_POWER_REPEATER: c_ulong = 0x0800;
2414pub const IW_POWER_MODIFIER: c_ulong = 0x000F;
2415pub const IW_POWER_MIN: c_ulong = 0x0001;
2416pub const IW_POWER_MAX: c_ulong = 0x0002;
2417pub const IW_POWER_RELATIVE: c_ulong = 0x0004;
2418
2419pub const IW_TXPOW_TYPE: c_ulong = 0x00FF;
2420pub const IW_TXPOW_DBM: c_ulong = 0x0000;
2421pub const IW_TXPOW_MWATT: c_ulong = 0x0001;
2422pub const IW_TXPOW_RELATIVE: c_ulong = 0x0002;
2423pub const IW_TXPOW_RANGE: c_ulong = 0x1000;
2424
2425pub const IW_RETRY_ON: c_ulong = 0x0000;
2426pub const IW_RETRY_TYPE: c_ulong = 0xF000;
2427pub const IW_RETRY_LIMIT: c_ulong = 0x1000;
2428pub const IW_RETRY_LIFETIME: c_ulong = 0x2000;
2429pub const IW_RETRY_MODIFIER: c_ulong = 0x00FF;
2430pub const IW_RETRY_MIN: c_ulong = 0x0001;
2431pub const IW_RETRY_MAX: c_ulong = 0x0002;
2432pub const IW_RETRY_RELATIVE: c_ulong = 0x0004;
2433pub const IW_RETRY_SHORT: c_ulong = 0x0010;
2434pub const IW_RETRY_LONG: c_ulong = 0x0020;
2435
2436pub const IW_SCAN_DEFAULT: c_ulong = 0x0000;
2437pub const IW_SCAN_ALL_ESSID: c_ulong = 0x0001;
2438pub const IW_SCAN_THIS_ESSID: c_ulong = 0x0002;
2439pub const IW_SCAN_ALL_FREQ: c_ulong = 0x0004;
2440pub const IW_SCAN_THIS_FREQ: c_ulong = 0x0008;
2441pub const IW_SCAN_ALL_MODE: c_ulong = 0x0010;
2442pub const IW_SCAN_THIS_MODE: c_ulong = 0x0020;
2443pub const IW_SCAN_ALL_RATE: c_ulong = 0x0040;
2444pub const IW_SCAN_THIS_RATE: c_ulong = 0x0080;
2445
2446pub const IW_SCAN_TYPE_ACTIVE: usize = 0;
2447pub const IW_SCAN_TYPE_PASSIVE: usize = 1;
2448
2449pub const IW_SCAN_MAX_DATA: usize = 4096;
2450
2451pub const IW_SCAN_CAPA_NONE: c_ulong = 0x00;
2452pub const IW_SCAN_CAPA_ESSID: c_ulong = 0x01;
2453pub const IW_SCAN_CAPA_BSSID: c_ulong = 0x02;
2454pub const IW_SCAN_CAPA_CHANNEL: c_ulong = 0x04;
2455pub const IW_SCAN_CAPA_MODE: c_ulong = 0x08;
2456pub const IW_SCAN_CAPA_RATE: c_ulong = 0x10;
2457pub const IW_SCAN_CAPA_TYPE: c_ulong = 0x20;
2458pub const IW_SCAN_CAPA_TIME: c_ulong = 0x40;
2459
2460pub const IW_CUSTOM_MAX: c_ulong = 256;
2461
2462pub const IW_GENERIC_IE_MAX: c_ulong = 1024;
2463
2464pub const IW_MLME_DEAUTH: c_ulong = 0;
2465pub const IW_MLME_DISASSOC: c_ulong = 1;
2466pub const IW_MLME_AUTH: c_ulong = 2;
2467pub const IW_MLME_ASSOC: c_ulong = 3;
2468
2469pub const IW_AUTH_INDEX: c_ulong = 0x0FFF;
2470pub const IW_AUTH_FLAGS: c_ulong = 0xF000;
2471
2472pub const IW_AUTH_WPA_VERSION: usize = 0;
2473pub const IW_AUTH_CIPHER_PAIRWISE: usize = 1;
2474pub const IW_AUTH_CIPHER_GROUP: usize = 2;
2475pub const IW_AUTH_KEY_MGMT: usize = 3;
2476pub const IW_AUTH_TKIP_COUNTERMEASURES: usize = 4;
2477pub const IW_AUTH_DROP_UNENCRYPTED: usize = 5;
2478pub const IW_AUTH_80211_AUTH_ALG: usize = 6;
2479pub const IW_AUTH_WPA_ENABLED: usize = 7;
2480pub const IW_AUTH_RX_UNENCRYPTED_EAPOL: usize = 8;
2481pub const IW_AUTH_ROAMING_CONTROL: usize = 9;
2482pub const IW_AUTH_PRIVACY_INVOKED: usize = 10;
2483pub const IW_AUTH_CIPHER_GROUP_MGMT: usize = 11;
2484pub const IW_AUTH_MFP: usize = 12;
2485
2486pub const IW_AUTH_WPA_VERSION_DISABLED: c_ulong = 0x00000001;
2487pub const IW_AUTH_WPA_VERSION_WPA: c_ulong = 0x00000002;
2488pub const IW_AUTH_WPA_VERSION_WPA2: c_ulong = 0x00000004;
2489
2490pub const IW_AUTH_CIPHER_NONE: c_ulong = 0x00000001;
2491pub const IW_AUTH_CIPHER_WEP40: c_ulong = 0x00000002;
2492pub const IW_AUTH_CIPHER_TKIP: c_ulong = 0x00000004;
2493pub const IW_AUTH_CIPHER_CCMP: c_ulong = 0x00000008;
2494pub const IW_AUTH_CIPHER_WEP104: c_ulong = 0x00000010;
2495pub const IW_AUTH_CIPHER_AES_CMAC: c_ulong = 0x00000020;
2496
2497pub const IW_AUTH_KEY_MGMT_802_1X: usize = 1;
2498pub const IW_AUTH_KEY_MGMT_PSK: usize = 2;
2499
2500pub const IW_AUTH_ALG_OPEN_SYSTEM: c_ulong = 0x00000001;
2501pub const IW_AUTH_ALG_SHARED_KEY: c_ulong = 0x00000002;
2502pub const IW_AUTH_ALG_LEAP: c_ulong = 0x00000004;
2503
2504pub const IW_AUTH_ROAMING_ENABLE: usize = 0;
2505pub const IW_AUTH_ROAMING_DISABLE: usize = 1;
2506
2507pub const IW_AUTH_MFP_DISABLED: usize = 0;
2508pub const IW_AUTH_MFP_OPTIONAL: usize = 1;
2509pub const IW_AUTH_MFP_REQUIRED: usize = 2;
2510
2511pub const IW_ENCODE_SEQ_MAX_SIZE: usize = 8;
2512
2513pub const IW_ENCODE_ALG_NONE: usize = 0;
2514pub const IW_ENCODE_ALG_WEP: usize = 1;
2515pub const IW_ENCODE_ALG_TKIP: usize = 2;
2516pub const IW_ENCODE_ALG_CCMP: usize = 3;
2517pub const IW_ENCODE_ALG_PMK: usize = 4;
2518pub const IW_ENCODE_ALG_AES_CMAC: usize = 5;
2519
2520pub const IW_ENCODE_EXT_TX_SEQ_VALID: c_ulong = 0x00000001;
2521pub const IW_ENCODE_EXT_RX_SEQ_VALID: c_ulong = 0x00000002;
2522pub const IW_ENCODE_EXT_GROUP_KEY: c_ulong = 0x00000004;
2523pub const IW_ENCODE_EXT_SET_TX_KEY: c_ulong = 0x00000008;
2524
2525pub const IW_MICFAILURE_KEY_ID: c_ulong = 0x00000003;
2526pub const IW_MICFAILURE_GROUP: c_ulong = 0x00000004;
2527pub const IW_MICFAILURE_PAIRWISE: c_ulong = 0x00000008;
2528pub const IW_MICFAILURE_STAKEY: c_ulong = 0x00000010;
2529pub const IW_MICFAILURE_COUNT: c_ulong = 0x00000060;
2530
2531pub const IW_ENC_CAPA_WPA: c_ulong = 0x00000001;
2532pub const IW_ENC_CAPA_WPA2: c_ulong = 0x00000002;
2533pub const IW_ENC_CAPA_CIPHER_TKIP: c_ulong = 0x00000004;
2534pub const IW_ENC_CAPA_CIPHER_CCMP: c_ulong = 0x00000008;
2535pub const IW_ENC_CAPA_4WAY_HANDSHAKE: c_ulong = 0x00000010;
2536
2537pub const IW_EVENT_CAPA_K_0: c_ulong = 0x4000050; //   IW_EVENT_CAPA_MASK(0x8B04) | IW_EVENT_CAPA_MASK(0x8B06) | IW_EVENT_CAPA_MASK(0x8B1A);
2538pub const IW_EVENT_CAPA_K_1: c_ulong = 0x400; //   W_EVENT_CAPA_MASK(0x8B2A);
2539
2540pub const IW_PMKSA_ADD: usize = 1;
2541pub const IW_PMKSA_REMOVE: usize = 2;
2542pub const IW_PMKSA_FLUSH: usize = 3;
2543
2544pub const IW_PMKID_LEN: usize = 16;
2545
2546pub const IW_PMKID_CAND_PREAUTH: c_ulong = 0x00000001;
2547
2548pub const IW_EV_LCP_PK_LEN: usize = 4;
2549
2550pub const IW_EV_CHAR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + crate::IFNAMSIZ;
2551pub const IW_EV_UINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + size_of::<u32>();
2552pub const IW_EV_FREQ_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + size_of::<iw_freq>();
2553pub const IW_EV_PARAM_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + size_of::<iw_param>();
2554pub const IW_EV_ADDR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + size_of::<crate::sockaddr>();
2555pub const IW_EV_QUAL_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + size_of::<iw_quality>();
2556pub const IW_EV_POINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + 4;
2557
2558// linux/neighbor.h
2559pub const NUD_NONE: u16 = 0x00;
2560pub const NUD_INCOMPLETE: u16 = 0x01;
2561pub const NUD_REACHABLE: u16 = 0x02;
2562pub const NUD_STALE: u16 = 0x04;
2563pub const NUD_DELAY: u16 = 0x08;
2564pub const NUD_PROBE: u16 = 0x10;
2565pub const NUD_FAILED: u16 = 0x20;
2566pub const NUD_NOARP: u16 = 0x40;
2567pub const NUD_PERMANENT: u16 = 0x80;
2568
2569pub const NTF_USE: u8 = 0x01;
2570pub const NTF_SELF: u8 = 0x02;
2571pub const NTF_MASTER: u8 = 0x04;
2572pub const NTF_PROXY: u8 = 0x08;
2573pub const NTF_ROUTER: u8 = 0x80;
2574
2575pub const NDA_UNSPEC: c_ushort = 0;
2576pub const NDA_DST: c_ushort = 1;
2577pub const NDA_LLADDR: c_ushort = 2;
2578pub const NDA_CACHEINFO: c_ushort = 3;
2579pub const NDA_PROBES: c_ushort = 4;
2580pub const NDA_VLAN: c_ushort = 5;
2581pub const NDA_PORT: c_ushort = 6;
2582pub const NDA_VNI: c_ushort = 7;
2583pub const NDA_IFINDEX: c_ushort = 8;
2584
2585// linux/netlink.h
2586
2587pub const NLM_F_BULK: c_int = 0x200;
2588
2589// linux/rtnetlink.h
2590pub const TCA_UNSPEC: c_ushort = 0;
2591pub const TCA_KIND: c_ushort = 1;
2592pub const TCA_OPTIONS: c_ushort = 2;
2593pub const TCA_STATS: c_ushort = 3;
2594pub const TCA_XSTATS: c_ushort = 4;
2595pub const TCA_RATE: c_ushort = 5;
2596pub const TCA_FCNT: c_ushort = 6;
2597pub const TCA_STATS2: c_ushort = 7;
2598pub const TCA_STAB: c_ushort = 8;
2599
2600pub const RTM_NEWLINK: u16 = 16;
2601pub const RTM_DELLINK: u16 = 17;
2602pub const RTM_GETLINK: u16 = 18;
2603pub const RTM_SETLINK: u16 = 19;
2604pub const RTM_NEWADDR: u16 = 20;
2605pub const RTM_DELADDR: u16 = 21;
2606pub const RTM_GETADDR: u16 = 22;
2607pub const RTM_NEWROUTE: u16 = 24;
2608pub const RTM_DELROUTE: u16 = 25;
2609pub const RTM_GETROUTE: u16 = 26;
2610pub const RTM_NEWNEIGH: u16 = 28;
2611pub const RTM_DELNEIGH: u16 = 29;
2612pub const RTM_GETNEIGH: u16 = 30;
2613pub const RTM_NEWRULE: u16 = 32;
2614pub const RTM_DELRULE: u16 = 33;
2615pub const RTM_GETRULE: u16 = 34;
2616pub const RTM_NEWQDISC: u16 = 36;
2617pub const RTM_DELQDISC: u16 = 37;
2618pub const RTM_GETQDISC: u16 = 38;
2619pub const RTM_NEWTCLASS: u16 = 40;
2620pub const RTM_DELTCLASS: u16 = 41;
2621pub const RTM_GETTCLASS: u16 = 42;
2622pub const RTM_NEWTFILTER: u16 = 44;
2623pub const RTM_DELTFILTER: u16 = 45;
2624pub const RTM_GETTFILTER: u16 = 46;
2625pub const RTM_NEWACTION: u16 = 48;
2626pub const RTM_DELACTION: u16 = 49;
2627pub const RTM_GETACTION: u16 = 50;
2628pub const RTM_NEWPREFIX: u16 = 52;
2629pub const RTM_GETMULTICAST: u16 = 58;
2630pub const RTM_GETANYCAST: u16 = 62;
2631pub const RTM_NEWNEIGHTBL: u16 = 64;
2632pub const RTM_GETNEIGHTBL: u16 = 66;
2633pub const RTM_SETNEIGHTBL: u16 = 67;
2634pub const RTM_NEWNDUSEROPT: u16 = 68;
2635pub const RTM_NEWADDRLABEL: u16 = 72;
2636pub const RTM_DELADDRLABEL: u16 = 73;
2637pub const RTM_GETADDRLABEL: u16 = 74;
2638pub const RTM_GETDCB: u16 = 78;
2639pub const RTM_SETDCB: u16 = 79;
2640pub const RTM_NEWNETCONF: u16 = 80;
2641pub const RTM_GETNETCONF: u16 = 82;
2642pub const RTM_NEWMDB: u16 = 84;
2643pub const RTM_DELMDB: u16 = 85;
2644pub const RTM_GETMDB: u16 = 86;
2645pub const RTM_NEWNSID: u16 = 88;
2646pub const RTM_DELNSID: u16 = 89;
2647pub const RTM_GETNSID: u16 = 90;
2648
2649pub const RTM_F_NOTIFY: c_uint = 0x100;
2650pub const RTM_F_CLONED: c_uint = 0x200;
2651pub const RTM_F_EQUALIZE: c_uint = 0x400;
2652pub const RTM_F_PREFIX: c_uint = 0x800;
2653
2654pub const RTA_UNSPEC: c_ushort = 0;
2655pub const RTA_DST: c_ushort = 1;
2656pub const RTA_SRC: c_ushort = 2;
2657pub const RTA_IIF: c_ushort = 3;
2658pub const RTA_OIF: c_ushort = 4;
2659pub const RTA_GATEWAY: c_ushort = 5;
2660pub const RTA_PRIORITY: c_ushort = 6;
2661pub const RTA_PREFSRC: c_ushort = 7;
2662pub const RTA_METRICS: c_ushort = 8;
2663pub const RTA_MULTIPATH: c_ushort = 9;
2664pub const RTA_PROTOINFO: c_ushort = 10; // No longer used
2665pub const RTA_FLOW: c_ushort = 11;
2666pub const RTA_CACHEINFO: c_ushort = 12;
2667pub const RTA_SESSION: c_ushort = 13; // No longer used
2668pub const RTA_MP_ALGO: c_ushort = 14; // No longer used
2669pub const RTA_TABLE: c_ushort = 15;
2670pub const RTA_MARK: c_ushort = 16;
2671pub const RTA_MFC_STATS: c_ushort = 17;
2672
2673pub const RTN_UNSPEC: c_uchar = 0;
2674pub const RTN_UNICAST: c_uchar = 1;
2675pub const RTN_LOCAL: c_uchar = 2;
2676pub const RTN_BROADCAST: c_uchar = 3;
2677pub const RTN_ANYCAST: c_uchar = 4;
2678pub const RTN_MULTICAST: c_uchar = 5;
2679pub const RTN_BLACKHOLE: c_uchar = 6;
2680pub const RTN_UNREACHABLE: c_uchar = 7;
2681pub const RTN_PROHIBIT: c_uchar = 8;
2682pub const RTN_THROW: c_uchar = 9;
2683pub const RTN_NAT: c_uchar = 10;
2684pub const RTN_XRESOLVE: c_uchar = 11;
2685
2686pub const RTPROT_UNSPEC: c_uchar = 0;
2687pub const RTPROT_REDIRECT: c_uchar = 1;
2688pub const RTPROT_KERNEL: c_uchar = 2;
2689pub const RTPROT_BOOT: c_uchar = 3;
2690pub const RTPROT_STATIC: c_uchar = 4;
2691
2692pub const RT_SCOPE_UNIVERSE: c_uchar = 0;
2693pub const RT_SCOPE_SITE: c_uchar = 200;
2694pub const RT_SCOPE_LINK: c_uchar = 253;
2695pub const RT_SCOPE_HOST: c_uchar = 254;
2696pub const RT_SCOPE_NOWHERE: c_uchar = 255;
2697
2698pub const RT_TABLE_UNSPEC: c_uchar = 0;
2699pub const RT_TABLE_COMPAT: c_uchar = 252;
2700pub const RT_TABLE_DEFAULT: c_uchar = 253;
2701pub const RT_TABLE_MAIN: c_uchar = 254;
2702pub const RT_TABLE_LOCAL: c_uchar = 255;
2703
2704pub const RTMSG_OVERRUN: u32 = crate::NLMSG_OVERRUN as u32;
2705pub const RTMSG_NEWDEVICE: u32 = 0x11;
2706pub const RTMSG_DELDEVICE: u32 = 0x12;
2707pub const RTMSG_NEWROUTE: u32 = 0x21;
2708pub const RTMSG_DELROUTE: u32 = 0x22;
2709pub const RTMSG_NEWRULE: u32 = 0x31;
2710pub const RTMSG_DELRULE: u32 = 0x32;
2711pub const RTMSG_CONTROL: u32 = 0x40;
2712pub const RTMSG_AR_FAILED: u32 = 0x51;
2713
2714pub const RTEXT_FILTER_VF: c_int = 1 << 0;
2715pub const RTEXT_FILTER_BRVLAN: c_int = 1 << 1;
2716pub const RTEXT_FILTER_BRVLAN_COMPRESSED: c_int = 1 << 2;
2717pub const RTEXT_FILTER_SKIP_STATS: c_int = 1 << 3;
2718pub const RTEXT_FILTER_MRP: c_int = 1 << 4;
2719pub const RTEXT_FILTER_CFM_CONFIG: c_int = 1 << 5;
2720pub const RTEXT_FILTER_CFM_STATUS: c_int = 1 << 6;
2721
2722// userspace compat definitions for RTNLGRP_*
2723pub const RTMGRP_LINK: c_int = 0x00001;
2724pub const RTMGRP_NOTIFY: c_int = 0x00002;
2725pub const RTMGRP_NEIGH: c_int = 0x00004;
2726pub const RTMGRP_TC: c_int = 0x00008;
2727pub const RTMGRP_IPV4_IFADDR: c_int = 0x00010;
2728pub const RTMGRP_IPV4_MROUTE: c_int = 0x00020;
2729pub const RTMGRP_IPV4_ROUTE: c_int = 0x00040;
2730pub const RTMGRP_IPV4_RULE: c_int = 0x00080;
2731pub const RTMGRP_IPV6_IFADDR: c_int = 0x00100;
2732pub const RTMGRP_IPV6_MROUTE: c_int = 0x00200;
2733pub const RTMGRP_IPV6_ROUTE: c_int = 0x00400;
2734pub const RTMGRP_IPV6_IFINFO: c_int = 0x00800;
2735pub const RTMGRP_DECnet_IFADDR: c_int = 0x01000;
2736pub const RTMGRP_DECnet_ROUTE: c_int = 0x04000;
2737pub const RTMGRP_IPV6_PREFIX: c_int = 0x20000;
2738
2739// enum rtnetlink_groups
2740pub const RTNLGRP_NONE: c_uint = 0x00;
2741pub const RTNLGRP_LINK: c_uint = 0x01;
2742pub const RTNLGRP_NOTIFY: c_uint = 0x02;
2743pub const RTNLGRP_NEIGH: c_uint = 0x03;
2744pub const RTNLGRP_TC: c_uint = 0x04;
2745pub const RTNLGRP_IPV4_IFADDR: c_uint = 0x05;
2746pub const RTNLGRP_IPV4_MROUTE: c_uint = 0x06;
2747pub const RTNLGRP_IPV4_ROUTE: c_uint = 0x07;
2748pub const RTNLGRP_IPV4_RULE: c_uint = 0x08;
2749pub const RTNLGRP_IPV6_IFADDR: c_uint = 0x09;
2750pub const RTNLGRP_IPV6_MROUTE: c_uint = 0x0a;
2751pub const RTNLGRP_IPV6_ROUTE: c_uint = 0x0b;
2752pub const RTNLGRP_IPV6_IFINFO: c_uint = 0x0c;
2753pub const RTNLGRP_DECnet_IFADDR: c_uint = 0x0d;
2754pub const RTNLGRP_NOP2: c_uint = 0x0e;
2755pub const RTNLGRP_DECnet_ROUTE: c_uint = 0x0f;
2756pub const RTNLGRP_DECnet_RULE: c_uint = 0x10;
2757pub const RTNLGRP_NOP4: c_uint = 0x11;
2758pub const RTNLGRP_IPV6_PREFIX: c_uint = 0x12;
2759pub const RTNLGRP_IPV6_RULE: c_uint = 0x13;
2760pub const RTNLGRP_ND_USEROPT: c_uint = 0x14;
2761pub const RTNLGRP_PHONET_IFADDR: c_uint = 0x15;
2762pub const RTNLGRP_PHONET_ROUTE: c_uint = 0x16;
2763pub const RTNLGRP_DCB: c_uint = 0x17;
2764pub const RTNLGRP_IPV4_NETCONF: c_uint = 0x18;
2765pub const RTNLGRP_IPV6_NETCONF: c_uint = 0x19;
2766pub const RTNLGRP_MDB: c_uint = 0x1a;
2767pub const RTNLGRP_MPLS_ROUTE: c_uint = 0x1b;
2768pub const RTNLGRP_NSID: c_uint = 0x1c;
2769pub const RTNLGRP_MPLS_NETCONF: c_uint = 0x1d;
2770pub const RTNLGRP_IPV4_MROUTE_R: c_uint = 0x1e;
2771pub const RTNLGRP_IPV6_MROUTE_R: c_uint = 0x1f;
2772pub const RTNLGRP_NEXTHOP: c_uint = 0x20;
2773pub const RTNLGRP_BRVLAN: c_uint = 0x21;
2774pub const RTNLGRP_MCTP_IFADDR: c_uint = 0x22;
2775pub const RTNLGRP_TUNNEL: c_uint = 0x23;
2776pub const RTNLGRP_STATS: c_uint = 0x24;
2777
2778// linux/cn_proc.h
2779c_enum! {
2780    pub enum proc_cn_mcast_op {
2781        pub PROC_CN_MCAST_LISTEN = 1,
2782        pub PROC_CN_MCAST_IGNORE = 2,
2783    }
2784
2785    pub enum proc_cn_event {
2786        pub PROC_EVENT_NONE = 0x00000000,
2787        pub PROC_EVENT_FORK = 0x00000001,
2788        pub PROC_EVENT_EXEC = 0x00000002,
2789        pub PROC_EVENT_UID = 0x00000004,
2790        pub PROC_EVENT_GID = 0x00000040,
2791        pub PROC_EVENT_SID = 0x00000080,
2792        pub PROC_EVENT_PTRACE = 0x00000100,
2793        pub PROC_EVENT_COMM = 0x00000200,
2794        pub PROC_EVENT_NONZERO_EXIT = 0x20000000,
2795        pub PROC_EVENT_COREDUMP = 0x40000000,
2796        pub PROC_EVENT_EXIT = 0x80000000,
2797    }
2798}
2799
2800// linux/connector.h
2801pub const CN_IDX_PROC: c_uint = 0x1;
2802pub const CN_VAL_PROC: c_uint = 0x1;
2803pub const CN_IDX_CIFS: c_uint = 0x2;
2804pub const CN_VAL_CIFS: c_uint = 0x1;
2805pub const CN_W1_IDX: c_uint = 0x3;
2806pub const CN_W1_VAL: c_uint = 0x1;
2807pub const CN_IDX_V86D: c_uint = 0x4;
2808pub const CN_VAL_V86D_UVESAFB: c_uint = 0x1;
2809pub const CN_IDX_BB: c_uint = 0x5;
2810pub const CN_DST_IDX: c_uint = 0x6;
2811pub const CN_DST_VAL: c_uint = 0x1;
2812pub const CN_IDX_DM: c_uint = 0x7;
2813pub const CN_VAL_DM_USERSPACE_LOG: c_uint = 0x1;
2814pub const CN_IDX_DRBD: c_uint = 0x8;
2815pub const CN_VAL_DRBD: c_uint = 0x1;
2816pub const CN_KVP_IDX: c_uint = 0x9;
2817pub const CN_KVP_VAL: c_uint = 0x1;
2818pub const CN_VSS_IDX: c_uint = 0xA;
2819pub const CN_VSS_VAL: c_uint = 0x1;
2820
2821// linux/module.h
2822pub const MODULE_INIT_IGNORE_MODVERSIONS: c_uint = 0x0001;
2823pub const MODULE_INIT_IGNORE_VERMAGIC: c_uint = 0x0002;
2824
2825// linux/net_tstamp.h
2826pub const SOF_TIMESTAMPING_TX_HARDWARE: c_uint = 1 << 0;
2827pub const SOF_TIMESTAMPING_TX_SOFTWARE: c_uint = 1 << 1;
2828pub const SOF_TIMESTAMPING_RX_HARDWARE: c_uint = 1 << 2;
2829pub const SOF_TIMESTAMPING_RX_SOFTWARE: c_uint = 1 << 3;
2830pub const SOF_TIMESTAMPING_SOFTWARE: c_uint = 1 << 4;
2831pub const SOF_TIMESTAMPING_SYS_HARDWARE: c_uint = 1 << 5;
2832pub const SOF_TIMESTAMPING_RAW_HARDWARE: c_uint = 1 << 6;
2833pub const SOF_TIMESTAMPING_OPT_ID: c_uint = 1 << 7;
2834pub const SOF_TIMESTAMPING_TX_SCHED: c_uint = 1 << 8;
2835pub const SOF_TIMESTAMPING_TX_ACK: c_uint = 1 << 9;
2836pub const SOF_TIMESTAMPING_OPT_CMSG: c_uint = 1 << 10;
2837pub const SOF_TIMESTAMPING_OPT_TSONLY: c_uint = 1 << 11;
2838pub const SOF_TIMESTAMPING_OPT_STATS: c_uint = 1 << 12;
2839pub const SOF_TIMESTAMPING_OPT_PKTINFO: c_uint = 1 << 13;
2840pub const SOF_TIMESTAMPING_OPT_TX_SWHW: c_uint = 1 << 14;
2841pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15;
2842pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16;
2843pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17;
2844pub const SOF_TXTIME_DEADLINE_MODE: u32 = 1 << 0;
2845pub const SOF_TXTIME_REPORT_ERRORS: u32 = 1 << 1;
2846
2847pub const HWTSTAMP_TX_OFF: c_uint = 0;
2848pub const HWTSTAMP_TX_ON: c_uint = 1;
2849pub const HWTSTAMP_TX_ONESTEP_SYNC: c_uint = 2;
2850pub const HWTSTAMP_TX_ONESTEP_P2P: c_uint = 3;
2851
2852pub const HWTSTAMP_FILTER_NONE: c_uint = 0;
2853pub const HWTSTAMP_FILTER_ALL: c_uint = 1;
2854pub const HWTSTAMP_FILTER_SOME: c_uint = 2;
2855pub const HWTSTAMP_FILTER_PTP_V1_L4_EVENT: c_uint = 3;
2856pub const HWTSTAMP_FILTER_PTP_V1_L4_SYNC: c_uint = 4;
2857pub const HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: c_uint = 5;
2858pub const HWTSTAMP_FILTER_PTP_V2_L4_EVENT: c_uint = 6;
2859pub const HWTSTAMP_FILTER_PTP_V2_L4_SYNC: c_uint = 7;
2860pub const HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: c_uint = 8;
2861pub const HWTSTAMP_FILTER_PTP_V2_L2_EVENT: c_uint = 9;
2862pub const HWTSTAMP_FILTER_PTP_V2_L2_SYNC: c_uint = 10;
2863pub const HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: c_uint = 11;
2864pub const HWTSTAMP_FILTER_PTP_V2_EVENT: c_uint = 12;
2865pub const HWTSTAMP_FILTER_PTP_V2_SYNC: c_uint = 13;
2866pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: c_uint = 14;
2867pub const HWTSTAMP_FILTER_NTP_ALL: c_uint = 15;
2868
2869// linux/ptp_clock.h
2870pub const PTP_MAX_SAMPLES: c_uint = 25; // Maximum allowed offset measurement samples.
2871
2872const PTP_CLK_MAGIC: u32 = b'=' as u32;
2873
2874pub const PTP_CLOCK_GETCAPS: Ioctl = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 1);
2875pub const PTP_EXTTS_REQUEST: Ioctl = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 2);
2876pub const PTP_PEROUT_REQUEST: Ioctl = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 3);
2877pub const PTP_ENABLE_PPS: Ioctl = _IOW::<c_int>(PTP_CLK_MAGIC, 4);
2878pub const PTP_SYS_OFFSET: Ioctl = _IOW::<ptp_sys_offset>(PTP_CLK_MAGIC, 5);
2879pub const PTP_PIN_GETFUNC: Ioctl = _IOWR::<ptp_pin_desc>(PTP_CLK_MAGIC, 6);
2880pub const PTP_PIN_SETFUNC: Ioctl = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 7);
2881pub const PTP_SYS_OFFSET_PRECISE: Ioctl = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 8);
2882pub const PTP_SYS_OFFSET_EXTENDED: Ioctl = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 9);
2883
2884pub const PTP_CLOCK_GETCAPS2: Ioctl = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 10);
2885pub const PTP_EXTTS_REQUEST2: Ioctl = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 11);
2886pub const PTP_PEROUT_REQUEST2: Ioctl = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 12);
2887pub const PTP_ENABLE_PPS2: Ioctl = _IOW::<c_int>(PTP_CLK_MAGIC, 13);
2888pub const PTP_SYS_OFFSET2: Ioctl = _IOW::<ptp_sys_offset>(PTP_CLK_MAGIC, 14);
2889pub const PTP_PIN_GETFUNC2: Ioctl = _IOWR::<ptp_pin_desc>(PTP_CLK_MAGIC, 15);
2890pub const PTP_PIN_SETFUNC2: Ioctl = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 16);
2891pub const PTP_SYS_OFFSET_PRECISE2: Ioctl = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 17);
2892pub const PTP_SYS_OFFSET_EXTENDED2: Ioctl = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 18);
2893
2894// enum ptp_pin_function
2895pub const PTP_PF_NONE: c_uint = 0;
2896pub const PTP_PF_EXTTS: c_uint = 1;
2897pub const PTP_PF_PEROUT: c_uint = 2;
2898pub const PTP_PF_PHYSYNC: c_uint = 3;
2899
2900// linux/tls.h
2901pub const TLS_TX: c_int = 1;
2902pub const TLS_RX: c_int = 2;
2903
2904pub const TLS_TX_ZEROCOPY_RO: c_int = 3;
2905pub const TLS_RX_EXPECT_NO_PAD: c_int = 4;
2906
2907pub const TLS_1_2_VERSION_MAJOR: __u8 = 0x3;
2908pub const TLS_1_2_VERSION_MINOR: __u8 = 0x3;
2909pub const TLS_1_2_VERSION: __u16 =
2910    ((TLS_1_2_VERSION_MAJOR as __u16) << 8) | (TLS_1_2_VERSION_MINOR as __u16);
2911
2912pub const TLS_1_3_VERSION_MAJOR: __u8 = 0x3;
2913pub const TLS_1_3_VERSION_MINOR: __u8 = 0x4;
2914pub const TLS_1_3_VERSION: __u16 =
2915    ((TLS_1_3_VERSION_MAJOR as __u16) << 8) | (TLS_1_3_VERSION_MINOR as __u16);
2916
2917pub const TLS_CIPHER_AES_GCM_128: __u16 = 51;
2918pub const TLS_CIPHER_AES_GCM_128_IV_SIZE: usize = 8;
2919pub const TLS_CIPHER_AES_GCM_128_KEY_SIZE: usize = 16;
2920pub const TLS_CIPHER_AES_GCM_128_SALT_SIZE: usize = 4;
2921pub const TLS_CIPHER_AES_GCM_128_TAG_SIZE: usize = 16;
2922pub const TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE: usize = 8;
2923
2924pub const TLS_CIPHER_AES_GCM_256: __u16 = 52;
2925pub const TLS_CIPHER_AES_GCM_256_IV_SIZE: usize = 8;
2926pub const TLS_CIPHER_AES_GCM_256_KEY_SIZE: usize = 32;
2927pub const TLS_CIPHER_AES_GCM_256_SALT_SIZE: usize = 4;
2928pub const TLS_CIPHER_AES_GCM_256_TAG_SIZE: usize = 16;
2929pub const TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE: usize = 8;
2930
2931pub const TLS_CIPHER_AES_CCM_128: __u16 = 53;
2932pub const TLS_CIPHER_AES_CCM_128_IV_SIZE: usize = 8;
2933pub const TLS_CIPHER_AES_CCM_128_KEY_SIZE: usize = 16;
2934pub const TLS_CIPHER_AES_CCM_128_SALT_SIZE: usize = 4;
2935pub const TLS_CIPHER_AES_CCM_128_TAG_SIZE: usize = 16;
2936pub const TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE: usize = 8;
2937
2938pub const TLS_CIPHER_CHACHA20_POLY1305: __u16 = 54;
2939pub const TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE: usize = 12;
2940pub const TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE: usize = 32;
2941pub const TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE: usize = 0;
2942pub const TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE: usize = 16;
2943pub const TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE: usize = 8;
2944
2945pub const TLS_CIPHER_SM4_GCM: __u16 = 55;
2946pub const TLS_CIPHER_SM4_GCM_IV_SIZE: usize = 8;
2947pub const TLS_CIPHER_SM4_GCM_KEY_SIZE: usize = 16;
2948pub const TLS_CIPHER_SM4_GCM_SALT_SIZE: usize = 4;
2949pub const TLS_CIPHER_SM4_GCM_TAG_SIZE: usize = 16;
2950pub const TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE: usize = 8;
2951
2952pub const TLS_CIPHER_SM4_CCM: __u16 = 56;
2953pub const TLS_CIPHER_SM4_CCM_IV_SIZE: usize = 8;
2954pub const TLS_CIPHER_SM4_CCM_KEY_SIZE: usize = 16;
2955pub const TLS_CIPHER_SM4_CCM_SALT_SIZE: usize = 4;
2956pub const TLS_CIPHER_SM4_CCM_TAG_SIZE: usize = 16;
2957pub const TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE: usize = 8;
2958
2959pub const TLS_CIPHER_ARIA_GCM_128: __u16 = 57;
2960pub const TLS_CIPHER_ARIA_GCM_128_IV_SIZE: usize = 8;
2961pub const TLS_CIPHER_ARIA_GCM_128_KEY_SIZE: usize = 16;
2962pub const TLS_CIPHER_ARIA_GCM_128_SALT_SIZE: usize = 4;
2963pub const TLS_CIPHER_ARIA_GCM_128_TAG_SIZE: usize = 16;
2964pub const TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE: usize = 8;
2965
2966pub const TLS_CIPHER_ARIA_GCM_256: __u16 = 58;
2967pub const TLS_CIPHER_ARIA_GCM_256_IV_SIZE: usize = 8;
2968pub const TLS_CIPHER_ARIA_GCM_256_KEY_SIZE: usize = 32;
2969pub const TLS_CIPHER_ARIA_GCM_256_SALT_SIZE: usize = 4;
2970pub const TLS_CIPHER_ARIA_GCM_256_TAG_SIZE: usize = 16;
2971pub const TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE: usize = 8;
2972
2973pub const TLS_SET_RECORD_TYPE: c_int = 1;
2974pub const TLS_GET_RECORD_TYPE: c_int = 2;
2975
2976pub const SOL_TLS: c_int = 282;
2977
2978// enum
2979pub const TLS_INFO_UNSPEC: c_int = 0x00;
2980pub const TLS_INFO_VERSION: c_int = 0x01;
2981pub const TLS_INFO_CIPHER: c_int = 0x02;
2982pub const TLS_INFO_TXCONF: c_int = 0x03;
2983pub const TLS_INFO_RXCONF: c_int = 0x04;
2984pub const TLS_INFO_ZC_RO_TX: c_int = 0x05;
2985pub const TLS_INFO_RX_NO_PAD: c_int = 0x06;
2986
2987pub const TLS_CONF_BASE: c_int = 1;
2988pub const TLS_CONF_SW: c_int = 2;
2989pub const TLS_CONF_HW: c_int = 3;
2990pub const TLS_CONF_HW_RECORD: c_int = 4;
2991
2992// linux/if_alg.h
2993pub const ALG_SET_KEY: c_int = 1;
2994pub const ALG_SET_IV: c_int = 2;
2995pub const ALG_SET_OP: c_int = 3;
2996pub const ALG_SET_AEAD_ASSOCLEN: c_int = 4;
2997pub const ALG_SET_AEAD_AUTHSIZE: c_int = 5;
2998pub const ALG_SET_DRBG_ENTROPY: c_int = 6;
2999pub const ALG_SET_KEY_BY_KEY_SERIAL: c_int = 7;
3000
3001pub const ALG_OP_DECRYPT: c_int = 0;
3002pub const ALG_OP_ENCRYPT: c_int = 1;
3003
3004// include/uapi/linux/if.h
3005pub const IF_OPER_UNKNOWN: c_int = 0;
3006pub const IF_OPER_NOTPRESENT: c_int = 1;
3007pub const IF_OPER_DOWN: c_int = 2;
3008pub const IF_OPER_LOWERLAYERDOWN: c_int = 3;
3009pub const IF_OPER_TESTING: c_int = 4;
3010pub const IF_OPER_DORMANT: c_int = 5;
3011pub const IF_OPER_UP: c_int = 6;
3012
3013pub const IF_LINK_MODE_DEFAULT: c_int = 0;
3014pub const IF_LINK_MODE_DORMANT: c_int = 1;
3015pub const IF_LINK_MODE_TESTING: c_int = 2;
3016
3017// include/uapi/linux/mman.h
3018pub const MAP_SHARED_VALIDATE: c_int = 0x3;
3019pub const MAP_DROPPABLE: c_int = 0x8;
3020
3021// uapi/linux/vm_sockets.h
3022pub const VMADDR_CID_ANY: c_uint = 0xFFFFFFFF;
3023pub const VMADDR_CID_HYPERVISOR: c_uint = 0;
3024#[deprecated(
3025    since = "0.2.74",
3026    note = "VMADDR_CID_RESERVED is removed since Linux v5.6 and \
3027            replaced with VMADDR_CID_LOCAL"
3028)]
3029pub const VMADDR_CID_RESERVED: c_uint = 1;
3030pub const VMADDR_CID_LOCAL: c_uint = 1;
3031pub const VMADDR_CID_HOST: c_uint = 2;
3032pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF;
3033
3034// uapi/linux/inotify.h
3035pub const IN_ACCESS: u32 = 0x0000_0001;
3036pub const IN_MODIFY: u32 = 0x0000_0002;
3037pub const IN_ATTRIB: u32 = 0x0000_0004;
3038pub const IN_CLOSE_WRITE: u32 = 0x0000_0008;
3039pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010;
3040pub const IN_CLOSE: u32 = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE;
3041pub const IN_OPEN: u32 = 0x0000_0020;
3042pub const IN_MOVED_FROM: u32 = 0x0000_0040;
3043pub const IN_MOVED_TO: u32 = 0x0000_0080;
3044pub const IN_MOVE: u32 = IN_MOVED_FROM | IN_MOVED_TO;
3045pub const IN_CREATE: u32 = 0x0000_0100;
3046pub const IN_DELETE: u32 = 0x0000_0200;
3047pub const IN_DELETE_SELF: u32 = 0x0000_0400;
3048pub const IN_MOVE_SELF: u32 = 0x0000_0800;
3049pub const IN_UNMOUNT: u32 = 0x0000_2000;
3050pub const IN_Q_OVERFLOW: u32 = 0x0000_4000;
3051pub const IN_IGNORED: u32 = 0x0000_8000;
3052pub const IN_ONLYDIR: u32 = 0x0100_0000;
3053pub const IN_DONT_FOLLOW: u32 = 0x0200_0000;
3054pub const IN_EXCL_UNLINK: u32 = 0x0400_0000;
3055
3056// uapi/linux/securebits.h
3057const SECURE_NOROOT: c_int = 0;
3058const SECURE_NOROOT_LOCKED: c_int = 1;
3059
3060pub const SECBIT_NOROOT: c_int = issecure_mask(SECURE_NOROOT);
3061pub const SECBIT_NOROOT_LOCKED: c_int = issecure_mask(SECURE_NOROOT_LOCKED);
3062
3063const SECURE_NO_SETUID_FIXUP: c_int = 2;
3064const SECURE_NO_SETUID_FIXUP_LOCKED: c_int = 3;
3065
3066pub const SECBIT_NO_SETUID_FIXUP: c_int = issecure_mask(SECURE_NO_SETUID_FIXUP);
3067pub const SECBIT_NO_SETUID_FIXUP_LOCKED: c_int = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED);
3068
3069const SECURE_KEEP_CAPS: c_int = 4;
3070const SECURE_KEEP_CAPS_LOCKED: c_int = 5;
3071
3072pub const SECBIT_KEEP_CAPS: c_int = issecure_mask(SECURE_KEEP_CAPS);
3073pub const SECBIT_KEEP_CAPS_LOCKED: c_int = issecure_mask(SECURE_KEEP_CAPS_LOCKED);
3074
3075const SECURE_NO_CAP_AMBIENT_RAISE: c_int = 6;
3076const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED: c_int = 7;
3077
3078pub const SECBIT_NO_CAP_AMBIENT_RAISE: c_int = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE);
3079pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED: c_int =
3080    issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED);
3081
3082const SECURE_EXEC_RESTRICT_FILE: c_int = 8;
3083const SECURE_EXEC_RESTRICT_FILE_LOCKED: c_int = 9;
3084
3085pub const SECBIT_EXEC_RESTRICT_FILE: c_int = issecure_mask(SECURE_EXEC_RESTRICT_FILE);
3086pub const SECBIT_EXEC_RESTRICT_FILE_LOCKED: c_int = issecure_mask(SECURE_EXEC_RESTRICT_FILE_LOCKED);
3087
3088const SECURE_EXEC_DENY_INTERACTIVE: c_int = 10;
3089const SECURE_EXEC_DENY_INTERACTIVE_LOCKED: c_int = 11;
3090
3091pub const SECBIT_EXEC_DENY_INTERACTIVE: c_int = issecure_mask(SECURE_EXEC_DENY_INTERACTIVE);
3092pub const SECBIT_EXEC_DENY_INTERACTIVE_LOCKED: c_int =
3093    issecure_mask(SECURE_EXEC_DENY_INTERACTIVE_LOCKED);
3094
3095pub const SECUREBITS_DEFAULT: c_int = 0x00000000;
3096pub const SECURE_ALL_BITS: c_int = SECBIT_NOROOT
3097    | SECBIT_NO_SETUID_FIXUP
3098    | SECBIT_KEEP_CAPS
3099    | SECBIT_NO_CAP_AMBIENT_RAISE
3100    | SECBIT_EXEC_RESTRICT_FILE
3101    | SECBIT_EXEC_DENY_INTERACTIVE;
3102pub const SECURE_ALL_LOCKS: c_int = SECURE_ALL_BITS << 1;
3103
3104pub const SECURE_ALL_UNPRIVILEGED: c_int =
3105    issecure_mask(SECURE_EXEC_RESTRICT_FILE) | issecure_mask(SECURE_EXEC_DENY_INTERACTIVE);
3106
3107const fn issecure_mask(x: c_int) -> c_int {
3108    1 << x
3109}
3110
3111pub const IN_MASK_CREATE: u32 = 0x1000_0000;
3112pub const IN_MASK_ADD: u32 = 0x2000_0000;
3113pub const IN_ISDIR: u32 = 0x4000_0000;
3114pub const IN_ONESHOT: u32 = 0x8000_0000;
3115
3116pub const IN_ALL_EVENTS: u32 = IN_ACCESS
3117    | IN_MODIFY
3118    | IN_ATTRIB
3119    | IN_CLOSE_WRITE
3120    | IN_CLOSE_NOWRITE
3121    | IN_OPEN
3122    | IN_MOVED_FROM
3123    | IN_MOVED_TO
3124    | IN_DELETE
3125    | IN_CREATE
3126    | IN_DELETE_SELF
3127    | IN_MOVE_SELF;
3128
3129pub const IN_CLOEXEC: c_int = O_CLOEXEC;
3130pub const IN_NONBLOCK: c_int = O_NONBLOCK;
3131
3132// uapi/linux/mount.h
3133pub const OPEN_TREE_CLONE: c_uint = 0x01;
3134pub const OPEN_TREE_CLOEXEC: c_uint = O_CLOEXEC as c_uint;
3135
3136// uapi/linux/netfilter/nf_tables.h
3137pub const NFT_TABLE_MAXNAMELEN: c_int = 256;
3138pub const NFT_CHAIN_MAXNAMELEN: c_int = 256;
3139pub const NFT_SET_MAXNAMELEN: c_int = 256;
3140pub const NFT_OBJ_MAXNAMELEN: c_int = 256;
3141pub const NFT_USERDATA_MAXLEN: c_int = 256;
3142
3143pub const NFT_REG_VERDICT: c_int = 0;
3144pub const NFT_REG_1: c_int = 1;
3145pub const NFT_REG_2: c_int = 2;
3146pub const NFT_REG_3: c_int = 3;
3147pub const NFT_REG_4: c_int = 4;
3148pub const __NFT_REG_MAX: c_int = 5;
3149pub const NFT_REG32_00: c_int = 8;
3150pub const NFT_REG32_01: c_int = 9;
3151pub const NFT_REG32_02: c_int = 10;
3152pub const NFT_REG32_03: c_int = 11;
3153pub const NFT_REG32_04: c_int = 12;
3154pub const NFT_REG32_05: c_int = 13;
3155pub const NFT_REG32_06: c_int = 14;
3156pub const NFT_REG32_07: c_int = 15;
3157pub const NFT_REG32_08: c_int = 16;
3158pub const NFT_REG32_09: c_int = 17;
3159pub const NFT_REG32_10: c_int = 18;
3160pub const NFT_REG32_11: c_int = 19;
3161pub const NFT_REG32_12: c_int = 20;
3162pub const NFT_REG32_13: c_int = 21;
3163pub const NFT_REG32_14: c_int = 22;
3164pub const NFT_REG32_15: c_int = 23;
3165
3166pub const NFT_REG_SIZE: c_int = 16;
3167pub const NFT_REG32_SIZE: c_int = 4;
3168
3169pub const NFT_CONTINUE: c_int = -1;
3170pub const NFT_BREAK: c_int = -2;
3171pub const NFT_JUMP: c_int = -3;
3172pub const NFT_GOTO: c_int = -4;
3173pub const NFT_RETURN: c_int = -5;
3174
3175pub const NFT_MSG_NEWTABLE: c_int = 0;
3176pub const NFT_MSG_GETTABLE: c_int = 1;
3177pub const NFT_MSG_DELTABLE: c_int = 2;
3178pub const NFT_MSG_NEWCHAIN: c_int = 3;
3179pub const NFT_MSG_GETCHAIN: c_int = 4;
3180pub const NFT_MSG_DELCHAIN: c_int = 5;
3181pub const NFT_MSG_NEWRULE: c_int = 6;
3182pub const NFT_MSG_GETRULE: c_int = 7;
3183pub const NFT_MSG_DELRULE: c_int = 8;
3184pub const NFT_MSG_NEWSET: c_int = 9;
3185pub const NFT_MSG_GETSET: c_int = 10;
3186pub const NFT_MSG_DELSET: c_int = 11;
3187pub const NFT_MSG_NEWSETELEM: c_int = 12;
3188pub const NFT_MSG_GETSETELEM: c_int = 13;
3189pub const NFT_MSG_DELSETELEM: c_int = 14;
3190pub const NFT_MSG_NEWGEN: c_int = 15;
3191pub const NFT_MSG_GETGEN: c_int = 16;
3192pub const NFT_MSG_TRACE: c_int = 17;
3193cfg_if! {
3194    if #[cfg(not(target_arch = "sparc64"))] {
3195        pub const NFT_MSG_NEWOBJ: c_int = 18;
3196        pub const NFT_MSG_GETOBJ: c_int = 19;
3197        pub const NFT_MSG_DELOBJ: c_int = 20;
3198        pub const NFT_MSG_GETOBJ_RESET: c_int = 21;
3199    }
3200}
3201
3202pub const NFT_MSG_MAX: c_int = 34;
3203
3204pub const NFT_SET_ANONYMOUS: c_int = 0x1;
3205pub const NFT_SET_CONSTANT: c_int = 0x2;
3206pub const NFT_SET_INTERVAL: c_int = 0x4;
3207pub const NFT_SET_MAP: c_int = 0x8;
3208pub const NFT_SET_TIMEOUT: c_int = 0x10;
3209pub const NFT_SET_EVAL: c_int = 0x20;
3210
3211pub const NFT_SET_POL_PERFORMANCE: c_int = 0;
3212pub const NFT_SET_POL_MEMORY: c_int = 1;
3213
3214pub const NFT_SET_ELEM_INTERVAL_END: c_int = 0x1;
3215
3216pub const NFT_DATA_VALUE: c_uint = 0;
3217pub const NFT_DATA_VERDICT: c_uint = 0xffffff00;
3218
3219pub const NFT_DATA_RESERVED_MASK: c_uint = 0xffffff00;
3220
3221pub const NFT_DATA_VALUE_MAXLEN: c_int = 64;
3222
3223pub const NFT_BYTEORDER_NTOH: c_int = 0;
3224pub const NFT_BYTEORDER_HTON: c_int = 1;
3225
3226pub const NFT_CMP_EQ: c_int = 0;
3227pub const NFT_CMP_NEQ: c_int = 1;
3228pub const NFT_CMP_LT: c_int = 2;
3229pub const NFT_CMP_LTE: c_int = 3;
3230pub const NFT_CMP_GT: c_int = 4;
3231pub const NFT_CMP_GTE: c_int = 5;
3232
3233pub const NFT_RANGE_EQ: c_int = 0;
3234pub const NFT_RANGE_NEQ: c_int = 1;
3235
3236pub const NFT_LOOKUP_F_INV: c_int = 1 << 0;
3237
3238pub const NFT_DYNSET_OP_ADD: c_int = 0;
3239pub const NFT_DYNSET_OP_UPDATE: c_int = 1;
3240
3241pub const NFT_DYNSET_F_INV: c_int = 1 << 0;
3242
3243pub const NFT_PAYLOAD_LL_HEADER: c_int = 0;
3244pub const NFT_PAYLOAD_NETWORK_HEADER: c_int = 1;
3245pub const NFT_PAYLOAD_TRANSPORT_HEADER: c_int = 2;
3246
3247pub const NFT_PAYLOAD_CSUM_NONE: c_int = 0;
3248pub const NFT_PAYLOAD_CSUM_INET: c_int = 1;
3249
3250pub const NFT_META_LEN: c_int = 0;
3251pub const NFT_META_PROTOCOL: c_int = 1;
3252pub const NFT_META_PRIORITY: c_int = 2;
3253pub const NFT_META_MARK: c_int = 3;
3254pub const NFT_META_IIF: c_int = 4;
3255pub const NFT_META_OIF: c_int = 5;
3256pub const NFT_META_IIFNAME: c_int = 6;
3257pub const NFT_META_OIFNAME: c_int = 7;
3258pub const NFT_META_IIFTYPE: c_int = 8;
3259pub const NFT_META_OIFTYPE: c_int = 9;
3260pub const NFT_META_SKUID: c_int = 10;
3261pub const NFT_META_SKGID: c_int = 11;
3262pub const NFT_META_NFTRACE: c_int = 12;
3263pub const NFT_META_RTCLASSID: c_int = 13;
3264pub const NFT_META_SECMARK: c_int = 14;
3265pub const NFT_META_NFPROTO: c_int = 15;
3266pub const NFT_META_L4PROTO: c_int = 16;
3267pub const NFT_META_BRI_IIFNAME: c_int = 17;
3268pub const NFT_META_BRI_OIFNAME: c_int = 18;
3269pub const NFT_META_PKTTYPE: c_int = 19;
3270pub const NFT_META_CPU: c_int = 20;
3271pub const NFT_META_IIFGROUP: c_int = 21;
3272pub const NFT_META_OIFGROUP: c_int = 22;
3273pub const NFT_META_CGROUP: c_int = 23;
3274pub const NFT_META_PRANDOM: c_int = 24;
3275
3276pub const NFT_CT_STATE: c_int = 0;
3277pub const NFT_CT_DIRECTION: c_int = 1;
3278pub const NFT_CT_STATUS: c_int = 2;
3279pub const NFT_CT_MARK: c_int = 3;
3280pub const NFT_CT_SECMARK: c_int = 4;
3281pub const NFT_CT_EXPIRATION: c_int = 5;
3282pub const NFT_CT_HELPER: c_int = 6;
3283pub const NFT_CT_L3PROTOCOL: c_int = 7;
3284pub const NFT_CT_SRC: c_int = 8;
3285pub const NFT_CT_DST: c_int = 9;
3286pub const NFT_CT_PROTOCOL: c_int = 10;
3287pub const NFT_CT_PROTO_SRC: c_int = 11;
3288pub const NFT_CT_PROTO_DST: c_int = 12;
3289pub const NFT_CT_LABELS: c_int = 13;
3290pub const NFT_CT_PKTS: c_int = 14;
3291pub const NFT_CT_BYTES: c_int = 15;
3292pub const NFT_CT_AVGPKT: c_int = 16;
3293pub const NFT_CT_ZONE: c_int = 17;
3294pub const NFT_CT_EVENTMASK: c_int = 18;
3295pub const NFT_CT_SRC_IP: c_int = 19;
3296pub const NFT_CT_DST_IP: c_int = 20;
3297pub const NFT_CT_SRC_IP6: c_int = 21;
3298pub const NFT_CT_DST_IP6: c_int = 22;
3299
3300pub const NFT_LIMIT_PKTS: c_int = 0;
3301pub const NFT_LIMIT_PKT_BYTES: c_int = 1;
3302
3303pub const NFT_LIMIT_F_INV: c_int = 1 << 0;
3304
3305pub const NFT_QUEUE_FLAG_BYPASS: c_int = 0x01;
3306pub const NFT_QUEUE_FLAG_CPU_FANOUT: c_int = 0x02;
3307pub const NFT_QUEUE_FLAG_MASK: c_int = 0x03;
3308
3309pub const NFT_QUOTA_F_INV: c_int = 1 << 0;
3310
3311pub const NFT_REJECT_ICMP_UNREACH: c_int = 0;
3312pub const NFT_REJECT_TCP_RST: c_int = 1;
3313pub const NFT_REJECT_ICMPX_UNREACH: c_int = 2;
3314
3315pub const NFT_REJECT_ICMPX_NO_ROUTE: c_int = 0;
3316pub const NFT_REJECT_ICMPX_PORT_UNREACH: c_int = 1;
3317pub const NFT_REJECT_ICMPX_HOST_UNREACH: c_int = 2;
3318pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: c_int = 3;
3319
3320pub const NFT_NAT_SNAT: c_int = 0;
3321pub const NFT_NAT_DNAT: c_int = 1;
3322
3323pub const NFT_TRACETYPE_UNSPEC: c_int = 0;
3324pub const NFT_TRACETYPE_POLICY: c_int = 1;
3325pub const NFT_TRACETYPE_RETURN: c_int = 2;
3326pub const NFT_TRACETYPE_RULE: c_int = 3;
3327
3328pub const NFT_NG_INCREMENTAL: c_int = 0;
3329pub const NFT_NG_RANDOM: c_int = 1;
3330
3331// linux/input.h
3332pub const FF_MAX: __u16 = 0x7f;
3333pub const FF_CNT: usize = FF_MAX as usize + 1;
3334
3335// linux/input-event-codes.h
3336pub const INPUT_PROP_POINTER: __u16 = 0x00;
3337pub const INPUT_PROP_DIRECT: __u16 = 0x01;
3338pub const INPUT_PROP_BUTTONPAD: __u16 = 0x02;
3339pub const INPUT_PROP_SEMI_MT: __u16 = 0x03;
3340pub const INPUT_PROP_TOPBUTTONPAD: __u16 = 0x04;
3341pub const INPUT_PROP_POINTING_STICK: __u16 = 0x05;
3342pub const INPUT_PROP_ACCELEROMETER: __u16 = 0x06;
3343pub const INPUT_PROP_MAX: __u16 = 0x1f;
3344pub const INPUT_PROP_CNT: usize = INPUT_PROP_MAX as usize + 1;
3345pub const EV_MAX: __u16 = 0x1f;
3346pub const EV_CNT: usize = EV_MAX as usize + 1;
3347pub const SYN_MAX: __u16 = 0xf;
3348pub const SYN_CNT: usize = SYN_MAX as usize + 1;
3349pub const KEY_MAX: __u16 = 0x2ff;
3350pub const KEY_CNT: usize = KEY_MAX as usize + 1;
3351pub const REL_MAX: __u16 = 0x0f;
3352pub const REL_CNT: usize = REL_MAX as usize + 1;
3353pub const ABS_MAX: __u16 = 0x3f;
3354pub const ABS_CNT: usize = ABS_MAX as usize + 1;
3355pub const SW_MAX: __u16 = 0x10;
3356pub const SW_CNT: usize = SW_MAX as usize + 1;
3357pub const MSC_MAX: __u16 = 0x07;
3358pub const MSC_CNT: usize = MSC_MAX as usize + 1;
3359pub const LED_MAX: __u16 = 0x0f;
3360pub const LED_CNT: usize = LED_MAX as usize + 1;
3361pub const REP_MAX: __u16 = 0x01;
3362pub const REP_CNT: usize = REP_MAX as usize + 1;
3363pub const SND_MAX: __u16 = 0x07;
3364pub const SND_CNT: usize = SND_MAX as usize + 1;
3365
3366// linux/uinput.h
3367pub const UINPUT_VERSION: c_uint = 5;
3368pub const UINPUT_MAX_NAME_SIZE: usize = 80;
3369
3370// uapi/linux/fanotify.h
3371pub const FAN_ACCESS: u64 = 0x0000_0001;
3372pub const FAN_MODIFY: u64 = 0x0000_0002;
3373pub const FAN_ATTRIB: u64 = 0x0000_0004;
3374pub const FAN_CLOSE_WRITE: u64 = 0x0000_0008;
3375pub const FAN_CLOSE_NOWRITE: u64 = 0x0000_0010;
3376pub const FAN_OPEN: u64 = 0x0000_0020;
3377pub const FAN_MOVED_FROM: u64 = 0x0000_0040;
3378pub const FAN_MOVED_TO: u64 = 0x0000_0080;
3379pub const FAN_CREATE: u64 = 0x0000_0100;
3380pub const FAN_DELETE: u64 = 0x0000_0200;
3381pub const FAN_DELETE_SELF: u64 = 0x0000_0400;
3382pub const FAN_MOVE_SELF: u64 = 0x0000_0800;
3383pub const FAN_OPEN_EXEC: u64 = 0x0000_1000;
3384
3385pub const FAN_Q_OVERFLOW: u64 = 0x0000_4000;
3386pub const FAN_FS_ERROR: u64 = 0x0000_8000;
3387
3388pub const FAN_OPEN_PERM: u64 = 0x0001_0000;
3389pub const FAN_ACCESS_PERM: u64 = 0x0002_0000;
3390pub const FAN_OPEN_EXEC_PERM: u64 = 0x0004_0000;
3391
3392pub const FAN_EVENT_ON_CHILD: u64 = 0x0800_0000;
3393
3394pub const FAN_RENAME: u64 = 0x1000_0000;
3395
3396pub const FAN_ONDIR: u64 = 0x4000_0000;
3397
3398pub const FAN_CLOSE: u64 = FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE;
3399pub const FAN_MOVE: u64 = FAN_MOVED_FROM | FAN_MOVED_TO;
3400
3401pub const FAN_CLOEXEC: c_uint = 0x0000_0001;
3402pub const FAN_NONBLOCK: c_uint = 0x0000_0002;
3403
3404pub const FAN_CLASS_NOTIF: c_uint = 0x0000_0000;
3405pub const FAN_CLASS_CONTENT: c_uint = 0x0000_0004;
3406pub const FAN_CLASS_PRE_CONTENT: c_uint = 0x0000_0008;
3407
3408pub const FAN_UNLIMITED_QUEUE: c_uint = 0x0000_0010;
3409pub const FAN_UNLIMITED_MARKS: c_uint = 0x0000_0020;
3410pub const FAN_ENABLE_AUDIT: c_uint = 0x0000_0040;
3411
3412pub const FAN_REPORT_PIDFD: c_uint = 0x0000_0080;
3413pub const FAN_REPORT_TID: c_uint = 0x0000_0100;
3414pub const FAN_REPORT_FID: c_uint = 0x0000_0200;
3415pub const FAN_REPORT_DIR_FID: c_uint = 0x0000_0400;
3416pub const FAN_REPORT_NAME: c_uint = 0x0000_0800;
3417pub const FAN_REPORT_TARGET_FID: c_uint = 0x0000_1000;
3418
3419pub const FAN_REPORT_DFID_NAME: c_uint = FAN_REPORT_DIR_FID | FAN_REPORT_NAME;
3420pub const FAN_REPORT_DFID_NAME_TARGET: c_uint =
3421    FAN_REPORT_DFID_NAME | FAN_REPORT_FID | FAN_REPORT_TARGET_FID;
3422
3423pub const FAN_MARK_ADD: c_uint = 0x0000_0001;
3424pub const FAN_MARK_REMOVE: c_uint = 0x0000_0002;
3425pub const FAN_MARK_DONT_FOLLOW: c_uint = 0x0000_0004;
3426pub const FAN_MARK_ONLYDIR: c_uint = 0x0000_0008;
3427pub const FAN_MARK_IGNORED_MASK: c_uint = 0x0000_0020;
3428pub const FAN_MARK_IGNORED_SURV_MODIFY: c_uint = 0x0000_0040;
3429pub const FAN_MARK_FLUSH: c_uint = 0x0000_0080;
3430pub const FAN_MARK_EVICTABLE: c_uint = 0x0000_0200;
3431pub const FAN_MARK_IGNORE: c_uint = 0x0000_0400;
3432
3433pub const FAN_MARK_INODE: c_uint = 0x0000_0000;
3434pub const FAN_MARK_MOUNT: c_uint = 0x0000_0010;
3435pub const FAN_MARK_FILESYSTEM: c_uint = 0x0000_0100;
3436
3437pub const FAN_MARK_IGNORE_SURV: c_uint = FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY;
3438
3439pub const FANOTIFY_METADATA_VERSION: u8 = 3;
3440
3441pub const FAN_EVENT_INFO_TYPE_FID: u8 = 1;
3442pub const FAN_EVENT_INFO_TYPE_DFID_NAME: u8 = 2;
3443pub const FAN_EVENT_INFO_TYPE_DFID: u8 = 3;
3444pub const FAN_EVENT_INFO_TYPE_PIDFD: u8 = 4;
3445pub const FAN_EVENT_INFO_TYPE_ERROR: u8 = 5;
3446
3447pub const FAN_EVENT_INFO_TYPE_OLD_DFID_NAME: u8 = 10;
3448pub const FAN_EVENT_INFO_TYPE_NEW_DFID_NAME: u8 = 12;
3449
3450pub const FAN_RESPONSE_INFO_NONE: u8 = 0;
3451pub const FAN_RESPONSE_INFO_AUDIT_RULE: u8 = 1;
3452
3453pub const FAN_ALLOW: u32 = 0x01;
3454pub const FAN_DENY: u32 = 0x02;
3455pub const FAN_AUDIT: u32 = 0x10;
3456pub const FAN_INFO: u32 = 0x20;
3457
3458pub const FAN_NOFD: c_int = -1;
3459pub const FAN_NOPIDFD: c_int = FAN_NOFD;
3460pub const FAN_EPIDFD: c_int = -2;
3461
3462// linux/futex.h
3463pub const FUTEX_WAIT: c_int = 0;
3464pub const FUTEX_WAKE: c_int = 1;
3465pub const FUTEX_FD: c_int = 2;
3466pub const FUTEX_REQUEUE: c_int = 3;
3467pub const FUTEX_CMP_REQUEUE: c_int = 4;
3468pub const FUTEX_WAKE_OP: c_int = 5;
3469pub const FUTEX_LOCK_PI: c_int = 6;
3470pub const FUTEX_UNLOCK_PI: c_int = 7;
3471pub const FUTEX_TRYLOCK_PI: c_int = 8;
3472pub const FUTEX_WAIT_BITSET: c_int = 9;
3473pub const FUTEX_WAKE_BITSET: c_int = 10;
3474pub const FUTEX_WAIT_REQUEUE_PI: c_int = 11;
3475pub const FUTEX_CMP_REQUEUE_PI: c_int = 12;
3476pub const FUTEX_LOCK_PI2: c_int = 13;
3477
3478pub const FUTEX_PRIVATE_FLAG: c_int = 128;
3479pub const FUTEX_CLOCK_REALTIME: c_int = 256;
3480pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME);
3481
3482pub const FUTEX_WAITERS: u32 = 0x80000000;
3483pub const FUTEX_OWNER_DIED: u32 = 0x40000000;
3484pub const FUTEX_TID_MASK: u32 = 0x3fffffff;
3485
3486pub const FUTEX_BITSET_MATCH_ANY: c_int = 0xffffffff;
3487
3488pub const FUTEX_OP_SET: c_int = 0;
3489pub const FUTEX_OP_ADD: c_int = 1;
3490pub const FUTEX_OP_OR: c_int = 2;
3491pub const FUTEX_OP_ANDN: c_int = 3;
3492pub const FUTEX_OP_XOR: c_int = 4;
3493
3494pub const FUTEX_OP_OPARG_SHIFT: c_int = 8;
3495
3496pub const FUTEX_OP_CMP_EQ: c_int = 0;
3497pub const FUTEX_OP_CMP_NE: c_int = 1;
3498pub const FUTEX_OP_CMP_LT: c_int = 2;
3499pub const FUTEX_OP_CMP_LE: c_int = 3;
3500pub const FUTEX_OP_CMP_GT: c_int = 4;
3501pub const FUTEX_OP_CMP_GE: c_int = 5;
3502
3503pub fn FUTEX_OP(op: c_int, oparg: c_int, cmp: c_int, cmparg: c_int) -> c_int {
3504    ((op & 0xf) << 28) | ((cmp & 0xf) << 24) | ((oparg & 0xfff) << 12) | (cmparg & 0xfff)
3505}
3506
3507// linux/kexec.h
3508pub const KEXEC_ON_CRASH: c_int = 0x00000001;
3509pub const KEXEC_PRESERVE_CONTEXT: c_int = 0x00000002;
3510pub const KEXEC_ARCH_MASK: c_int = 0xffff0000;
3511pub const KEXEC_FILE_UNLOAD: c_int = 0x00000001;
3512pub const KEXEC_FILE_ON_CRASH: c_int = 0x00000002;
3513pub const KEXEC_FILE_NO_INITRAMFS: c_int = 0x00000004;
3514
3515// linux/reboot.h
3516pub const LINUX_REBOOT_MAGIC1: c_int = 0xfee1dead;
3517pub const LINUX_REBOOT_MAGIC2: c_int = 672274793;
3518pub const LINUX_REBOOT_MAGIC2A: c_int = 85072278;
3519pub const LINUX_REBOOT_MAGIC2B: c_int = 369367448;
3520pub const LINUX_REBOOT_MAGIC2C: c_int = 537993216;
3521
3522pub const LINUX_REBOOT_CMD_RESTART: c_int = 0x01234567;
3523pub const LINUX_REBOOT_CMD_HALT: c_int = 0xCDEF0123;
3524pub const LINUX_REBOOT_CMD_CAD_ON: c_int = 0x89ABCDEF;
3525pub const LINUX_REBOOT_CMD_CAD_OFF: c_int = 0x00000000;
3526pub const LINUX_REBOOT_CMD_POWER_OFF: c_int = 0x4321FEDC;
3527pub const LINUX_REBOOT_CMD_RESTART2: c_int = 0xA1B2C3D4;
3528pub const LINUX_REBOOT_CMD_SW_SUSPEND: c_int = 0xD000FCE2;
3529pub const LINUX_REBOOT_CMD_KEXEC: c_int = 0x45584543;
3530
3531// linux/errqueue.h
3532pub const SO_EE_ORIGIN_NONE: u8 = 0;
3533pub const SO_EE_ORIGIN_LOCAL: u8 = 1;
3534pub const SO_EE_ORIGIN_ICMP: u8 = 2;
3535pub const SO_EE_ORIGIN_ICMP6: u8 = 3;
3536pub const SO_EE_ORIGIN_TXSTATUS: u8 = 4;
3537pub const SO_EE_ORIGIN_TIMESTAMPING: u8 = SO_EE_ORIGIN_TXSTATUS;
3538
3539// linux/sctp.h
3540pub const SCTP_FUTURE_ASSOC: c_int = 0;
3541pub const SCTP_CURRENT_ASSOC: c_int = 1;
3542pub const SCTP_ALL_ASSOC: c_int = 2;
3543pub const SCTP_RTOINFO: c_int = 0;
3544pub const SCTP_ASSOCINFO: c_int = 1;
3545pub const SCTP_INITMSG: c_int = 2;
3546pub const SCTP_NODELAY: c_int = 3;
3547pub const SCTP_AUTOCLOSE: c_int = 4;
3548pub const SCTP_SET_PEER_PRIMARY_ADDR: c_int = 5;
3549pub const SCTP_PRIMARY_ADDR: c_int = 6;
3550pub const SCTP_ADAPTATION_LAYER: c_int = 7;
3551pub const SCTP_DISABLE_FRAGMENTS: c_int = 8;
3552pub const SCTP_PEER_ADDR_PARAMS: c_int = 9;
3553pub const SCTP_DEFAULT_SEND_PARAM: c_int = 10;
3554pub const SCTP_EVENTS: c_int = 11;
3555pub const SCTP_I_WANT_MAPPED_V4_ADDR: c_int = 12;
3556pub const SCTP_MAXSEG: c_int = 13;
3557pub const SCTP_STATUS: c_int = 14;
3558pub const SCTP_GET_PEER_ADDR_INFO: c_int = 15;
3559pub const SCTP_DELAYED_ACK_TIME: c_int = 16;
3560pub const SCTP_DELAYED_ACK: c_int = SCTP_DELAYED_ACK_TIME;
3561pub const SCTP_DELAYED_SACK: c_int = SCTP_DELAYED_ACK_TIME;
3562pub const SCTP_CONTEXT: c_int = 17;
3563pub const SCTP_FRAGMENT_INTERLEAVE: c_int = 18;
3564pub const SCTP_PARTIAL_DELIVERY_POINT: c_int = 19;
3565pub const SCTP_MAX_BURST: c_int = 20;
3566pub const SCTP_AUTH_CHUNK: c_int = 21;
3567pub const SCTP_HMAC_IDENT: c_int = 22;
3568pub const SCTP_AUTH_KEY: c_int = 23;
3569pub const SCTP_AUTH_ACTIVE_KEY: c_int = 24;
3570pub const SCTP_AUTH_DELETE_KEY: c_int = 25;
3571pub const SCTP_PEER_AUTH_CHUNKS: c_int = 26;
3572pub const SCTP_LOCAL_AUTH_CHUNKS: c_int = 27;
3573pub const SCTP_GET_ASSOC_NUMBER: c_int = 28;
3574pub const SCTP_GET_ASSOC_ID_LIST: c_int = 29;
3575pub const SCTP_AUTO_ASCONF: c_int = 30;
3576pub const SCTP_PEER_ADDR_THLDS: c_int = 31;
3577pub const SCTP_RECVRCVINFO: c_int = 32;
3578pub const SCTP_RECVNXTINFO: c_int = 33;
3579pub const SCTP_DEFAULT_SNDINFO: c_int = 34;
3580pub const SCTP_AUTH_DEACTIVATE_KEY: c_int = 35;
3581pub const SCTP_REUSE_PORT: c_int = 36;
3582pub const SCTP_PEER_ADDR_THLDS_V2: c_int = 37;
3583pub const SCTP_PR_SCTP_NONE: c_int = 0x0000;
3584pub const SCTP_PR_SCTP_TTL: c_int = 0x0010;
3585pub const SCTP_PR_SCTP_RTX: c_int = 0x0020;
3586pub const SCTP_PR_SCTP_PRIO: c_int = 0x0030;
3587pub const SCTP_PR_SCTP_MAX: c_int = SCTP_PR_SCTP_PRIO;
3588pub const SCTP_PR_SCTP_MASK: c_int = 0x0030;
3589pub const SCTP_ENABLE_RESET_STREAM_REQ: c_int = 0x01;
3590pub const SCTP_ENABLE_RESET_ASSOC_REQ: c_int = 0x02;
3591pub const SCTP_ENABLE_CHANGE_ASSOC_REQ: c_int = 0x04;
3592pub const SCTP_ENABLE_STRRESET_MASK: c_int = 0x07;
3593pub const SCTP_STREAM_RESET_INCOMING: c_int = 0x01;
3594pub const SCTP_STREAM_RESET_OUTGOING: c_int = 0x02;
3595
3596pub const SCTP_INIT: c_int = 0;
3597pub const SCTP_SNDRCV: c_int = 1;
3598pub const SCTP_SNDINFO: c_int = 2;
3599pub const SCTP_RCVINFO: c_int = 3;
3600pub const SCTP_NXTINFO: c_int = 4;
3601pub const SCTP_PRINFO: c_int = 5;
3602pub const SCTP_AUTHINFO: c_int = 6;
3603pub const SCTP_DSTADDRV4: c_int = 7;
3604pub const SCTP_DSTADDRV6: c_int = 8;
3605
3606pub const SCTP_UNORDERED: c_int = 1 << 0;
3607pub const SCTP_ADDR_OVER: c_int = 1 << 1;
3608pub const SCTP_ABORT: c_int = 1 << 2;
3609pub const SCTP_SACK_IMMEDIATELY: c_int = 1 << 3;
3610pub const SCTP_SENDALL: c_int = 1 << 6;
3611pub const SCTP_PR_SCTP_ALL: c_int = 1 << 7;
3612pub const SCTP_NOTIFICATION: c_int = MSG_NOTIFICATION;
3613pub const SCTP_EOF: c_int = crate::MSG_FIN;
3614
3615/* DCCP socket options */
3616pub const DCCP_SOCKOPT_PACKET_SIZE: c_int = 1;
3617pub const DCCP_SOCKOPT_SERVICE: c_int = 2;
3618pub const DCCP_SOCKOPT_CHANGE_L: c_int = 3;
3619pub const DCCP_SOCKOPT_CHANGE_R: c_int = 4;
3620pub const DCCP_SOCKOPT_GET_CUR_MPS: c_int = 5;
3621pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: c_int = 6;
3622pub const DCCP_SOCKOPT_SEND_CSCOV: c_int = 10;
3623pub const DCCP_SOCKOPT_RECV_CSCOV: c_int = 11;
3624pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: c_int = 12;
3625pub const DCCP_SOCKOPT_CCID: c_int = 13;
3626pub const DCCP_SOCKOPT_TX_CCID: c_int = 14;
3627pub const DCCP_SOCKOPT_RX_CCID: c_int = 15;
3628pub const DCCP_SOCKOPT_QPOLICY_ID: c_int = 16;
3629pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: c_int = 17;
3630pub const DCCP_SOCKOPT_CCID_RX_INFO: c_int = 128;
3631pub const DCCP_SOCKOPT_CCID_TX_INFO: c_int = 192;
3632
3633/// maximum number of services provided on the same listening port
3634pub const DCCP_SERVICE_LIST_MAX_LEN: c_int = 32;
3635
3636pub const CTL_KERN: c_int = 1;
3637pub const CTL_VM: c_int = 2;
3638pub const CTL_NET: c_int = 3;
3639pub const CTL_FS: c_int = 5;
3640pub const CTL_DEBUG: c_int = 6;
3641pub const CTL_DEV: c_int = 7;
3642pub const CTL_BUS: c_int = 8;
3643pub const CTL_ABI: c_int = 9;
3644pub const CTL_CPU: c_int = 10;
3645
3646pub const CTL_BUS_ISA: c_int = 1;
3647
3648pub const INOTIFY_MAX_USER_INSTANCES: c_int = 1;
3649pub const INOTIFY_MAX_USER_WATCHES: c_int = 2;
3650pub const INOTIFY_MAX_QUEUED_EVENTS: c_int = 3;
3651
3652pub const KERN_OSTYPE: c_int = 1;
3653pub const KERN_OSRELEASE: c_int = 2;
3654pub const KERN_OSREV: c_int = 3;
3655pub const KERN_VERSION: c_int = 4;
3656pub const KERN_SECUREMASK: c_int = 5;
3657pub const KERN_PROF: c_int = 6;
3658pub const KERN_NODENAME: c_int = 7;
3659pub const KERN_DOMAINNAME: c_int = 8;
3660pub const KERN_PANIC: c_int = 15;
3661pub const KERN_REALROOTDEV: c_int = 16;
3662pub const KERN_SPARC_REBOOT: c_int = 21;
3663pub const KERN_CTLALTDEL: c_int = 22;
3664pub const KERN_PRINTK: c_int = 23;
3665pub const KERN_NAMETRANS: c_int = 24;
3666pub const KERN_PPC_HTABRECLAIM: c_int = 25;
3667pub const KERN_PPC_ZEROPAGED: c_int = 26;
3668pub const KERN_PPC_POWERSAVE_NAP: c_int = 27;
3669pub const KERN_MODPROBE: c_int = 28;
3670pub const KERN_SG_BIG_BUFF: c_int = 29;
3671pub const KERN_ACCT: c_int = 30;
3672pub const KERN_PPC_L2CR: c_int = 31;
3673pub const KERN_RTSIGNR: c_int = 32;
3674pub const KERN_RTSIGMAX: c_int = 33;
3675pub const KERN_SHMMAX: c_int = 34;
3676pub const KERN_MSGMAX: c_int = 35;
3677pub const KERN_MSGMNB: c_int = 36;
3678pub const KERN_MSGPOOL: c_int = 37;
3679pub const KERN_SYSRQ: c_int = 38;
3680pub const KERN_MAX_THREADS: c_int = 39;
3681pub const KERN_RANDOM: c_int = 40;
3682pub const KERN_SHMALL: c_int = 41;
3683pub const KERN_MSGMNI: c_int = 42;
3684pub const KERN_SEM: c_int = 43;
3685pub const KERN_SPARC_STOP_A: c_int = 44;
3686pub const KERN_SHMMNI: c_int = 45;
3687pub const KERN_OVERFLOWUID: c_int = 46;
3688pub const KERN_OVERFLOWGID: c_int = 47;
3689pub const KERN_SHMPATH: c_int = 48;
3690pub const KERN_HOTPLUG: c_int = 49;
3691pub const KERN_IEEE_EMULATION_WARNINGS: c_int = 50;
3692pub const KERN_S390_USER_DEBUG_LOGGING: c_int = 51;
3693pub const KERN_CORE_USES_PID: c_int = 52;
3694pub const KERN_TAINTED: c_int = 53;
3695pub const KERN_CADPID: c_int = 54;
3696pub const KERN_PIDMAX: c_int = 55;
3697pub const KERN_CORE_PATTERN: c_int = 56;
3698pub const KERN_PANIC_ON_OOPS: c_int = 57;
3699pub const KERN_HPPA_PWRSW: c_int = 58;
3700pub const KERN_HPPA_UNALIGNED: c_int = 59;
3701pub const KERN_PRINTK_RATELIMIT: c_int = 60;
3702pub const KERN_PRINTK_RATELIMIT_BURST: c_int = 61;
3703pub const KERN_PTY: c_int = 62;
3704pub const KERN_NGROUPS_MAX: c_int = 63;
3705pub const KERN_SPARC_SCONS_PWROFF: c_int = 64;
3706pub const KERN_HZ_TIMER: c_int = 65;
3707pub const KERN_UNKNOWN_NMI_PANIC: c_int = 66;
3708pub const KERN_BOOTLOADER_TYPE: c_int = 67;
3709pub const KERN_RANDOMIZE: c_int = 68;
3710pub const KERN_SETUID_DUMPABLE: c_int = 69;
3711pub const KERN_SPIN_RETRY: c_int = 70;
3712pub const KERN_ACPI_VIDEO_FLAGS: c_int = 71;
3713pub const KERN_IA64_UNALIGNED: c_int = 72;
3714pub const KERN_COMPAT_LOG: c_int = 73;
3715pub const KERN_MAX_LOCK_DEPTH: c_int = 74;
3716pub const KERN_NMI_WATCHDOG: c_int = 75;
3717pub const KERN_PANIC_ON_NMI: c_int = 76;
3718
3719pub const VM_OVERCOMMIT_MEMORY: c_int = 5;
3720pub const VM_PAGE_CLUSTER: c_int = 10;
3721pub const VM_DIRTY_BACKGROUND: c_int = 11;
3722pub const VM_DIRTY_RATIO: c_int = 12;
3723pub const VM_DIRTY_WB_CS: c_int = 13;
3724pub const VM_DIRTY_EXPIRE_CS: c_int = 14;
3725pub const VM_NR_PDFLUSH_THREADS: c_int = 15;
3726pub const VM_OVERCOMMIT_RATIO: c_int = 16;
3727pub const VM_PAGEBUF: c_int = 17;
3728pub const VM_HUGETLB_PAGES: c_int = 18;
3729pub const VM_SWAPPINESS: c_int = 19;
3730pub const VM_LOWMEM_RESERVE_RATIO: c_int = 20;
3731pub const VM_MIN_FREE_KBYTES: c_int = 21;
3732pub const VM_MAX_MAP_COUNT: c_int = 22;
3733pub const VM_LAPTOP_MODE: c_int = 23;
3734pub const VM_BLOCK_DUMP: c_int = 24;
3735pub const VM_HUGETLB_GROUP: c_int = 25;
3736pub const VM_VFS_CACHE_PRESSURE: c_int = 26;
3737pub const VM_LEGACY_VA_LAYOUT: c_int = 27;
3738pub const VM_SWAP_TOKEN_TIMEOUT: c_int = 28;
3739pub const VM_DROP_PAGECACHE: c_int = 29;
3740pub const VM_PERCPU_PAGELIST_FRACTION: c_int = 30;
3741pub const VM_ZONE_RECLAIM_MODE: c_int = 31;
3742pub const VM_MIN_UNMAPPED: c_int = 32;
3743pub const VM_PANIC_ON_OOM: c_int = 33;
3744pub const VM_VDSO_ENABLED: c_int = 34;
3745pub const VM_MIN_SLAB: c_int = 35;
3746
3747pub const NET_CORE: c_int = 1;
3748pub const NET_ETHER: c_int = 2;
3749pub const NET_802: c_int = 3;
3750pub const NET_UNIX: c_int = 4;
3751pub const NET_IPV4: c_int = 5;
3752pub const NET_IPX: c_int = 6;
3753pub const NET_ATALK: c_int = 7;
3754pub const NET_NETROM: c_int = 8;
3755pub const NET_AX25: c_int = 9;
3756pub const NET_BRIDGE: c_int = 10;
3757pub const NET_ROSE: c_int = 11;
3758pub const NET_IPV6: c_int = 12;
3759pub const NET_X25: c_int = 13;
3760pub const NET_TR: c_int = 14;
3761pub const NET_DECNET: c_int = 15;
3762pub const NET_ECONET: c_int = 16;
3763pub const NET_SCTP: c_int = 17;
3764pub const NET_LLC: c_int = 18;
3765pub const NET_NETFILTER: c_int = 19;
3766pub const NET_DCCP: c_int = 20;
3767pub const NET_IRDA: c_int = 412;
3768
3769// include/linux/sched.h
3770/// I'm a virtual CPU.
3771pub const PF_VCPU: c_int = 0x00000001;
3772/// I am an IDLE thread.
3773pub const PF_IDLE: c_int = 0x00000002;
3774/// Getting shut down.
3775pub const PF_EXITING: c_int = 0x00000004;
3776/// Coredumps should ignore this task.
3777pub const PF_POSTCOREDUMP: c_int = 0x00000008;
3778/// Task is an IO worker.
3779pub const PF_IO_WORKER: c_int = 0x00000010;
3780/// I'm a workqueue worker.
3781pub const PF_WQ_WORKER: c_int = 0x00000020;
3782/// Forked but didn't exec.
3783pub const PF_FORKNOEXEC: c_int = 0x00000040;
3784/// Process policy on mce errors.
3785pub const PF_MCE_PROCESS: c_int = 0x00000080;
3786/// Used super-user privileges.
3787pub const PF_SUPERPRIV: c_int = 0x00000100;
3788/// Dumped core.
3789pub const PF_DUMPCORE: c_int = 0x00000200;
3790/// Killed by a signal.
3791pub const PF_SIGNALED: c_int = 0x00000400;
3792/// Allocating memory to free memory.
3793///
3794/// See `memalloc_noreclaim_save()`.
3795pub const PF_MEMALLOC: c_int = 0x00000800;
3796/// `set_user()` noticed that `RLIMIT_NPROC` was exceeded.
3797pub const PF_NPROC_EXCEEDED: c_int = 0x00001000;
3798/// If unset the fpu must be initialized before use.
3799pub const PF_USED_MATH: c_int = 0x00002000;
3800/// Kernel thread cloned from userspace thread.
3801pub const PF_USER_WORKER: c_int = 0x00004000;
3802/// This thread should not be frozen.
3803pub const PF_NOFREEZE: c_int = 0x00008000;
3804/// I am `kswapd`.
3805pub const PF_KSWAPD: c_int = 0x00020000;
3806/// All allocations inherit `GFP_NOFS`.
3807///
3808/// See `memalloc_nfs_save()`.
3809pub const PF_MEMALLOC_NOFS: c_int = 0x00040000;
3810/// All allocations inherit `GFP_NOIO`.
3811///
3812/// See `memalloc_noio_save()`.
3813pub const PF_MEMALLOC_NOIO: c_int = 0x00080000;
3814/// Throttle writes only against the bdi I write to, I am cleaning
3815/// dirty pages from some other bdi.
3816pub const PF_LOCAL_THROTTLE: c_int = 0x00100000;
3817/// I am a kernel thread.
3818pub const PF_KTHREAD: c_int = 0x00200000;
3819/// Randomize virtual address space.
3820pub const PF_RANDOMIZE: c_int = 0x00400000;
3821/// Userland is not allowed to meddle with `cpus_mask`.
3822pub const PF_NO_SETAFFINITY: c_int = 0x04000000;
3823/// Early kill for mce process policy.
3824pub const PF_MCE_EARLY: c_int = 0x08000000;
3825/// Allocations constrained to zones which allow long term pinning.
3826///
3827/// See `memalloc_pin_save()`.
3828pub const PF_MEMALLOC_PIN: c_int = 0x10000000;
3829/// Plug has ts that needs updating.
3830pub const PF_BLOCK_TS: c_int = 0x20000000;
3831/// This thread called `freeze_processes()` and should not be frozen.
3832pub const PF_SUSPEND_TASK: c_int = PF_SUSPEND_TASK_UINT as _;
3833// The used value is the highest possible bit fitting on 32 bits, so directly
3834// defining it as a signed integer causes the compiler to report an overflow.
3835// Use instead a private intermediary that assuringly has the correct type and
3836// cast it where necessary to the wanted final type, which preserves the
3837// desired information as-is in terms of integer representation.
3838const PF_SUSPEND_TASK_UINT: c_uint = 0x80000000;
3839
3840pub const CLONE_PIDFD: c_int = 0x1000;
3841
3842pub const SCHED_FLAG_RESET_ON_FORK: c_int = 0x01;
3843pub const SCHED_FLAG_RECLAIM: c_int = 0x02;
3844pub const SCHED_FLAG_DL_OVERRUN: c_int = 0x04;
3845pub const SCHED_FLAG_KEEP_POLICY: c_int = 0x08;
3846pub const SCHED_FLAG_KEEP_PARAMS: c_int = 0x10;
3847pub const SCHED_FLAG_UTIL_CLAMP_MIN: c_int = 0x20;
3848pub const SCHED_FLAG_UTIL_CLAMP_MAX: c_int = 0x40;
3849
3850// linux/if_xdp.h
3851pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0;
3852pub const XDP_COPY: crate::__u16 = 1 << 1;
3853pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2;
3854pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3;
3855pub const XDP_USE_SG: crate::__u16 = 1 << 4;
3856
3857pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0;
3858
3859pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0;
3860
3861pub const XDP_MMAP_OFFSETS: c_int = 1;
3862pub const XDP_RX_RING: c_int = 2;
3863pub const XDP_TX_RING: c_int = 3;
3864pub const XDP_UMEM_REG: c_int = 4;
3865pub const XDP_UMEM_FILL_RING: c_int = 5;
3866pub const XDP_UMEM_COMPLETION_RING: c_int = 6;
3867pub const XDP_STATISTICS: c_int = 7;
3868pub const XDP_OPTIONS: c_int = 8;
3869
3870pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0;
3871
3872pub const XDP_PGOFF_RX_RING: crate::off_t = 0;
3873pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000;
3874pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000;
3875pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000;
3876
3877pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48;
3878pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong =
3879    (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
3880
3881pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0;
3882
3883pub const XDP_UMEM_TX_SW_CSUM: crate::__u32 = 1 << 1;
3884pub const XDP_UMEM_TX_METADATA_LEN: crate::__u32 = 1 << 2;
3885
3886pub const XDP_TXMD_FLAGS_TIMESTAMP: crate::__u32 = 1 << 0;
3887pub const XDP_TXMD_FLAGS_CHECKSUM: crate::__u32 = 1 << 1;
3888
3889pub const XDP_TX_METADATA: crate::__u32 = 1 << 1;
3890
3891pub const SOL_XDP: c_int = 283;
3892
3893// linux/mount.h
3894pub const MOUNT_ATTR_RDONLY: crate::__u64 = 0x00000001;
3895pub const MOUNT_ATTR_NOSUID: crate::__u64 = 0x00000002;
3896pub const MOUNT_ATTR_NODEV: crate::__u64 = 0x00000004;
3897pub const MOUNT_ATTR_NOEXEC: crate::__u64 = 0x00000008;
3898pub const MOUNT_ATTR__ATIME: crate::__u64 = 0x00000070;
3899pub const MOUNT_ATTR_RELATIME: crate::__u64 = 0x00000000;
3900pub const MOUNT_ATTR_NOATIME: crate::__u64 = 0x00000010;
3901pub const MOUNT_ATTR_STRICTATIME: crate::__u64 = 0x00000020;
3902pub const MOUNT_ATTR_NODIRATIME: crate::__u64 = 0x00000080;
3903pub const MOUNT_ATTR_IDMAP: crate::__u64 = 0x00100000;
3904pub const MOUNT_ATTR_NOSYMFOLLOW: crate::__u64 = 0x00200000;
3905
3906pub const MOUNT_ATTR_SIZE_VER0: c_int = 32;
3907
3908pub const SCHED_FLAG_KEEP_ALL: c_int = SCHED_FLAG_KEEP_POLICY | SCHED_FLAG_KEEP_PARAMS;
3909
3910pub const SCHED_FLAG_UTIL_CLAMP: c_int = SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX;
3911
3912pub const SCHED_FLAG_ALL: c_int = SCHED_FLAG_RESET_ON_FORK
3913    | SCHED_FLAG_RECLAIM
3914    | SCHED_FLAG_DL_OVERRUN
3915    | SCHED_FLAG_KEEP_ALL
3916    | SCHED_FLAG_UTIL_CLAMP;
3917
3918// ioctl_eventpoll: added in Linux 6.9
3919pub const EPIOCSPARAMS: Ioctl = 0x40088a01;
3920pub const EPIOCGPARAMS: Ioctl = 0x80088a02;
3921
3922// siginfo.h
3923pub const SI_DETHREAD: c_int = -7;
3924pub const TRAP_PERF: c_int = 6;
3925
3926f! {
3927    pub fn SCTP_PR_INDEX(policy: c_int) -> c_int {
3928        policy >> (4 - 1)
3929    }
3930
3931    pub fn SCTP_PR_POLICY(policy: c_int) -> c_int {
3932        policy & SCTP_PR_SCTP_MASK
3933    }
3934
3935    pub fn SCTP_PR_SET_POLICY(flags: &mut c_int, policy: c_int) -> () {
3936        *flags &= !SCTP_PR_SCTP_MASK;
3937        *flags |= policy;
3938    }
3939
3940    pub fn SO_EE_OFFENDER(ee: *const crate::sock_extended_err) -> *mut crate::sockaddr {
3941        ee.offset(1) as *mut crate::sockaddr
3942    }
3943
3944    pub fn TPACKET_ALIGN(x: usize) -> usize {
3945        (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)
3946    }
3947
3948    pub fn BPF_CLASS(code: __u32) -> __u32 {
3949        code & 0x07
3950    }
3951
3952    pub fn BPF_SIZE(code: __u32) -> __u32 {
3953        code & 0x18
3954    }
3955
3956    pub fn BPF_MODE(code: __u32) -> __u32 {
3957        code & 0xe0
3958    }
3959
3960    pub fn BPF_OP(code: __u32) -> __u32 {
3961        code & 0xf0
3962    }
3963
3964    pub fn BPF_SRC(code: __u32) -> __u32 {
3965        code & 0x08
3966    }
3967
3968    pub fn BPF_RVAL(code: __u32) -> __u32 {
3969        code & 0x18
3970    }
3971
3972    pub fn BPF_MISCOP(code: __u32) -> __u32 {
3973        code & 0xf8
3974    }
3975
3976    pub fn BPF_STMT(code: __u16, k: __u32) -> sock_filter {
3977        sock_filter {
3978            code,
3979            jt: 0,
3980            jf: 0,
3981            k,
3982        }
3983    }
3984
3985    pub fn BPF_JUMP(code: __u16, k: __u32, jt: __u8, jf: __u8) -> sock_filter {
3986        sock_filter { code, jt, jf, k }
3987    }
3988
3989    #[cfg(target_env = "gnu")]
3990    pub fn SUN_LEN(s: crate::sockaddr_un) -> usize {
3991        offset_of!(crate::sockaddr_un, sun_path) + crate::strlen(s.sun_path.as_ptr())
3992    }
3993
3994    #[cfg(target_env = "musl")]
3995    pub fn SUN_LEN(s: crate::sockaddr_un) -> usize {
3996        2 * crate::strlen(s.sun_path.as_ptr())
3997    }
3998}
3999
4000safe_f! {
4001    pub const fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool {
4002        policy == SCTP_PR_SCTP_TTL
4003    }
4004
4005    pub const fn SCTP_PR_RTX_ENABLED(policy: c_int) -> bool {
4006        policy == SCTP_PR_SCTP_RTX
4007    }
4008
4009    pub const fn SCTP_PR_PRIO_ENABLED(policy: c_int) -> bool {
4010        policy == SCTP_PR_SCTP_PRIO
4011    }
4012}
4013
4014// These functions are not available on OpenHarmony
4015cfg_if! {
4016    if #[cfg(not(target_env = "ohos"))] {
4017        extern "C" {
4018            // Only `getspnam_r` is implemented for musl, out of all of the reenterant
4019            // functions from `shadow.h`.
4020            // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h
4021            pub fn getspnam_r(
4022                name: *const c_char,
4023                spbuf: *mut crate::spwd,
4024                buf: *mut c_char,
4025                buflen: size_t,
4026                spbufp: *mut *mut crate::spwd,
4027            ) -> c_int;
4028
4029            pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> mqd_t;
4030            pub fn mq_close(mqd: mqd_t) -> c_int;
4031            pub fn mq_unlink(name: *const c_char) -> c_int;
4032            pub fn mq_receive(
4033                mqd: mqd_t,
4034                msg_ptr: *mut c_char,
4035                msg_len: size_t,
4036                msg_prio: *mut c_uint,
4037            ) -> ssize_t;
4038            #[cfg_attr(
4039                any(gnu_time_bits64, musl32_time64),
4040                link_name = "__mq_timedreceive_time64"
4041            )]
4042            pub fn mq_timedreceive(
4043                mqd: mqd_t,
4044                msg_ptr: *mut c_char,
4045                msg_len: size_t,
4046                msg_prio: *mut c_uint,
4047                abs_timeout: *const crate::timespec,
4048            ) -> ssize_t;
4049            pub fn mq_send(
4050                mqd: mqd_t,
4051                msg_ptr: *const c_char,
4052                msg_len: size_t,
4053                msg_prio: c_uint,
4054            ) -> c_int;
4055            #[cfg_attr(
4056                any(gnu_time_bits64, musl32_time64),
4057                link_name = "__mq_timedsend_time64"
4058            )]
4059            pub fn mq_timedsend(
4060                mqd: mqd_t,
4061                msg_ptr: *const c_char,
4062                msg_len: size_t,
4063                msg_prio: c_uint,
4064                abs_timeout: *const crate::timespec,
4065            ) -> c_int;
4066            pub fn mq_getattr(mqd: mqd_t, attr: *mut crate::mq_attr) -> c_int;
4067            pub fn mq_setattr(
4068                mqd: mqd_t,
4069                newattr: *const crate::mq_attr,
4070                oldattr: *mut crate::mq_attr,
4071            ) -> c_int;
4072        }
4073    }
4074}
4075
4076extern "C" {
4077    pub fn mrand48() -> c_long;
4078    pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort;
4079    pub fn lcong48(p: *mut c_ushort);
4080
4081    #[cfg_attr(gnu_time_bits64, link_name = "__lutimes64")]
4082    #[cfg_attr(musl32_time64, link_name = "__lutimes_time64")]
4083    pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
4084
4085    pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
4086    pub fn shm_unlink(name: *const c_char) -> c_int;
4087
4088    // System V IPC
4089    pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t;
4090    pub fn semget(key: crate::key_t, nsems: c_int, semflag: c_int) -> c_int;
4091    pub fn semop(semid: c_int, sops: *mut crate::sembuf, nsops: size_t) -> c_int;
4092    #[cfg_attr(gnu_time_bits64, link_name = "__semctl64")]
4093    pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int;
4094    #[cfg_attr(gnu_time_bits64, link_name = "__msgctl64")]
4095    pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int;
4096    pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int;
4097    pub fn msgrcv(
4098        msqid: c_int,
4099        msgp: *mut c_void,
4100        msgsz: size_t,
4101        msgtyp: c_long,
4102        msgflg: c_int,
4103    ) -> ssize_t;
4104    pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int;
4105
4106    #[cfg_attr(gnu_file_offset_bits64, link_name = "fallocate64")]
4107    pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int;
4108    #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fallocate64")]
4109    pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
4110    pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t;
4111    pub fn getxattr(
4112        path: *const c_char,
4113        name: *const c_char,
4114        value: *mut c_void,
4115        size: size_t,
4116    ) -> ssize_t;
4117    pub fn lgetxattr(
4118        path: *const c_char,
4119        name: *const c_char,
4120        value: *mut c_void,
4121        size: size_t,
4122    ) -> ssize_t;
4123    pub fn fgetxattr(
4124        filedes: c_int,
4125        name: *const c_char,
4126        value: *mut c_void,
4127        size: size_t,
4128    ) -> ssize_t;
4129    pub fn setxattr(
4130        path: *const c_char,
4131        name: *const c_char,
4132        value: *const c_void,
4133        size: size_t,
4134        flags: c_int,
4135    ) -> c_int;
4136    pub fn lsetxattr(
4137        path: *const c_char,
4138        name: *const c_char,
4139        value: *const c_void,
4140        size: size_t,
4141        flags: c_int,
4142    ) -> c_int;
4143    pub fn fsetxattr(
4144        filedes: c_int,
4145        name: *const c_char,
4146        value: *const c_void,
4147        size: size_t,
4148        flags: c_int,
4149    ) -> c_int;
4150    pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t;
4151    pub fn llistxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t;
4152    pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t) -> ssize_t;
4153    pub fn removexattr(path: *const c_char, name: *const c_char) -> c_int;
4154    pub fn lremovexattr(path: *const c_char, name: *const c_char) -> c_int;
4155    pub fn fremovexattr(filedes: c_int, name: *const c_char) -> c_int;
4156    pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int;
4157    pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int;
4158    #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timerfd_gettime64")]
4159    pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int;
4160    #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timerfd_settime64")]
4161    pub fn timerfd_settime(
4162        fd: c_int,
4163        flags: c_int,
4164        new_value: *const crate::itimerspec,
4165        old_value: *mut crate::itimerspec,
4166    ) -> c_int;
4167    pub fn quotactl(cmd: c_int, special: *const c_char, id: c_int, data: *mut c_char) -> c_int;
4168    pub fn epoll_pwait(
4169        epfd: c_int,
4170        events: *mut crate::epoll_event,
4171        maxevents: c_int,
4172        timeout: c_int,
4173        sigmask: *const crate::sigset_t,
4174    ) -> c_int;
4175    pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int;
4176    #[cfg_attr(gnu_time_bits64, link_name = "__sigtimedwait64")]
4177    #[cfg_attr(musl32_time64, link_name = "__sigtimedwait_time64")]
4178    pub fn sigtimedwait(
4179        set: *const sigset_t,
4180        info: *mut siginfo_t,
4181        timeout: *const crate::timespec,
4182    ) -> c_int;
4183    pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int;
4184    pub fn accept4(fd: c_int, addr: *mut crate::sockaddr, len: *mut socklen_t, flg: c_int)
4185        -> c_int;
4186    pub fn reboot(how_to: c_int) -> c_int;
4187    pub fn setfsgid(gid: crate::gid_t) -> c_int;
4188    pub fn setfsuid(uid: crate::uid_t) -> c_int;
4189
4190    // Not available now on Android
4191    pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
4192    pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int;
4193
4194    pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
4195
4196    pub fn remap_file_pages(
4197        addr: *mut c_void,
4198        size: size_t,
4199        prot: c_int,
4200        pgoff: size_t,
4201        flags: c_int,
4202    ) -> c_int;
4203    #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemps64")]
4204    pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int;
4205
4206    pub fn vhangup() -> c_int;
4207    pub fn sync();
4208    pub fn syncfs(fd: c_int) -> c_int;
4209    pub fn syscall(num: c_long, ...) -> c_long;
4210    pub fn sched_setaffinity(
4211        pid: crate::pid_t,
4212        cpusetsize: size_t,
4213        cpuset: *const crate::cpu_set_t,
4214    ) -> c_int;
4215    pub fn epoll_create(size: c_int) -> c_int;
4216    pub fn epoll_create1(flags: c_int) -> c_int;
4217    pub fn epoll_wait(
4218        epfd: c_int,
4219        events: *mut crate::epoll_event,
4220        maxevents: c_int,
4221        timeout: c_int,
4222    ) -> c_int;
4223    pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int;
4224    pub fn unshare(flags: c_int) -> c_int;
4225    pub fn umount(target: *const c_char) -> c_int;
4226    pub fn tee(fd_in: c_int, fd_out: c_int, len: size_t, flags: c_uint) -> ssize_t;
4227    pub fn splice(
4228        fd_in: c_int,
4229        off_in: *mut loff_t,
4230        fd_out: c_int,
4231        off_out: *mut loff_t,
4232        len: size_t,
4233        flags: c_uint,
4234    ) -> ssize_t;
4235    pub fn eventfd(initval: c_uint, flags: c_int) -> c_int;
4236    pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int;
4237    pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int;
4238
4239    #[cfg_attr(gnu_time_bits64, link_name = "__sched_rr_get_interval64")]
4240    #[cfg_attr(musl32_time64, link_name = "__sched_rr_get_interval_time64")]
4241    pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int;
4242    pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int;
4243    pub fn setns(fd: c_int, nstype: c_int) -> c_int;
4244    pub fn swapoff(path: *const c_char) -> c_int;
4245    pub fn vmsplice(fd: c_int, iov: *const crate::iovec, nr_segs: size_t, flags: c_uint)
4246        -> ssize_t;
4247    pub fn personality(persona: c_ulong) -> c_int;
4248    pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int;
4249    pub fn clone(
4250        cb: extern "C" fn(*mut c_void) -> c_int,
4251        child_stack: *mut c_void,
4252        flags: c_int,
4253        arg: *mut c_void,
4254        ...
4255    ) -> c_int;
4256    pub fn sched_getscheduler(pid: crate::pid_t) -> c_int;
4257    #[cfg_attr(
4258        any(gnu_time_bits64, musl32_time64),
4259        link_name = "__clock_nanosleep_time64"
4260    )]
4261    pub fn clock_nanosleep(
4262        clk_id: crate::clockid_t,
4263        flags: c_int,
4264        rqtp: *const crate::timespec,
4265        rmtp: *mut crate::timespec,
4266    ) -> c_int;
4267    pub fn umount2(target: *const c_char, flags: c_int) -> c_int;
4268    pub fn swapon(path: *const c_char, swapflags: c_int) -> c_int;
4269    pub fn sched_setscheduler(
4270        pid: crate::pid_t,
4271        policy: c_int,
4272        param: *const crate::sched_param,
4273    ) -> c_int;
4274    #[cfg_attr(gnu_file_offset_bits64, link_name = "sendfile64")]
4275    pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t;
4276    pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int;
4277    pub fn getdtablesize() -> c_int;
4278    pub fn getgrouplist(
4279        user: *const c_char,
4280        group: crate::gid_t,
4281        groups: *mut crate::gid_t,
4282        ngroups: *mut c_int,
4283    ) -> c_int;
4284    pub fn posix_spawn(
4285        pid: *mut crate::pid_t,
4286        path: *const c_char,
4287        file_actions: *const crate::posix_spawn_file_actions_t,
4288        attrp: *const crate::posix_spawnattr_t,
4289        argv: *const *mut c_char,
4290        envp: *const *mut c_char,
4291    ) -> c_int;
4292    pub fn posix_spawnp(
4293        pid: *mut crate::pid_t,
4294        file: *const c_char,
4295        file_actions: *const crate::posix_spawn_file_actions_t,
4296        attrp: *const crate::posix_spawnattr_t,
4297        argv: *const *mut c_char,
4298        envp: *const *mut c_char,
4299    ) -> c_int;
4300    pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
4301    pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
4302    pub fn posix_spawnattr_getsigdefault(
4303        attr: *const posix_spawnattr_t,
4304        default: *mut crate::sigset_t,
4305    ) -> c_int;
4306    pub fn posix_spawnattr_setsigdefault(
4307        attr: *mut posix_spawnattr_t,
4308        default: *const crate::sigset_t,
4309    ) -> c_int;
4310    pub fn posix_spawnattr_getsigmask(
4311        attr: *const posix_spawnattr_t,
4312        default: *mut crate::sigset_t,
4313    ) -> c_int;
4314    pub fn posix_spawnattr_setsigmask(
4315        attr: *mut posix_spawnattr_t,
4316        default: *const crate::sigset_t,
4317    ) -> c_int;
4318    pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int;
4319    pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
4320    pub fn posix_spawnattr_getpgroup(
4321        attr: *const posix_spawnattr_t,
4322        flags: *mut crate::pid_t,
4323    ) -> c_int;
4324    pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int;
4325    pub fn posix_spawnattr_getschedpolicy(
4326        attr: *const posix_spawnattr_t,
4327        flags: *mut c_int,
4328    ) -> c_int;
4329    pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int;
4330    pub fn posix_spawnattr_getschedparam(
4331        attr: *const posix_spawnattr_t,
4332        param: *mut crate::sched_param,
4333    ) -> c_int;
4334    pub fn posix_spawnattr_setschedparam(
4335        attr: *mut posix_spawnattr_t,
4336        param: *const crate::sched_param,
4337    ) -> c_int;
4338
4339    pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
4340    pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
4341    pub fn posix_spawn_file_actions_addopen(
4342        actions: *mut posix_spawn_file_actions_t,
4343        fd: c_int,
4344        path: *const c_char,
4345        oflag: c_int,
4346        mode: mode_t,
4347    ) -> c_int;
4348    pub fn posix_spawn_file_actions_addclose(
4349        actions: *mut posix_spawn_file_actions_t,
4350        fd: c_int,
4351    ) -> c_int;
4352    pub fn posix_spawn_file_actions_adddup2(
4353        actions: *mut posix_spawn_file_actions_t,
4354        fd: c_int,
4355        newfd: c_int,
4356    ) -> c_int;
4357    pub fn fread_unlocked(
4358        buf: *mut c_void,
4359        size: size_t,
4360        nobj: size_t,
4361        stream: *mut crate::FILE,
4362    ) -> size_t;
4363    pub fn inotify_rm_watch(fd: c_int, wd: c_int) -> c_int;
4364    pub fn inotify_init() -> c_int;
4365    pub fn inotify_init1(flags: c_int) -> c_int;
4366    pub fn inotify_add_watch(fd: c_int, path: *const c_char, mask: u32) -> c_int;
4367    pub fn fanotify_init(flags: c_uint, event_f_flags: c_uint) -> c_int;
4368
4369    pub fn gethostid() -> c_long;
4370
4371    pub fn klogctl(syslog_type: c_int, bufp: *mut c_char, len: c_int) -> c_int;
4372
4373    pub fn name_to_handle_at(
4374        dirfd: c_int,
4375        path: *const c_char,
4376        handle: *mut file_handle,
4377        mount_id: *mut c_int,
4378        flags: c_int,
4379    ) -> c_int;
4380    pub fn open_by_handle_at(mount_fd: c_int, handle: *mut file_handle, flags: c_int) -> c_int;
4381}
4382
4383// LFS64 extensions
4384//
4385// * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones
4386cfg_if! {
4387    if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] {
4388        extern "C" {
4389            pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int;
4390            pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut crate::fpos64_t) -> c_int;
4391            pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE;
4392            pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int;
4393            pub fn sendfile64(
4394                out_fd: c_int,
4395                in_fd: c_int,
4396                offset: *mut off64_t,
4397                count: size_t,
4398            ) -> ssize_t;
4399            pub fn tmpfile64() -> *mut crate::FILE;
4400        }
4401    }
4402}
4403
4404cfg_if! {
4405    if #[cfg(target_env = "uclibc")] {
4406        mod uclibc;
4407        pub use self::uclibc::*;
4408    } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
4409        mod musl;
4410        pub use self::musl::*;
4411    } else if #[cfg(target_env = "gnu")] {
4412        mod gnu;
4413        pub use self::gnu::*;
4414    }
4415}
4416
4417mod arch;
4418pub use self::arch::*;