]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Timer.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1990, 1996-1998 Apple Computer, Inc.
32 * All Rights Reserved.
38 * From v01.12 06/22/90 mbs
39 * Modified for MP, 1996 by Tuyen Nguyen
40 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
43 #include <sys/errno.h>
44 #include <sys/types.h>
45 #include <sys/param.h>
46 #include <machine/spl.h>
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
50 #include <sys/filedesc.h>
51 #include <sys/fcntl.h>
53 #include <sys/socket.h>
56 #include <netat/sysglue.h>
57 #include <netat/appletalk.h>
58 #include <netat/at_pcb.h>
59 #include <netat/debug.h>
60 #include <netat/adsp.h>
61 #include <netat/adsp_internal.h>
68 * Cleanly abort a session that might be open. Called if probe timer expires,
69 * or from AppleTalk event handler (close or network gone away)
71 * Only call if the session is active (I.e. not for closed or listeners)
78 void TrashSession(sp
) /* (CCBPtr sp) */
82 sp
->userFlags
|= eTearDown
;
86 DoClose(sp
, errAborted
, 1);
98 void DoTimerElem(t
) /* (TimerElemPtr t) */
103 sp
= (CCBPtr
)((Ptr
)t
- t
->type
); /* Recover stream pointer for this guy */
105 if (t
->type
== kFlushTimerType
) { /* flush write data time just fired */
106 if (sp
->sData
) { /* If there's any data, flush it. */
110 } else if (t
->type
== kRetryTimerType
) {
111 if (sp
->waitingAck
) {
114 sp
->sendSeq
= sp
->firstRtmtSeq
;
116 sp
->resentData
= 1; /* Had to resend data */
117 sp
->noXmitFlow
= 1; /* Don't incr. max packets. */
119 if ((sp
->pktSendMax
/= 2) == 0) /* Back off on max # packets
123 if ((sp
->roundTrip
*= 2) > sp
->probeInterval
)
124 sp
->roundTrip
= sp
->probeInterval
;
125 sp
->rtmtInterval
= sp
->roundTrip
+ ((short)2 *
126 (short)sp
->deviation
);
129 } else if (t
->type
== kAttnTimerType
) {
130 if (sp
->sapb
) { /* Unacknowledged attn pkt */
131 sp
->sendAttnData
= 1;
134 } else if (t
->type
== kResetTimerType
) {
135 if (sp
->frpb
) { /* Unacknowledged forward reset */
136 sp
->sendCtl
|= B_CTL_FRESET
;
139 } else if (t
->type
== kProbeTimerType
) {
140 if (sp
->state
== sOpen
|| sp
->state
== sClosing
) {
141 if (--sp
->probeCntr
== 0) { /* Connection died */
145 InsertTimerElem(&adspGlobal
.slowTimers
, &sp
->ProbeTimer
,
147 sp
->sendCtl
|= B_CTL_PROBE
;
150 } else if (sp
->state
== sOpening
) {
151 if ((sp
->openState
== O_STATE_OPENWAIT
) ||
152 (sp
->openState
== O_STATE_ESTABLISHED
))
154 if (--sp
->openRetrys
== 0) { /* Oops, didn't open */
156 DoClose(sp
, errOpening
, 1);
159 else /* Send packet again */
161 sp
->sendCtl
|= (sp
->openState
== O_STATE_OPENWAIT
) ?
162 B_CTL_OREQ
: B_CTL_OREQACK
;
165 } /* we're opening */
170 dPrintf(D_M_ADSP
, D_L_ERROR
, ("DoTimerElem:Unknown timer type!\n"));
179 void TimerTick_funnel(void *arg
)
191 * Called 6 times per second
197 void TimerTick() /* (void) */
203 TimerQueueTick(&adspGlobal
.slowTimers
);
204 TimerQueueTick(&adspGlobal
.fastTimers
);
205 timeout(TimerTick_funnel
, (caddr_t
)0, HZ
/6);
211 untimeout(TimerTick_funnel
, (caddr_t
) 0);