summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorPhil Vachon <phil@cowpig.ca>2014-10-21 14:14:51 -0400
committerPhil Vachon <phil@cowpig.ca>2014-10-21 14:14:51 -0400
commit520453e2b42e7bb3bc42fc73b5df325cd6918ac9 (patch)
treeb94bffadd6e11acb118be647889733f834ac8ee9 /src/sys
parent168b9280da8bd3ca0044fe562ea1434fe359fcc7 (diff)
downloadnix-520453e2b42e7bb3bc42fc73b5df325cd6918ac9.zip
Add defines for Mac OS X/Darwin
Apple likes to Think Different(tm), especially where constants are involved. Make sure that we have the appropriate constants available for various performance-focused TCP socket options, and that the IP multicast-related defines are correct.
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/socket.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/sys/socket.rs b/src/sys/socket.rs
index 158c259b..3ff7500b 100644
--- a/src/sys/socket.rs
+++ b/src/sys/socket.rs
@@ -130,7 +130,7 @@ mod consts {
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod consts {
- use libc::{c_int};
+ use libc::{c_int, uint8_t};
pub type AddressFamily = c_int;
@@ -150,6 +150,9 @@ mod consts {
pub type SockLevel = c_int;
pub const SOL_SOCKET: SockLevel = 0xffff;
+ pub const IPPROTO_IP: SockLevel = 0;
+ pub const IPPROTO_TCP: SockLevel = 6;
+ pub const IPPROTO_UDP: SockLevel = 17;
pub type SockOpt = c_int;
@@ -190,6 +193,33 @@ mod consts {
pub const SO_WANTOOBFLAG: SockOpt = 0x8000;
#[allow(type_overflow)]
pub const SO_RESTRICT_DENYSET: SockOpt = 0x80000000;
+
+ // Socket options for TCP sockets
+ pub const TCP_NODELAY: SockOpt = 1;
+ pub const TCP_MAXSEG: SockOpt = 2;
+
+ // Socket options for the IP layer of the socket
+ pub const IP_MULTICAST_IF: SockOpt = 9;
+
+ pub type IpMulticastTtl = uint8_t;
+
+ pub const IP_MULTICAST_TTL: SockOpt = 10;
+ pub const IP_MULTICAST_LOOP: SockOpt = 11;
+ pub const IP_ADD_MEMBERSHIP: SockOpt = 12;
+ pub const IP_DROP_MEMBERSHIP: SockOpt = 13;
+
+ pub type InAddrT = u32;
+
+ // Declarations of special addresses
+ pub const INADDR_ANY: InAddrT = 0;
+ pub const INADDR_NONE: InAddrT = 0xffffffff;
+ pub const INADDR_BROADCAST: InAddrT = 0xffffffff;
+
+ pub type SockMessageFlags = i32;
+ // Flags for send/recv and their relatives
+ pub const MSG_OOB: SockMessageFlags = 0x1;
+ pub const MSG_PEEK: SockMessageFlags = 0x2;
+ pub const MSG_DONTWAIT: SockMessageFlags = 0x80;
}
pub fn socket(domain: AddressFamily, mut ty: SockType, flags: SockFlag) -> SysResult<Fd> {