xref: /titanic_53/usr/src/uts/common/netinet/tcp.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate /*
7*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1982, 1986 Regents of the University of California.
8*7c478bd9Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
9*7c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
10*7c478bd9Sstevel@tonic-gate  */
11*7c478bd9Sstevel@tonic-gate 
12*7c478bd9Sstevel@tonic-gate #ifndef	_NETINET_TCP_H
13*7c478bd9Sstevel@tonic-gate #define	_NETINET_TCP_H
14*7c478bd9Sstevel@tonic-gate 
15*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
16*7c478bd9Sstevel@tonic-gate /* tcp.h 1.11 88/08/19 SMI; from UCB 7.2 10/28/86	*/
17*7c478bd9Sstevel@tonic-gate 
18*7c478bd9Sstevel@tonic-gate 
19*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
20*7c478bd9Sstevel@tonic-gate #include <sys/inttypes.h>
21*7c478bd9Sstevel@tonic-gate 
22*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
23*7c478bd9Sstevel@tonic-gate extern "C" {
24*7c478bd9Sstevel@tonic-gate #endif
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate typedef	uint32_t	tcp_seq;
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate  * TCP header.
29*7c478bd9Sstevel@tonic-gate  * Per RFC 793, September, 1981.
30*7c478bd9Sstevel@tonic-gate  */
31*7c478bd9Sstevel@tonic-gate struct tcphdr {
32*7c478bd9Sstevel@tonic-gate 	uint16_t	th_sport;	/* source port */
33*7c478bd9Sstevel@tonic-gate 	uint16_t	th_dport;	/* destination port */
34*7c478bd9Sstevel@tonic-gate 	tcp_seq		th_seq;		/* sequence number */
35*7c478bd9Sstevel@tonic-gate 	tcp_seq		th_ack;		/* acknowledgement number */
36*7c478bd9Sstevel@tonic-gate #ifdef _BIT_FIELDS_LTOH
37*7c478bd9Sstevel@tonic-gate 	uint_t	th_x2:4,		/* (unused) */
38*7c478bd9Sstevel@tonic-gate 		th_off:4;		/* data offset */
39*7c478bd9Sstevel@tonic-gate #else
40*7c478bd9Sstevel@tonic-gate 	uint_t	th_off:4,		/* data offset */
41*7c478bd9Sstevel@tonic-gate 		th_x2:4;		/* (unused) */
42*7c478bd9Sstevel@tonic-gate #endif
43*7c478bd9Sstevel@tonic-gate 	uchar_t	th_flags;
44*7c478bd9Sstevel@tonic-gate #define	TH_FIN	0x01
45*7c478bd9Sstevel@tonic-gate #define	TH_SYN	0x02
46*7c478bd9Sstevel@tonic-gate #define	TH_RST	0x04
47*7c478bd9Sstevel@tonic-gate #define	TH_PUSH	0x08
48*7c478bd9Sstevel@tonic-gate #define	TH_ACK	0x10
49*7c478bd9Sstevel@tonic-gate #define	TH_URG	0x20
50*7c478bd9Sstevel@tonic-gate #define	TH_ECE	0x40
51*7c478bd9Sstevel@tonic-gate #define	TH_CWR	0x80
52*7c478bd9Sstevel@tonic-gate 	uint16_t	th_win;		/* window */
53*7c478bd9Sstevel@tonic-gate 	uint16_t	th_sum;		/* checksum */
54*7c478bd9Sstevel@tonic-gate 	uint16_t	th_urp;		/* urgent pointer */
55*7c478bd9Sstevel@tonic-gate };
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #define	TCPOPT_EOL	0
58*7c478bd9Sstevel@tonic-gate #define	TCPOPT_NOP	1
59*7c478bd9Sstevel@tonic-gate #define	TCPOPT_MAXSEG	2
60*7c478bd9Sstevel@tonic-gate #define	TCPOPT_WSCALE	3
61*7c478bd9Sstevel@tonic-gate #define	TCPOPT_SACK_PERMITTED	4
62*7c478bd9Sstevel@tonic-gate #define	TCPOPT_SACK	5
63*7c478bd9Sstevel@tonic-gate #define	TCPOPT_TSTAMP	8
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate /*
66*7c478bd9Sstevel@tonic-gate  * Default maximum segment size for TCP.
67*7c478bd9Sstevel@tonic-gate  * With an IP MTU of 576, this is 536.
68*7c478bd9Sstevel@tonic-gate  */
69*7c478bd9Sstevel@tonic-gate #define	TCP_MSS	536
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate /*
72*7c478bd9Sstevel@tonic-gate  * Options for use with [gs]etsockopt at the TCP level.
73*7c478bd9Sstevel@tonic-gate  *
74*7c478bd9Sstevel@tonic-gate  * Note: Some of the TCP_ namespace has conflict with and
75*7c478bd9Sstevel@tonic-gate  * and is exposed through <xti.h>. (It also requires exposing
76*7c478bd9Sstevel@tonic-gate  * options not implemented). The options with potential
77*7c478bd9Sstevel@tonic-gate  * for conflicts use #ifndef guards.
78*7c478bd9Sstevel@tonic-gate  */
79*7c478bd9Sstevel@tonic-gate #ifndef TCP_NODELAY
80*7c478bd9Sstevel@tonic-gate #define	TCP_NODELAY	0x01	/* don't delay send to coalesce packets */
81*7c478bd9Sstevel@tonic-gate #endif
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate #ifndef TCP_MAXSEG
84*7c478bd9Sstevel@tonic-gate #define	TCP_MAXSEG	0x02	/* set maximum segment size */
85*7c478bd9Sstevel@tonic-gate #endif
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate #ifndef TCP_KEEPALIVE
88*7c478bd9Sstevel@tonic-gate #define	TCP_KEEPALIVE	0x8	/* set keepalive timer */
89*7c478bd9Sstevel@tonic-gate #endif
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate #define	TCP_NOTIFY_THRESHOLD		0x10
93*7c478bd9Sstevel@tonic-gate #define	TCP_ABORT_THRESHOLD		0x11
94*7c478bd9Sstevel@tonic-gate #define	TCP_CONN_NOTIFY_THRESHOLD	0x12
95*7c478bd9Sstevel@tonic-gate #define	TCP_CONN_ABORT_THRESHOLD	0x13
96*7c478bd9Sstevel@tonic-gate #define	TCP_RECVDSTADDR			0x14
97*7c478bd9Sstevel@tonic-gate #define	TCP_INIT_CWND			0x15
98*7c478bd9Sstevel@tonic-gate #define	TCP_KEEPALIVE_THRESHOLD		0x16
99*7c478bd9Sstevel@tonic-gate #define	TCP_KEEPALIVE_ABORT_THRESHOLD	0x17
100*7c478bd9Sstevel@tonic-gate #define	TCP_CORK			0x18
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate /* gap for expansion of ``standard'' options */
103*7c478bd9Sstevel@tonic-gate #define	TCP_ANONPRIVBIND		0x20	/* for internal use only  */
104*7c478bd9Sstevel@tonic-gate #define	TCP_EXCLBIND			0x21	/* for internal use only  */
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
107*7c478bd9Sstevel@tonic-gate }
108*7c478bd9Sstevel@tonic-gate #endif
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate #endif	/* _NETINET_TCP_H */
111