]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netccitt/llc_timer.c
6014a31ffc99bf2c44183a92d1d589a01a12a50a
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (C) Dirk Husemann, Computer Science Department IV,
24 * University of Erlangen-Nuremberg, Germany, 1990, 1991, 1992
25 * Copyright (c) 1992, 1993
26 * The Regents of the University of California. All rights reserved.
28 * This code is derived from software contributed to Berkeley by
29 * Dirk Husemann and the Computer Science Department (IV) of
30 * the University of Erlangen-Nuremberg, Germany.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * @(#)llc_timer.c 8.1 (Berkeley) 6/10/93
63 #include <sys/param.h>
64 #include <sys/systm.h>
66 #include <sys/domain.h>
67 #include <sys/socket.h>
68 #include <sys/protosw.h>
69 #include <sys/errno.h>
71 #include <sys/kernel.h>
74 #include <net/if_dl.h>
75 #include <net/if_llc.h>
77 #include <netccitt/dll.h>
78 #include <netccitt/llc_var.h>
82 * Various timer values. They can be adjusted
83 * by patching the binary with adb if necessary.
85 /* ISO 8802-2 timers */
86 int llc_n2
= LLC_N2_VALUE
;
87 int llc_ACK_timer
= LLC_ACK_TIMER
;
88 int llc_P_timer
= LLC_P_TIMER
;
89 int llc_BUSY_timer
= LLC_BUSY_TIMER
;
90 int llc_REJ_timer
= LLC_REJ_TIMER
;
91 /* Implementation specific timers */
92 int llc_AGE_timer
= LLC_AGE_TIMER
;
93 int llc_DACTION_timer
= LLC_DACTION_TIMER
;
96 * The timer routine. We are called every 500ms by the kernel.
97 * Handle the various virtual timers.
103 register struct llc_linkcb
*linkp
;
104 register struct llc_linkcb
*nlinkp
;
107 register int s
= splimp();
110 * All links are accessible over the doubly linked list llccb_q
114 * A for-loop is not that great an idea as the linkp
115 * might get deleted if the age timer has expired ...
118 while (LQVALID(linkp
)) {
119 nlinkp
= LQNEXT(linkp
);
121 * Check implementation specific timers first
123 /* The delayed action/acknowledge idle timer */
124 switch (LLC_TIMERXPIRED(linkp
, DACTION
)) {
125 case LLC_TIMER_RUNNING
:
126 LLC_AGETIMER(linkp
, DACTION
);
128 case LLC_TIMER_EXPIRED
: {
130 register int pollfinal
;
132 switch (LLC_GETFLAG(linkp
, DACTION
)) {
134 cmdrsp
= LLC_CMD
, pollfinal
= 0;
136 case LLC_DACKCMDPOLL
:
137 cmdrsp
= LLC_CMD
, pollfinal
= 1;
140 cmdrsp
= LLC_RSP
, pollfinal
= 0;
142 case LLC_DACKRSPFINAL
:
143 cmdrsp
= LLC_RSP
, pollfinal
= 1;
146 llc_send(linkp
, LLCFT_RR
, cmdrsp
, pollfinal
);
147 LLC_STOPTIMER(linkp
, DACTION
);
151 /* The link idle timer */
152 switch (LLC_TIMERXPIRED(linkp
, AGE
)) {
153 case LLC_TIMER_RUNNING
:
154 LLC_AGETIMER(linkp
, AGE
);
156 case LLC_TIMER_EXPIRED
:
158 * Only crunch the link when really no
159 * timers are running any more.
161 if (llc_anytimersup(linkp
) == 0) {
163 LLC_STOPTIMER(linkp
, AGE
);
166 LLC_STARTTIMER(linkp
, AGE
);
171 * Now, check all the ISO 8802-2 timers
173 FOR_ALL_LLC_TIMERS(timer
) {
175 if ((linkp
->llcl_timerflags
& (1<<timer
)) &&
176 (linkp
->llcl_timers
[timer
] == 0)) {
179 action
= LLC_ACK_TIMER_EXPIRED
;
182 action
= LLC_P_TIMER_EXPIRED
;
185 action
= LLC_BUSY_TIMER_EXPIRED
;
188 action
= LLC_REJ_TIMER_EXPIRED
;
191 linkp
->llcl_timerflags
&= ~(1<<timer
);
192 (void)llc_statehandler(linkp
, (struct llc
*)0, action
, 0, 1);
193 } else if (linkp
->llcl_timers
[timer
] > 0)
194 linkp
->llcl_timers
[timer
]--;
197 gone
: linkp
= nlinkp
;