123189Smckusick /* 229148Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 3*32787Sbostic * All rights reserved. 423189Smckusick * 5*32787Sbostic * Redistribution and use in source and binary forms are permitted 6*32787Sbostic * provided that this notice is preserved and that due credit is given 7*32787Sbostic * to the University of California at Berkeley. The name of the University 8*32787Sbostic * may not be used to endorse or promote products derived from this 9*32787Sbostic * software without specific prior written permission. This software 10*32787Sbostic * is provided ``as is'' without express or implied warranty. 11*32787Sbostic * 12*32787Sbostic * @(#)tcp_fsm.h 7.2 (Berkeley) 12/07/87 1323189Smckusick */ 144725Swnj 154725Swnj /* 164924Swnj * TCP FSM state definitions. 175065Swnj * Per RFC793, September, 1981. 184725Swnj */ 194725Swnj 205065Swnj #define TCP_NSTATES 11 214725Swnj 225065Swnj #define TCPS_CLOSED 0 /* closed */ 235065Swnj #define TCPS_LISTEN 1 /* listening for connection */ 245065Swnj #define TCPS_SYN_SENT 2 /* active, have sent syn */ 255085Swnj #define TCPS_SYN_RECEIVED 3 /* have send and received syn */ 265074Swnj /* states < TCPS_ESTABLISHED are those where connections not established */ 275065Swnj #define TCPS_ESTABLISHED 4 /* established */ 285085Swnj #define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 295074Swnj /* states > TCPS_CLOSE_WAIT are those where user has closed */ 305085Swnj #define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ 315085Swnj #define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 325085Swnj #define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ 335085Swnj /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 345085Swnj #define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ 355085Swnj #define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 364725Swnj 375085Swnj #define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) 385065Swnj #define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT) 395065Swnj 405085Swnj #ifdef TCPOUTFLAGS 415085Swnj /* 425085Swnj * Flags used when sending segments in tcp_output. 435085Swnj * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally 445173Swnj * determined by state, with the proviso that TH_FIN is sent only 455173Swnj * if all data queued for output is included in the segment. 465085Swnj */ 475085Swnj u_char tcp_outflags[TCP_NSTATES] = { 485085Swnj TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK, 495085Swnj TH_ACK, TH_ACK, 505244Sroot TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK, 515085Swnj }; 525085Swnj #endif 535085Swnj 544730Swnj #ifdef KPROF 554899Swnj int tcp_acounts[TCP_NSTATES][PRU_NREQ]; 564725Swnj #endif 574725Swnj 585085Swnj #ifdef TCPSTATES 594725Swnj char *tcpstates[] = { 605065Swnj "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", 615244Sroot "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING", 625244Sroot "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT", 634725Swnj }; 644725Swnj #endif 65