Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ioctl flags in linux/if_tun.h #3960

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ TIME_WAIT
TMPFS_MAGIC
TMP_MAX
TRACEFS_MAGIC
TUNSETCARRIER
TUNGETDEVNETNS
UDF_SUPER_MAGIC
UNAME26
USBDEVICE_SUPER_MAGIC
Expand Down
26 changes: 26 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,32 @@ IFF_MULTI_QUEUE
IFF_NO_CARRIER
IFF_NOARP
IFF_NOFILTER
TUNSETNOCSUM
TUNSETDEBUG
TUNSETIFF
TUNSETPERSIST
TUNSETOWNER
TUNSETLINK
TUNSETGROUP
TUNGETFEATURES
TUNSETOFFLOAD
TUNSETTXFILTER
TUNGETIFF
TUNGETSNDBUF
TUNSETSNDBUF
TUNATTACHFILTER
TUNDETACHFILTER
TUNGETVNETHDRSZ
TUNSETVNETHDRSZ
TUNSETQUEUE
TUNSETIFINDEX
TUNGETFILTER
TUNSETVNETLE
TUNGETVNETLE
TUNSETVNETBE
TUNGETVNETBE
TUNSETSTEERINGEBPF
TUNSETFILTEREBPF
TUN_TX_TIMESTAMP
TUN_F_CSUM
TUN_F_TSO4
Expand Down
34 changes: 34 additions & 0 deletions src/unix/linux_like/linux/arch/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,34 @@ pub const BLKIOMIN: ::Ioctl = 0x1278;
pub const BLKIOOPT: ::Ioctl = 0x1279;
pub const BLKSSZGET: ::Ioctl = 0x1268;
pub const BLKPBSZGET: ::Ioctl = 0x127B;
// linux/if_tun.h
pub const TUNSETNOCSUM: ::Ioctl = 0x400454c8;
pub const TUNSETDEBUG: ::Ioctl = 0x400454c9;
pub const TUNSETIFF: ::Ioctl = 0x400454ca;
pub const TUNSETPERSIST: ::Ioctl = 0x400454cb;
pub const TUNSETOWNER: ::Ioctl = 0x400454cc;
pub const TUNSETLINK: ::Ioctl = 0x400454cd;
pub const TUNSETGROUP: ::Ioctl = 0x400454ce;
pub const TUNGETFEATURES: ::Ioctl = 0x800454cf;
pub const TUNSETOFFLOAD: ::Ioctl = 0x400454d0;
pub const TUNSETTXFILTER: ::Ioctl = 0x400454d1;
pub const TUNGETIFF: ::Ioctl = 0x800454d2;
pub const TUNGETSNDBUF: ::Ioctl = 0x800454d3;
pub const TUNSETSNDBUF: ::Ioctl = 0x400454d4;
pub const TUNGETVNETHDRSZ: ::Ioctl = 0x800454d7;
pub const TUNSETVNETHDRSZ: ::Ioctl = 0x400454d8;
pub const TUNSETQUEUE: ::Ioctl = 0x400454d9;
pub const TUNSETIFINDEX: ::Ioctl = 0x400454da;
pub const TUNSETVNETLE: ::Ioctl = 0x400454dc;
pub const TUNGETVNETLE: ::Ioctl = 0x800454dd;
/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
* little-endian hosts. Not all kernel configurations support them, but all
* configurations that support SET also support GET.
*/
pub const TUNSETVNETBE: ::Ioctl = 0x400454de;
pub const TUNGETVNETBE: ::Ioctl = 0x800454df;
pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x800454e0;
pub const TUNSETFILTEREBPF: ::Ioctl = 0x800454e1;

cfg_if! {
// Those type are constructed using the _IOC macro
Expand All @@ -227,6 +255,9 @@ cfg_if! {
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
pub const TUNATTACHFILTER: ::Ioctl = 0x400854d5;
pub const TUNDETACHFILTER: ::Ioctl = 0x400854d6;
pub const TUNGETFILTER: ::Ioctl = 0x800854db;
} else if #[cfg(any(target_arch = "x86_64",
target_arch = "riscv64",
target_arch = "aarch64",
Expand All @@ -240,6 +271,9 @@ cfg_if! {
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602;
pub const TUNATTACHFILTER: ::Ioctl = 0x401054d5;
pub const TUNDETACHFILTER: ::Ioctl = 0x401054d6;
pub const TUNGETFILTER: ::Ioctl = 0x801054db;
}
}

