#include <netinet/tcp.h>

netinet/tcp.h

includes: sys/appleapiopts.h, sys/socket.h, sys/types.h, machine/endian.h, machine/types.h, netinet/in.h, sys/types.h
81 macros · 2 typedefs · 2 structs

typedeftcp_seq

typedef __uint32_t tcp_seq

typedeftcp_cc

typedef __uint32_t tcp_cc
connection count per rfc1644

macrotcp6_seq

#define tcp6_seq tcp_seq
for KAME src sync over BSD*'s

macrotcp6hdr

#define tcp6hdr tcphdr
for KAME src sync over BSD*'s

structtcphdr

TCP header. Per RFC 793, September, 1981.
size 20, align 4
unsigned shortth_sportsource port
unsigned shortth_dportdestination port
tcp_seqth_seqsequence number
tcp_seqth_ackacknowledgement number
unsigned int:4th_x2(unused)
unsigned int:4th_offdata offset
unsigned charth_flags
unsigned shortth_winwindow
unsigned shortth_sumchecksum
unsigned shortth_urpurgent pointer

macroTH_FIN

#define TH_FIN 0x01

macroTH_SYN

#define TH_SYN 0x02

macroTH_RST

#define TH_RST 0x04

macroTH_PUSH

#define TH_PUSH 0x08

macroTH_ACK

#define TH_ACK 0x10

macroTH_URG

#define TH_URG 0x20

macroTH_ECE

#define TH_ECE 0x40

macroTH_CWR

#define TH_CWR 0x80

macroTH_AE

#define TH_AE 0x100
maps into th_x2

macroTH_FLAGS_ALL

#define TH_FLAGS_ALL (TH_FLAGS|TH_PUSH)

macroTH_ACCEPT

#define TH_ACCEPT (TH_FIN|TH_SYN|TH_RST|TH_ACK)

macroTH_ACE

#define TH_ACE (TH_AE|TH_CWR|TH_ECE)

macroTCPOPT_EOL

#define TCPOPT_EOL 0

macroTCPOLEN_EOL

#define TCPOLEN_EOL 1

macroTCPOPT_NOP

#define TCPOPT_NOP 1

macroTCPOLEN_NOP

#define TCPOLEN_NOP 1

macroTCPOPT_MAXSEG

#define TCPOPT_MAXSEG 2

macroTCPOLEN_MAXSEG

#define TCPOLEN_MAXSEG 4

macroTCPOPT_WINDOW

#define TCPOPT_WINDOW 3

macroTCPOLEN_WINDOW

#define TCPOLEN_WINDOW 3

macroTCPOPT_SACK_PERMITTED

#define TCPOPT_SACK_PERMITTED 4
SACK capability in SYN

macroTCPOLEN_SACK_PERMITTED

#define TCPOLEN_SACK_PERMITTED 2

macroTCPOPT_SACK

#define TCPOPT_SACK 5

macroTCPOLEN_SACKHDR

#define TCPOLEN_SACKHDR 2

macroTCPOLEN_SACK

#define TCPOLEN_SACK 8
len of sack block

macroTCPOPT_TIMESTAMP

#define TCPOPT_TIMESTAMP 8

macroTCPOLEN_TIMESTAMP

#define TCPOLEN_TIMESTAMP 10

macroTCPOLEN_TSTAMP_APPA

#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2)
appendix A

macroTCPOPT_TSTAMP_HDR

#define TCPOPT_TSTAMP_HDR (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)

macroMAX_TCPOPTLEN

#define MAX_TCPOPTLEN 40
Absolute maximum TCP options len

macroTCPOPT_CC

#define TCPOPT_CC 11
CC options: RFC-1644

macroTCPOPT_CCNEW

#define TCPOPT_CCNEW 12

macroTCPOPT_CCECHO

#define TCPOPT_CCECHO 13

macroTCPOLEN_CC

#define TCPOLEN_CC 6

macroTCPOLEN_CC_APPA

#define TCPOLEN_CC_APPA (TCPOLEN_CC+2)

macroTCPOPT_CC_HDR

#define TCPOPT_CC_HDR(ccopt) (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC)

macroTCPOPT_SIGNATURE

