From 468478cfb3f36b2d919036109a0c3a4ff180911c Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Fri, 16 Aug 2024 15:35:41 -0400 Subject: [PATCH] *BSD: Add ioctls for BPF/network interface operations --- libc-test/build.rs | 4 ++ libc-test/semver/apple.txt | 27 +++++++++++++ libc-test/semver/dragonfly.txt | 43 +++++++++++++++++++++ libc-test/semver/freebsd.txt | 46 +++++++++++++++++++++++ libc-test/semver/netbsd.txt | 45 ++++++++++++++++++++++ libc-test/semver/openbsd.txt | 38 +++++++++++++++++++ src/unix/bsd/apple/mod.rs | 43 +++++++++++---------- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 13 +++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 42 +++++++++++++++++++++ src/unix/bsd/freebsdlike/mod.rs | 16 +++++--- src/unix/bsd/mod.rs | 42 +++++++++++++++++++++ src/unix/bsd/netbsdlike/mod.rs | 5 +++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 24 ++++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 16 ++++++++ 14 files changed, 379 insertions(+), 25 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 16964b75e1d6..c510f21ffa3b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -453,6 +453,7 @@ fn test_openbsd(target: &str) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", + "netinet6/in6_var.h", "net/bpf.h", "regex.h", "resolv.h", @@ -1035,6 +1036,7 @@ fn test_netbsd(target: &str) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", + "netinet6/in6_var.h", "poll.h", "pthread.h", "pwd.h", @@ -1240,6 +1242,7 @@ fn test_dragonflybsd(target: &str) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", + "netinet6/in6_var.h", "poll.h", "pthread.h", "pthread_np.h", @@ -2056,6 +2059,7 @@ fn test_freebsd(target: &str) { "netinet/sctp.h", "netinet/tcp.h", "netinet/udp.h", + "netinet6/in6_var.h", "poll.h", "pthread.h", "pthread_np.h", diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index bb80ce86b48c..f4e7ecb0ecf9 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1313,7 +1313,32 @@ SIGINFO SIGIO SIGNATURE SIGSTKSZ +SIOCADDMULTI +SIOCAIFADDR +SIOCAIFADDR_IN6 +SIOCDELMULTI +SIOCDIFADDR +SIOCDIFADDR_IN6 SIOCGIFADDR +SIOCGIFBRDADDR +SIOCGIFCAP +SIOCGIFDEVMTU +SIOCGIFDSTADDR +SIOCGIFFLAGS +SIOCGIFMTU +SIOCGIFNETMASK +SIOCIFCREATE +SIOCIFCREATE2 +SIOCIFDESTROY +SIOCSDRVSPEC +SIOCSIFADDR +SIOCSIFBRDADDR +SIOCSIFCAP +SIOCSIFDSTADDR +SIOCSIFFLAGS +SIOCSIFLLADDR +SIOCSIFMTU +SIOCSIFNETMASK SOCK_MAXADDRLEN SOCK_RAW SOCK_RDM @@ -1768,6 +1793,8 @@ backtrace_symbols_fd basename boolean_t bpf_hdr +bpf_stat +bpf_version brk bsearch chflags diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index a0cc6c6c83fc..fb3ef2007938 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -82,22 +82,26 @@ B14400 B28800 B7200 B76800 +BIOCFEEDBACK BIOCFLUSH BIOCGBLEN BIOCGDLT BIOCGDLTLIST BIOCGETIF +BIOCGFEEDBACK BIOCGHDRCMPLT BIOCGRSIG BIOCGRTIMEOUT BIOCGSEESENT BIOCGSTATS BIOCIMMEDIATE +BIOCLOCK BIOCPROMISC BIOCSBLEN BIOCSDLT BIOCSETF BIOCSETIF +BIOCSFEEDBACK BIOCSHDRCMPLT BIOCSRSIG BIOCSRTIMEOUT @@ -870,6 +874,22 @@ RLIMIT_STACK RLIMIT_VMEM RLIM_INFINITY RLIM_NLIMITS +RTAX_AUTHOR +RTAX_BRD +RTAX_DST +RTAX_GATEWAY +RTAX_GENMASK +RTAX_IFA +RTAX_IFP +RTAX_NETMASK +RTA_AUTHOR +RTA_BRD +RTA_DST +RTA_GATEWAY +RTA_GENMASK +RTA_IFA +RTA_IFP +RTA_NETMASK RTLD_NEXT RTLD_NODELETE RTLD_NOLOAD @@ -918,7 +938,30 @@ SIGINFO SIGIO SIGNATURE SIGSTKSZ +SIOCADDMULTI +SIOCAIFADDR +SIOCAIFADDR_IN6 +SIOCDELMULTI +SIOCDIFADDR +SIOCDIFADDR_IN6 SIOCGIFADDR +SIOCGIFBRDADDR +SIOCGIFCAP +SIOCGIFDSTADDR +SIOCGIFFLAGS +SIOCGIFMTU +SIOCGIFNETMASK +SIOCIFCREATE +SIOCIFCREATE2 +SIOCIFDESTROY +SIOCSDRVSPEC +SIOCSIFADDR +SIOCSIFBRDADDR +SIOCSIFCAP +SIOCSIFDSTADDR +SIOCSIFFLAGS +SIOCSIFMTU +SIOCSIFNETMASK SLIPDISC SOCK_CLOEXEC SOCK_MAXADDRLEN diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 4e1f998f3998..3edb9dcb2764 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -117,6 +117,7 @@ B7200 B76800 B921600 BIOCFLUSH +BIOCFEEDBACK BIOCGBLEN BIOCGDLT BIOCGDLTLIST @@ -127,12 +128,15 @@ BIOCGRTIMEOUT BIOCGSEESENT BIOCGSTATS BIOCIMMEDIATE +BIOCLOCK BIOCPROMISC +BIOCROTZBUF BIOCSBLEN BIOCSDLT BIOCSETF BIOCSETFNR BIOCSETIF +BIOCSETZBUF BIOCSHDRCMPLT BIOCSRSIG BIOCSRTIMEOUT @@ -1221,6 +1225,22 @@ RLIMIT_UMTXP RLIMIT_VMEM RLIM_INFINITY RLIM_NLIMITS +RTAX_AUTHOR +RTAX_BRD +RTAX_DST +RTAX_GATEWAY +RTAX_GENMASK +RTAX_IFA +RTAX_IFP +RTAX_NETMASK +RTA_AUTHOR +RTA_BRD +RTA_DST +RTA_GATEWAY +RTA_GENMASK +RTA_IFA +RTA_IFP +RTA_NETMASK RTLD_NEXT RTLD_NODELETE RTLD_NOLOAD @@ -1417,7 +1437,30 @@ SIGLIBRT SIGLWP SIGSTKSZ SIGTHR +SIOCADDMULTI +SIOCAIFADDR +SIOCAIFADDR_IN6 +SIOCDELMULTI +SIOCDIFADDR +SIOCDIFADDR_IN6 SIOCGIFADDR +SIOCGIFBRDADDR +SIOCGIFCAP +SIOCGIFDSTADDR +SIOCGIFFLAGS +SIOCGIFMTU +SIOCGIFNETMASK +SIOCIFCREATE +SIOCIFCREATE2 +SIOCIFDESTROY +SIOCSDRVSPEC +SIOCSIFADDR +SIOCSIFBRDADDR +SIOCSIFCAP +SIOCSIFDSTADDR +SIOCSIFFLAGS +SIOCSIFMTU +SIOCSIFNETMASK SLIPDISC SOCKCREDSIZE SOCK_CLOEXEC @@ -1819,7 +1862,10 @@ bpf_hdr bpf_insn bpf_program bpf_stat +bpf_ts bpf_version +bpf_xhdr +bpf_zbuf bsearch cap_enter cap_getmode diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index b82d9cbeca06..44d08df7b866 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -104,19 +104,23 @@ B460800 B7200 B76800 B921600 +BIOCFEEDBACK BIOCFLUSH BIOCGBLEN BIOCGDLT BIOCGETIF +BIOCGFEEDBACK BIOCGHDRCMPLT BIOCGRSIG BIOCGSEESENT BIOCGSTATS BIOCIMMEDIATE +BIOCLOCK BIOCPROMISC BIOCSBLEN BIOCSDLT BIOCSETIF +BIOCSFEEDBACK BIOCSHDRCMPLT BIOCSRSIG BIOCSSEESENT @@ -926,6 +930,22 @@ RLIM_INFINITY RLIM_NLIMITS RLIM_SAVED_CUR RLIM_SAVED_MAX +RTAX_AUTHOR +RTAX_BRD +RTAX_DST +RTAX_GATEWAY +RTAX_GENMASK +RTAX_IFA +RTAX_IFP +RTAX_NETMASK +RTA_AUTHOR +RTA_BRD +RTA_DST +RTA_GATEWAY +RTA_GENMASK +RTA_IFA +RTA_IFP +RTA_NETMASK RTLD_NEXT RTLD_NOLOAD RTLD_SELF @@ -958,7 +978,30 @@ SIGINFO SIGIO SIGNATURE SIGSTKSZ +SIOCADDMULTI +SIOCAIFADDR +SIOCAIFADDR_IN6 +SIOCDELMULTI +SIOCDIFADDR +SIOCDIFADDR_IN6 SIOCGIFADDR +SIOCGIFBRDADDR +SIOCGIFCAP +SIOCGIFDSTADDR +SIOCGIFFLAGS +SIOCGIFMTU +SIOCGIFNETMASK +SIOCIFCREATE +SIOCIFCREATE2 +SIOCIFDESTROY +SIOCSDRVSPEC +SIOCSIFADDR +SIOCSIFBRDADDR +SIOCSIFCAP +SIOCSIFDSTADDR +SIOCSIFFLAGS +SIOCSIFMTU +SIOCSIFNETMASK SOCKCREDSIZE SOCK_CLOEXEC SOCK_CONN_DGRAM @@ -1214,6 +1257,8 @@ backtrace_symbols backtrace_symbols_fd backtrace_symbols_fmt backtrace_symbols_fd_fmt +bpf_stat +bpf_version bsearch chflags chroot diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 3833884c855c..d110e999054b 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -78,6 +78,7 @@ BIOCGHDRCMPLT BIOCGRSIG BIOCGSTATS BIOCIMMEDIATE +BIOCLOCK BIOCPROMISC BIOCSBLEN BIOCSDLT @@ -760,6 +761,22 @@ RLIM_INFINITY RLIM_NLIMITS RLIM_SAVED_CUR RLIM_SAVED_MAX +RTAX_AUTHOR +RTAX_BRD +RTAX_DST +RTAX_GATEWAY +RTAX_GENMASK +RTAX_IFA +RTAX_IFP +RTAX_NETMASK +RTA_AUTHOR +RTA_BRD +RTA_DST +RTA_GATEWAY +RTA_GENMASK +RTA_IFA +RTA_IFP +RTA_NETMASK RTLD_NEXT RTLD_SELF RUSAGE_CHILDREN @@ -781,7 +798,26 @@ SIGEMT SIGINFO SIGIO SIGSTKSZ +SIOCADDMULTI +SIOCAIFADDR +SIOCAIFADDR_IN6 +SIOCDELMULTI +SIOCDIFADDR +SIOCDIFADDR_IN6 SIOCGIFADDR +SIOCGIFBRDADDR +SIOCGIFDSTADDR +SIOCGIFFLAGS +SIOCGIFMTU +SIOCGIFNETMASK +SIOCIFCREATE +SIOCIFDESTROY +SIOCSIFADDR +SIOCSIFBRDADDR +SIOCSIFDSTADDR +SIOCSIFFLAGS +SIOCSIFMTU +SIOCSIFNETMASK SOCK_CLOEXEC SOCK_DNS SOCK_NONBLOCK @@ -1012,6 +1048,8 @@ backtrace_symbols backtrace_symbols_fd backtrace_symbols_fmt basename +bpf_stat +bpf_version bsearch caddr_t calloc_conceal diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 9951f2314153..3c575c9cb6be 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -161,6 +161,8 @@ pub type copyfile_callback_t = ::Option< pub type attrgroup_t = u32; pub type vol_capabilities_set_t = [u32; 4]; +pub type u_int = ::c_uint; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl ::Copy for timezone {} @@ -1208,6 +1210,12 @@ s! { pub ifs6_out_mldreport: ::u_quad_t, pub ifs6_out_mlddone: ::u_quad_t, } + + // net/bpf.h + pub struct bpf_stat { + pub bs_recv: ::u_int, + pub bs_drop: ::u_int, + } } s_no_extra_traits! { @@ -3813,6 +3821,22 @@ pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; pub const CTLIOCGINFO: c_ulong = 0xc0644e03; +// +pub const SIOCAIFADDR: ::c_ulong = 0x8040691a; +pub const SIOCGIFCAP: ::c_ulong = 0xc020695b; +pub const SIOCGIFDEVMTU: ::c_ulong = 0xc0206944; +pub const SIOCGIFMTU: ::c_ulong = 0xc0206933; +pub const SIOCIFCREATE: ::c_ulong = 0xc0206978; +pub const SIOCIFCREATE2: ::c_ulong = 0xc020697a; +pub const SIOCSDRVSPEC: ::c_ulong = 0x8028697b; +pub const SIOCSIFCAP: ::c_ulong = 0x8020695a; +pub const SIOCSIFLLADDR: ::c_ulong = 0x8020693c; +pub const SIOCSIFMTU: ::c_ulong = 0x80206934; + +// +pub const SIOCAIFADDR_IN6: ::c_ulong = 0x8080691a; +pub const SIOCDIFADDR_IN6: ::c_ulong = 0x81206919; + // // sys/netinet/in.h // Protocols (RFC 1700) @@ -4966,25 +4990,6 @@ pub const RTV_SSTHRESH: ::c_int = 0x20; pub const RTV_RTT: ::c_int = 0x40; pub const RTV_RTTVAR: ::c_int = 0x80; -// Bitmask values for rtm_addrs. -pub const RTA_DST: ::c_int = 0x1; -pub const RTA_GATEWAY: ::c_int = 0x2; -pub const RTA_NETMASK: ::c_int = 0x4; -pub const RTA_GENMASK: ::c_int = 0x8; -pub const RTA_IFP: ::c_int = 0x10; -pub const RTA_IFA: ::c_int = 0x20; -pub const RTA_AUTHOR: ::c_int = 0x40; -pub const RTA_BRD: ::c_int = 0x80; - -// Index offsets for sockaddr array for alternate internal encoding. -pub const RTAX_DST: ::c_int = 0; -pub const RTAX_GATEWAY: ::c_int = 1; -pub const RTAX_NETMASK: ::c_int = 2; -pub const RTAX_GENMASK: ::c_int = 3; -pub const RTAX_IFP: ::c_int = 4; -pub const RTAX_IFA: ::c_int = 5; -pub const RTAX_AUTHOR: ::c_int = 6; -pub const RTAX_BRD: ::c_int = 7; pub const RTAX_MAX: ::c_int = 8; pub const KERN_PROCARGS2: ::c_int = 49; diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 489b82adb84b..23657fa323f7 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1159,6 +1159,19 @@ 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 +// +pub const BIOCLOCK: ::c_ulong = 0x2004427a; +pub const BIOCGFEEDBACK: ::c_ulong = 0x4004427c; +pub const BIOCSFEEDBACK: ::c_ulong = 0x8004427d; +pub const BIOCFEEDBACK: ::c_ulong = ::BIOCSFEEDBACK; + +// +pub const SIOCAIFADDR: ::c_ulong = 0x8020691a; + +// +pub const SIOCAIFADDR_IN6: ::c_ulong = 0x80206919; +pub const SIOCDIFADDR_IN6: ::c_ulong = 0x80206918; + // // sys/netinet/in.h // Protocols (RFC 1700) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 307ca87127f3..2cc19186f371 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -50,6 +50,13 @@ pub type sctp_assoc_t = u32; pub type eventfd_t = u64; +// net/bpf.h + +pub type bpf_int32 = i32; +pub type bpf_u_int32 = u32; +pub type bpf_int64 = i64; +pub type bpf_u_int64 = u64; + #[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_support_flags { @@ -1350,6 +1357,26 @@ s! { pub strchange_instrms: u16, pub strchange_outstrms: u16, } + + // net/bpf.h + + pub struct bpf_zbuf { + pub bz_bufa: *mut ::c_void, + pub bz_bufb: *mut ::c_void, + pub bz_buflen: ::size_t, + } + + pub struct bpf_ts { + pub bt_sec: ::bpf_int64, + pub bt_frac: ::bpf_u_int64, + } + + pub struct bpf_xhdr { + pub bh_tstamp: ::bpf_ts, + pub bh_caplen: ::bpf_u_int32, + pub bh_datalen: ::bpf_u_int32, + pub bh_hdrlen: ::c_ushort, + } } s_no_extra_traits! { @@ -3311,6 +3338,21 @@ pub const AF_IEEE80211: ::c_int = 37; pub const AF_INET_SDP: ::c_int = 40; pub const AF_INET6_SDP: ::c_int = 42; +// +pub const BIOCROTZBUF: ::c_ulong = 0x40184280; +pub const BIOCSETZBUF: ::c_ulong = 0x80184281; +pub const BIOCLOCK: ::c_ulong = 0x2000427a; +pub const BIOCFEEDBACK: ::c_ulong = 0x8004427c; + +// +pub const OSIOCAIFADDR: ::c_ulong = 0x8040691a; +pub const SIOCAIFADDR: ::c_ulong = 0x8044692b; + +// +pub const OSIOCAIFADDR_IN6: ::c_ulong = 0x8080691a; +pub const SIOCAIFADDR_IN6: ::c_ulong = 0x8088691b; +pub const SIOCDIFADDR_IN6: ::c_ulong = 0x81206919; + // sys/net/if.h pub const IF_MAXUNIT: ::c_int = 0x7fff; /// (n) interface is up diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 89557e152062..6b18646ff236 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -306,11 +306,6 @@ s! { pub bs_drop: ::c_uint, } - pub struct bpf_version { - pub bv_major: ::c_ushort, - pub bv_minor: ::c_ushort, - } - pub struct bpf_hdr { pub bh_tstamp: ::timeval, pub bh_caplen: u32, @@ -1354,7 +1349,16 @@ pub const SF_NOUNLINK: ::c_ulong = 0x00100000; pub const TIMER_ABSTIME: ::c_int = 1; -// +// +pub const SIOCGIFCAP: ::c_ulong = 0xc020691f; +pub const SIOCGIFMTU: ::c_ulong = 0xc0206933; +pub const SIOCIFCREATE: ::c_ulong = 0xc020697a; +pub const SIOCIFCREATE2: ::c_ulong = 0xc020697c; +pub const SIOCSDRVSPEC: ::c_ulong = 0x8028697b; +pub const SIOCSIFCAP: ::c_ulong = 0x8020691e; +pub const SIOCSIFMTU: ::c_ulong = 0x80206934; + +// pub const NTP_API: ::c_int = 4; pub const MAXPHASE: ::c_long = 500000000; pub const MAXFREQ: ::c_long = 500000; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 83e675ca3474..324acd583ede 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -122,6 +122,11 @@ s! { pub flag: *mut ::c_int, pub val: ::c_int, } + + pub struct bpf_version { + pub bv_major: ::c_ushort, + pub bv_minor: ::c_ushort, + } } s_no_extra_traits! { @@ -493,7 +498,22 @@ pub const BIOCIMMEDIATE: ::c_ulong = 0x80044270; pub const BIOCVERSION: ::c_ulong = 0x40044271; pub const BIOCGHDRCMPLT: ::c_ulong = 0x40044274; pub const BIOCSHDRCMPLT: ::c_ulong = 0x80044275; + +// +pub const SIOCADDMULTI: ::c_ulong = 0x80206931; +pub const SIOCDELMULTI: ::c_ulong = 0x80206932; +pub const SIOCDIFADDR: ::c_ulong = 0x80206919; pub const SIOCGIFADDR: ::c_ulong = 0xc0206921; +pub const SIOCGIFBRDADDR: ::c_ulong = 0xc0206923; +pub const SIOCGIFDSTADDR: ::c_ulong = 0xc0206922; +pub const SIOCGIFFLAGS: ::c_ulong = 0xc0206911; +pub const SIOCGIFNETMASK: ::c_ulong = 0xc0206925; +pub const SIOCIFDESTROY: ::c_ulong = 0x80206979; +pub const SIOCSIFADDR: ::c_ulong = 0x8020690c; +pub const SIOCSIFBRDADDR: ::c_ulong = 0x80206913; +pub const SIOCSIFDSTADDR: ::c_ulong = 0x8020690e; +pub const SIOCSIFFLAGS: ::c_ulong = 0x80206910; +pub const SIOCSIFNETMASK: ::c_ulong = 0x80206916; pub const REG_BASIC: ::c_int = 0o0000; pub const REG_EXTENDED: ::c_int = 0o0001; @@ -541,6 +561,28 @@ pub const ITIMER_REAL: ::c_int = 0; pub const ITIMER_VIRTUAL: ::c_int = 1; pub const ITIMER_PROF: ::c_int = 2; +// + +// Bitmask values for rtm_addrs. +pub const RTA_DST: ::c_int = 0x1; +pub const RTA_GATEWAY: ::c_int = 0x2; +pub const RTA_NETMASK: ::c_int = 0x4; +pub const RTA_GENMASK: ::c_int = 0x8; +pub const RTA_IFP: ::c_int = 0x10; +pub const RTA_IFA: ::c_int = 0x20; +pub const RTA_AUTHOR: ::c_int = 0x40; +pub const RTA_BRD: ::c_int = 0x80; + +// Index offsets for sockaddr array for alternate internal encoding. +pub const RTAX_DST: ::c_int = 0; +pub const RTAX_GATEWAY: ::c_int = 1; +pub const RTAX_NETMASK: ::c_int = 2; +pub const RTAX_GENMASK: ::c_int = 3; +pub const RTAX_IFP: ::c_int = 4; +pub const RTAX_IFA: ::c_int = 5; +pub const RTAX_AUTHOR: ::c_int = 6; +pub const RTAX_BRD: ::c_int = 7; + f! { pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr { if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 29f54b92cd48..cf328028e94f 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -664,6 +664,11 @@ pub const RB_AUTOBOOT: ::c_int = 0; pub const TCP_INFO: ::c_int = 9; +// +pub const SIOCAIFADDR: ::c_ulong = 0x8020691a; +pub const SIOCIFCREATE: ::c_ulong = 0x8020697a; +pub const SIOCSIFMTU: ::c_ulong = 0x8020697f; + #[link(name = "util")] extern "C" { pub fn setgrent(); diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index f919b73e5c2f..2b884b60e56d 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -777,6 +777,14 @@ s! { pub tcpi_snd_zerowin: u32, pub __tcpi_pad: [u32; 26], } + + // + pub struct bpf_stat { + pub bs_recv: u64, + pub bs_drop: u64, + pub bs_capt: u64, + pub bs_padding: [u64; 13], + } } s_no_extra_traits! { @@ -1852,6 +1860,22 @@ pub const BIOCSDLT: ::c_ulong = 0x80044278; pub const BIOCGSEESENT: ::c_ulong = 0x40044276; pub const BIOCSSEESENT: ::c_ulong = 0x80044277; +// +pub const BIOCGFEEDBACK: ::c_ulong = 0x4004427c; +pub const BIOCSFEEDBACK: ::c_ulong = 0x8004427d; +pub const BIOCFEEDBACK: ::c_ulong = ::BIOCSFEEDBACK; +pub const BIOCLOCK: ::c_ulong = 0x2004427e; + +// +pub const SIOCGIFCAP: ::c_ulong = 0xc0206976; +pub const SIOCIFCREATE2: ::c_ulong = 0xc020697c; +pub const SIOCSDRVSPEC: ::c_ulong = 0x8020697b; +pub const SIOCSIFCAP: ::c_ulong = 0x80206975; + +// +pub const SIOCAIFADDR_IN6: ::c_ulong = 0x8020696b; +pub const SIOCDIFADDR_IN6: ::c_ulong = 0x80206919; + // pub const MNT_UNION: ::c_int = 0x00000020; pub const MNT_NOCOREDUMP: ::c_int = 0x00008000; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 357662547b8e..9292028909e1 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -45,6 +45,8 @@ pub type ACTION = ::c_uint; pub type posix_spawnattr_t = *mut ::c_void; pub type posix_spawn_file_actions_t = *mut ::c_void; +pub type u_int = ::c_uint; + cfg_if! { if #[cfg(target_pointer_width = "64")] { type Elf_Addr = Elf64_Addr; @@ -604,6 +606,13 @@ s! { pub tcpi_so_snd_sb_lowat: u32, pub tcpi_so_snd_sb_wat: u32, } + + // net/bpf.h + + pub struct bpf_stat { + pub bs_recv: ::u_int, + pub bs_drop: ::u_int, + } } impl siginfo_t { @@ -1881,6 +1890,13 @@ pub const RB_RESET: ::c_int = 0x08000; pub const RB_GOODRANDOM: ::c_int = 0x10000; pub const RB_UNHIBERNATE: ::c_int = 0x20000; +// +pub const BIOCLOCK: ::c_ulong = 0x20004276; + +// +pub const SIOCAIFADDR_IN6: ::c_ulong = 0x8080691a; +pub const SIOCDIFADDR_IN6: ::c_ulong = 0x81206919; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES