before carry to arpavax
[unix-history] / usr / src / sys / netinet / tcp_timer.c
CommitLineData
a6503abf 1/* tcp_timer.c 4.2 81/11/25 */
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"
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 */
24tcp_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 */
34tcp_slowtimo()
35{
36 register struct inpcb *ip;
37 register struct tcpcb *tp;
38 int s = splnet();
39 register short *tmp;
40 register int i;
41COUNT(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;
a6503abf 49 for (i = 0; i < TCPT_NTIMERS; i++) {
f03530e6
BJ
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 }
a6503abf 58 tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */
f03530e6
BJ
59 splx(s);
60}
61
62/*
a6503abf 63 * Cancel all timers for TCP tp.
f03530e6
BJ
64 */
65tcp_tcancel(tp)
66 struct tcpcb *tp;
67{
f03530e6
BJ
68 register int i;
69
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 77tcp_timers(tp, timer)
f03530e6 78 register struct tcpcb *tp;
a6503abf 79 int timer;
f03530e6
BJ
80{
81
82COUNT(TCP_TIMERS);
83 switch (timertype) {
84
a6503abf
BJ
85 case TCPT_2MSL:
86 tcp_close(tp);
87 return;
f03530e6 88
a6503abf
BJ
89 case TCPT_REXMT:
90 tp->t_xmtime <<= 1;
91 if (tp->t_xmtime > TCPT_TOOLONG) {
92 tcp_drop(tp, ETIMEDOUT);
93 return;
f03530e6 94 }
a6503abf
BJ
95 tcp_output(tp);
96 return;
f03530e6 97
a6503abf
BJ
98 case TCPT_PERSIST:
99 if (tcp_output(tp) == 0)
100 tp->snd_wnd++, (void) tcp_output(tp), tp->snd_wnd--;
f03530e6 101
a6503abf
BJ
102 case TCPT_KEEP:
103 return;
f03530e6 104 }
f03530e6 105}