#define TCPOPT_SIGNATURE 19
Keyed MD5: RFC 2385

macroTCPOLEN_SIGNATURE

#define TCPOLEN_SIGNATURE 18

macroTCPOPT_FASTOPEN

#define TCPOPT_FASTOPEN 34

macroTCPOLEN_FASTOPEN_REQ

#define TCPOLEN_FASTOPEN_REQ 2

macroTCPOPT_ACCECN0

#define TCPOPT_ACCECN0 172
AccECN Order 0

macroTCPOPT_ACCECN1

#define TCPOPT_ACCECN1 174
AccECN Order 1

macroTCPOLEN_ACCECN_EMPTY

#define TCPOLEN_ACCECN_EMPTY 2
Empty option contains kind and length

macroTCPOLEN_ACCECN_COUNTER

#define TCPOLEN_ACCECN_COUNTER 3
Length of each AccECN counter

macroTCPOPT_SACK_PERMIT_HDR

Option definitions
#define TCPOPT_SACK_PERMIT_HDR (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK_PERMITTED<<8|TCPOLEN_SACK_PERMITTED)

macroTCPOPT_SACK_HDR

#define TCPOPT_SACK_HDR (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK<<8)

macroMAX_SACK_BLKS

Miscellaneous constants
#define MAX_SACK_BLKS 6
Max # SACK blocks stored at sender side

macroTCP_MAX_SACK

#define TCP_MAX_SACK 4
MAX # SACKs sent in any segment

macroTCP_MSS

Default maximum segment size for TCP. With an IP MTU of 576, this is 536, but 512 is probably more convenient. This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
#define TCP_MSS 512

macroTCP_MINMSS

TCP_MINMSS is defined to be 216 which is fine for the smallest link MTU (256 bytes, SLIP interface) in the Internet. However it is very unlikely to come across such low MTU interfaces these days (anno dato 2004). Probably it can be set to 512 without ill effects. But we play safe. See tcp_subr.c tcp_minmss SYSCTL declaration for more comments. Setting this to "0" disables the minmss check.
#define TCP_MINMSS 216

macroTCP6_MSS

Default maximum segment size for TCP6. With an IP6 MSS of 1280, this is 1220, but 1024 is probably more convenient. (xxx kazu in doubt) This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr))
#define TCP6_MSS 1024

macroTCP_MAXWIN

#define TCP_MAXWIN 65535
largest value for (unscaled) window

macroTTCP_CLIENT_SND_WND

#define TTCP_CLIENT_SND_WND 4096
dflt send window for T/TCP client

macroTCP_MAX_WINSHIFT

#define TCP_MAX_WINSHIFT 14
maximum window shift

macroTCP_MAXHLEN

#define TCP_MAXHLEN (0xf<<2)
max length of header in bytes

macroTCP_MAXOLEN

#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr))

macroTCP_NODELAY

User-settable options (used with setsockopt).
#define TCP_NODELAY 0x01
don't delay send to coalesce packets

macroTCP_MAXSEG

#define TCP_MAXSEG 0x02
set maximum segment size

macroTCP_NOPUSH

#define TCP_NOPUSH 0x04
don't push last block of write

macroTCP_NOOPT

#define TCP_NOOPT 0x08
don't use TCP options

macroTCP_KEEPALIVE

#define TCP_KEEPALIVE 0x10
idle time used when SO_KEEPALIVE is enabled

macroTCP_CONNECTIONTIMEOUT

#define TCP_CONNECTIONTIMEOUT 0x20
connection timeout

macroPERSIST_TIMEOUT

#define PERSIST_TIMEOUT 0x40
time after which a connection in persist timeout will terminate. see draft-ananth-tcpm-persist-02.txt

macroTCP_RXT_CONNDROPTIME

#define TCP_RXT_CONNDROPTIME 0x80
time after which tcp retransmissions will be stopped and the connection will be dropped

macroTCP_RXT_FINDROP

#define TCP_RXT_FINDROP 0x100
when this option is set, drop a connection after retransmitting the FIN 3 times. It will prevent holding too many mbufs in socket buffer queues.

macroTCP_KEEPINTVL

#define TCP_KEEPINTVL 0x101
interval between keepalives

macroTCP_KEEPCNT

