1*5089Swnj /* tcp_timer.c 4.3 81/11/26 */ 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" 9*5089Swnj #include "../net/in.h" 10*5089Swnj #include "../net/in_pcb.h" 11*5089Swnj #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" 17*5089Swnj #include "../net/tcp_seq.h" 18*5089Swnj #include "../net/tcp_timer.h" 195069Swnj #include "../net/tcp_var.h" 20*5089Swnj #include "../net/tcpip.h" 215069Swnj #include "/usr/include/errno.h" 225069Swnj 235069Swnj /* 245069Swnj * Fast timeout routine for processing delayed acks 255069Swnj */ 265069Swnj tcp_fasttimo() 275069Swnj { 285069Swnj 29*5089Swnj 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 short *tmp; 435069Swnj register int i; 44*5089Swnj COUNT(TCP_SLOWTIMO); 455069Swnj 465069Swnj /* 475069Swnj * Search through tcb's and update active timers. 485069Swnj */ 495069Swnj for (ip = tcb.inp_next; ip != &tcb; ip = ip->inp_next) { 505069Swnj tp = intotcpcb(ip); 515075Swnj for (i = 0; i < TCPT_NTIMERS; i++) { 52*5089Swnj if (tp->t_timer[i] && --tp->t_timer[i] == 0) 535069Swnj (void) tcp_usrreq(tp->t_inpcb->inp_socket, 545069Swnj PRU_SLOWTIMO, (struct mbuf *)0, 555069Swnj (caddr_t)i); 565069Swnj tmp++; 575069Swnj } 585069Swnj } 595075Swnj tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */ 605069Swnj splx(s); 615069Swnj } 625069Swnj 635069Swnj /* 645075Swnj * Cancel all timers for TCP tp. 655069Swnj */ 66*5089Swnj tcp_canceltimers(tp) 675069Swnj struct tcpcb *tp; 685069Swnj { 695069Swnj register int i; 705069Swnj 71*5089Swnj COUNT(TCP_CANCELTIMERS); 725075Swnj for (i = 0; i < TCPT_NTIMERS; i++) 735075Swnj tp->t_timer[i] = 0; 745069Swnj } 755069Swnj 765069Swnj /* 775069Swnj * TCP timer went off processing. 785069Swnj */ 795075Swnj tcp_timers(tp, timer) 805069Swnj register struct tcpcb *tp; 815075Swnj int timer; 825069Swnj { 835069Swnj 845069Swnj COUNT(TCP_TIMERS); 85*5089Swnj switch (timer) { 865069Swnj 875075Swnj case TCPT_2MSL: 885075Swnj tcp_close(tp); 895075Swnj return; 905069Swnj 915075Swnj case TCPT_REXMT: 92*5089Swnj #if 0 935075Swnj tp->t_xmtime <<= 1; 94*5089Swnj if (tp->t_xmtime > TCPSC_TOOLONG) { 955075Swnj tcp_drop(tp, ETIMEDOUT); 965075Swnj return; 975069Swnj } 98*5089Swnj #endif 995075Swnj tcp_output(tp); 1005075Swnj return; 1015069Swnj 1025075Swnj case TCPT_PERSIST: 1035075Swnj if (tcp_output(tp) == 0) 1045075Swnj tp->snd_wnd++, (void) tcp_output(tp), tp->snd_wnd--; 105*5089Swnj /* reset? */ 106*5089Swnj return; 1075069Swnj 1085075Swnj case TCPT_KEEP: 109*5089Swnj /* reset? */ 1105075Swnj return; 1115069Swnj } 1125069Swnj } 113