1 /* tcp_timer.c 4.4 81/11/29 */ 2 3 #include "../h/param.h" 4 #include "../h/systm.h" 5 #include "../h/mbuf.h" 6 #include "../h/socket.h" 7 #include "../h/socketvar.h" 8 #include "../h/protosw.h" 9 #include "../net/in.h" 10 #include "../net/in_pcb.h" 11 #include "../net/in_systm.h" 12 #include "../net/if.h" 13 #include "../net/ip.h" 14 #include "../net/ip_var.h" 15 #include "../net/tcp.h" 16 #include "../net/tcp_fsm.h" 17 #include "../net/tcp_seq.h" 18 #include "../net/tcp_timer.h" 19 #include "../net/tcp_var.h" 20 #include "../net/tcpip.h" 21 #include "../errno.h" 22 23 /* 24 * Fast timeout routine for processing delayed acks 25 */ 26 tcp_fasttimo() 27 { 28 29 COUNT(TCP_FASTTIMO); 30 } 31 32 /* 33 * Tcp protocol timeout routine called every 500 ms. 34 * Updates the timers in all active tcb's and 35 * causes finite state machine actions if timers expire. 36 */ 37 tcp_slowtimo() 38 { 39 register struct inpcb *ip; 40 register struct tcpcb *tp; 41 int s = splnet(); 42 register int i; 43 COUNT(TCP_SLOWTIMO); 44 45 /* 46 * Search through tcb's and update active timers. 47 */ 48 for (ip = tcb.inp_next; ip != &tcb; ip = ip->inp_next) { 49 tp = intotcpcb(ip); 50 for (i = 0; i < TCPT_NTIMERS; i++) { 51 if (tp->t_timer[i] && --tp->t_timer[i] == 0) 52 (void) tcp_usrreq(tp->t_inpcb->inp_socket, 53 PRU_SLOWTIMO, (struct mbuf *)0, 54 (caddr_t)i); 55 } 56 } 57 tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */ 58 splx(s); 59 } 60 61 /* 62 * Cancel all timers for TCP tp. 63 */ 64 tcp_canceltimers(tp) 65 struct tcpcb *tp; 66 { 67 register int i; 68 69 COUNT(TCP_CANCELTIMERS); 70 for (i = 0; i < TCPT_NTIMERS; i++) 71 tp->t_timer[i] = 0; 72 } 73 74 /* 75 * TCP timer went off processing. 76 */ 77 tcp_timers(tp, timer) 78 register struct tcpcb *tp; 79 int timer; 80 { 81 82 COUNT(TCP_TIMERS); 83 switch (timer) { 84 85 case TCPT_2MSL: 86 tcp_close(tp); 87 return; 88 89 case TCPT_REXMT: 90 #if 0 91 tp->t_xmtime <<= 1; 92 if (tp->t_xmtime > TCPSC_TOOLONG) { 93 tcp_drop(tp, ETIMEDOUT); 94 return; 95 } 96 #endif 97 tcp_output(tp); 98 return; 99 100 case TCPT_PERSIST: 101 if (tcp_output(tp) == 0) 102 tp->snd_wnd++, (void) tcp_output(tp), tp->snd_wnd--; 103 /* reset? */ 104 return; 105 106 case TCPT_KEEP: 107 /* reset? */ 108 return; 109 } 110 } 111