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