1*5067Swnj /* tcp_var.h 4.7 81/11/24 */ 24808Swnj 34808Swnj /* 44808Swnj * Kernel variables for tcp. 54808Swnj */ 64808Swnj 74808Swnj /* 84901Swnj * Tcp+ip header, after ip options removed. 94901Swnj */ 104901Swnj struct tcpiphdr { 114901Swnj struct ipovly ti_i; /* overlaid ip structure */ 124901Swnj struct tcphdr ti_t; /* tcp header */ 134901Swnj }; 144901Swnj #define ti_next ti_i.ih_next 154901Swnj #define ti_prev ti_i.ih_prev 164901Swnj #define ti_x1 ti_i.ih_x1 174901Swnj #define ti_pr ti_i.ih_pr 184901Swnj #define ti_len ti_i.ih_len 194901Swnj #define ti_src ti_i.ih_src 204901Swnj #define ti_dst ti_i.ih_dst 214901Swnj #define ti_sport ti_t.th_sport 224901Swnj #define ti_dport ti_t.th_dport 234901Swnj #define ti_seq ti_t.th_seq 244901Swnj #define ti_ackno ti_t.th_ackno 254901Swnj #define ti_x2 ti_t.th_x2 264901Swnj #define ti_off ti_t.th_off 274901Swnj #define ti_flags ti_t.th_flags 284901Swnj #define ti_win ti_t.th_win 294901Swnj #define ti_sum ti_t.th_sum 304901Swnj #define ti_urp ti_t.th_urp 314901Swnj 324901Swnj /* 33*5067Swnj * TCP sequence numbers are 32 bit integers operated 34*5067Swnj * on with modular arithmetic. These macros can be 35*5067Swnj * used to compare such integers. 36*5067Swnj */ 37*5067Swnj #define SEQ_LT(a,b) ((int)((a)-(b)) < 0) 38*5067Swnj #define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0) 39*5067Swnj #define SEQ_GT(a,b) ((int)((a)-(b)) > 0) 40*5067Swnj #define SEQ_GEQ(a,b) ((int)((a)-(b)) >= 0) 41*5067Swnj 42*5067Swnj /* 43*5067Swnj * Definitions of the TCP timers. These timers are counted 44*5067Swnj * down PR_SLOWHZ times a second. 45*5067Swnj */ 46*5067Swnj #define TCPT_NTIMERS 7 47*5067Swnj 48*5067Swnj #define TCPT_INIT 0 /* initialization */ 49*5067Swnj #define TCPT_REXMT 1 /* retransmit */ 50*5067Swnj #define TCPT_REXMTTL 2 /* retransmit too long */ 51*5067Swnj #define TCPT_KEEP 3 /* keep alive */ 52*5067Swnj #define TCPT_KEEPTTL 4 /* keep alive too long */ 53*5067Swnj #define TCPT_PERSIST 5 /* retransmit persistance */ 54*5067Swnj #define TCPT_2MSL 6 /* 2*msl quiet time timer */ 55*5067Swnj 56*5067Swnj /* 574808Swnj * Tcp control block. 584808Swnj */ 594881Swnj struct tcpcb { 604881Swnj struct tcpiphdr *seg_next,*seg_prev; /* seq queue */ 61*5067Swnj short seqcnt; /* count of chars in seq queue */ 62*5067Swnj u_char t_state; /* state of this connection */ 63*5067Swnj short t_timers[TCPT_NTIMERS]; /* tcp timers */ 64*5067Swnj u_char t_options; /* connection options: */ 65*5067Swnj #define TO_PUSH 0x01 /* push mode */ 66*5067Swnj #define TO_URG 0x02 /* urgent mode */ 67*5067Swnj #define TO_KEEP 0x04 /* use keep-alives */ 68*5067Swnj u_char t_flags; 69*5067Swnj #define TF_OWEACK 0x01 /* owe ack to peer */ 70*5067Swnj struct mbuf *seg_unack; /* unacked message queue */ 714881Swnj struct tcpiphdr *t_template; /* skeletal packet for transmit */ 72*5067Swnj struct inpcb *t_inpcb; /* back pointer to internet pcb */ 734808Swnj /* 74*5067Swnj * The following fields are used as in the protocol specification. 75*5067Swnj * See RFC783, Dec. 1981, page 21. 764808Swnj */ 77*5067Swnj /* send sequence variables */ 78*5067Swnj tcp_seq snd_una; /* send unacknowledged */ 79*5067Swnj tcp_seq snd_nxt; /* send next */ 80*5067Swnj u_short snd_wnd; /* send window */ 81*5067Swnj tcp_seq snd_up; /* send urgent pointer */ 82*5067Swnj tcp_seq snd_wl1; /* window update seg seq number */ 83*5067Swnj tcp_seq snd_wl2; /* window update seg ack number */ 84*5067Swnj tcp_seq iss; /* initial send sequence number */ 85*5067Swnj /* receive sequence variables */ 86*5067Swnj tcp_seq rcv_nxt; /* receive next */ 87*5067Swnj u_short rcv_wnd; /* receive window */ 88*5067Swnj tcp_seq rcv_up; /* receive urgent pointer */ 89*5067Swnj tcp_seq irs; /* initial receive sequence number */ 90*5067Swnj /* 91*5067Swnj * Additional variables for this implementation. 92*5067Swnj */ 93*5067Swnj /* send variables */ 94*5067Swnj tcp_seq snd_off; /*??*/ /* seq # of first datum in send buf */ 95*5067Swnj tcp_seq seq_fin; /*??*/ /* seq # of FIN sent */ 96*5067Swnj tcp_seq snd_hi; /*??*/ /* highest seq # sent */ 97*5067Swnj tcp_seq snd_end; /*??*/ /* send eol pointer */ 98*5067Swnj tcp_seq snd_lst; /*??*/ /* seq # of last sent datum */ 99*5067Swnj tcp_seq snd_wl; /*??*/ /* seq # of last sent window */ 100*5067Swnj tcp_seq snd_wnd; /*??*/ /* send window max */ 101*5067Swnj /* retransmit variables */ 102*5067Swnj tcp_seq t_rexmt_val; /*??*/ /* val saved in rexmt timer */ 103*5067Swnj tcp_seq t_rtl_val; /*??*/ /* val saved in rexmt too long timer */ 104*5067Swnj tcp_seq t_xmt_val; /*??*/ /* seq # sent when xmt timer started */ 105*5067Swnj u_char t_xmtime; /*??*/ /* current rexmt time */ 106*5067Swnj short t_xmt; /*??*/ /* round trip transmission time */ 107*5067Swnj /* receive variables */ 108*5067Swnj tcp_seq rcv_end; /*??*/ /* rcv eol pointer */ 109*5067Swnj tcp_seq rcv_adv; /*??*/ /* advertised window */ 110*5067Swnj }; 1114808Swnj 1124881Swnj #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) 1134881Swnj #define sototcpcb(so) (intotcpcb(sotoinpcb(so))) 1144881Swnj 1154808Swnj #define ISSINCR 128 /* increment for iss each second */ 1164808Swnj #define TCPSIZE 20 /* size of TCP leader (bytes) */ 1174808Swnj 118*5067Swnj #define TCP_TTL 30 /* time to live for TCP segs: 30s */ 1194808Swnj /* 120*5067Swnj * TCPSC constants give various timeouts in ``slow-clock'' ticks. 1214808Swnj */ 122*5067Swnj #define TCPSC_MSL (TCP_TTL*PR_SLOWHZ) /* max seg lifetime */ 123*5067Swnj #define TCPSC_REXMT (1*PR_SLOWHZ) /* base retransmit time */ 124*5067Swnj #define TCPSC_REXMTTL (TCP_TTL*2*PR_SLOWHZ) /* retransmit too long */ 125*5067Swnj #define TCPSC_KEEP (TCP_TTL*4*PR_SLOWHZ) /* keep alive */ 126*5067Swnj #define TCPSC_KEEPTTL (4*TCPSC_KEEP) /* keep alive too long */ 127*5067Swnj #define TCPSC_PERSIST (5*PR_SLOWHZ) /* retransmit persistance */ 128*5067Swnj #define TCPSC_2MSL (TCP_TTL*2*PR_SLOWHZ) /* 2*msl quiet time timer */ 1294808Swnj 130*5067Swnj #define TCPSC_REMAX (TCP_TTL*PR_SLOWHZ) /* maximum rexmt time */ 131*5067Swnj 1324926Swnj struct tcpstat { 1334926Swnj int tcps_badsum; 1344926Swnj int tcps_badoff; 1354926Swnj int tcps_hdrops; 1364926Swnj int tcps_badsegs; 1374926Swnj int tcps_unack; 1384926Swnj }; 1394926Swnj 1404808Swnj #ifdef KERNEL 141*5067Swnj tcp_seq tcp_iss; /* tcp initial send seq # */ 142*5067Swnj struct inpcb tcb; /* head of queue of active tcpcb's */ 143*5067Swnj struct tcpstat tcpstat; /* tcp statistics */ 1444808Swnj #endif 1454881Swnj struct tcpiphdr *tcp_template(); 1464808Swnj #endif 1474808Swnj 148*5067Swnj #ifdef TCPTIMERS 149*5067Swnj char *tcptimers[] = 150*5067Swnj { "INIT", "REXMT", "REXMTTL", "KEEP", "KEEPTTL", "PERSIST", "2MSL" }; 151*5067Swnj #endif 152