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