xref: /csrg-svn/sys/netinet/tcp_fsm.h (revision 23189)
1*23189Smckusick /*
2*23189Smckusick  * Copyright (c) 1982 Regents of the University of California.
3*23189Smckusick  * All rights reserved.  The Berkeley software License Agreement
4*23189Smckusick  * specifies the terms and conditions for redistribution.
5*23189Smckusick  *
6*23189Smckusick  *	@(#)tcp_fsm.h	6.2 (Berkeley) 06/08/85
7*23189Smckusick  */
84725Swnj 
94725Swnj /*
104924Swnj  * TCP FSM state definitions.
115065Swnj  * Per RFC793, September, 1981.
124725Swnj  */
134725Swnj 
145065Swnj #define	TCP_NSTATES	11
154725Swnj 
165065Swnj #define	TCPS_CLOSED		0	/* closed */
175065Swnj #define	TCPS_LISTEN		1	/* listening for connection */
185065Swnj #define	TCPS_SYN_SENT		2	/* active, have sent syn */
195085Swnj #define	TCPS_SYN_RECEIVED	3	/* have send and received syn */
205074Swnj /* states < TCPS_ESTABLISHED are those where connections not established */
215065Swnj #define	TCPS_ESTABLISHED	4	/* established */
225085Swnj #define	TCPS_CLOSE_WAIT		5	/* rcvd fin, waiting for close */
235074Swnj /* states > TCPS_CLOSE_WAIT are those where user has closed */
245085Swnj #define	TCPS_FIN_WAIT_1		6	/* have closed, sent fin */
255085Swnj #define	TCPS_CLOSING		7	/* closed xchd FIN; await FIN ACK */
265085Swnj #define	TCPS_LAST_ACK		8	/* had fin and close; await FIN ACK */
275085Swnj /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
285085Swnj #define	TCPS_FIN_WAIT_2		9	/* have closed, fin is acked */
295085Swnj #define	TCPS_TIME_WAIT		10	/* in 2*msl quiet wait after close */
304725Swnj 
315085Swnj #define	TCPS_HAVERCVDSYN(s)	((s) >= TCPS_SYN_RECEIVED)
325065Swnj #define	TCPS_HAVERCVDFIN(s)	((s) >= TCPS_TIME_WAIT)
335065Swnj 
345085Swnj #ifdef	TCPOUTFLAGS
355085Swnj /*
365085Swnj  * Flags used when sending segments in tcp_output.
375085Swnj  * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally
385173Swnj  * determined by state, with the proviso that TH_FIN is sent only
395173Swnj  * if all data queued for output is included in the segment.
405085Swnj  */
415085Swnj u_char	tcp_outflags[TCP_NSTATES] = {
425085Swnj     TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK,
435085Swnj     TH_ACK, TH_ACK,
445244Sroot     TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK,
455085Swnj };
465085Swnj #endif
475085Swnj 
484730Swnj #ifdef KPROF
494899Swnj int	tcp_acounts[TCP_NSTATES][PRU_NREQ];
504725Swnj #endif
514725Swnj 
525085Swnj #ifdef	TCPSTATES
534725Swnj char *tcpstates[] = {
545065Swnj 	"CLOSED",	"LISTEN",	"SYN_SENT",	"SYN_RCVD",
555244Sroot 	"ESTABLISHED",	"CLOSE_WAIT",	"FIN_WAIT_1",	"CLOSING",
565244Sroot 	"LAST_ACK",	"FIN_WAIT_2",	"TIME_WAIT",
574725Swnj };
584725Swnj #endif
59