1 /* tcp_timer.c 4.2 81/11/25 */ 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/inet.h" 10 #include "../net/inet_pcb.h" 11 #include "../net/inet_systm.h" 12 #include "../net/if.h" 13 #include "../net/imp.h" 14 #include "../net/ip.h" 15 #include "../net/ip_var.h" 16 #include "../net/tcp.h" 17 #include "../net/tcp_fsm.h" 18 #include "../net/tcp_var.h" 19 #include "/usr/include/errno.h" 20 21 /* 22 * Fast timeout routine for processing delayed acks 23 */ 24 tcp_fasttimo() 25 { 26 27 } 28 29 /* 30 * Tcp protocol timeout routine called every 500 ms. 31 * Updates the timers in all active tcb's and 32 * causes finite state machine actions if timers expire. 33 */ 34 tcp_slowtimo() 35 { 36 register struct inpcb *ip; 37 register struct tcpcb *tp; 38 int s = splnet(); 39 register short *tmp; 40 register int i; 41 COUNT(TCP_TIMEO); 42 43 /* 44 * Search through tcb's and update active timers. 45 */ 46 for (ip = tcb.inp_next; ip != &tcb; ip = ip->inp_next) { 47 tp = intotcpcb(ip); 48 tmp = &tp->t_init; 49 for (i = 0; i < TCPT_NTIMERS; i++) { 50 if (*tmp && --*tmp == 0) 51 (void) tcp_usrreq(tp->t_inpcb->inp_socket, 52 PRU_SLOWTIMO, (struct mbuf *)0, 53 (caddr_t)i); 54 tmp++; 55 } 56 tp->t_xmt++; 57 } 58 tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */ 59 splx(s); 60 } 61 62 /* 63 * Cancel all timers for TCP tp. 64 */ 65 tcp_tcancel(tp) 66 struct tcpcb *tp; 67 { 68 register int i; 69 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 (timertype) { 84 85 case TCPT_2MSL: 86 tcp_close(tp); 87 return; 88 89 case TCPT_REXMT: 90 tp->t_xmtime <<= 1; 91 if (tp->t_xmtime > TCPT_TOOLONG) { 92 tcp_drop(tp, ETIMEDOUT); 93 return; 94 } 95 tcp_output(tp); 96 return; 97 98 case TCPT_PERSIST: 99 if (tcp_output(tp) == 0) 100 tp->snd_wnd++, (void) tcp_output(tp), tp->snd_wnd--; 101 102 case TCPT_KEEP: 103 return; 104 } 105 } 106