Skip to content
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

Add TCP FastOpen support for macOS #1635

Merged
merged 1 commit into from
Feb 23, 2020
Merged
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
48 changes: 48 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub type posix_spawn_file_actions_t = *mut ::c_void;
pub type key_t = ::c_int;
pub type shmatt_t = ::c_ushort;

pub type sae_associd_t = u32;
pub type sae_connid_t = u32;

deprecated_mach! {
pub type vm_prot_t = ::c_int;
pub type vm_size_t = ::uintptr_t;
Expand Down Expand Up @@ -493,6 +496,16 @@ s! {
pub struct in_addr {
pub s_addr: ::in_addr_t,
}

// sys/socket.h

pub struct sa_endpoints_t {
pub sae_srcif: ::c_uint, // optional source interface
pub sae_srcaddr: *const ::sockaddr, // optional source address
pub sae_srcaddrlen: ::socklen_t, // size of source address
pub sae_dstaddr: *const ::sockaddr, // destination address
pub sae_dstaddrlen: ::socklen_t, // size of destination address
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -2216,6 +2229,8 @@ pub const IPV6_RECVPKTINFO: ::c_int = 61;
pub const TCP_NOPUSH: ::c_int = 4;
pub const TCP_NOOPT: ::c_int = 8;
pub const TCP_KEEPALIVE: ::c_int = 0x10;
/// Enable/Disable TCP Fastopen on this socket
pub const TCP_FASTOPEN: ::c_int = 0x105;

pub const SOL_LOCAL: ::c_int = 0;

Expand Down Expand Up @@ -2304,6 +2319,23 @@ pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
pub const SHUT_RDWR: ::c_int = 2;

pub const SAE_ASSOCID_ANY: ::sae_associd_t = 0;
/// ((sae_associd_t)(-1ULL))
pub const SAE_ASSOCID_ALL: ::sae_associd_t = 0xffffffff;

pub const SAE_CONNID_ANY: ::sae_connid_t = 0;
/// ((sae_connid_t)(-1ULL))
pub const SAE_CONNID_ALL: ::sae_connid_t = 0xffffffff;

// connectx() flag parameters

/// resume connect() on read/write
pub const CONNECT_RESUME_ON_READ_WRITE: ::c_uint = 0x1;
/// data is idempotent
pub const CONNECT_DATA_IDEMPOTENT: ::c_uint = 0x2;
/// data includes security that replaces the TFO-cookie
pub const CONNECT_DATA_AUTHENTICATED: ::c_uint = 0x4;

pub const LOCK_SH: ::c_int = 1;
pub const LOCK_EX: ::c_int = 2;
pub const LOCK_NB: ::c_int = 4;
Expand Down Expand Up @@ -3528,6 +3560,22 @@ extern "C" {
newfd: ::c_int,
) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;

pub fn connectx(
socket: ::c_int,
endpoints: *const sa_endpoints_t,
associd: sae_associd_t,
flags: ::c_uint,
iov: *const ::iovec,
iovcnt: ::c_uint,
len: *mut ::size_t,
connid: *mut sae_connid_t,
) -> ::c_int;
pub fn disconnectx(
socket: ::c_int,
associd: sae_associd_t,
connid: sae_connid_t,
) -> ::c_int;
}

cfg_if! {
Expand Down