1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35#include <sys/errno.h>
36#include <sys/types.h>
37#include <sys/param.h>
38#include <machine/spl.h>
39#include <sys/systm.h>
40#include <sys/kernel.h>
41#include <sys/proc.h>
42#include <sys/filedesc.h>
43#include <sys/fcntl.h>
44#include <sys/mbuf.h>
45#include <sys/socket.h>
46#include <sys/time.h>
47
48#include <netat/sysglue.h>
49#include <netat/appletalk.h>
50#include <netat/at_pcb.h>
51#include <netat/debug.h>
52#include <netat/adsp.h>
53#include <netat/adsp_internal.h>
54
55void TimerTick();
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70void TrashSession(sp)
71 CCBPtr sp;
72{
73 int s;
74
75 ATDISABLE(s, sp->lock);
76 sp->userFlags |= eTearDown;
77 sp->removing = 1;
78 sp->state = sClosed;
79 ATENABLE(s, sp->lock);
80
81 DoClose(sp, errAborted, 1);
82}
83
84
85
86
87
88
89
90
91
92
93void DoTimerElem(t)
94 TimerElemPtr t;
95{
96 CCBPtr sp;
97 int s;
98
99 sp = (CCBPtr)((Ptr)t - t->type);
100 ATDISABLE(s, sp->lock);
101
102 if (t->type == kFlushTimerType) {
103 if (sp->sData) {
104 sp->writeFlush = 1;
105 goto send;
106 }
107 } else if (t->type == kRetryTimerType) {
108 if (sp->waitingAck) {
109
110 sp->waitingAck = 0;
111 sp->sendSeq = sp->firstRtmtSeq;
112 sp->pktSendCnt = 0;
113 sp->resentData = 1;
114 sp->noXmitFlow = 1;
115
116 if ((sp->pktSendMax /= 2) == 0)
117
118 sp->pktSendMax = 1;
119
120 if ((sp->roundTrip *= 2) > sp->probeInterval)
121 sp->roundTrip = sp->probeInterval;
122 sp->rtmtInterval = sp->roundTrip + ((short)2 *
123 (short)sp->deviation);
124 goto send;
125 }
126 } else if (t->type == kAttnTimerType) {
127 if (sp->sapb) {
128 sp->sendAttnData = 1;
129 goto send;
130 }
131 } else if (t->type == kResetTimerType) {
132 if (sp->frpb) {
133 sp->sendCtl |= B_CTL_FRESET;
134 goto send;
135 }
136 } else if (t->type == kProbeTimerType) {
137 if (sp->state == sOpen || sp->state == sClosing) {
138 if (--sp->probeCntr == 0) {
139 ATENABLE(s, sp->lock);
140 TrashSession(sp);
141 return;
142 } else {
143 InsertTimerElem(&adspGlobal.slowTimers, &sp->ProbeTimer,
144 sp->probeInterval);
145 sp->sendCtl |= B_CTL_PROBE;
146 goto send;
147 }
148 } else if (sp->state == sOpening) {
149 if ((sp->openState == O_STATE_OPENWAIT) ||
150 (sp->openState == O_STATE_ESTABLISHED))
151 {
152 if (--sp->openRetrys == 0) {
153 sp->state = sClosed;
154 ATENABLE(s, sp->lock);
155 DoClose(sp, errOpening, 1);
156 return;
157 }
158 else
159 {
160 sp->sendCtl |= (sp->openState == O_STATE_OPENWAIT) ?
161 B_CTL_OREQ : B_CTL_OREQACK;
162 goto send;
163 }
164 }
165 }
166 }
167
168 else {
169 dPrintf(D_M_ADSP, D_L_ERROR, ("DoTimerElem:Unknown timer type!\n"));
170 }
171
172 ATENABLE(s, sp->lock);
173 return;
174
175send:
176 ATENABLE(s, sp->lock);
177 CheckSend(sp);
178}
179
180void TimerTick_funnel(void *arg)
181{
182 atalk_lock();
183 TimerTick();
184 atalk_unlock();
185}
186
187static StopTimer;
188
189
190
191
192
193
194
195
196
197
198void TimerTick()
199{
200
201 if (StopTimer) {
202 return;
203 }
204 TimerQueueTick(&adspGlobal.slowTimers);
205 TimerQueueTick(&adspGlobal.fastTimers);
206 timeout(TimerTick_funnel, (caddr_t)0, HZ/6);
207}
208
209void TimerStop()
210{
211 StopTimer = 1;
212 untimeout(TimerTick_funnel, (caddr_t) 0);
213}
214