Expand Down
34 changes: 34 additions & 0 deletions src/unix/linux_like/linux/arch/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,34 @@ pub const BLKIOMIN: ::Ioctl = 0x20001278;
pub const BLKIOOPT: ::Ioctl = 0x20001279;
pub const BLKSSZGET: ::Ioctl = 0x20001268;
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
// linux/if_tun.h
pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8;
pub const TUNSETDEBUG: ::Ioctl = 0x800454c9;
pub const TUNSETIFF: ::Ioctl = 0x800454ca;
pub const TUNSETPERSIST: ::Ioctl = 0x800454cb;
pub const TUNSETOWNER: ::Ioctl = 0x800454cc;
pub const TUNSETLINK: ::Ioctl = 0x800454cd;
pub const TUNSETGROUP: ::Ioctl = 0x800454ce;
pub const TUNGETFEATURES: ::Ioctl = 0x400454cf;
pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0;
pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1;
pub const TUNGETIFF: ::Ioctl = 0x400454d2;
pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3;
pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4;
pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7;
pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8;
pub const TUNSETQUEUE: ::Ioctl = 0x800454d9;
pub const TUNSETIFINDEX: ::Ioctl = 0x800454da;
pub const TUNSETVNETLE: ::Ioctl = 0x800454dc;
pub const TUNGETVNETLE: ::Ioctl = 0x400454dd;
/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
* little-endian hosts. Not all kernel configurations support them, but all
* configurations that support SET also support GET.
*/
pub const TUNSETVNETBE: ::Ioctl = 0x800454de;
pub const TUNGETVNETBE: ::Ioctl = 0x400454df;
pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0;
pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1;

cfg_if! {
// Those type are constructed using the _IOC macro
Expand All @@ -209,6 +237,9 @@ cfg_if! {
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5;
pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6;
pub const TUNGETFILTER: ::Ioctl = 0x400854db;
} else if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
Expand All @@ -218,6 +249,9 @@ cfg_if! {
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5;
pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6;
pub const TUNGETFILTER: ::Ioctl = 0x401054db;
}
}

Expand Down
34 changes: 34 additions & 0 deletions src/unix/linux_like/linux/arch/powerpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,34 @@ pub const BLKIOOPT: ::Ioctl = 0x20001279;
pub const BLKSSZGET: ::Ioctl = 0x20001268;
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
//pub const FIOQSIZE: ::Ioctl = 0x40086680;
// linux/if_tun.h
pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8;
pub const TUNSETDEBUG: ::Ioctl = 0x800454c9;
pub const TUNSETIFF: ::Ioctl = 0x800454ca;
pub const TUNSETPERSIST: ::Ioctl = 0x800454cb;
pub const TUNSETOWNER: ::Ioctl = 0x800454cc;
pub const TUNSETLINK: ::Ioctl = 0x800454cd;
pub const TUNSETGROUP: ::Ioctl = 0x800454ce;
pub const TUNGETFEATURES: ::Ioctl = 0x400454cf;
pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0;
pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1;
pub const TUNGETIFF: ::Ioctl = 0x400454d2;
pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3;
pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4;
pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7;
pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8;
pub const TUNSETQUEUE: ::Ioctl = 0x800454d9;
pub const TUNSETIFINDEX: ::Ioctl = 0x800454da;
pub const TUNSETVNETLE: ::Ioctl = 0x800454dc;
pub const TUNGETVNETLE: ::Ioctl = 0x400454dd;
/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
* little-endian hosts. Not all kernel configurations support them, but all
* configurations that support SET also support GET.
*/
pub const TUNSETVNETBE: ::Ioctl = 0x800454de;
pub const TUNGETVNETBE: ::Ioctl = 0x400454df;
pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0;
pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1;

