2004-04-21 02:54:31 +04:00
|
|
|
/* $NetBSD: tcp_fsm.h,v 1.14 2004/04/20 22:54:31 matt Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-05-13 10:02:48 +04:00
|
|
|
* Copyright (c) 1982, 1986, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-06-29 10:29:24 +04:00
|
|
|
* @(#)tcp_fsm.h 8.1 (Berkeley) 6/10/93
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
1998-02-10 04:26:19 +03:00
|
|
|
#ifndef _NETINET_TCP_FSM_H_
|
|
|
|
#define _NETINET_TCP_FSM_H_
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* TCP FSM state definitions.
|
|
|
|
* Per RFC793, September, 1981.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define TCP_NSTATES 11
|
|
|
|
|
|
|
|
#define TCPS_CLOSED 0 /* closed */
|
|
|
|
#define TCPS_LISTEN 1 /* listening for connection */
|
|
|
|
#define TCPS_SYN_SENT 2 /* active, have sent syn */
|
|
|
|
#define TCPS_SYN_RECEIVED 3 /* have send and received syn */
|
|
|
|
/* states < TCPS_ESTABLISHED are those where connections not established */
|
|
|
|
#define TCPS_ESTABLISHED 4 /* established */
|
|
|
|
#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */
|
|
|
|
/* states > TCPS_CLOSE_WAIT are those where user has closed */
|
|
|
|
#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */
|
1997-06-18 14:05:44 +04:00
|
|
|
#define TCPS_CLOSING 7 /* closed xchd FIN; await ACK */
|
1993-03-21 12:45:37 +03:00
|
|
|
#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */
|
|
|
|
/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
|
|
|
|
#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */
|
|
|
|
#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */
|
|
|
|
|
|
|
|
#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED)
|
1994-10-14 19:01:48 +03:00
|
|
|
#define TCPS_HAVEESTABLISHED(s) ((s) >= TCPS_ESTABLISHED)
|
1998-07-03 09:39:56 +04:00
|
|
|
#define TCPS_HAVERCVDFIN(s) \
|
|
|
|
((s) == TCPS_CLOSE_WAIT || ((s) >= TCPS_CLOSING && (s) != TCPS_FIN_WAIT_2))
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#ifdef TCPOUTFLAGS
|
|
|
|
/*
|
|
|
|
* Flags used when sending segments in tcp_output.
|
|
|
|
* Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally
|
|
|
|
* determined by state, with the proviso that TH_FIN is sent only
|
|
|
|
* if all data queued for output is included in the segment.
|
|
|
|
*/
|
2001-10-20 07:19:41 +04:00
|
|
|
const u_char tcp_outflags[TCP_NSTATES] = {
|
2003-11-20 19:21:48 +03:00
|
|
|
TH_RST|TH_ACK, /* CLOSED */
|
|
|
|
0, /* LISTEN */
|
|
|
|
TH_SYN, /* SYN_SENT */
|
|
|
|
TH_SYN|TH_ACK, /* SYN_RCVD */
|
|
|
|
TH_ACK, /* ESTABLISHED */
|
|
|
|
TH_ACK, /* CLOSE_WAIT */
|
|
|
|
TH_FIN|TH_ACK, /* FIN_WAIT_1 */
|
|
|
|
TH_FIN|TH_ACK, /* CLOSING */
|
|
|
|
TH_FIN|TH_ACK, /* LAST_ACK */
|
|
|
|
TH_ACK, /* FIN_WAIT_2 */
|
|
|
|
TH_ACK, /* TIME_WAIT */
|
1993-03-21 12:45:37 +03:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef KPROF
|
|
|
|
int tcp_acounts[TCP_NSTATES][PRU_NREQ];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TCPSTATES
|
2001-10-20 07:19:41 +04:00
|
|
|
const char * const tcpstates[] = {
|
1993-03-21 12:45:37 +03:00
|
|
|
"CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD",
|
|
|
|
"ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING",
|
|
|
|
"LAST_ACK", "FIN_WAIT_2", "TIME_WAIT",
|
|
|
|
};
|
2004-04-21 02:54:31 +04:00
|
|
|
#elif defined(_KERNEL)
|
|
|
|
extern const char * const tcpstates[];
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif
|
1998-02-10 04:26:19 +03:00
|
|
|
|
|
|
|
#endif /* _NETINET_TCP_FSM_H_ */
|