aboutsummaryrefslogtreecommitdiff
path: root/libc/src/unix/bsd/netbsdlike/netbsd
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2018-01-15 09:30:24 -0800
committerDaniel Mueller <deso@posteo.net>2018-01-15 09:30:24 -0800
commitd8a58488bd56ef9c09e167173124c3519bc7405d (patch)
treef52c843b4862a8ce80b3912805638be5846166fc /libc/src/unix/bsd/netbsdlike/netbsd
parent7e6a449f276cd85ebd9201ef1a62aff3bc4d1595 (diff)
downloadnitrocli-d8a58488bd56ef9c09e167173124c3519bc7405d.tar.gz
nitrocli-d8a58488bd56ef9c09e167173124c3519bc7405d.tar.bz2
Update libc crate to 0.2.36
Import subrepo libc/:libc at 16a0f4a3d6c836f88f50c58f5d0a74a32cbf0193
Diffstat (limited to 'libc/src/unix/bsd/netbsdlike/netbsd')
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/mod.rs280
1 files changed, 263 insertions, 17 deletions
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
index ff6dd24..4c528b5 100644
--- a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -1,3 +1,6 @@
+use dox::mem;
+
+pub type c_char = i8;
pub type clock_t = ::c_uint;
pub type suseconds_t = ::c_int;
pub type dev_t = u64;
@@ -5,6 +8,7 @@ pub type blksize_t = ::int32_t;
pub type fsblkcnt_t = ::uint64_t;
pub type fsfilcnt_t = ::uint64_t;
pub type idtype_t = ::c_int;
+pub type mqd_t = ::c_int;
s! {
pub struct aiocb {
@@ -44,6 +48,13 @@ s! {
__unused8: *mut ::c_void,
}
+ pub struct mq_attr {
+ pub mq_flags: ::c_long,
+ pub mq_maxmsg: ::c_long,
+ pub mq_msgsize: ::c_long,
+ pub mq_curmsgs: ::c_long,
+ }
+
pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
@@ -281,6 +292,27 @@ s! {
pub ifm_index: ::c_ushort,
pub ifm_data: if_data,
}
+
+ pub struct sockcred {
+ pub sc_pid: ::pid_t,
+ pub sc_uid: ::uid_t,
+ pub sc_euid: ::uid_t,
+ pub sc_gid: ::gid_t,
+ pub sc_egid: ::gid_t,
+ pub sc_ngroups: ::c_int,
+ pub sc_groups: [::gid_t; 1],
+ }
+
+ pub struct sockaddr_dl {
+ pub sdl_len: ::c_uchar,
+ pub sdl_family: ::c_uchar,
+ pub sdl_index: ::c_ushort,
+ pub sdl_type: ::uint8_t,
+ pub sdl_nlen: ::uint8_t,
+ pub sdl_alen: ::uint8_t,
+ pub sdl_slen: ::uint8_t,
+ pub sdl_data: [::c_char; 12],
+ }
}
pub const AT_FDCWD: ::c_int = -100;
@@ -316,14 +348,22 @@ pub const MS_INVALIDATE : ::c_int = 0x2;
pub const RLIM_NLIMITS: ::c_int = 12;
-pub const ENOATTR : ::c_int = 93;
-pub const EILSEQ : ::c_int = 85;
-pub const EOVERFLOW : ::c_int = 84;
-pub const ECANCELED : ::c_int = 87;
-pub const EIDRM : ::c_int = 82;
-pub const ENOMSG : ::c_int = 83;
-pub const ENOTSUP : ::c_int = 86;
-pub const ELAST : ::c_int = 96;
+pub const EIDRM: ::c_int = 82;
+pub const ENOMSG: ::c_int = 83;
+pub const EOVERFLOW: ::c_int = 84;
+pub const EILSEQ: ::c_int = 85;
+pub const ENOTSUP: ::c_int = 86;
+pub const ECANCELED: ::c_int = 87;
+pub const EBADMSG: ::c_int = 88;
+pub const ENODATA: ::c_int = 89;
+pub const ENOSR: ::c_int = 90;
+pub const ENOSTR: ::c_int = 91;
+pub const ETIME: ::c_int = 92;
+pub const ENOATTR: ::c_int = 93;
+pub const EMULTIHOP: ::c_int = 94;
+pub const ENOLINK: ::c_int = 95;
+pub const EPROTO: ::c_int = 96;
+pub const ELAST: ::c_int = 96;
pub const F_DUPFD_CLOEXEC : ::c_int = 12;
pub const F_CLOSEM: ::c_int = 10;
@@ -346,6 +386,103 @@ pub const SO_TIMESTAMP: ::c_int = 0x2000;
pub const SO_OVERFLOWED: ::c_int = 0x1009;
pub const SO_NOHEADER: ::c_int = 0x100a;
+// https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373
+pub const IFF_UP: ::c_int = 0x0001; // interface is up
+pub const IFF_BROADCAST: ::c_int = 0x0002; // broadcast address valid
+pub const IFF_DEBUG: ::c_int = 0x0004; // turn on debugging
+pub const IFF_LOOPBACK: ::c_int = 0x0008; // is a loopback net
+pub const IFF_POINTOPOINT: ::c_int = 0x0010; // interface is point-to-point link
+pub const IFF_NOTRAILERS: ::c_int = 0x0020; // avoid use of trailers
+pub const IFF_RUNNING: ::c_int = 0x0040; // resources allocated
+pub const IFF_NOARP: ::c_int = 0x0080; // no address resolution protocol
+pub const IFF_PROMISC: ::c_int = 0x0100; // receive all packets
+pub const IFF_ALLMULTI: ::c_int = 0x0200; // receive all multicast packets
+pub const IFF_OACTIVE: ::c_int = 0x0400; // transmission in progress
+pub const IFF_SIMPLEX: ::c_int = 0x0800; // 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_MULTICAST: ::c_int = 0x8000; // supports multicast
+
+// sys/netinet/in.h
+// Protocols (RFC 1700)
+// NOTE: These are in addition to the constants defined in src/unix/mod.rs
+
+// IPPROTO_IP defined in src/unix/mod.rs
+/// Hop-by-hop option header
+pub const IPPROTO_HOPOPTS: ::c_int = 0;
+// IPPROTO_ICMP defined in src/unix/mod.rs
+/// group mgmt protocol
+pub const IPPROTO_IGMP: ::c_int = 2;
+/// gateway^2 (deprecated)
+pub const IPPROTO_GGP: ::c_int = 3;
+/// for compatibility
+pub const IPPROTO_IPIP: ::c_int = 4;
+// IPPROTO_TCP defined in src/unix/mod.rs
+/// exterior gateway protocol
+pub const IPPROTO_EGP: ::c_int = 8;
+/// pup
+pub const IPPROTO_PUP: ::c_int = 12;
+// IPPROTO_UDP defined in src/unix/mod.rs
+/// xns idp
+pub const IPPROTO_IDP: ::c_int = 22;
+/// tp-4 w/ class negotiation
+pub const IPPROTO_TP: ::c_int = 29;
+/// DCCP
+pub const IPPROTO_DCCP: ::c_int = 33;
+// IPPROTO_IPV6 defined in src/unix/mod.rs
+/// IP6 routing header
+pub const IPPROTO_ROUTING: ::c_int = 43;
+/// IP6 fragmentation header
+pub const IPPROTO_FRAGMENT: ::c_int = 44;
+/// resource reservation
+pub const IPPROTO_RSVP: ::c_int = 46;
+/// General Routing Encap.
+pub const IPPROTO_GRE: ::c_int = 47;
+/// IP6 Encap Sec. Payload
+pub const IPPROTO_ESP: ::c_int = 50;
+/// IP6 Auth Header
+pub const IPPROTO_AH: ::c_int = 51;
+/// IP Mobility RFC 2004
+pub const IPPROTO_MOBILE: ::c_int = 55;
+/// IPv6 ICMP
+pub const IPPROTO_IPV6_ICMP: ::c_int = 58;
+// IPPROTO_ICMPV6 defined in src/unix/mod.rs
+/// IP6 no next header
+pub const IPPROTO_NONE: ::c_int = 59;
+/// IP6 destination option
+pub const IPPROTO_DSTOPTS: ::c_int = 60;
+/// ISO cnlp
+pub const IPPROTO_EON: ::c_int = 80;
+/// Ethernet-in-IP
+pub const IPPROTO_ETHERIP: ::c_int = 97;
+/// encapsulation header
+pub const IPPROTO_ENCAP: ::c_int = 98;
+/// Protocol indep. multicast
+pub const IPPROTO_PIM: ::c_int = 103;
+/// IP Payload Comp. Protocol
+pub const IPPROTO_IPCOMP: ::c_int = 108;
+/// VRRP RFC 2338
+pub const IPPROTO_VRRP: ::c_int = 112;
+/// Common Address Resolution Protocol
+pub const IPPROTO_CARP: ::c_int = 112;
+/// L2TPv3
+// TEMP: Disabled for now; this constant was added to NetBSD on 2017-02-16,
+// but isn't yet supported by the NetBSD rumprun kernel image used for
+// libc testing.
+//pub const IPPROTO_L2TP: ::c_int = 115;
+/// SCTP
+pub const IPPROTO_SCTP: ::c_int = 132;
+/// PFSYNC
+pub const IPPROTO_PFSYNC: ::c_int = 240;
+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;
+
+/// sysctl placeholder for (FAST_)IPSEC
+pub const CTL_IPPROTO_IPSEC: ::c_int = 258;
+
pub const AF_OROUTE: ::c_int = 17;
pub const AF_ARP: ::c_int = 28;
pub const pseudo_AF_KEY: ::c_int = 29;
@@ -386,6 +523,65 @@ pub const MAP_NORESERVE : ::c_int = 0x40;
pub const MAP_HASSEMAPHORE : ::c_int = 0x200;
pub const MAP_WIRED: ::c_int = 0x800;
+pub const DCCP_TYPE_REQUEST: ::c_int = 0;
+pub const DCCP_TYPE_RESPONSE: ::c_int = 1;
+pub const DCCP_TYPE_DATA: ::c_int = 2;
+pub const DCCP_TYPE_ACK: ::c_int = 3;
+pub const DCCP_TYPE_DATAACK: ::c_int = 4;
+pub const DCCP_TYPE_CLOSEREQ: ::c_int = 5;
+pub const DCCP_TYPE_CLOSE: ::c_int = 6;
+pub const DCCP_TYPE_RESET: ::c_int = 7;
+pub const DCCP_TYPE_MOVE: ::c_int = 8;
+
+pub const DCCP_FEATURE_CC: ::c_int = 1;
+pub const DCCP_FEATURE_ECN: ::c_int = 2;
+pub const DCCP_FEATURE_ACKRATIO: ::c_int = 3;
+pub const DCCP_FEATURE_ACKVECTOR: ::c_int = 4;
+pub const DCCP_FEATURE_MOBILITY: ::c_int = 5;
+pub const DCCP_FEATURE_LOSSWINDOW: ::c_int = 6;
+pub const DCCP_FEATURE_CONN_NONCE: ::c_int = 8;
+pub const DCCP_FEATURE_IDENTREG: ::c_int = 7;
+
+pub const DCCP_OPT_PADDING: ::c_int = 0;
+pub const DCCP_OPT_DATA_DISCARD: ::c_int = 1;
+pub const DCCP_OPT_SLOW_RECV: ::c_int = 2;
+pub const DCCP_OPT_BUF_CLOSED: ::c_int = 3;
+pub const DCCP_OPT_CHANGE_L: ::c_int = 32;
+pub const DCCP_OPT_CONFIRM_L: ::c_int = 33;
+pub const DCCP_OPT_CHANGE_R: ::c_int = 34;
+pub const DCCP_OPT_CONFIRM_R: ::c_int = 35;
+pub const DCCP_OPT_INIT_COOKIE: ::c_int = 36;
+pub const DCCP_OPT_NDP_COUNT: ::c_int = 37;
+pub const DCCP_OPT_ACK_VECTOR0: ::c_int = 38;
+pub const DCCP_OPT_ACK_VECTOR1: ::c_int = 39;
+pub const DCCP_OPT_RECV_BUF_DROPS: ::c_int = 40;
+pub const DCCP_OPT_TIMESTAMP: ::c_int = 41;
+pub const DCCP_OPT_TIMESTAMP_ECHO: ::c_int = 42;
+pub const DCCP_OPT_ELAPSEDTIME: ::c_int = 43;
+pub const DCCP_OPT_DATACHECKSUM: ::c_int = 44;
+
+pub const DCCP_REASON_UNSPEC: ::c_int = 0;
+pub const DCCP_REASON_CLOSED: ::c_int = 1;
+pub const DCCP_REASON_INVALID: ::c_int = 2;
+pub const DCCP_REASON_OPTION_ERR: ::c_int = 3;
+pub const DCCP_REASON_FEA_ERR: ::c_int = 4;
+pub const DCCP_REASON_CONN_REF: ::c_int = 5;
+pub const DCCP_REASON_BAD_SNAME: ::c_int = 6;
+pub const DCCP_REASON_BAD_COOKIE: ::c_int = 7;
+pub const DCCP_REASON_INV_MOVE: ::c_int = 8;
+pub const DCCP_REASON_UNANSW_CH: ::c_int = 10;
+pub const DCCP_REASON_FRUITLESS_NEG: ::c_int = 11;
+
+pub const DCCP_CCID: ::c_int = 1;
+pub const DCCP_CSLEN: ::c_int = 2;
+pub const DCCP_MAXSEG: ::c_int = 4;
+pub const DCCP_SERVICE: ::c_int = 8;
+
+pub const DCCP_NDP_LIMIT: ::c_int = 16;
+pub const DCCP_SEQ_NUM_LIMIT: ::c_int = 16777216;
+pub const DCCP_MAX_OPTIONS: ::c_int = 32;
+pub const DCCP_MAX_PKTS: ::c_int = 100;
+
pub const _PC_LINK_MAX : ::c_int = 1;
pub const _PC_MAX_CANON : ::c_int = 2;
pub const _PC_MAX_INPUT : ::c_int = 3;
@@ -511,13 +707,13 @@ pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
-pub const EVFILT_AIO: ::int32_t = 2;
-pub const EVFILT_PROC: ::int32_t = 4;
-pub const EVFILT_READ: ::int32_t = 0;
-pub const EVFILT_SIGNAL: ::int32_t = 5;
-pub const EVFILT_TIMER: ::int32_t = 6;
-pub const EVFILT_VNODE: ::int32_t = 3;
-pub const EVFILT_WRITE: ::int32_t = 1;
+pub const EVFILT_AIO: ::uint32_t = 2;
+pub const EVFILT_PROC: ::uint32_t = 4;
+pub const EVFILT_READ: ::uint32_t = 0;
+pub const EVFILT_SIGNAL: ::uint32_t = 5;
+pub const EVFILT_TIMER: ::uint32_t = 6;
+pub const EVFILT_VNODE: ::uint32_t = 3;
+pub const EVFILT_WRITE: ::uint32_t = 1;
pub const EV_ADD: ::uint32_t = 0x1;
pub const EV_DELETE: ::uint32_t = 0x2;
@@ -700,8 +896,23 @@ pub const KERN_PROC_UID: ::c_int = 5;
pub const KERN_PROC_RUID: ::c_int = 6;
pub const KERN_PROC_GID: ::c_int = 7;
pub const KERN_PROC_RGID: ::c_int = 8;
-
+pub const KERN_PROC_ARGV: ::c_int = 1;
+pub const KERN_PROC_NARGV: ::c_int = 2;
+pub const KERN_PROC_ENV: ::c_int = 3;
+pub const KERN_PROC_NENV: ::c_int = 4;
+pub const KERN_PROC_PATHNAME: ::c_int = 5;
+
+pub const EAI_AGAIN: ::c_int = 2;
+pub const EAI_BADFLAGS: ::c_int = 3;
+pub const EAI_FAIL: ::c_int = 4;
+pub const EAI_FAMILY: ::c_int = 5;
+pub const EAI_MEMORY: ::c_int = 6;
+pub const EAI_NODATA: ::c_int = 7;
+pub const EAI_NONAME: ::c_int = 8;
+pub const EAI_SERVICE: ::c_int = 9;
+pub const EAI_SOCKTYPE: ::c_int = 10;
pub const EAI_SYSTEM: ::c_int = 11;
+pub const EAI_OVERFLOW: ::c_int = 14;
pub const AIO_CANCELED: ::c_int = 1;
pub const AIO_NOTCANCELED: ::c_int = 2;
@@ -741,12 +952,21 @@ pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
f! {
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
- unsafe { *(dirp as *const ::c_int) }
+ *(dirp as *const ::c_int)
}
pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0xffff
}
+
+ pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
+ let ngrps = if ngrps > 0 {
+ ngrps - 1
+ } else {
+ 0
+ };
+ mem::size_of::<sockcred>() + mem::size_of::<::gid_t>() * ngrps
+ }
}
extern {
@@ -798,6 +1018,32 @@ extern {
flags: ::c_int,
data: *mut ::c_void,
size: ::size_t) -> ::c_int;
+ pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
+ pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
+ pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
+ pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) -> ::c_int;
+ pub fn mq_receive(mqd: ::mqd_t,
+ msg_ptr: *mut ::c_char,
+ msg_len: ::size_t,
+ msq_prio: *mut ::c_uint) -> ::ssize_t;
+ pub fn mq_send(mqd: ::mqd_t,
+ msg_ptr: *const ::c_char,
+ msg_len: ::size_t,
+ msq_prio: ::c_uint) -> ::c_int;
+ pub fn mq_setattr(mqd: ::mqd_t,
+ newattr: *const ::mq_attr,
+ oldattr: *mut ::mq_attr) -> ::c_int;
+ pub fn mq_timedreceive(mqd: ::mqd_t,
+ msg_ptr: *mut ::c_char,
+ msg_len: ::size_t,
+ msq_prio: *mut ::c_uint,
+ abs_timeout: *const ::timespec) -> ::ssize_t;
+ pub fn mq_timedsend(mqd: ::mqd_t,
+ msg_ptr: *const ::c_char,
+ msg_len: ::size_t,
+ msq_prio: ::c_uint,
+ abs_timeout: *const ::timespec) -> ::c_int;
+ pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
pub fn ptrace(request: ::c_int,
pid: ::pid_t,
addr: *mut ::c_void,