xref: /illumos-gate/usr/src/uts/common/netinet/tcp.h (revision 707e74bc)
17c478bd9Sstevel@tonic-gate /*
2*707e74bcSKacheong Poon  * CDDL HEADER START
3*707e74bcSKacheong Poon  *
4*707e74bcSKacheong Poon  * The contents of this file are subject to the terms of the
5*707e74bcSKacheong Poon  * Common Development and Distribution License (the "License").
6*707e74bcSKacheong Poon  * You may not use this file except in compliance with the License.
7*707e74bcSKacheong Poon  *
8*707e74bcSKacheong Poon  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*707e74bcSKacheong Poon  * or http://www.opensolaris.org/os/licensing.
10*707e74bcSKacheong Poon  * See the License for the specific language governing permissions
11*707e74bcSKacheong Poon  * and limitations under the License.
12*707e74bcSKacheong Poon  *
13*707e74bcSKacheong Poon  * When distributing Covered Code, include this CDDL HEADER in each
14*707e74bcSKacheong Poon  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*707e74bcSKacheong Poon  * If applicable, add the following below this CDDL HEADER, with the
16*707e74bcSKacheong Poon  * fields enclosed by brackets "[]" replaced with your own identifying
17*707e74bcSKacheong Poon  * information: Portions Copyright [yyyy] [name of copyright owner]
18*707e74bcSKacheong Poon  *
19*707e74bcSKacheong Poon  * CDDL HEADER END
20*707e74bcSKacheong Poon  */
21*707e74bcSKacheong Poon 
22*707e74bcSKacheong Poon /*
23*707e74bcSKacheong Poon  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * Copyright (c) 1982, 1986 Regents of the University of California.
287c478bd9Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
297c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifndef	_NETINET_TCP_H
337c478bd9Sstevel@tonic-gate #define	_NETINET_TCP_H
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /* tcp.h 1.11 88/08/19 SMI; from UCB 7.2 10/28/86	*/
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
397c478bd9Sstevel@tonic-gate #include <sys/inttypes.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
427c478bd9Sstevel@tonic-gate extern "C" {
437c478bd9Sstevel@tonic-gate #endif
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate typedef	uint32_t	tcp_seq;
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * TCP header.
487c478bd9Sstevel@tonic-gate  * Per RFC 793, September, 1981.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate struct tcphdr {
517c478bd9Sstevel@tonic-gate 	uint16_t	th_sport;	/* source port */
527c478bd9Sstevel@tonic-gate 	uint16_t	th_dport;	/* destination port */
537c478bd9Sstevel@tonic-gate 	tcp_seq		th_seq;		/* sequence number */
547c478bd9Sstevel@tonic-gate 	tcp_seq		th_ack;		/* acknowledgement number */
557c478bd9Sstevel@tonic-gate #ifdef _BIT_FIELDS_LTOH
567c478bd9Sstevel@tonic-gate 	uint_t	th_x2:4,		/* (unused) */
577c478bd9Sstevel@tonic-gate 		th_off:4;		/* data offset */
587c478bd9Sstevel@tonic-gate #else
597c478bd9Sstevel@tonic-gate 	uint_t	th_off:4,		/* data offset */
607c478bd9Sstevel@tonic-gate 		th_x2:4;		/* (unused) */
617c478bd9Sstevel@tonic-gate #endif
627c478bd9Sstevel@tonic-gate 	uchar_t	th_flags;
637c478bd9Sstevel@tonic-gate #define	TH_FIN	0x01
647c478bd9Sstevel@tonic-gate #define	TH_SYN	0x02
657c478bd9Sstevel@tonic-gate #define	TH_RST	0x04
667c478bd9Sstevel@tonic-gate #define	TH_PUSH	0x08
677c478bd9Sstevel@tonic-gate #define	TH_ACK	0x10
687c478bd9Sstevel@tonic-gate #define	TH_URG	0x20
697c478bd9Sstevel@tonic-gate #define	TH_ECE	0x40
707c478bd9Sstevel@tonic-gate #define	TH_CWR	0x80
717c478bd9Sstevel@tonic-gate 	uint16_t	th_win;		/* window */
727c478bd9Sstevel@tonic-gate 	uint16_t	th_sum;		/* checksum */
737c478bd9Sstevel@tonic-gate 	uint16_t	th_urp;		/* urgent pointer */
747c478bd9Sstevel@tonic-gate };
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #define	TCPOPT_EOL	0
777c478bd9Sstevel@tonic-gate #define	TCPOPT_NOP	1
787c478bd9Sstevel@tonic-gate #define	TCPOPT_MAXSEG	2
797c478bd9Sstevel@tonic-gate #define	TCPOPT_WSCALE	3
807c478bd9Sstevel@tonic-gate #define	TCPOPT_SACK_PERMITTED	4
817c478bd9Sstevel@tonic-gate #define	TCPOPT_SACK	5
827c478bd9Sstevel@tonic-gate #define	TCPOPT_TSTAMP	8
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * Default maximum segment size for TCP.
867c478bd9Sstevel@tonic-gate  * With an IP MTU of 576, this is 536.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate #define	TCP_MSS	536
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /*
917c478bd9Sstevel@tonic-gate  * Options for use with [gs]etsockopt at the TCP level.
927c478bd9Sstevel@tonic-gate  *
937c478bd9Sstevel@tonic-gate  * Note: Some of the TCP_ namespace has conflict with and
947c478bd9Sstevel@tonic-gate  * and is exposed through <xti.h>. (It also requires exposing
957c478bd9Sstevel@tonic-gate  * options not implemented). The options with potential
967c478bd9Sstevel@tonic-gate  * for conflicts use #ifndef guards.
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate #ifndef TCP_NODELAY
997c478bd9Sstevel@tonic-gate #define	TCP_NODELAY	0x01	/* don't delay send to coalesce packets */
1007c478bd9Sstevel@tonic-gate #endif
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate #ifndef TCP_MAXSEG
1037c478bd9Sstevel@tonic-gate #define	TCP_MAXSEG	0x02	/* set maximum segment size */
1047c478bd9Sstevel@tonic-gate #endif
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate #ifndef TCP_KEEPALIVE
1077c478bd9Sstevel@tonic-gate #define	TCP_KEEPALIVE	0x8	/* set keepalive timer */
1087c478bd9Sstevel@tonic-gate #endif
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #define	TCP_NOTIFY_THRESHOLD		0x10
1127c478bd9Sstevel@tonic-gate #define	TCP_ABORT_THRESHOLD		0x11
1137c478bd9Sstevel@tonic-gate #define	TCP_CONN_NOTIFY_THRESHOLD	0x12
1147c478bd9Sstevel@tonic-gate #define	TCP_CONN_ABORT_THRESHOLD	0x13
1157c478bd9Sstevel@tonic-gate #define	TCP_RECVDSTADDR			0x14
1167c478bd9Sstevel@tonic-gate #define	TCP_INIT_CWND			0x15
1177c478bd9Sstevel@tonic-gate #define	TCP_KEEPALIVE_THRESHOLD		0x16
1187c478bd9Sstevel@tonic-gate #define	TCP_KEEPALIVE_ABORT_THRESHOLD	0x17
1197c478bd9Sstevel@tonic-gate #define	TCP_CORK			0x18
120*707e74bcSKacheong Poon #define	TCP_RTO_INITIAL			0x19
121*707e74bcSKacheong Poon #define	TCP_RTO_MIN			0x1A
122*707e74bcSKacheong Poon #define	TCP_RTO_MAX			0x1B
123*707e74bcSKacheong Poon #define	TCP_LINGER2			0x1C
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /* gap for expansion of ``standard'' options */
1267c478bd9Sstevel@tonic-gate #define	TCP_ANONPRIVBIND		0x20	/* for internal use only  */
1277c478bd9Sstevel@tonic-gate #define	TCP_EXCLBIND			0x21	/* for internal use only  */
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1307c478bd9Sstevel@tonic-gate }
1317c478bd9Sstevel@tonic-gate #endif
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate #endif	/* _NETINET_TCP_H */
134