Skip to content

Commit a58ce98

Browse files
committed
Auto merge of #873 - LuoZijun:patch-2, r=alexcrichton
Add `net/if_utun.h` and `linux/if_tun.h` constants for macos and linux platform Add `net/if_utun.h` constants for macos platform. Add `linux/if_tun.h` constants for linux platform.
2 parents 2cff15e + 348bda9 commit a58ce98

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ fn main() {
169169
cfg.header("xlocale.h");
170170
cfg.header("sys/xattr.h");
171171
cfg.header("sys/sys_domain.h");
172+
cfg.header("net/if_utun.h");
172173
if target.starts_with("x86") {
173174
cfg.header("crt_externs.h");
174175
}
@@ -264,6 +265,7 @@ fn main() {
264265
cfg.header("linux/random.h");
265266
cfg.header("elf.h");
266267
cfg.header("link.h");
268+
cfg.header("linux/if_tun.h");
267269
}
268270

269271
if freebsd {

src/unix/bsd/apple/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ pub const MSG_RCVMORE: ::c_int = 0x4000;
15231523
pub const SCM_TIMESTAMP: ::c_int = 0x02;
15241524
pub const SCM_CREDS: ::c_int = 0x03;
15251525

1526-
/// https://github.com/aosm/xnu/blob/master/bsd/net/if.h#L140-L156
1526+
// https://github.com/aosm/xnu/blob/master/bsd/net/if.h#L140-L156
15271527
pub const IFF_UP: ::c_int = 0x1; // interface is up
15281528
pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
15291529
pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
@@ -2070,6 +2070,10 @@ pub const LC_SEGMENT_64: u32 = 0x19;
20702070
pub const MH_MAGIC: u32 = 0xfeedface;
20712071
pub const MH_MAGIC_64: u32 = 0xfeedfacf;
20722072

2073+
// net/if_utun.h
2074+
pub const UTUN_OPT_FLAGS: ::c_int = 1;
2075+
pub const UTUN_OPT_IFNAME: ::c_int = 2;
2076+
20732077
f! {
20742078
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
20752079
status >> 8

src/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ pub const S_ISGID: ::c_int = 0x400;
210210
pub const S_ISVTX: ::c_int = 0x200;
211211

212212
pub const IF_NAMESIZE: ::size_t = 16;
213+
pub const IFNAMSIZ: ::size_t = IF_NAMESIZE;
213214

214215
pub const LOG_EMERG: ::c_int = 0;
215216
pub const LOG_ALERT: ::c_int = 1;

src/unix/notbsd/linux/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,28 @@ pub const IFF_LOWER_UP: ::c_int = 0x10000;
726726
pub const IFF_DORMANT: ::c_int = 0x20000;
727727
pub const IFF_ECHO: ::c_int = 0x40000;
728728

729+
// linux/if_tun.h
730+
// Read queue size
731+
pub const TUN_READQ_SIZE: ::c_short = 500;
732+
// TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead.
733+
pub const TUN_TUN_DEV: ::c_short = IFF_TUN;
734+
pub const TUN_TAP_DEV: ::c_short = IFF_TAP;
735+
pub const TUN_TYPE_MASK: ::c_short = 0x000f;
736+
// TUNSETIFF ifr flags
737+
pub const IFF_TUN: ::c_short = 0x0001;
738+
pub const IFF_TAP: ::c_short = 0x0002;
739+
pub const IFF_NO_PI: ::c_short = 0x1000;
740+
// This flag has no real effect
741+
pub const IFF_ONE_QUEUE: ::c_short = 0x2000;
742+
pub const IFF_VNET_HDR: ::c_short = 0x4000;
743+
pub const IFF_TUN_EXCL: ::c_short = 0x8000;
744+
pub const IFF_MULTI_QUEUE: ::c_short = 0x0100;
745+
pub const IFF_ATTACH_QUEUE: ::c_short = 0x0200;
746+
pub const IFF_DETACH_QUEUE: ::c_short = 0x0400;
747+
// read-only flag
748+
pub const IFF_PERSIST: ::c_short = 0x0800;
749+
pub const IFF_NOFILTER: ::c_short = 0x1000;
750+
729751
pub const ST_RDONLY: ::c_ulong = 1;
730752
pub const ST_NOSUID: ::c_ulong = 2;
731753
pub const ST_NODEV: ::c_ulong = 4;

0 commit comments

Comments
 (0)