#define TCP_KEEPCNT 0x102
number of keepalives before close

macroTCP_SENDMOREACKS

#define TCP_SENDMOREACKS 0x103
always ack every other packet

macroTCP_ENABLE_ECN

#define TCP_ENABLE_ECN 0x104
Enable ECN on a connection

macroTCP_FASTOPEN

#define TCP_FASTOPEN 0x105
Enable/Disable TCP Fastopen on this socket

macroTCP_CONNECTION_INFO

#define TCP_CONNECTION_INFO 0x106
State of TCP connection

macroTCP_NOTSENT_LOWAT

#define TCP_NOTSENT_LOWAT 0x201
Low water mark for TCP unsent data

structtcp_connection_info

size 112, align 8
u_int8_ttcpi_stateconnection state
u_int8_ttcpi_snd_wscaleWindow scale for send window
u_int8_ttcpi_rcv_wscaleWindow scale for receive window
u_int8_t__pad1
u_int32_ttcpi_optionsTCP options supported
u_int32_ttcpi_flagsflags
u_int32_ttcpi_rtoretransmit timeout in ms
u_int32_ttcpi_maxsegmaximum segment size supported
u_int32_ttcpi_snd_ssthreshslow start threshold in bytes
u_int32_ttcpi_snd_cwndsend congestion window in bytes
u_int32_ttcpi_snd_wndsend widnow in bytes
u_int32_ttcpi_snd_sbbytesbytes in send socket buffer, including in-flight data
u_int32_ttcpi_rcv_wndreceive window in bytes
u_int32_ttcpi_rttcurmost recent RTT in ms
u_int32_ttcpi_srttaverage RTT in ms
u_int32_ttcpi_rttvarRTT variance
u_int32_t:1tcpi_tfo_cookie_reqCookie requested?
u_int32_t:1tcpi_tfo_cookie_rcvCookie received?
u_int32_t:1tcpi_tfo_syn_lossFallback to reg. TCP after SYN-loss
u_int32_t:1tcpi_tfo_syn_data_sentSYN+data has been sent out
u_int32_t:1tcpi_tfo_syn_data_ackedSYN+data has been fully acknowledged
u_int32_t:1tcpi_tfo_syn_data_rcvServer received SYN+data with a valid cookie
u_int32_t:1tcpi_tfo_cookie_req_rcvServer received cookie-request
u_int32_t:1tcpi_tfo_cookie_sentServer announced cookie
u_int32_t:1tcpi_tfo_cookie_invalidServer received an invalid cookie
u_int32_t:1tcpi_tfo_cookie_wrongOur sent cookie was wrong
u_int32_t:1tcpi_tfo_no_cookie_rcvWe did not receive a cookie upon our request
u_int32_t:1tcpi_tfo_heuristics_disableTFO-heuristics disabled it
u_int32_t:1tcpi_tfo_send_blackholeA sending-blackhole got detected
u_int32_t:1tcpi_tfo_recv_blackholeA receiver-blackhole got detected
u_int32_t:1tcpi_tfo_onebyte_proxyA proxy acknowledges all but one byte of the SYN
u_int32_t:17__pad2
u_int64_ttcpi_txpackets
u_int64_ttcpi_txbytes
u_int64_ttcpi_txretransmitbytes
u_int64_ttcpi_rxpackets
u_int64_ttcpi_rxbytes
u_int64_ttcpi_rxoutoforderbytes
u_int64_ttcpi_txretransmitpackets

macroTCPCI_OPT_TIMESTAMPS

#define TCPCI_OPT_TIMESTAMPS 0x00000001
Timestamps enabled

macroTCPCI_OPT_SACK

#define TCPCI_OPT_SACK 0x00000002
SACK enabled

macroTCPCI_OPT_WSCALE

#define TCPCI_OPT_WSCALE 0x00000004
Window scaling enabled

macroTCPCI_OPT_ECN

#define TCPCI_OPT_ECN 0x00000008
ECN enabled

macroTCPCI_FLAG_LOSSRECOVERY

#define TCPCI_FLAG_LOSSRECOVERY 0x00000001

macroTCPCI_FLAG_REORDERING_DETECTED

#define TCPCI_FLAG_REORDERING_DETECTED 0x00000002