2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)tcp.h 8.1 (Berkeley) 6/10/93
32 #ifndef _NETINET_TCP_H
33 #define _NETINET_TCP_H 1
38 * User-settable options (used with setsockopt).
40 #define TCP_NODELAY 1 /* Don't delay send to coalesce packets */
41 #define TCP_MAXSEG 2 /* Set maximum segment size */
42 #define TCP_CORK 3 /* Control sending of partial frames */
43 #define TCP_KEEPIDLE 4 /* Start keeplives after this period */
44 #define TCP_KEEPINTVL 5 /* Interval between keepalives */
45 #define TCP_KEEPCNT 6 /* Number of keepalives before death */
46 #define TCP_SYNCNT 7 /* Number of SYN retransmits */
47 #define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
48 #define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
49 #define TCP_WINDOW_CLAMP 10 /* Bound advertised window */
50 #define TCP_INFO 11 /* Information about this connection. */
51 #define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */
54 # include <sys/types.h>
57 typedef u_int32_t tcp_seq
;
60 * Per RFC 793, September, 1981.
64 u_int16_t th_sport
; /* source port */
65 u_int16_t th_dport
; /* destination port */
66 tcp_seq th_seq
; /* sequence number */
67 tcp_seq th_ack
; /* acknowledgement number */
68 # if __BYTE_ORDER == __LITTLE_ENDIAN
69 u_int8_t th_x2
:4; /* (unused) */
70 u_int8_t th_off
:4; /* data offset */
72 # if __BYTE_ORDER == __BIG_ENDIAN
73 u_int8_t th_off
:4; /* data offset */
74 u_int8_t th_x2
:4; /* (unused) */
83 u_int16_t th_win
; /* window */
84 u_int16_t th_sum
; /* checksum */
85 u_int16_t th_urp
; /* urgent pointer */
88 # else /* !__FAVOR_BSD */
95 # if __BYTE_ORDER == __LITTLE_ENDIAN
105 # elif __BYTE_ORDER == __BIG_ENDIAN
116 # error "Adjust your <bits/endian.h> defines"
122 # endif /* __FAVOR_BSD */
136 TCP_CLOSING
/* now a valid state */
139 # define TCPOPT_EOL 0
140 # define TCPOPT_NOP 1
141 # define TCPOPT_MAXSEG 2
142 # define TCPOLEN_MAXSEG 4
143 # define TCPOPT_WINDOW 3
144 # define TCPOLEN_WINDOW 3
145 # define TCPOPT_SACK_PERMITTED 4 /* Experimental */
146 # define TCPOLEN_SACK_PERMITTED 2
147 # define TCPOPT_SACK 5 /* Experimental */
148 # define TCPOPT_TIMESTAMP 8
149 # define TCPOLEN_TIMESTAMP 10
150 # define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
152 # define TCPOPT_TSTAMP_HDR \
153 (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
156 * Default maximum segment size for TCP.
157 * With an IP MSS of 576, this is 536,
158 * but 512 is probably more convenient.
159 * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
163 # define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
165 # define TCP_MAX_WINSHIFT 14 /* maximum window shift */
167 # define SOL_TCP 6 /* TCP level */
170 # define TCPI_OPT_TIMESTAMPS 1
171 # define TCPI_OPT_SACK 2
172 # define TCPI_OPT_WSCALE 4
173 # define TCPI_OPT_ECN 8
175 /* Values for tcpi_state. */
188 u_int8_t tcpi_ca_state
;
189 u_int8_t tcpi_retransmits
;
190 u_int8_t tcpi_probes
;
191 u_int8_t tcpi_backoff
;
192 u_int8_t tcpi_options
;
193 u_int8_t tcpi_snd_wscale
: 4, tcpi_rcv_wscale
: 4;
197 u_int32_t tcpi_snd_mss
;
198 u_int32_t tcpi_rcv_mss
;
200 u_int32_t tcpi_unacked
;
201 u_int32_t tcpi_sacked
;
203 u_int32_t tcpi_retrans
;
204 u_int32_t tcpi_fackets
;
207 u_int32_t tcpi_last_data_sent
;
208 u_int32_t tcpi_last_ack_sent
; /* Not remembered, sorry. */
209 u_int32_t tcpi_last_data_recv
;
210 u_int32_t tcpi_last_ack_recv
;
214 u_int32_t tcpi_rcv_ssthresh
;
216 u_int32_t tcpi_rttvar
;
217 u_int32_t tcpi_snd_ssthresh
;
218 u_int32_t tcpi_snd_cwnd
;
219 u_int32_t tcpi_advmss
;
220 u_int32_t tcpi_reordering
;
225 #endif /* netinet/tcp.h */