1 /* tcp_fsm.h 4.2 81/11/03 */ 2 3 /* 4 * TCP FSM definitions. 5 * 6 * The TCP is conceptually a finite state machine with 13 states 7 * and 9 inputs. The states and inputs are defined here, as well 8 * as an array which is used in network profiling to keep event 9 * counters on the state transitions. The actual state transitions 10 * occur on input to the tcp machine (tcp_input.c) and when user 11 * requests are made (tcp_states.c). 12 * 13 * This TCP machine has two more states than suggested in RFC 793, 14 * the extra states being L_SYN_RCVD and RCV_WAIT. 15 * 16 * EXPLAIN THE EXTRA STATES!!! 17 */ 18 19 /* 20 * States 21 */ 22 #define TCP_NSTATES 14 23 24 #define EFAILEC -1 /* new state for failure, internally */ 25 #define SAME 0 /* no state change, internally */ 26 #define LISTEN 1 /* listening for connection */ 27 #define SYN_SENT 2 /* active, have sent syn */ 28 #define SYN_RCVD 3 29 #define L_SYN_RCVD 4 30 #define ESTAB 5 /* established */ 31 #define FIN_W1 6 /* have closed and sent fin */ 32 #define FIN_W2 7 /* have closed and rcvd ack of fin */ 33 #define TIME_WAIT 8 /* in 2*msl quiet wait after close */ 34 #define CLOSE_WAIT 9 /* rcvd fin, waiting for UCLOSE */ 35 #define CLOSING 10 /* closed xchd FIN; await FIN ACK */ 36 #define LAST_ACK 11 /* had fin and UCLOSE; await FIN ACK */ 37 #define RCV_WAIT 12 /* waiting for user to drain data */ 38 #define CLOSED 13 /* closed */ 39 40 /* 41 * Inputs to fsm. 42 */ 43 #define TCP_NINPUTS 10 44 45 #define IUOPENA 0 /* active open by user */ 46 #define INRECV 1 /* segment received from net */ 47 #define IUOPENR 2 /* passive open by user */ 48 #define IUCLOSE 3 /* close by user */ 49 #define ISTIMER 4 /* tcp timer expired */ 50 #define IURECV 5 /* user read data; adjust window */ 51 #define IUSEND 6 /* user sending data */ 52 #define IUABORT 7 /* user aborts connection */ 53 #define INCLEAR 8 /* network clear */ 54 #define INSEND 9 /* send by tcp to remote peer */ 55 56 #ifdef KPROF 57 int acounts[TCP_NSTATES][TCP_NINPUTS]; 58 #endif 59 60 #ifdef TCPSTATES 61 char *tcpstates[] = { 62 "SAME", "LISTEN", "SYN_SENT", "SYN_RCVD", 63 "L_SYN_RCVD", "ESTAB", "FIN_W1", "FIN_W2", 64 "TIME_WAIT", "CLOSE_WAIT", "CLOSING", "LAST_ACK", 65 "RCV_WAIT", "CLOSED" 66 }; 67 char *tcpinputs[] = { 68 "BAD", "UOPENA", "NRECV", "UOPENR", 69 "UCLOSE", "STIMER", "URECV", "USEND", 70 "UABORT", "NCLEAR", "NSEND", 71 }; 72 char *tcptimers[] = { "INIT", "REXMT", "REXMTTL", "PERSIST", "FINACK" }; 73 #endif 74