Skip to content

Add net interface device flag #839

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

Closed
wants to merge 5 commits into from
Closed
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
20 changes: 19 additions & 1 deletion src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,25 @@ pub const MSG_RCVMORE: ::c_int = 0x4000;
pub const SCM_TIMESTAMP: ::c_int = 0x02;
pub const SCM_CREDS: ::c_int = 0x03;

pub const IFF_LOOPBACK: ::c_int = 0x8;
/// https://github.com/aosm/xnu/blob/master/bsd/net/if.h#L140-L156
pub const IFF_UP: ::c_int = 0x1; // interface is up
pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
pub const IFF_NOTRAILERS: ::c_int = 0x20; // obsolete: avoid use of trailers
pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress
pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast


pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
Expand Down
56 changes: 37 additions & 19 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,31 @@ pub const NOTE_CHILD: ::uint32_t = 0x00000004;
pub const SO_SNDSPACE: ::c_int = 0x100a;
pub const SO_CPUHINT: ::c_int = 0x1030;

//
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/net/if.h#L101
pub const IFF_UP: ::c_int = 0x1; // interface is up
pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
pub const IFF_SMART: ::c_int = 0x20; // interface manages own routes
pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
pub const IFF_OACTIVE_COMPAT: ::c_int = 0x400; // was transmission in progress
pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
pub const IFF_POLLING_COMPAT: ::c_int = 0x10000; // was interface is in polling mode
pub const IFF_PPROMISC: ::c_int = 0x20000; // user-requested promisc mode
pub const IFF_MONITOR: ::c_int = 0x40000; // user-requested monitor mode
pub const IFF_STATICARP: ::c_int = 0x80000; // static ARP
pub const IFF_NPOLLING: ::c_int = 0x100000; // interface is in polling mode
pub const IFF_IDIRECT: ::c_int = 0x200000; // direct input

// sys/netinet/in.h
// Protocols (RFC 1700)
// NOTE: These are in addition to the constants defined in src/unix/mod.rs
Expand Down Expand Up @@ -590,7 +614,7 @@ pub const IPPROTO_GMTP: ::c_int = 100;
/// payload compression (IPComp)
pub const IPPROTO_IPCOMP: ::c_int = 108;

/* 101-254: Partly Unassigned */
// 101-254: Partly Unassigned
/// Protocol Independent Mcast
pub const IPPROTO_PIM: ::c_int = 103;
/// CARP
Expand All @@ -600,8 +624,8 @@ pub const IPPROTO_PGM: ::c_int = 113;
/// PFSYNC
pub const IPPROTO_PFSYNC: ::c_int = 240;

/* 255: Reserved */
/* BSD Private, local use, namespace incursion, no longer used */
// 255: Reserved
// BSD Private, local use, namespace incursion, no longer used
/// divert pseudo-protocol
pub const IPPROTO_DIVERT: ::c_int = 254;
pub const IPPROTO_MAX: ::c_int = 256;
Expand Down Expand Up @@ -653,12 +677,8 @@ pub const LC_MONETARY_MASK: ::c_int = (1 << 2);
pub const LC_NUMERIC_MASK: ::c_int = (1 << 3);
pub const LC_TIME_MASK: ::c_int = (1 << 4);
pub const LC_MESSAGES_MASK: ::c_int = (1 << 5);
pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
| LC_CTYPE_MASK
| LC_MESSAGES_MASK
| LC_MONETARY_MASK
| LC_NUMERIC_MASK
| LC_TIME_MASK;
pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | LC_MONETARY_MASK |
LC_NUMERIC_MASK | LC_TIME_MASK;

pub const TIOCSIG: ::c_uint = 0x2000745f;
pub const BTUARTDISC: ::c_int = 0x7;
Expand All @@ -669,11 +689,11 @@ pub const TIOCMODS: ::c_ulong = 0x80047404;
pub const TIOCREMOTE: ::c_ulong = 0x80047469;

