1*5173Swnj /* tcp_fsm.h 4.10 81/12/03 */ 24725Swnj 34725Swnj /* 44924Swnj * TCP FSM state definitions. 55065Swnj * Per RFC793, September, 1981. 64725Swnj */ 74725Swnj 85065Swnj #define TCP_NSTATES 11 94725Swnj 105065Swnj #define TCPS_CLOSED 0 /* closed */ 115065Swnj #define TCPS_LISTEN 1 /* listening for connection */ 125065Swnj #define TCPS_SYN_SENT 2 /* active, have sent syn */ 135085Swnj #define TCPS_SYN_RECEIVED 3 /* have send and received syn */ 145074Swnj /* states < TCPS_ESTABLISHED are those where connections not established */ 155065Swnj #define TCPS_ESTABLISHED 4 /* established */ 165085Swnj #define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 175074Swnj /* states > TCPS_CLOSE_WAIT are those where user has closed */ 185085Swnj #define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ 195085Swnj #define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 205085Swnj #define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ 215085Swnj /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 225085Swnj #define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ 235085Swnj #define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 244725Swnj 255085Swnj #define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) 265065Swnj #define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT) 275085Swnj #define TCPS_OURFINNOTACKED(s) ((s) > TCPS_CLOSE_WAIT && (s) < TCPS_FIN_WAIT_2) 285065Swnj 295085Swnj #ifdef TCPOUTFLAGS 305085Swnj /* 315085Swnj * Flags used when sending segments in tcp_output. 325085Swnj * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally 33*5173Swnj * determined by state, with the proviso that TH_FIN is sent only 34*5173Swnj * if all data queued for output is included in the segment. 355085Swnj */ 365085Swnj u_char tcp_outflags[TCP_NSTATES] = { 375085Swnj TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK, 385085Swnj TH_ACK, TH_ACK, 395085Swnj TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, 405085Swnj }; 415085Swnj #endif 425085Swnj 434730Swnj #ifdef KPROF 444899Swnj int tcp_acounts[TCP_NSTATES][PRU_NREQ]; 454725Swnj #endif 464725Swnj 475085Swnj #ifdef TCPSTATES 484725Swnj char *tcpstates[] = { 495065Swnj "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", 505085Swnj "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "FIN_WAIT_2", 515085Swnj "TIME_WAIT", "CLOSING", "LAST_ACK", 524725Swnj }; 534725Swnj #endif 54