fetch.9: Minor fixes.
[dragonfly.git] / sys / netproto / atm / uni / uniarp_timer.c
blob831f15c9e14111de2886d34a645f9f9b884deec7
1 /*
3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/sys/netatm/uni/uniarp_timer.c,v 1.4 2000/01/17 20:49:55 mks Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/uni/uniarp_timer.c,v 1.6 2006/01/14 13:36:39 swildner Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * UNI ATMARP support (RFC1577) - Timer processing
38 #include <netproto/atm/kern_include.h>
40 #include <netproto/atm/ipatm/ipatm_var.h>
41 #include <netproto/atm/ipatm/ipatm_serv.h>
42 #include "uniip_var.h"
45 * Local functions
47 static void uniarp_svc_oldage (struct uniarp *);
48 static void uniarp_pvc_oldage (struct uniarp *);
52 * Process a UNI ATMARP entry timeout
54 * Called when a previously scheduled uniarp control block timer expires.
56 * Called at splnet.
58 * Arguments:
59 * tip pointer to uniarp timer control block
61 * Returns:
62 * none
65 void
66 uniarp_timeout(struct atm_time *tip)
68 struct uniip *uip;
69 struct uniarp *uap;
70 struct ipvcc *ivp;
74 * Back-off to uniarp control block
76 uap = (struct uniarp *)
77 ((caddr_t)tip - (int)(&((struct uniarp *)0)->ua_time));
78 uip = uap->ua_intf;
82 * Do we know the IP address for this entry yet??
84 if (uap->ua_dstip.s_addr == 0) {
87 * No, then send another InATMARP_REQ on each active VCC
88 * associated with this entry to solicit the peer's identity.
90 for (ivp = uap->ua_ivp; ivp; ivp = ivp->iv_arpnext) {
91 if (ivp->iv_state != IPVCC_ACTIVE)
92 continue;
93 uniarp_inarp_req(uip, &uap->ua_dstatm,
94 &uap->ua_dstatmsub, ivp);
98 * Restart retry timer
100 UNIARP_TIMER(uap, UNIARP_ARP_RETRY);
101 } else {
103 * Yes, then we're trying to find the ATM address for this
104 * IP address - so send another ATMARP_REQ to the arpserver
105 * (if it's up at the moment)
107 if (uip->uip_arpstate == UIAS_CLIENT_ACTIVE)
108 uniarp_arp_req(uip, &uap->ua_dstip);
111 * Restart retry timer
113 UNIARP_TIMER(uap, UNIARP_ARP_RETRY);
116 return;
121 * Process an UNI ARP SVC entry aging timer expiration
123 * This function is called when an SVC arp entry's aging timer has expired.
125 * Called at splnet().
127 * Arguments:
128 * uap pointer to atmarp table entry
130 * Returns:
131 * none
134 static void
135 uniarp_svc_oldage(struct uniarp *uap)
137 struct ipvcc *ivp, *inext;
138 struct uniip *uip = uap->ua_intf;
142 * Permanent (manually installed) entries are never aged
144 if (uap->ua_origin >= UAO_PERM)
145 return;
148 * If entry is valid and we're out of retrys, tell
149 * IP/ATM that the SVCs can't be used
151 if ((uap->ua_flags & UAF_VALID) && (uap->ua_retry-- == 0)) {
152 uap->ua_flags |= UAF_LOCKED;
153 for (ivp = uap->ua_ivp; ivp; ivp = inext) {
154 inext = ivp->iv_arpnext;
155 (*ivp->iv_ipnif->inf_arpnotify)(ivp, MAP_INVALID);
157 uap->ua_flags &= ~(UAF_LOCKED | UAF_VALID);
158 uap->ua_origin = 0;
161 * Delete and free an unused entry
163 if (uap->ua_ivp == NULL) {
164 UNIARP_CANCEL(uap);
165 UNIARP_DELETE(uap);
166 atm_free((caddr_t)uap);
167 return;
172 * We want to try and refresh this entry but we don't want
173 * to keep unused entries laying around forever.
175 if (uap->ua_ivp || (uap->ua_flags & UAF_USED)) {
176 if (uip->uip_arpstate == UIAS_CLIENT_ACTIVE) {
178 * If we are a client (and the server VCC is active),
179 * then we'll ask the server for a refresh
181 uniarp_arp_req(uip, &uap->ua_dstip);
182 } else {
184 * Otherwise, solicit the each active VCC peer with
185 * an Inverse ATMARP
187 for (ivp = uap->ua_ivp; ivp; ivp = ivp->iv_arpnext) {
188 if (ivp->iv_state != IPVCC_ACTIVE)
189 continue;
190 uniarp_inarp_req(uip, &uap->ua_dstatm,
191 &uap->ua_dstatmsub, ivp);
197 * Reset timeout
199 if (uap->ua_flags & UAF_VALID)
200 uap->ua_aging = UNIARP_RETRY_AGE;
201 else
202 uap->ua_aging = UNIARP_REVALID_AGE;
204 return;
209 * Process an UNI ARP PVC entry aging timer expiration
211 * This function is called when a PVC arp entry's aging timer has expired.
213 * Called at splnet().
215 * Arguments:
216 * uap pointer to atmarp table entry
218 * Returns:
219 * none
222 static void
223 uniarp_pvc_oldage(struct uniarp *uap)
225 struct ipvcc *ivp = uap->ua_ivp;
228 * If entry is valid and we're out of retrys, tell
229 * IP/ATM that PVC can't be used
231 if ((uap->ua_flags & UAF_VALID) && (uap->ua_retry-- == 0)) {
232 (*ivp->iv_ipnif->inf_arpnotify)(ivp, MAP_INVALID);
233 uap->ua_flags &= ~UAF_VALID;
237 * Solicit peer with Inverse ATMARP
239 uniarp_inarp_req(uap->ua_intf, &uap->ua_dstatm,
240 &uap->ua_dstatmsub, ivp);
243 * Reset timeout
245 if (uap->ua_flags & UAF_VALID)
246 uap->ua_aging = UNIARP_RETRY_AGE;
247 else
248 uap->ua_aging = UNIARP_REVALID_AGE;
250 return;
255 * Process a UNI ARP aging timer tick
257 * This function is called every UNIARP_AGING seconds, in order to age
258 * all the arp table entries. If an entry's timer is expired, then the
259 * uniarp old-age timeout function will be called for that entry.
261 * Called at splnet.
263 * Arguments:
264 * tip pointer to uniarp aging timer control block
266 * Returns:
267 * none
270 void
271 uniarp_aging(struct atm_time *tip)
273 struct uniarp *uap, *unext;
274 int i;
278 * Schedule next timeout
280 atm_timeout(&uniarp_timer, UNIARP_AGING, uniarp_aging);
283 * Run through arp table bumping each entry's aging timer.
284 * If an expired timer is found, process that entry.
286 for (i = 0; i < UNIARP_HASHSIZ; i++) {
287 for (uap = uniarp_arptab[i]; uap; uap = unext) {
288 unext = uap->ua_next;
290 if (uap->ua_aging && --uap->ua_aging == 0)
291 uniarp_svc_oldage(uap);
296 * Check out PVC aging timers too
298 for (uap = uniarp_pvctab; uap; uap = unext) {
299 unext = uap->ua_next;
301 if (uap->ua_aging && --uap->ua_aging == 0)
302 uniarp_pvc_oldage(uap);
306 * Only fully resolved SVC entries need aging, so there's no need
307 * to examine the 'no map' table