diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs index 4d000164bd..3de0a4cdd9 100644 --- a/src/sys/socket/consts.rs +++ b/src/sys/socket/consts.rs @@ -14,41 +14,32 @@ mod os { #[cfg(any(target_os = "macos", target_os = "ios"))] pub const AF_SYSTEM: c_int = libc::AF_SYSTEM; #[cfg(any(target_os = "macos", target_os = "ios"))] - pub const AF_SYS_CONTROL: c_int = 2; + pub const AF_SYS_CONTROL: c_int = libc::AF_SYS_CONTROL; pub const SOCK_STREAM: c_int = libc::SOCK_STREAM; pub const SOCK_DGRAM: c_int = libc::SOCK_DGRAM; pub const SOCK_SEQPACKET: c_int = libc::SOCK_SEQPACKET; pub const SOCK_RAW: c_int = libc::SOCK_RAW; - #[cfg(not(any(target_os = "linux", target_os = "android")))] pub const SOCK_RDM: c_int = libc::SOCK_RDM; - #[cfg(any(target_os = "linux", target_os = "android"))] - pub const SOCK_RDM: c_int = 4; + pub const SOL_SOCKET: c_int = libc::SOL_SOCKET; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SOL_IP: c_int = libc::SOL_IP; - pub const SOL_SOCKET: c_int = libc::SOL_SOCKET; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SOL_TCP: c_int = libc::SOL_TCP; #[cfg(any(target_os = "linux", target_os = "android"))] - pub const SOL_UDP: c_int = 17; + pub const SOL_UDP: c_int = libc::SOL_UDP; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SOL_IPV6: c_int = libc::SOL_IPV6; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SOL_NETLINK: c_int = libc::SOL_NETLINK; + pub const IPPROTO_IP: c_int = libc::IPPROTO_IP; pub const IPPROTO_IPV6: c_int = libc::IPPROTO_IPV6; pub const IPPROTO_TCP: c_int = libc::IPPROTO_TCP; - #[cfg(any(target_os = "linux", target_os = "android", target_os = "dragonfly"))] - pub const IPPROTO_UDP: c_int = SOL_UDP; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const IPPROTO_UDP: c_int = 17; + pub const IPPROTO_UDP: c_int = libc::IPPROTO_UDP; #[cfg(any(target_os = "macos", target_os = "ios"))] - pub const SYSPROTO_CONTROL: c_int = 2; + pub const SYSPROTO_CONTROL: c_int = libc::SYSPROTO_CONTROL; pub const SO_ACCEPTCONN: c_int = libc::SO_ACCEPTCONN; #[cfg(any(target_os = "linux", target_os = "android"))] @@ -62,151 +53,84 @@ mod os { #[cfg(any(target_os = "linux", target_os = "android"))] pub const SO_DOMAIN: c_int = libc::SO_DOMAIN; pub const SO_DONTROUTE: c_int = libc::SO_DONTROUTE; - #[cfg(not(target_os = "netbsd"))] - pub const SO_DONTTRUNC: c_int = 0x2000; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_DONTTRUNC: c_int = libc::SO_DONTTRUNC; pub const SO_ERROR: c_int = libc::SO_ERROR; pub const SO_KEEPALIVE: c_int = libc::SO_KEEPALIVE; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_LABEL: c_int = 0x1010; + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] + pub const SO_LABEL: c_int = libc::SO_LABEL; pub const SO_LINGER: c_int = libc::SO_LINGER; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SO_MARK: c_int = libc::SO_MARK; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_NREAD: c_int = 0x1020; - #[cfg(any(target_os = "macos", + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_NREAD: c_int = libc::SO_NREAD; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_NKE: c_int = libc::SO_NKE; + #[cfg(any(target_os = "dragonfly", target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_NKE: c_int = 0x1021; - #[cfg(target_os = "dragonfly")] + target_os = "macos", + target_os = "ios"))] pub const SO_NOSIGPIPE: c_int = libc::SO_NOSIGPIPE; #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_NOSIGPIPE: c_int = 0x1022; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_NOADDRERR: c_int = 0x1023; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_NOTIFYCONFLICT: c_int = 0x1026; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_NP_EXTENSIONS: c_int = 0x1083; + target_os = "ios"))] + pub const SO_NOADDRERR: c_int = libc::SO_NOADDRERR; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_NOTIFYCONFLICT: c_int = libc::SO_NOTIFYCONFLICT; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_NP_EXTENSIONS: c_int = libc::SO_NP_EXTENSIONS; #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_NWRITE: c_int = 0x1024; + target_os = "ios"))] + pub const SO_NWRITE: c_int = libc::SO_NWRITE; pub const SO_OOBINLINE: c_int = libc::SO_OOBINLINE; - #[cfg(target_os = "linux")] - pub const SO_ORIGINAL_DST: c_int = 80; + #[cfg(any(target_os = "linux", target_os = "android"))] + pub const SO_ORIGINAL_DST: c_int = libc::SO_ORIGINAL_DST; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SO_PASSCRED: c_int = libc::SO_PASSCRED; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SO_PEEK_OFF: c_int = libc::SO_PEEK_OFF; - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(any(target_os = "linux", + target_os = "android", + target_os = "openbsd"))] pub const SO_PEERCRED: c_int = libc::SO_PEERCRED; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_PEERLABEL: c_int = 0x1011; + #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] + pub const SO_PEERLABEL: c_int = libc::SO_PEERLABEL; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SO_PRIORITY: c_int = libc::SO_PRIORITY; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SO_PROTOCOL: c_int = libc::SO_PROTOCOL; pub const SO_RCVBUF: c_int = libc::SO_RCVBUF; #[cfg(any(target_os = "linux", target_os = "android"))] - pub const SO_RCVBUFFORCE: c_int = 33; + pub const SO_RCVBUFFORCE: c_int = libc::SO_RCVBUFFORCE; pub const SO_RCVLOWAT: c_int = libc::SO_RCVLOWAT; pub const SO_SNDLOWAT: c_int = libc::SO_SNDLOWAT; pub const SO_RCVTIMEO: c_int = libc::SO_RCVTIMEO; pub const SO_SNDTIMEO: c_int = libc::SO_SNDTIMEO; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_RANDOMPORT: c_int = 0x1082; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_RESTRICTIONS: c_int = 0x1081; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_RESTRICT_DENYIN: c_int = 0x00000001; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_RESTRICT_DENYOUT: c_int = 0x00000002; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - #[allow(overflowing_literals)] - pub const SO_RESTRICT_DENYSET: c_int = 0x80000000; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_RANDOMPORT: c_int = libc::SO_RANDOMPORT; pub const SO_REUSEADDR: c_int = libc::SO_REUSEADDR; pub const SO_REUSEPORT: c_int = libc::SO_REUSEPORT; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_REUSESHAREUID: c_int = 0x1025; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_REUSESHAREUID: c_int = libc::SO_REUSESHAREUID; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SO_RXQ_OVFL: c_int = libc::SO_RXQ_OVFL; pub const SO_SNDBUF: c_int = libc::SO_SNDBUF; #[cfg(any(target_os = "linux", target_os = "android"))] pub const SO_SNDBUFFORCE: c_int = libc::SO_SNDBUFFORCE; pub const SO_TIMESTAMP: c_int = libc::SO_TIMESTAMP; - #[cfg(not(target_os = "netbsd"))] - pub const SO_TIMESTAMP_MONOTONIC: c_int = 0x0800; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_TIMESTAMP_MONOTONIC: c_int = libc::SO_TIMESTAMP_MONOTONIC; pub const SO_TYPE: c_int = libc::SO_TYPE; #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd", - target_os = "netbsd"))] + target_os = "netbsd", + target_os = "dragonfly"))] pub const SO_USELOOPBACK: c_int = libc::SO_USELOOPBACK; - #[cfg(not(target_os = "netbsd"))] - pub const SO_WANTMORE: c_int = 0x4000; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SO_WANTOOBFLAG: c_int = 0x8000; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_WANTMORE: c_int = libc::SO_WANTMORE; + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub const SO_WANTOOBFLAG: c_int = libc::SO_WANTOOBFLAG; // Socket options for TCP sockets pub const TCP_NODELAY: c_int = libc::TCP_NODELAY; @@ -216,8 +140,9 @@ mod os { target_os = "freebsd", target_os = "ios", target_os = "openbsd", - target_os = "netbsd"))] - pub const TCP_MAXSEG: c_int = 2; + target_os = "netbsd", + target_os = "dragonfly"))] + pub const TCP_MAXSEG: c_int = libc::TCP_MAXSEG; #[cfg(any(target_os = "linux", target_os = "android"))] pub const TCP_CORK: c_int = libc::TCP_CORK; #[cfg(any(target_os = "linux", @@ -229,17 +154,9 @@ mod os { pub const TCP_KEEPALIVE: c_int = libc::TCP_KEEPALIVE; // Socket options for the IP layer of the socket - #[cfg(any(target_os = "linux", target_os = "android"))] - pub const IP_MULTICAST_IF: c_int = 32; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd", - target_os = "dragonfly"))] - pub const IP_MULTICAST_IF: c_int = 9; + pub const IP_MULTICAST_IF: c_int = libc::IP_MULTICAST_IF; - pub type IpMulticastTtl = uint8_t; + pub type IpMulticastTtl = uint8_t; //-- pub const IP_MULTICAST_TTL: c_int = libc::IP_MULTICAST_TTL; pub const IP_MULTICAST_LOOP: c_int = libc::IP_MULTICAST_LOOP; @@ -265,7 +182,7 @@ mod os { target_os = "dragonfly"))] pub const IPV6_LEAVE_GROUP: c_int = libc::IPV6_LEAVE_GROUP; - pub type InAddrT = u32; + pub type InAddrT = u32; //-- // Declarations of special addresses pub const INADDR_ANY: InAddrT = 0; @@ -278,11 +195,8 @@ mod os { MSG_OOB, MSG_PEEK, MSG_DONTWAIT, - #[cfg(not(target_os = "dragonfly"))] MSG_CTRUNC, - #[cfg(not(target_os = "dragonfly"))] MSG_TRUNC, - #[cfg(not(target_os = "dragonfly"))] MSG_EOR, #[cfg(any(target_os = "linux", target_os = "android"))] MSG_ERRQUEUE, @@ -297,14 +211,7 @@ mod os { pub const SHUT_RDWR: c_int = libc::SHUT_RDWR; // Ancillary message types - #[cfg(any(target_os = "linux", target_os = "android"))] pub const SCM_RIGHTS: c_int = libc::SCM_RIGHTS; - #[cfg(any(target_os = "macos", - target_os = "freebsd", - target_os = "ios", - target_os = "openbsd", - target_os = "netbsd"))] - pub const SCM_RIGHTS: c_int = 1; }