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.2 2003/06/17 04:28:49 dillon Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * UNI ATMARP support (RFC1577) - Timer processing
38 #include <netatm/kern_include.h>
40 #include <netatm/ipatm/ipatm_var.h>
41 #include <netatm/ipatm/ipatm_serv.h>
42 #include <netatm/uni/uniip_var.h>
47 static void uniarp_svc_oldage __P((struct uniarp *));
48 static void uniarp_pvc_oldage __P((struct uniarp *));
52 * Process a UNI ATMARP entry timeout
54 * Called when a previously scheduled uniarp control block timer expires.
59 * tip pointer to uniarp timer control block
75 * Back-off to uniarp control block
77 uap = (struct uniarp *)
78 ((caddr_t)tip - (int)(&((struct uniarp *)0)->ua_time));
83 * Do we know the IP address for this entry yet??
85 if (uap->ua_dstip.s_addr == 0) {
88 * No, then send another InATMARP_REQ on each active VCC
89 * associated with this entry to solicit the peer's identity.
91 for (ivp = uap->ua_ivp; ivp; ivp = ivp->iv_arpnext) {
92 if (ivp->iv_state != IPVCC_ACTIVE)
94 (void) uniarp_inarp_req(uip, &uap->ua_dstatm,
95 &uap->ua_dstatmsub, ivp);
101 UNIARP_TIMER(uap, UNIARP_ARP_RETRY);
104 * Yes, then we're trying to find the ATM address for this
105 * IP address - so send another ATMARP_REQ to the arpserver
106 * (if it's up at the moment)
108 if (uip->uip_arpstate == UIAS_CLIENT_ACTIVE)
109 (void) uniarp_arp_req(uip, &uap->ua_dstip);
112 * Restart retry timer
114 UNIARP_TIMER(uap, UNIARP_ARP_RETRY);
122 * Process an UNI ARP SVC entry aging timer expiration
124 * This function is called when an SVC arp entry's aging timer has expired.
126 * Called at splnet().
129 * uap pointer to atmarp table entry
136 uniarp_svc_oldage(uap)
139 struct ipvcc *ivp, *inext;
140 struct uniip *uip = uap->ua_intf;
144 * Permanent (manually installed) entries are never aged
146 if (uap->ua_origin >= UAO_PERM)
150 * If entry is valid and we're out of retrys, tell
151 * IP/ATM that the SVCs can't be used
153 if ((uap->ua_flags & UAF_VALID) && (uap->ua_retry-- == 0)) {
154 uap->ua_flags |= UAF_LOCKED;
155 for (ivp = uap->ua_ivp; ivp; ivp = inext) {
156 inext = ivp->iv_arpnext;
157 (*ivp->iv_ipnif->inf_arpnotify)(ivp, MAP_INVALID);
159 uap->ua_flags &= ~(UAF_LOCKED | UAF_VALID);
163 * Delete and free an unused entry
165 if (uap->ua_ivp == NULL) {
168 atm_free((caddr_t)uap);
174 * We want to try and refresh this entry but we don't want
175 * to keep unused entries laying around forever.
177 if (uap->ua_ivp || (uap->ua_flags & UAF_USED)) {
178 if (uip->uip_arpstate == UIAS_CLIENT_ACTIVE) {
180 * If we are a client (and the server VCC is active),
181 * then we'll ask the server for a refresh
183 (void) uniarp_arp_req(uip, &uap->ua_dstip);
186 * Otherwise, solicit the each active VCC peer with
189 for (ivp = uap->ua_ivp; ivp; ivp = ivp->iv_arpnext) {
190 if (ivp->iv_state != IPVCC_ACTIVE)
192 (void) uniarp_inarp_req(uip, &uap->ua_dstatm,
193 &uap->ua_dstatmsub, ivp);
201 if (uap->ua_flags & UAF_VALID)
202 uap->ua_aging = UNIARP_RETRY_AGE;
204 uap->ua_aging = UNIARP_REVALID_AGE;
211 * Process an UNI ARP PVC entry aging timer expiration
213 * This function is called when a PVC arp entry's aging timer has expired.
215 * Called at splnet().
218 * uap pointer to atmarp table entry
225 uniarp_pvc_oldage(uap)
228 struct ipvcc *ivp = uap->ua_ivp;
231 * If entry is valid and we're out of retrys, tell
232 * IP/ATM that PVC can't be used
234 if ((uap->ua_flags & UAF_VALID) && (uap->ua_retry-- == 0)) {
235 (*ivp->iv_ipnif->inf_arpnotify)(ivp, MAP_INVALID);
236 uap->ua_flags &= ~UAF_VALID;
240 * Solicit peer with Inverse ATMARP
242 (void) uniarp_inarp_req(uap->ua_intf, &uap->ua_dstatm,
243 &uap->ua_dstatmsub, ivp);
248 if (uap->ua_flags & UAF_VALID)
249 uap->ua_aging = UNIARP_RETRY_AGE;
251 uap->ua_aging = UNIARP_REVALID_AGE;
258 * Process a UNI ARP aging timer tick
260 * This function is called every UNIARP_AGING seconds, in order to age
261 * all the arp table entries. If an entry's timer is expired, then the
262 * uniarp old-age timeout function will be called for that entry.
267 * tip pointer to uniarp aging timer control block
275 struct atm_time *tip;
277 struct uniarp *uap, *unext;
282 * Schedule next timeout
284 atm_timeout(&uniarp_timer, UNIARP_AGING, uniarp_aging);
287 * Run through arp table bumping each entry's aging timer.
288 * If an expired timer is found, process that entry.
290 for (i = 0; i < UNIARP_HASHSIZ; i++) {
291 for (uap = uniarp_arptab[i]; uap; uap = unext) {
292 unext = uap->ua_next;
294 if (uap->ua_aging && --uap->ua_aging == 0)
295 uniarp_svc_oldage(uap);
300 * Check out PVC aging timers too
302 for (uap = uniarp_pvctab; uap; uap = unext) {
303 unext = uap->ua_next;
305 if (uap->ua_aging && --uap->ua_aging == 0)
306 uniarp_pvc_oldage(uap);
310 * Only fully resolved SVC entries need aging, so there's no need
311 * to examine the 'no map' table