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