|
2 | 2 |
|
3 | 3 | use crate::prelude::*; |
4 | 4 |
|
| 5 | +cfg_if! { |
| 6 | + if #[cfg(doc)] { |
| 7 | + pub(crate) type Ioctl = c_int; |
| 8 | + } else { |
| 9 | + #[doc(hidden)] |
| 10 | + pub type Ioctl = c_int; |
| 11 | + } |
| 12 | +} |
| 13 | + |
5 | 14 | pub type clock_t = c_long; |
6 | 15 | pub type time_t = c_long; |
7 | 16 | pub type suseconds_t = c_long; |
@@ -337,19 +346,6 @@ s! { |
337 | 346 | pub dlpi_tls_data: *mut c_void, |
338 | 347 | } |
339 | 348 |
|
340 | | - // linux/filter.h |
341 | | - pub struct sock_filter { |
342 | | - pub code: crate::__u16, |
343 | | - pub jt: crate::__u8, |
344 | | - pub jf: crate::__u8, |
345 | | - pub k: crate::__u32, |
346 | | - } |
347 | | - |
348 | | - pub struct sock_fprog { |
349 | | - pub len: c_ushort, |
350 | | - pub filter: *mut sock_filter, |
351 | | - } |
352 | | - |
353 | 349 | // linux/seccomp.h |
354 | 350 | pub struct seccomp_data { |
355 | 351 | pub nr: c_int, |
@@ -1656,27 +1652,6 @@ pub const FIONREAD: c_int = 0x541B; |
1656 | 1652 | pub const TIOCCONS: c_int = 0x541D; |
1657 | 1653 | pub const TIOCSBRK: c_int = 0x5427; |
1658 | 1654 | pub const TIOCCBRK: c_int = 0x5428; |
1659 | | -cfg_if! { |
1660 | | - if #[cfg(any( |
1661 | | - target_arch = "x86", |
1662 | | - target_arch = "x86_64", |
1663 | | - target_arch = "arm", |
1664 | | - target_arch = "aarch64", |
1665 | | - target_arch = "riscv64", |
1666 | | - target_arch = "s390x" |
1667 | | - ))] { |
1668 | | - pub const FICLONE: c_int = 0x40049409; |
1669 | | - pub const FICLONERANGE: c_int = 0x4020940D; |
1670 | | - } else if #[cfg(any( |
1671 | | - target_arch = "mips", |
1672 | | - target_arch = "mips64", |
1673 | | - target_arch = "powerpc", |
1674 | | - target_arch = "powerpc64" |
1675 | | - ))] { |
1676 | | - pub const FICLONE: c_int = 0x80049409; |
1677 | | - pub const FICLONERANGE: c_int = 0x8020940D; |
1678 | | - } |
1679 | | -} |
1680 | 1655 |
|
1681 | 1656 | pub const ST_RDONLY: c_ulong = 1; |
1682 | 1657 | pub const ST_NOSUID: c_ulong = 2; |
@@ -1858,38 +1833,6 @@ pub const BLKIOOPT: c_int = 0x1279; |
1858 | 1833 | pub const BLKSSZGET: c_int = 0x1268; |
1859 | 1834 | pub const BLKPBSZGET: c_int = 0x127B; |
1860 | 1835 |
|
1861 | | -cfg_if! { |
1862 | | - // Those type are constructed using the _IOC macro |
1863 | | - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN |
1864 | | - // where D stands for direction (either None (00), Read (01) or Write (11)) |
1865 | | - // where S stands for size (int, long, struct...) |
1866 | | - // where T stands for type ('f','v','X'...) |
1867 | | - // where N stands for NR (NumbeR) |
1868 | | - if #[cfg(any(target_arch = "x86", target_arch = "arm"))] { |
1869 | | - pub const FS_IOC_GETFLAGS: c_int = 0x80046601; |
1870 | | - pub const FS_IOC_SETFLAGS: c_int = 0x40046602; |
1871 | | - pub const FS_IOC_GETVERSION: c_int = 0x80047601; |
1872 | | - pub const FS_IOC_SETVERSION: c_int = 0x40047602; |
1873 | | - pub const FS_IOC32_GETFLAGS: c_int = 0x80046601; |
1874 | | - pub const FS_IOC32_SETFLAGS: c_int = 0x40046602; |
1875 | | - pub const FS_IOC32_GETVERSION: c_int = 0x80047601; |
1876 | | - pub const FS_IOC32_SETVERSION: c_int = 0x40047602; |
1877 | | - } else if #[cfg(any( |
1878 | | - target_arch = "x86_64", |
1879 | | - target_arch = "riscv64", |
1880 | | - target_arch = "aarch64" |
1881 | | - ))] { |
1882 | | - pub const FS_IOC_GETFLAGS: c_int = 0x80086601; |
1883 | | - pub const FS_IOC_SETFLAGS: c_int = 0x40086602; |
1884 | | - pub const FS_IOC_GETVERSION: c_int = 0x80087601; |
1885 | | - pub const FS_IOC_SETVERSION: c_int = 0x40087602; |
1886 | | - pub const FS_IOC32_GETFLAGS: c_int = 0x80046601; |
1887 | | - pub const FS_IOC32_SETFLAGS: c_int = 0x40046602; |
1888 | | - pub const FS_IOC32_GETVERSION: c_int = 0x80047601; |
1889 | | - pub const FS_IOC32_SETVERSION: c_int = 0x40047602; |
1890 | | - } |
1891 | | -} |
1892 | | - |
1893 | 1836 | pub const EAI_AGAIN: c_int = 2; |
1894 | 1837 | pub const EAI_BADFLAGS: c_int = 3; |
1895 | 1838 | pub const EAI_FAIL: c_int = 4; |
@@ -2624,65 +2567,6 @@ pub const SND_CNT: usize = SND_MAX as usize + 1; |
2624 | 2567 | pub const UINPUT_VERSION: c_uint = 5; |
2625 | 2568 | pub const UINPUT_MAX_NAME_SIZE: usize = 80; |
2626 | 2569 |
|
2627 | | -// bionic/libc/kernel/uapi/linux/if_tun.h |
2628 | | -pub const IFF_TUN: c_int = 0x0001; |
2629 | | -pub const IFF_TAP: c_int = 0x0002; |
2630 | | -pub const IFF_NAPI: c_int = 0x0010; |
2631 | | -pub const IFF_NAPI_FRAGS: c_int = 0x0020; |
2632 | | -pub const IFF_NO_CARRIER: c_int = 0x0040; |
2633 | | -pub const IFF_NO_PI: c_int = 0x1000; |
2634 | | -pub const IFF_ONE_QUEUE: c_int = 0x2000; |
2635 | | -pub const IFF_VNET_HDR: c_int = 0x4000; |
2636 | | -pub const IFF_TUN_EXCL: c_int = 0x8000; |
2637 | | -pub const IFF_MULTI_QUEUE: c_int = 0x0100; |
2638 | | -pub const IFF_ATTACH_QUEUE: c_int = 0x0200; |
2639 | | -pub const IFF_DETACH_QUEUE: c_int = 0x0400; |
2640 | | -pub const IFF_PERSIST: c_int = 0x0800; |
2641 | | -pub const IFF_NOFILTER: c_int = 0x1000; |
2642 | | -pub const TUN_TX_TIMESTAMP: c_int = 1; |
2643 | | -// Features for GSO (TUNSETOFFLOAD) |
2644 | | -pub const TUN_F_CSUM: c_uint = 0x01; |
2645 | | -pub const TUN_F_TSO4: c_uint = 0x02; |
2646 | | -pub const TUN_F_TSO6: c_uint = 0x04; |
2647 | | -pub const TUN_F_TSO_ECN: c_uint = 0x08; |
2648 | | -pub const TUN_F_UFO: c_uint = 0x10; |
2649 | | -pub const TUN_F_USO4: c_uint = 0x20; |
2650 | | -pub const TUN_F_USO6: c_uint = 0x40; |
2651 | | -// Protocol info prepended to the packets (when IFF_NO_PI is not set) |
2652 | | -pub const TUN_PKT_STRIP: c_int = 0x0001; |
2653 | | -// Accept all multicast packets |
2654 | | -pub const TUN_FLT_ALLMULTI: c_int = 0x0001; |
2655 | | -// Ioctl operation codes |
2656 | | -const T_TYPE: u32 = b'T' as u32; |
2657 | | -pub const TUNSETNOCSUM: c_int = _IOW::<c_int>(T_TYPE, 200); |
2658 | | -pub const TUNSETDEBUG: c_int = _IOW::<c_int>(T_TYPE, 201); |
2659 | | -pub const TUNSETIFF: c_int = _IOW::<c_int>(T_TYPE, 202); |
2660 | | -pub const TUNSETPERSIST: c_int = _IOW::<c_int>(T_TYPE, 203); |
2661 | | -pub const TUNSETOWNER: c_int = _IOW::<c_int>(T_TYPE, 204); |
2662 | | -pub const TUNSETLINK: c_int = _IOW::<c_int>(T_TYPE, 205); |
2663 | | -pub const TUNSETGROUP: c_int = _IOW::<c_int>(T_TYPE, 206); |
2664 | | -pub const TUNGETFEATURES: c_int = _IOR::<c_int>(T_TYPE, 207); |
2665 | | -pub const TUNSETOFFLOAD: c_int = _IOW::<c_int>(T_TYPE, 208); |
2666 | | -pub const TUNSETTXFILTER: c_int = _IOW::<c_int>(T_TYPE, 209); |
2667 | | -pub const TUNGETIFF: c_int = _IOR::<c_int>(T_TYPE, 210); |
2668 | | -pub const TUNGETSNDBUF: c_int = _IOR::<c_int>(T_TYPE, 211); |
2669 | | -pub const TUNSETSNDBUF: c_int = _IOW::<c_int>(T_TYPE, 212); |
2670 | | -pub const TUNATTACHFILTER: c_int = _IOW::<sock_fprog>(T_TYPE, 213); |
2671 | | -pub const TUNDETACHFILTER: c_int = _IOW::<sock_fprog>(T_TYPE, 214); |
2672 | | -pub const TUNGETVNETHDRSZ: c_int = _IOR::<c_int>(T_TYPE, 215); |
2673 | | -pub const TUNSETVNETHDRSZ: c_int = _IOW::<c_int>(T_TYPE, 216); |
2674 | | -pub const TUNSETQUEUE: c_int = _IOW::<c_int>(T_TYPE, 217); |
2675 | | -pub const TUNSETIFINDEX: c_int = _IOW::<c_int>(T_TYPE, 218); |
2676 | | -pub const TUNGETFILTER: c_int = _IOR::<sock_fprog>(T_TYPE, 219); |
2677 | | -pub const TUNSETVNETLE: c_int = _IOW::<c_int>(T_TYPE, 220); |
2678 | | -pub const TUNGETVNETLE: c_int = _IOR::<c_int>(T_TYPE, 221); |
2679 | | -pub const TUNSETVNETBE: c_int = _IOW::<c_int>(T_TYPE, 222); |
2680 | | -pub const TUNGETVNETBE: c_int = _IOR::<c_int>(T_TYPE, 223); |
2681 | | -pub const TUNSETSTEERINGEBPF: c_int = _IOR::<c_int>(T_TYPE, 224); |
2682 | | -pub const TUNSETFILTEREBPF: c_int = _IOR::<c_int>(T_TYPE, 225); |
2683 | | -pub const TUNSETCARRIER: c_int = _IOW::<c_int>(T_TYPE, 226); |
2684 | | -pub const TUNGETDEVNETNS: c_int = _IO(T_TYPE, 227); |
2685 | | - |
2686 | 2570 | // start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h |
2687 | 2571 | // from https://android.googlesource.com/platform/bionic/+/HEAD/libc/kernel/uapi/linux/if_ether.h |
2688 | 2572 | pub const ETH_ALEN: c_int = 6; |
@@ -3716,7 +3600,6 @@ extern "C" { |
3716 | 3600 | pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; |
3717 | 3601 | pub fn mlock2(addr: *const c_void, len: size_t, flags: c_int) -> c_int; |
3718 | 3602 | pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; |
3719 | | - pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; |
3720 | 3603 | pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; |
3721 | 3604 | pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; |
3722 | 3605 | pub fn recvfrom( |
@@ -4257,28 +4140,3 @@ impl siginfo_t { |
4257 | 4140 | self.sifields().sigchld.si_stime |
4258 | 4141 | } |
4259 | 4142 | } |
4260 | | - |
4261 | | -/// Build an ioctl number for an argumentless ioctl. |
4262 | | -pub const fn _IO(ty: u32, nr: u32) -> c_int { |
4263 | | - super::_IOC(super::_IOC_NONE, ty, nr, 0) as c_int |
4264 | | -} |
4265 | | - |
4266 | | -/// Build an ioctl number for an read-only ioctl. |
4267 | | -pub const fn _IOR<T>(ty: u32, nr: u32) -> c_int { |
4268 | | - super::_IOC(super::_IOC_READ, ty, nr, mem::size_of::<T>()) as c_int |
4269 | | -} |
4270 | | - |
4271 | | -/// Build an ioctl number for an write-only ioctl. |
4272 | | -pub const fn _IOW<T>(ty: u32, nr: u32) -> c_int { |
4273 | | - super::_IOC(super::_IOC_WRITE, ty, nr, mem::size_of::<T>()) as c_int |
4274 | | -} |
4275 | | - |
4276 | | -/// Build an ioctl number for a read-write ioctl. |
4277 | | -pub const fn _IOWR<T>(ty: u32, nr: u32) -> c_int { |
4278 | | - super::_IOC( |
4279 | | - super::_IOC_READ | super::_IOC_WRITE, |
4280 | | - ty, |
4281 | | - nr, |
4282 | | - mem::size_of::<T>(), |
4283 | | - ) as c_int |
4284 | | -} |
0 commit comments