1 /* tcp_timer.c 4.3 81/11/26 */ 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 "/usr/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 short *tmp; 43 register int i; 44 COUNT(TCP_SLOWTIMO); 45 46 /* 47 * Search through tcb's and update active timers. 48 */ 49 for (ip = tcb.inp_next; ip != &tcb; ip = ip->inp_next) { 50 tp = intotcpcb(ip); 51 for (i = 0; i < TCPT_NTIMERS; i++) { 52 if (tp->t_timer[i] && --tp->t_timer[i] == 0) 53 (void) tcp_usrreq(tp->t_inpcb->inp_socket, 54 PRU_SLOWTIMO, (struct mbuf *)0, 55 (caddr_t)i); 56 tmp++; 57 } 58 } 59 tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */ 60 splx(s); 61 } 62 63 /* 64 * Cancel all timers for TCP tp. 65 */ 66 tcp_canceltimers(tp) 67 struct tcpcb *tp; 68 { 69 register int i; 70 71 COUNT(TCP_CANCELTIMERS); 72 for (i = 0; i < TCPT_NTIMERS; i++) 73 tp->t_timer[i] = 0; 74 } 75 76 /* 77 * TCP timer went off processing. 78 */ 79 tcp_timers(tp, timer) 80 register struct tcpcb *tp; 81 int timer; 82 { 83 84 COUNT(TCP_TIMERS); 85 switch (timer) { 86 87 case TCPT_2MSL: 88 tcp_close(tp); 89 return; 90 91 case TCPT_REXMT: 92 #if 0 93 tp->t_xmtime <<= 1; 94 if (tp->t_xmtime > TCPSC_TOOLONG) { 95 tcp_drop(tp, ETIMEDOUT); 96 return; 97 } 98 #endif 99 tcp_output(tp); 100 return; 101 102 case TCPT_PERSIST: 103 if (tcp_output(tp) == 0) 104 tp->snd_wnd++, (void) tcp_output(tp), tp->snd_wnd--; 105 /* reset? */ 106 return; 107 108 case TCPT_KEEP: 109 /* reset? */ 110 return; 111 } 112 } 113