// Constants used by "at" family of system calls.
pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor
pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor
pub const AT_SYMLINK_NOFOLLOW: ::c_int = 1;
pub const AT_REMOVEDIR: ::c_int = 2;
pub const AT_EACCESS: ::c_int = 4;
pub const AT_SYMLINK_FOLLOW: ::c_int = 8;
pub const AT_REMOVEDIR: ::c_int = 2;
pub const AT_EACCESS: ::c_int = 4;
pub const AT_SYMLINK_FOLLOW: ::c_int = 8;

pub const VCHECKPT: usize = 19;

Expand All @@ -687,17 +707,15 @@ pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 125;
pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 126;
pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 127;

extern {
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
extern "C" {
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;

pub fn setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int;

pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
timeout: *mut ::timespec) -> ::c_int;
pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut ::timespec) -> ::c_int;

pub fn freelocale(loc: ::locale_t);
}
91 changes: 49 additions & 42 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,31 @@ pub const AF_INET6_SDP: ::c_int = 42;
#[doc(hidden)]
pub const AF_MAX: ::c_int = 42;

// https://github.com/freebsd/freebsd/blob/master/sys/net/if.h#L140
pub const IFF_UP: ::c_int = 0x1; // (n) interface is up
pub const IFF_BROADCAST: ::c_int = 0x2; // (i) broadcast address valid
pub const IFF_DEBUG: ::c_int = 0x4; // (n) turn on debugging
pub const IFF_LOOPBACK: ::c_int = 0x8; // (i) is a loopback net
pub const IFF_POINTOPOINT: ::c_int = 0x10; // (i) is a point-to-point link
// 0x20 was IFF_SMART
pub const IFF_DRV_RUNNING: ::c_int = 0x40; // (d) resources allocated
pub const IFF_NOARP: ::c_int = 0x80; // (n) no address resolution protocol
pub const IFF_PROMISC: ::c_int = 0x100; // (n) receive all packets
pub const IFF_ALLMULTI: ::c_int = 0x200; // (n) receive all multicast packets
pub const IFF_DRV_OACTIVE: ::c_int = 0x400; // (d) tx hardware queue is full
pub const IFF_SIMPLEX: ::c_int = 0x800; // (i) can't hear own transmissions
pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
pub const IFF_MULTICAST: ::c_int = 0x8000; // (i) supports multicast
pub const IFF_CANTCONFIG: ::c_int = 0x10000; // (i) unconfigurable using ioctl(2)
pub const IFF_PPROMISC: ::c_int = 0x20000; // (n) user-requested promisc mode
pub const IFF_MONITOR: ::c_int = 0x40000; // (n) user-requested monitor mode
pub const IFF_STATICARP: ::c_int = 0x80000; // (n) static ARP
pub const IFF_DYING: ::c_int = 0x200000; // (n) interface is winding down
pub const IFF_RENAMING: ::c_int = 0x400000; // (n) interface is being renamed

// sys/netinet/in.h
// Protocols (RFC 1700)
// NOTE: These are in addition to the constants defined in src/unix/mod.rs
Expand Down Expand Up @@ -638,7 +663,7 @@ pub const IPPROTO_HIP: ::c_int = 139;
/// IP6 Shim6 Protocol
pub const IPPROTO_SHIM6: ::c_int = 140;

/* 101-254: Partly Unassigned */
// 101-254: Partly Unassigned
/// Protocol Independent Mcast
pub const IPPROTO_PIM: ::c_int = 103;
/// CARP
Expand All @@ -650,15 +675,15 @@ pub const IPPROTO_MPLS: ::c_int = 137;
/// PFSYNC
pub const IPPROTO_PFSYNC: ::c_int = 240;

/* 255: Reserved */
/* BSD Private, local use, namespace incursion, no longer used */
// 255: Reserved
// BSD Private, local use, namespace incursion, no longer used
/// OLD divert pseudo-proto
pub const IPPROTO_OLD_DIVERT: ::c_int = 254;
pub const IPPROTO_MAX: ::c_int = 256;
/// last return value of *_input(), meaning "all job for this pkt is done".
pub const IPPROTO_DONE: ::c_int = 257;

