1 /* tcp_fsm.h 6.1 83/07/29 */ 2 3 /* 4 * TCP FSM state definitions. 5 * Per RFC793, September, 1981. 6 */ 7 8 #define TCP_NSTATES 11 9 10 #define TCPS_CLOSED 0 /* closed */ 11 #define TCPS_LISTEN 1 /* listening for connection */ 12 #define TCPS_SYN_SENT 2 /* active, have sent syn */ 13 #define TCPS_SYN_RECEIVED 3 /* have send and received syn */ 14 /* states < TCPS_ESTABLISHED are those where connections not established */ 15 #define TCPS_ESTABLISHED 4 /* established */ 16 #define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 17 /* states > TCPS_CLOSE_WAIT are those where user has closed */ 18 #define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ 19 #define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 20 #define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ 21 /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 22 #define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ 23 #define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 24 25 #define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) 26 #define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT) 27 28 #ifdef TCPOUTFLAGS 29 /* 30 * Flags used when sending segments in tcp_output. 31 * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally 32 * determined by state, with the proviso that TH_FIN is sent only 33 * if all data queued for output is included in the segment. 34 */ 35 u_char tcp_outflags[TCP_NSTATES] = { 36 TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK, 37 TH_ACK, TH_ACK, 38 TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK, 39 }; 40 #endif 41 42 #ifdef KPROF 43 int tcp_acounts[TCP_NSTATES][PRU_NREQ]; 44 #endif 45 46 #ifdef TCPSTATES 47 char *tcpstates[] = { 48 "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", 49 "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING", 50 "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT", 51 }; 52 #endif 53