authorgravatar for jens.goldberg@gmail.comJens Goldberg <jens.goldberg@gmail.com> 2020-09-08 11:52:20+00:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-08 13:00:07-04:00
log5bf3e540188d06b06a0f18043c2685d3593c8107
tree72554d25401e2725b5e9abb11702cb046b00c484
parentf6f0e09456002a4f4a333cb7462540c39df78d56

Add the Linux TCP socket options


1 files changed, 117 insertions(+), 0 deletions(-)

lib/std/os/bits/linux.zig+117
......@@ -1590,6 +1590,123 @@ pub const RR_A = 1;
15901590pub const RR_CNAME = 5;
15911591pub const RR_AAAA = 28;
15921592
1593/// Turn off Nagle's algorithm
1594pub const TCP_NODELAY = 1;
1595/// Limit MSS
1596pub const TCP_MAXSEG = 2;
1597/// Never send partially complete segments.
1598pub const TCP_CORK = 3;
1599/// Start keeplives after this period, in seconds
1600pub const TCP_KEEPIDLE = 4;
1601/// Interval between keepalives
1602pub const TCP_KEEPINTVL = 5;
1603/// Number of keepalives before death
1604pub const TCP_KEEPCNT = 6;
1605/// Number of SYN retransmits
1606pub const TCP_SYNCNT = 7;
1607/// Life time of orphaned FIN-WAIT-2 state
1608pub const TCP_LINGER2 = 8;
1609/// Wake up listener only when data arrive
1610pub const TCP_DEFER_ACCEPT = 9;
1611/// Bound advertised window
1612pub const TCP_WINDOW_CLAMP = 10;
1613/// Information about this connection.
1614pub const TCP_INFO = 11;
1615/// Block/reenable quick acks
1616pub const TCP_QUICKACK = 12;
1617/// Congestion control algorithm
1618pub const TCP_CONGESTION = 13;
1619/// TCP MD5 Signature (RFC2385)
1620pub const TCP_MD5SIG = 14;
1621/// Use linear timeouts for thin streams
1622pub const TCP_THIN_LINEAR_TIMEOUTS = 16;
1623/// Fast retrans. after 1 dupack
1624pub const TCP_THIN_DUPACK = 17;
1625/// How long for loss retry before timeout
1626pub const TCP_USER_TIMEOUT = 18;
1627/// TCP sock is under repair right now
1628pub const TCP_REPAIR = 19;
1629pub const TCP_REPAIR_QUEUE = 20;
1630pub const TCP_QUEUE_SEQ = 21;
1631pub const TCP_REPAIR_OPTIONS = 22;
1632/// Enable FastOpen on listeners
1633pub const TCP_FASTOPEN = 23;
1634pub const TCP_TIMESTAMP = 24;
1635/// limit number of unsent bytes in write queue
1636pub const TCP_NOTSENT_LOWAT = 25;
1637/// Get Congestion Control (optional) info
1638pub const TCP_CC_INFO = 26;
1639/// Record SYN headers for new connections
1640pub const TCP_SAVE_SYN = 27;
1641/// Get SYN headers recorded for connection
1642pub const TCP_SAVED_SYN = 28;
1643/// Get/set window parameters
1644pub const TCP_REPAIR_WINDOW = 29;
1645/// Attempt FastOpen with connect
1646pub const TCP_FASTOPEN_CONNECT = 30;
1647/// Attach a ULP to a TCP connection
1648pub const TCP_ULP = 31;
1649/// TCP MD5 Signature with extensions
1650pub const TCP_MD5SIG_EXT = 32;
1651/// Set the key for Fast Open (cookie)
1652pub const TCP_FASTOPEN_KEY = 33;
1653/// Enable TFO without a TFO cookie
1654pub const TCP_FASTOPEN_NO_COOKIE = 34;
1655pub const TCP_ZEROCOPY_RECEIVE = 35;
1656/// Notify bytes available to read as a cmsg on read
1657pub const TCP_INQ = 36;
1658pub const TCP_CM_INQ = TCP_INQ;
1659/// delay outgoing packets by XX usec
1660pub const TCP_TX_DELAY = 37;
1661
1662pub const TCP_REPAIR_ON = 1;
1663pub const TCP_REPAIR_OFF = 0;
1664/// Turn off without window probes
1665pub const TCP_REPAIR_OFF_NO_WP = -1;
1666
1667pub const tcp_repair_opt = extern struct {
1668 opt_code: u32,
1669 opt_val: u32,
1670};
1671
1672pub const tcp_repair_window = extern struct {
1673 snd_wl1: u32,
1674 snd_wnd: u32,
1675 max_window: u32,
1676 rcv_wnd: u32,
1677 rcv_wup: u32,
1678};
1679
1680pub const TcpRepairOption = extern enum {
1681 TCP_NO_QUEUE,
1682 TCP_RECV_QUEUE,
1683 TCP_SEND_QUEUE,
1684 TCP_QUEUES_NR,
1685};
1686
1687/// why fastopen failed from client perspective
1688pub const tcp_fastopen_client_fail = extern enum {
1689 /// catch-all
1690 TFO_STATUS_UNSPEC,
1691 /// if not in TFO_CLIENT_NO_COOKIE mode
1692 TFO_COOKIE_UNAVAILABLE,
1693 /// SYN-ACK did not ack SYN data
1694 TFO_DATA_NOT_ACKED,
1695 /// SYN-ACK did not ack SYN data after timeout
1696 TFO_SYN_RETRANSMITTED,
1697};
1698
1699/// for TCP_INFO socket option
1700pub const TCPI_OPT_TIMESTAMPS = 1;
1701pub const TCPI_OPT_SACK = 2;
1702pub const TCPI_OPT_WSCALE = 4;
1703/// ECN was negociated at TCP session init
1704pub const TCPI_OPT_ECN = 8;
1705/// we received at least one packet with ECT
1706pub const TCPI_OPT_ECN_SEEN = 16;
1707/// SYN-ACK acked data in SYN sent or rcvd
1708pub const TCPI_OPT_SYN_DATA = 32;
1709
15931710pub const nfds_t = usize;
15941711pub const pollfd = extern struct {
15951712 fd: fd_t,