xref: /illumos-gate/usr/src/uts/common/netinet/tcp.h (revision 861fa149)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
25  * Copyright 2022 Oxide Computer Company
26  */
27 
28 /*
29  * Copyright (c) 1982, 1986 Regents of the University of California.
30  * All rights reserved.  The Berkeley software License Agreement
31  * specifies the terms and conditions for redistribution.
32  */
33 
34 #ifndef	_NETINET_TCP_H
35 #define	_NETINET_TCP_H
36 
37 /* tcp.h 1.11 88/08/19 SMI; from UCB 7.2 10/28/86	*/
38 
39 
40 #include <sys/isa_defs.h>
41 #include <sys/inttypes.h>
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 typedef	uint32_t	tcp_seq;
48 /*
49  * TCP header.
50  * Per RFC 793, September, 1981.
51  */
52 struct tcphdr {
53 	uint16_t	th_sport;	/* source port */
54 	uint16_t	th_dport;	/* destination port */
55 	tcp_seq		th_seq;		/* sequence number */
56 	tcp_seq		th_ack;		/* acknowledgement number */
57 #ifdef _BIT_FIELDS_LTOH
58 	uint_t	th_x2:4,		/* (unused) */
59 		th_off:4;		/* data offset */
60 #else
61 	uint_t	th_off:4,		/* data offset */
62 		th_x2:4;		/* (unused) */
63 #endif
64 	uchar_t	th_flags;
65 #define	TH_FIN	0x01
66 #define	TH_SYN	0x02
67 #define	TH_RST	0x04
68 #define	TH_PUSH	0x08
69 #define	TH_ACK	0x10
70 #define	TH_URG	0x20
71 #define	TH_ECE	0x40
72 #define	TH_CWR	0x80
73 	uint16_t	th_win;		/* window */
74 	uint16_t	th_sum;		/* checksum */
75 	uint16_t	th_urp;		/* urgent pointer */
76 };
77 
78 #define	TCPOPT_EOL	0
79 #define	TCPOPT_NOP	1
80 #define	TCPOPT_MAXSEG	2
81 #define	TCPOPT_WSCALE	3
82 #define	TCPOPT_SACK_PERMITTED	4
83 #define	TCPOPT_SACK	5
84 #define	TCPOPT_TSTAMP	8
85 
86 /*
87  * Default maximum segment size for TCP.
88  * With an IP MTU of 576, this is 536.
89  */
90 #define	TCP_MSS	536
91 
92 /*
93  * Options for use with [gs]etsockopt at the TCP level.
94  *
95  * Note: Some of the TCP_ namespace has conflict with and
96  * and is exposed through <xti.h>. (It also requires exposing
97  * options not implemented). The options with potential
98  * for conflicts use #ifndef guards.
99  */
100 #ifndef TCP_NODELAY
101 #define	TCP_NODELAY	0x01	/* don't delay send to coalesce packets */
102 #endif
103 
104 #ifndef TCP_MAXSEG
105 #define	TCP_MAXSEG	0x02	/* set maximum segment size */
106 #endif
107 
108 #ifndef TCP_KEEPALIVE
109 #define	TCP_KEEPALIVE	0x8	/* set keepalive timer */
110 #endif
111 
112 
113 #define	TCP_NOTIFY_THRESHOLD		0x10
114 #define	TCP_ABORT_THRESHOLD		0x11
115 #define	TCP_CONN_NOTIFY_THRESHOLD	0x12
116 #define	TCP_CONN_ABORT_THRESHOLD	0x13
117 #define	TCP_RECVDSTADDR			0x14
118 #define	TCP_INIT_CWND			0x15
119 #define	TCP_KEEPALIVE_THRESHOLD		0x16
120 #define	TCP_KEEPALIVE_ABORT_THRESHOLD	0x17
121 #define	TCP_CORK			0x18
122 #define	TCP_RTO_INITIAL			0x19
123 #define	TCP_RTO_MIN			0x1A
124 #define	TCP_RTO_MAX			0x1B
125 #define	TCP_LINGER2			0x1C
126 
127 /* gap for expansion of ``standard'' options */
128 #define	TCP_ANONPRIVBIND		0x20	/* for internal use only  */
129 #define	TCP_EXCLBIND			0x21	/* for internal use only  */
130 #define	TCP_KEEPIDLE			0x22
131 #define	TCP_KEEPCNT			0x23
132 #define	TCP_KEEPINTVL			0x24
133 #define	TCP_CONGESTION			0x25
134 #define	TCP_QUICKACK			0x26	/* enable/disable quick acks */
135 
136 #ifdef	__cplusplus
137 }
138 #endif
139 
140 #endif	/* _NETINET_TCP_H */
141