cfg_if! {
// Those type are constructed using the _IOC macro
Expand All @@ -195,6 +223,9 @@ cfg_if! {
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5;
pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6;
pub const TUNGETFILTER: ::Ioctl = 0x400854db;
} else if #[cfg(target_arch = "powerpc64")] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
Expand All @@ -204,6 +235,9 @@ cfg_if! {
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5;
pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6;
pub const TUNGETFILTER: ::Ioctl = 0x401054db;
}
}

Expand Down
35 changes: 35 additions & 0 deletions src/unix/linux_like/linux/arch/sparc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,35 @@ pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
//pub const TIOCGRS485: ::Ioctl = 0x40205441;
//pub const TIOCSRS485: ::Ioctl = 0xc0205442;

// linux/if_tun.h
pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8;
pub const TUNSETDEBUG: ::Ioctl = 0x800454c9;
pub const TUNSETIFF: ::Ioctl = 0x800454ca;
pub const TUNSETPERSIST: ::Ioctl = 0x800454cb;
pub const TUNSETOWNER: ::Ioctl = 0x800454cc;
pub const TUNSETLINK: ::Ioctl = 0x800454cd;
pub const TUNSETGROUP: ::Ioctl = 0x800454ce;
pub const TUNGETFEATURES: ::Ioctl = 0x400454cf;
pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0;
pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1;
pub const TUNGETIFF: ::Ioctl = 0x400454d2;
pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3;
pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4;
pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7;
pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8;
pub const TUNSETQUEUE: ::Ioctl = 0x800454d9;
pub const TUNSETIFINDEX: ::Ioctl = 0x800454da;
pub const TUNSETVNETLE: ::Ioctl = 0x800454dc;
pub const TUNGETVNETLE: ::Ioctl = 0x400454dd;
/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
* little-endian hosts. Not all kernel configurations support them, but all
* configurations that support SET also support GET.
*/
pub const TUNSETVNETBE: ::Ioctl = 0x800454de;
pub const TUNGETVNETBE: ::Ioctl = 0x400454df;
pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0;
pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1;

pub const TIOCM_LE: ::c_int = 0x001;
pub const TIOCM_DTR: ::c_int = 0x002;
pub const TIOCM_RTS: ::c_int = 0x004;
Expand Down Expand Up @@ -246,6 +275,9 @@ cfg_if! {
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5;
pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6;
pub const TUNGETFILTER: ::Ioctl = 0x400854db;
} else if #[cfg(target_arch = "sparc64")] {
pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601;
pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602;
Expand All @@ -255,5 +287,8 @@ cfg_if! {
pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602;
pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601;
pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602;
pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5;
pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6;
pub const TUNGETFILTER: ::Ioctl = 0x401054db;
}
}
23 changes: 23 additions & 0 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,29 @@ pub const REG_EEND: ::c_int = 14;
pub const REG_ESIZE: ::c_int = 15;
pub const REG_ERPAREN: ::c_int = 16;

cfg_if! {
if #[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64",
target_arch = "loongarch64",
target_arch = "riscv64",
target_arch = "s390x"))] {
pub const TUNSETCARRIER: ::Ioctl = 0x400454e2;
pub const TUNGETDEVNETNS: ::Ioctl = 0x54e3;
} else if #[cfg(any(target_arch = "mips",
target_arch = "mips64",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "sparc",
target_arch = "sparc64"))] {
pub const TUNSETCARRIER: ::Ioctl = 0x800454e2;
pub const TUNGETDEVNETNS: ::Ioctl = 0x200054e3;
} else {
// Unknown target_arch
}
}

extern "C" {
pub fn fgetspent_r(
fp: *mut ::FILE,
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,7 @@ pub const IFLA_INFO_SLAVE_KIND: ::c_ushort = 4;
pub const IFLA_INFO_SLAVE_DATA: ::c_ushort = 5;

// linux/if_tun.h
/* TUNSETIFF ifr flags */
pub const IFF_TUN: ::c_int = 0x0001;
pub const IFF_TAP: ::c_int = 0x0002;
pub const IFF_NAPI: ::c_int = 0x0010;
Expand Down