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