Skip to content

Commit 0d0d090

Browse files
committed
if_tun.h ioctls for android
Add missing constants from linux/if_tun.h header on android platform. Mainly ioctl operation codes
1 parent c0a3093 commit 0d0d090

File tree

8 files changed

+82
-1
lines changed

8 files changed

+82
-1
lines changed

libc-test/semver/android-aarch64.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ SYS_lseek
1717
SYS_memfd_secret
1818
SYS_mmap
1919
SYS_syscalls
20+
TUNATTACHFILTER
21+
TUNDETACHFILTER
22+
TUNGETFILTER
2023
__system_property_wait
2124
user_fpsimd_struct
2225
user_regs_struct

libc-test/semver/android-arm.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ SYS_ustat
114114
SYS_utimes
115115
SYS_vfork
116116
SYS_vserver
117+
TUNATTACHFILTER
118+
TUNDETACHFILTER
119+
TUNGETFILTER
117120
__c_anonymous_uc_sigmask
118121
__c_anonymous_uc_sigmask_with_padding
119122
greg_t

libc-test/semver/android-i686.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ AT_SYSINFO
22
AT_SYSINFO_EHDR
33
AT_VECTOR_SIZE_ARCH
44
SYS_memfd_secret
5+
TUNATTACHFILTER
6+
TUNDETACHFILTER
7+
TUNGETFILTER
58
__c_anonymous_uc_sigmask
69
__c_anonymous_uc_sigmask_with_padding
710
time64_t

libc-test/semver/android-x86_64.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ SYS_shmdt
6363
SYS_shmget
6464
SYS_tuxcall
6565
SYS_vserver
66+
TUNATTACHFILTER
67+
TUNDETACHFILTER
68+
TUNGETFILTER
6669
__c_anonymous_uc_sigmask
6770
_libc_fpxreg
6871
_libc_xmmreg

libc-test/semver/android.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2897,13 +2897,39 @@ TIOCSWINSZ
28972897
TMPFS_MAGIC
28982898
TMP_MAX
28992899
TOSTOP
2900+
TUNGETFEATURES
2901+
TUNGETIFF
2902+
TUNGETSNDBUF
2903+
TUNGETVNETBE
2904+
TUNGETVNETHDRSZ
2905+
TUNGETVNETLE
2906+
TUNSETDEBUG
2907+
TUNSETFILTEREBPF
2908+
TUNSETGROUP
2909+
TUNSETIFF
2910+
TUNSETIFINDEX
2911+
TUNSETLINK
2912+
TUNSETNOCSUM
2913+
TUNSETOFFLOAD
2914+
TUNSETOWNER
2915+
TUNSETPERSIST
2916+
TUNSETQUEUE
2917+
TUNSETSNDBUF
2918+
TUNSETSTEERINGEBPF
2919+
TUNSETTXFILTER
2920+
TUNSETVNETBE
2921+
TUNSETVNETHDRSZ
2922+
TUNSETVNETLE
29002923
TUN_F_CSUM
29012924
TUN_F_TSO4
29022925
TUN_F_TSO6
29032926
TUN_F_TSO_ECN
29042927
TUN_F_UFO
29052928
TUN_F_USO4
29062929
TUN_F_USO6
2930+
TUN_FLT_ALLMULTI
2931+
TUN_PKT_STRIP
2932+
TUN_TX_TIMESTAMP
29072933
UINPUT_MAX_NAME_SIZE
29082934
UINPUT_VERSION
29092935
UIO_MAXIOV

src/unix/linux_like/android/b32/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ pub const UT_HOSTSIZE: usize = 16;
232232
pub const SIGSTKSZ: size_t = 8192;
233233
pub const MINSIGSTKSZ: size_t = 2048;
234234

235+
// linux/if_tun.h
236+
// Ioctl operation codes
237+
pub const TUNATTACHFILTER: c_int = 0x400854d5;
238+
pub const TUNDETACHFILTER: c_int = 0x400854d6;
239+
pub const TUNGETFILTER: c_int = 0x800854db;
240+
235241
extern "C" {
236242
pub fn timegm64(tm: *const crate::tm) -> crate::time64_t;
237243
}

src/unix/linux_like/android/b64/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ pub const UT_LINESIZE: usize = 32;
288288
pub const UT_NAMESIZE: usize = 32;
289289
pub const UT_HOSTSIZE: usize = 256;
290290