/* Only used internally, so can be outside the range of valid IP protocols. */
// Only used internally, so can be outside the range of valid IP protocols.
/// divert pseudo-protocol
pub const IPPROTO_DIVERT: ::c_int = 258;
/// SeND pseudo-protocol
Expand Down Expand Up @@ -691,9 +716,9 @@ pub const IPC_RMID: ::c_int = 0;
pub const IPC_SET: ::c_int = 1;
pub const IPC_STAT: ::c_int = 2;
pub const IPC_INFO: ::c_int = 3;
pub const IPC_R : ::c_int = 0o400;
pub const IPC_W : ::c_int = 0o200;
pub const IPC_M : ::c_int = 0o10000;
pub const IPC_R: ::c_int = 0o400;
pub const IPC_W: ::c_int = 0o200;
pub const IPC_M: ::c_int = 0o10000;
pub const MSG_NOERROR: ::c_int = 0o10000;
pub const SHM_RDONLY: ::c_int = 0o10000;
pub const SHM_RND: ::c_int = 0o20000;
Expand Down Expand Up @@ -744,12 +769,8 @@ pub const LC_MESSAGES_MASK: ::c_int = (1 << 2);
pub const LC_MONETARY_MASK: ::c_int = (1 << 3);
pub const LC_NUMERIC_MASK: ::c_int = (1 << 4);
pub const LC_TIME_MASK: ::c_int = (1 << 5);
pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
| LC_CTYPE_MASK
| LC_MESSAGES_MASK
| LC_MONETARY_MASK
| LC_NUMERIC_MASK
| LC_TIME_MASK;
pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | LC_MONETARY_MASK |
LC_NUMERIC_MASK | LC_TIME_MASK;

pub const WSTOPPED: ::c_int = 2; // same as WUNTRACED
pub const WCONTINUED: ::c_int = 4;
Expand Down Expand Up @@ -783,11 +804,10 @@ pub const _SC_CPUSET_SIZE: ::c_int = 122;
pub const XU_NGROUPS: ::c_int = 16;
pub const XUCRED_VERSION: ::c_uint = 0;

extern {
extern "C" {
pub fn __error() -> *mut ::c_int;

pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;

pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
Expand All @@ -796,44 +816,31 @@ extern {
pub fn jail(jail: *mut ::jail) -> ::c_int;
pub fn jail_attach(jid: ::c_int) -> ::c_int;
pub fn jail_remove(jid: ::c_int) -> ::c_int;
pub fn jail_get(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)
-> ::c_int;
pub fn jail_set(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)
-> ::c_int;

pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
len: ::off_t) -> ::c_int;
pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
advise: ::c_int) -> ::c_int;
pub fn jail_get(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int) -> ::c_int;
pub fn jail_set(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int) -> ::c_int;

pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int;
pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
pub fn mkostemps(template: *mut ::c_char,
suffixlen: ::c_int,
flags: ::c_int) -> ::c_int;
pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int;

pub fn getutxuser(user: *const ::c_char) -> *mut utmpx;
pub fn setutxdb(_type: ::c_int, file: *const ::c_char) -> ::c_int;

pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
timeout: *mut ::timespec) -> ::ssize_t;
pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut ::timespec) -> ::ssize_t;

pub fn freelocale(loc: ::locale_t) -> ::c_int;
pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t,
options: ::c_int) -> ::c_int;
pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int;

pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void,
shmflg: ::c_int) -> *mut ::c_void;
pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void;
pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
pub fn shmctl(shmid: ::c_int, cmd: ::c_int,
buf: *mut ::shmid_ds) -> ::c_int;
pub fn msgctl(msqid: ::c_int, cmd: ::c_int,
buf: *mut ::msqid_ds) -> ::c_int;
pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int;
pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut ::msqid_ds) -> ::c_int;
pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
msgtyp: ::c_long, msgflg: ::c_int) -> ::c_int;
pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
msgflg: ::c_int) -> ::c_int;
pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t, msgtyp: ::c_long, msgflg: ::c_int) -> ::c_int;
pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t, msgflg: ::c_int) -> ::c_int;
pub fn cfmakesane(termios: *mut ::termios);
}

Expand Down
Loading