Commit | Line | Data |
---|---|---|
f1b2fa5b | 1 | /* tcp_timer.c 4.4 81/11/29 */ |
f03530e6 BJ |
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" | |
0974b45c BJ |
9 | #include "../net/in.h" |
10 | #include "../net/in_pcb.h" | |
11 | #include "../net/in_systm.h" | |
f03530e6 | 12 | #include "../net/if.h" |
f03530e6 BJ |
13 | #include "../net/ip.h" |
14 | #include "../net/ip_var.h" | |
15 | #include "../net/tcp.h" | |
16 | #include "../net/tcp_fsm.h" | |
0974b45c BJ |
17 | #include "../net/tcp_seq.h" |
18 | #include "../net/tcp_timer.h" | |
f03530e6 | 19 | #include "../net/tcp_var.h" |
0974b45c | 20 | #include "../net/tcpip.h" |
f1b2fa5b | 21 | #include "../errno.h" |
f03530e6 BJ |
22 | |
23 | /* | |
24 | * Fast timeout routine for processing delayed acks | |
25 | */ | |
26 | tcp_fasttimo() | |
27 | { | |
28 | ||
0974b45c | 29 | COUNT(TCP_FASTTIMO); |
f03530e6 BJ |
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(); | |
f03530e6 | 42 | register int i; |
0974b45c | 43 | COUNT(TCP_SLOWTIMO); |
f03530e6 BJ |
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); | |
a6503abf | 50 | for (i = 0; i < TCPT_NTIMERS; i++) { |
0974b45c | 51 | if (tp->t_timer[i] && --tp->t_timer[i] == 0) |
f03530e6 BJ |
52 | (void) tcp_usrreq(tp->t_inpcb->inp_socket, |
53 | PRU_SLOWTIMO, (struct mbuf *)0, | |
54 | (caddr_t)i); | |
f03530e6 | 55 | } |
f03530e6 | 56 | } |
a6503abf | 57 | tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */ |
f03530e6 BJ |
58 | splx(s); |
59 | } | |
60 | ||
61 | /* | |
a6503abf | 62 | * Cancel all timers for TCP tp. |
f03530e6 | 63 | */ |
0974b45c | 64 | tcp_canceltimers(tp) |
f03530e6 BJ |
65 | struct tcpcb *tp; |
66 | { | |
f03530e6 BJ |
67 | register int i; |
68 | ||
0974b45c | 69 | COUNT(TCP_CANCELTIMERS); |
a6503abf BJ |
70 | for (i = 0; i < TCPT_NTIMERS; i++) |
71 | tp->t_timer[i] = 0; | |
f03530e6 BJ |
72 | } |
73 | ||
74 | /* | |
75 | * TCP timer went off processing. | |
76 | */ | |
a6503abf | 77 | tcp_timers(tp, timer) |
f03530e6 | 78 | register struct tcpcb *tp; |
a6503abf | 79 | int timer; |
f03530e6 BJ |
80 | { |
81 | ||
82 | COUNT(TCP_TIMERS); | |
0974b45c | 83 | switch (timer) { |
f03530e6 | 84 | |
a6503abf BJ |
85 | case TCPT_2MSL: |
86 | tcp_close(tp); | |
87 | return; | |
f03530e6 | 88 | |
a6503abf | 89 | case TCPT_REXMT: |
0974b45c | 90 | #if 0 |
a6503abf | 91 | tp->t_xmtime <<= 1; |
0974b45c | 92 | if (tp->t_xmtime > TCPSC_TOOLONG) { |
a6503abf BJ |
93 | tcp_drop(tp, ETIMEDOUT); |
94 | return; | |
f03530e6 | 95 | } |
0974b45c | 96 | #endif |
a6503abf BJ |
97 | tcp_output(tp); |
98 | return; | |
f03530e6 | 99 | |
a6503abf BJ |
100 | case TCPT_PERSIST: |
101 | if (tcp_output(tp) == 0) | |
102 | tp->snd_wnd++, (void) tcp_output(tp), tp->snd_wnd--; | |
0974b45c BJ |
103 | /* reset? */ |
104 | return; | |
f03530e6 | 105 | |
a6503abf | 106 | case TCPT_KEEP: |
0974b45c | 107 | /* reset? */ |
a6503abf | 108 | return; |
f03530e6 | 109 | } |
f03530e6 | 110 | } |