291+
// linux/if_tun.h
292+
// Ioctl operation codes
293+
pub const TUNATTACHFILTER: c_int = 0x401054d5;
294+
pub const TUNDETACHFILTER: c_int = 0x401054d6;
295+
pub const TUNGETFILTER: c_int = 0x801054db;
296+
291297
f! {
292298
// Sadly, Android before 5.0 (API level 21), the accept4 syscall is not
293299
// exposed by the libc. As work-around, we implement it through `syscall`

src/unix/linux_like/android/mod.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2623,7 +2623,7 @@ pub const SND_CNT: usize = SND_MAX as usize + 1;
26232623
pub const UINPUT_VERSION: c_uint = 5;
26242624
pub const UINPUT_MAX_NAME_SIZE: usize = 80;
26252625

2626-
// bionic/libc/kernel/uapi/linux/if_tun.h
2626+
// linux/if_tun.h
26272627
pub const IFF_TUN: c_int = 0x0001;
26282628
pub const IFF_TAP: c_int = 0x0002;
26292629
pub const IFF_NAPI: c_int = 0x0010;
@@ -2638,6 +2638,7 @@ pub const IFF_ATTACH_QUEUE: c_int = 0x0200;
26382638
pub const IFF_DETACH_QUEUE: c_int = 0x0400;
26392639
pub const IFF_PERSIST: c_int = 0x0800;
26402640
pub const IFF_NOFILTER: c_int = 0x1000;
2641+
pub const TUN_TX_TIMESTAMP: c_int = 1;
26412642
// Features for GSO (TUNSETOFFLOAD)
26422643
pub const TUN_F_CSUM: c_uint = 0x01;
26432644
pub const TUN_F_TSO4: c_uint = 0x02;
@@ -2646,6 +2647,36 @@ pub const TUN_F_TSO_ECN: c_uint = 0x08;
26462647
pub const TUN_F_UFO: c_uint = 0x10;
26472648
pub const TUN_F_USO4: c_uint = 0x20;
26482649
pub const TUN_F_USO6: c_uint = 0x40;
2650+
// Protocol info prepended to the packets (when IFF_NO_PI is not set)
2651+
pub const TUN_PKT_STRIP: c_int = 0x0001;
2652+
// Accept all multicast packets
2653+
pub const TUN_FLT_ALLMULTI: c_int = 0x0001;
2654+
// Ioctl operation codes
2655+
pub const TUNSETNOCSUM: c_int = 0x400454c8;
2656+
pub const TUNSETDEBUG: c_int = 0x400454c9;
2657+
pub const TUNSETIFF: c_int = 0x400454ca;
2658+
pub const TUNSETPERSIST: c_int = 0x400454cb;
2659+
pub const TUNSETOWNER: c_int = 0x400454cc;
2660+
pub const TUNSETLINK: c_int = 0x400454cd;
2661+
pub const TUNSETGROUP: c_int = 0x400454ce;
2662+
pub const TUNGETFEATURES: c_int = 0x800454cf;
2663+
pub const TUNSETOFFLOAD: c_int = 0x400454d0;
2664+
pub const TUNSETTXFILTER: c_int = 0x400454d1;
2665+
pub const TUNGETIFF: c_int = 0x800454d2;
2666+
pub const TUNGETSNDBUF: c_int = 0x800454d3;
2667+
pub const TUNSETSNDBUF: c_int = 0x400454d4;
2668+
pub const TUNGETVNETHDRSZ: c_int = 0x800454d7;
2669+
pub const TUNSETVNETHDRSZ: c_int = 0x400454d8;
2670+
pub const TUNSETQUEUE: c_int = 0x400454d9;
2671+
pub const TUNSETIFINDEX: c_int = 0x400454da;
2672+
pub const TUNSETVNETLE: c_int = 0x400454dc;
2673+
pub const TUNGETVNETLE: c_int = 0x800454dd;
2674+
pub const TUNSETVNETBE: c_int = 0x400454de;
2675+
pub const TUNGETVNETBE: c_int = 0x800454df;
2676+
pub const TUNSETSTEERINGEBPF: c_int = 0x800454e0;
2677+
pub const TUNSETFILTEREBPF: c_int = 0x800454e1;
2678+
pub const TUNSETCARRIER: c_int = 0x400454e2;
2679+
pub const TUNGETDEVNETNS: c_int = 0x000054e3;
26492680

26502681
// start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h
26512682
// from https://android.googlesource.com/platform/bionic/+/HEAD/libc/kernel/uapi/linux/if_ether.h

0 commit comments

Comments
 (0)