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