os/ossrv/genericopenlibs/cstdlib/LINCINET/TCP_FSM.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LINCINET/TCP_FSM.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,85 @@
     1.4 +/* TCP_FSM.H
     1.5 + * 
     1.6 + * Portions Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
     1.7 + * All rights reserved.
     1.8 + */
     1.9 +
    1.10 +/*
    1.11 + * Copyright (c) 1982, 1986 Regents of the University of California.
    1.12 + * All rights reserved.  The Berkeley software License Agreement
    1.13 + * specifies the terms and conditions for redistribution.
    1.14 + */
    1.15 +
    1.16 +/** @file
    1.17 +@publishedAll
    1.18 +@released
    1.19 +*/
    1.20 +
    1.21 +/*
    1.22 + * TCP FSM state definitions.
    1.23 + * Per RFC793, September, 1981.
    1.24 + */
    1.25 +
    1.26 +#ifndef	_NETINET_TCP_FSM_H
    1.27 +#define	_NETINET_TCP_FSM_H
    1.28 +
    1.29 +#ifdef	__cplusplus
    1.30 +extern "C" {
    1.31 +#endif
    1.32 +
    1.33 +#define	TCP_NSTATES	11
    1.34 +
    1.35 +#define	TCPS_CLOSED		0	/* closed */
    1.36 +#define	TCPS_LISTEN		1	/* listening for connection */
    1.37 +#define	TCPS_SYN_SENT		2	/* active, have sent syn */
    1.38 +#define	TCPS_SYN_RECEIVED	3	/* have send and received syn */
    1.39 +/** 
    1.40 +states < TCPS_ESTABLISHED are those where connections not established 
    1.41 +*/
    1.42 +#define	TCPS_ESTABLISHED	4	/* established */
    1.43 +#define	TCPS_CLOSE_WAIT		5	/* rcvd fin, waiting for close */
    1.44 +
    1.45 +/** 
    1.46 +states > TCPS_CLOSE_WAIT are those where user has closed 
    1.47 +*/
    1.48 +#define	TCPS_FIN_WAIT_1		6	/* have closed, sent fin */
    1.49 +#define	TCPS_CLOSING		7	/* closed xchd FIN; await FIN ACK */
    1.50 +#define	TCPS_LAST_ACK		8	/* had fin and close; await FIN ACK */
    1.51 +
    1.52 +/** 
    1.53 +states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN 
    1.54 +*/
    1.55 +#define	TCPS_FIN_WAIT_2		9	/* have closed, fin is acked */
    1.56 +#define	TCPS_TIME_WAIT		10	/* in 2*msl quiet wait after close */
    1.57 +
    1.58 +#define	TCPS_HAVERCVDSYN(s)	((s) >= TCPS_SYN_RECEIVED)
    1.59 +#define	TCPS_HAVERCVDFIN(s)	((s) >= TCPS_TIME_WAIT)
    1.60 +
    1.61 +#ifdef	TCPOUTFLAGS
    1.62 +/**
    1.63 +Flags used when sending segments in tcp_output.
    1.64 +Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally
    1.65 +determined by state, with the proviso that TH_FIN is sent only
    1.66 +if all data queued for output is included in the segment.
    1.67 +*/
    1.68 +const u_char	tcp_outflags[TCP_NSTATES] = {
    1.69 +    TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK,
    1.70 +    TH_ACK, TH_ACK,
    1.71 +    TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK,
    1.72 +};
    1.73 +#endif
    1.74 +
    1.75 +#ifdef	TCPSTATES
    1.76 +
    1.77 +const char *tcpstates[] = {
    1.78 +	"CLOSED",	"LISTEN",	"SYN_SENT",	"SYN_RCVD",
    1.79 +	"ESTABLISHED",	"CLOSE_WAIT",	"FIN_WAIT_1",	"CLOSING",
    1.80 +	"LAST_ACK",	"FIN_WAIT_2",	"TIME_WAIT",
    1.81 +};
    1.82 +#endif
    1.83 +
    1.84 +#ifdef	__cplusplus
    1.85 +}
    1.86 +#endif
    1.87 +
    1.88 +#endif	/* _NETINET_TCP_FSM_H */