xref: /illumos-gate/usr/src/uts/common/netinet/tcp_fsm.h (revision e5803b76927480e8f9b67b22201c484ccf4c2bcf)
1 /*
2  * Copyright (c) 1997-1998 by Sun Microsystems, Inc.
3  * All rights reserved.
4  */
5 
6 /*
7  * Copyright (c) 1982, 1986 Regents of the University of California.
8  * All rights reserved.  The Berkeley software License Agreement
9  * specifies the terms and conditions for redistribution.
10  */
11 
12 /*
13  * TCP FSM state definitions.
14  * Per RFC793, September, 1981.
15  */
16 
17 #ifndef	_NETINET_TCP_FSM_H
18 #define	_NETINET_TCP_FSM_H
19 
20 #pragma ident	"%Z%%M%	%I%	%E% SMI"
21 /* tcp_fsm.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/86	*/
22 
23 #ifdef	__cplusplus
24 extern "C" {
25 #endif
26 
27 #define	TCP_NSTATES	11
28 
29 #define	TCPS_CLOSED		0	/* closed */
30 #define	TCPS_LISTEN		1	/* listening for connection */
31 #define	TCPS_SYN_SENT		2	/* active, have sent syn */
32 #define	TCPS_SYN_RECEIVED	3	/* have send and received syn */
33 /* states < TCPS_ESTABLISHED are those where connections not established */
34 #define	TCPS_ESTABLISHED	4	/* established */
35 #define	TCPS_CLOSE_WAIT		5	/* rcvd fin, waiting for close */
36 /* states > TCPS_CLOSE_WAIT are those where user has closed */
37 #define	TCPS_FIN_WAIT_1		6	/* have closed, sent fin */
38 #define	TCPS_CLOSING		7	/* closed xchd FIN; await FIN ACK */
39 #define	TCPS_LAST_ACK		8	/* had fin and close; await FIN ACK */
40 /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
41 #define	TCPS_FIN_WAIT_2		9	/* have closed, fin is acked */
42 #define	TCPS_TIME_WAIT		10	/* in 2*msl quiet wait after close */
43 
44 #define	TCPS_HAVERCVDSYN(s)	((s) >= TCPS_SYN_RECEIVED)
45 #define	TCPS_HAVERCVDFIN(s)	((s) >= TCPS_TIME_WAIT)
46 
47 #ifdef	TCPOUTFLAGS
48 /*
49  * Flags used when sending segments in tcp_output.
50  * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally
51  * determined by state, with the proviso that TH_FIN is sent only
52  * if all data queued for output is included in the segment.
53  */
54 uchar_t	tcp_outflags[TCP_NSTATES] = {
55     TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK,
56     TH_ACK, TH_ACK,
57     TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK,
58 };
59 #endif
60 
61 #ifdef KPROF
62 int	tcp_acounts[TCP_NSTATES][PRU_NREQ];
63 #endif
64 
65 #ifdef	TCPSTATES
66 char *tcpstates[] = {
67 	"CLOSED",	"LISTEN",	"SYN_SENT",	"SYN_RCVD",
68 	"ESTABLISHED",	"CLOSE_WAIT",	"FIN_WAIT_1",	"CLOSING",
69 	"LAST_ACK",	"FIN_WAIT_2",	"TIME_WAIT",
70 };
71 #endif
72 
73 #ifdef	__cplusplus
74 }
75 #endif
76 
77 #endif	/* _NETINET_TCP_FSM_H */
78