1*5112Swnj /* tcp_timer.c 4.4 81/11/29 */ 25069Swnj 35069Swnj #include "../h/param.h" 45069Swnj #include "../h/systm.h" 55069Swnj #include "../h/mbuf.h" 65069Swnj #include "../h/socket.h" 75069Swnj #include "../h/socketvar.h" 85069Swnj #include "../h/protosw.h" 95089Swnj #include "../net/in.h" 105089Swnj #include "../net/in_pcb.h" 115089Swnj #include "../net/in_systm.h" 125069Swnj #include "../net/if.h" 135069Swnj #include "../net/ip.h" 145069Swnj #include "../net/ip_var.h" 155069Swnj #include "../net/tcp.h" 165069Swnj #include "../net/tcp_fsm.h" 175089Swnj #include "../net/tcp_seq.h" 185089Swnj #include "../net/tcp_timer.h" 195069Swnj #include "../net/tcp_var.h" 205089Swnj #include "../net/tcpip.h" 21*5112Swnj #include "../errno.h" 225069Swnj 235069Swnj /* 245069Swnj * Fast timeout routine for processing delayed acks 255069Swnj */ 265069Swnj tcp_fasttimo() 275069Swnj { 285069Swnj 295089Swnj COUNT(TCP_FASTTIMO); 305069Swnj } 315069Swnj 325069Swnj /* 335069Swnj * Tcp protocol timeout routine called every 500 ms. 345069Swnj * Updates the timers in all active tcb's and 355069Swnj * causes finite state machine actions if timers expire. 365069Swnj */ 375069Swnj tcp_slowtimo() 385069Swnj { 395069Swnj register struct inpcb *ip; 405069Swnj register struct tcpcb *tp; 415069Swnj int s = splnet(); 425069Swnj register int i; 435089Swnj COUNT(TCP_SLOWTIMO); 445069Swnj 455069Swnj /* 465069Swnj * Search through tcb's and update active timers. 475069Swnj */ 485069Swnj for (ip = tcb.inp_next; ip != &tcb; ip = ip->inp_next) { 495069Swnj tp = intotcpcb(ip); 505075Swnj for (i = 0; i < TCPT_NTIMERS; i++) { 515089Swnj if (tp->t_timer[i] && --tp->t_timer[i] == 0) 525069Swnj (void) tcp_usrreq(tp->t_inpcb->inp_socket, 535069Swnj PRU_SLOWTIMO, (struct mbuf *)0, 545069Swnj (caddr_t)i); 555069Swnj } 565069Swnj } 575075Swnj tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */ 585069Swnj splx(s); 595069Swnj } 605069Swnj 615069Swnj /* 625075Swnj * Cancel all timers for TCP tp. 635069Swnj */ 645089Swnj tcp_canceltimers(tp) 655069Swnj struct tcpcb *tp; 665069Swnj { 675069Swnj register int i; 685069Swnj 695089Swnj COUNT(TCP_CANCELTIMERS); 705075Swnj for (i = 0; i < TCPT_NTIMERS; i++) 715075Swnj tp->t_timer[i] = 0; 725069Swnj } 735069Swnj 745069Swnj /* 755069Swnj * TCP timer went off processing. 765069Swnj */ 775075Swnj tcp_timers(tp, timer) 785069Swnj register struct tcpcb *tp; 795075Swnj int timer; 805069Swnj { 815069Swnj 825069Swnj COUNT(TCP_TIMERS); 835089Swnj switch (timer) { 845069Swnj 855075Swnj case TCPT_2MSL: 865075Swnj tcp_close(tp); 875075Swnj return; 885069Swnj 895075Swnj case TCPT_REXMT: 905089Swnj #if 0 915075Swnj tp->t_xmtime <<= 1; 925089Swnj if (tp->t_xmtime > TCPSC_TOOLONG) { 935075Swnj tcp_drop(tp, ETIMEDOUT); 945075Swnj return; 955069Swnj } 965089Swnj #endif 975075Swnj tcp_output(tp); 985075Swnj return; 995069Swnj 1005075Swnj case TCPT_PERSIST: 1015075Swnj if (tcp_output(tp) == 0) 1025075Swnj tp->snd_wnd++, (void) tcp_output(tp), tp->snd_wnd--; 1035089Swnj /* reset? */ 1045089Swnj return; 1055069Swnj 1065075Swnj case TCPT_KEEP: 1075089Swnj /* reset? */ 1085075Swnj return; 1095069Swnj } 1105069Swnj } 111