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/usr.sbin/atm/atmarpd/atmarp_timer.c,v 1.3 1999/08/28 01:15:30 peter Exp $
30 * Server Cache Synchronization Protocol (SCSP) Support
31 * ----------------------------------------------------
33 * SCSP-ATMARP server interface: timer routines
37 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <netatm/port.h>
43 #include <netatm/queue.h>
44 #include <netatm/atm.h>
45 #include <netatm/atm_if.h>
46 #include <netatm/atm_sap.h>
47 #include <netatm/atm_sys.h>
48 #include <netatm/atm_ioctl.h>
57 #include "../scspd/scsp_msg.h"
58 #include "../scspd/scsp_if.h"
59 #include "../scspd/scsp_var.h"
60 #include "atmarp_var.h"
63 * Cache update timeout processing
65 * When the cache update timer fires, we read the cache from the
66 * kernel, update the internal cache, and restart the timer.
69 * tp pointer to a HARP timer block
76 atmarp_cache_timeout(Harp_timer *tp)
81 * Verify the status of all configured interfaces
83 for (aip = atmarp_intf_head; aip; aip = aip->ai_next) {
84 if (atmarp_if_ready(aip)) {
86 * The interface is up but we don't have
87 * a connection to SCSP--make a connection
89 if (aip->ai_state == AI_STATE_NULL)
90 atmarp_scsp_connect(aip);
93 * The interface is down--disconnect from SCSP
95 if (aip->ai_state != AI_STATE_NULL)
96 atmarp_scsp_disconnect(aip);
101 * Read the cache from the kernel
103 atmarp_get_updated_cache();
106 * Restart the cache update timer
108 HARP_TIMER(tp, ATMARP_CACHE_INTERVAL, atmarp_cache_timeout);
113 * Permanent cache entry timer processing
115 * Permanent cache entries (entries that are administratively added
116 * and the entry for the server itself) don't ever get refreshed, so
117 * we broadcast updates for them every 10 minutes so they won't get
118 * deleted from the remote servers' caches
121 * tp pointer to a HARP timer block
128 atmarp_perm_timeout(Harp_timer *tp)
135 * Loop through all interfaces
137 for (aip = atmarp_intf_head; aip; aip = aip->ai_next) {
139 * Loop through the interface's cache
141 for (i = 0; i < ATMARP_HASHSIZ; i++) {
142 for (aap = aip->ai_arptbl[i]; aap;
143 aap = aap->aa_next) {
145 * Find and update permanent entries
147 if ((aap->aa_flags & (AAF_PERM |
150 rc = atmarp_scsp_update(aap,
158 * Restart the permanent cache entry timer
160 HARP_TIMER(tp, ATMARP_PERM_INTERVAL, atmarp_perm_timeout);
165 * Keepalive timeout processing
167 * When the keepalive timer fires, we send a NOP to SCSP. This
168 * will help us detect a broken connection.
171 * tp pointer to a HARP timer block
178 atmarp_keepalive_timeout(Harp_timer *tp)
184 * Back off to start of DCS entry
186 aip = (Atmarp_intf *) ((caddr_t)tp -
187 (uintptr_t)(&((Atmarp_intf *)0)->ai_keepalive_t));
190 * Get a message buffer
192 msg = (Scsp_if_msg *)UM_ALLOC(sizeof(Scsp_if_msg));
195 UM_ZERO(msg, sizeof(Scsp_if_msg));
198 * Build a NOP message
200 msg->si_type = SCSP_NOP_REQ;
201 msg->si_proto = SCSP_PROTO_ATMARP;
202 msg->si_len = sizeof(Scsp_if_msg_hdr);
205 * Send the message to SCSP
207 atmarp_scsp_out(aip, (char *)msg, msg->si_len);
211 * Restart the keepalive timer
213 HARP_TIMER(&aip->ai_keepalive_t, ATMARP_KEEPALIVE_INTERVAL,
214 atmarp_keepalive_timeout);