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/ipatm/ipatm_if.c,v 1.4 2000/01/17 20:49:43 mks Exp $
38 #include <netatm/kern_include.h>
40 #include <netatm/ipatm/ipatm_var.h>
41 #include <netatm/ipatm/ipatm_serv.h>
44 __RCSID("@(#) $FreeBSD: src/sys/netatm/ipatm/ipatm_if.c,v 1.4 2000/01/17 20:49:43 mks Exp $");
51 static void ipatm_closenif __P((struct ip_nif *));
55 * Process Network Interface status change
57 * Called whenever a network interface status change is requested.
63 * nip pointer to atm network interface control block
64 * arg command specific parameter
67 * 0 command successful
68 * errno command failed - reason indicated
72 ipatm_nifstat(cmd, nip, arg)
83 * Look for corresponding IP interface
85 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
86 if (inp->inf_nif == nip)
97 * Make sure i/f isn't already attached
105 * Get a new interface block
107 inp = (struct ip_nif *)atm_allocate(&ipatm_nifpool);
113 inp->inf_state = IPNIF_ADDR;
114 inp->inf_arpnotify = ipatm_arpnotify;
115 inp->inf_ipinput = ipatm_ipinput;
116 inp->inf_createsvc = ipatm_createsvc;
117 LINK2TAIL(inp, struct ip_nif, ipatm_nif_head, inf_next);
122 * Make sure i/f is attached
130 * Validate interface stuff
132 if (Q_HEAD(inp->inf_vcq, struct ipvcc))
133 panic("ipatm_nifstat: ipvcc queue not empty");
136 * If we're active, close all our VCCs and tell the
137 * interface service about the deactivation
139 if (inp->inf_state == IPNIF_ACTIVE) {
144 (void) (*inp->inf_serv->is_ifdact)(inp);
148 * Clean up and free block
150 UNLINK(inp, struct ip_nif, ipatm_nif_head, inf_next);
151 atm_free((caddr_t)inp);
156 * We only care about IP addresses
158 #if (defined(BSD) && (BSD >= 199103))
159 if (((struct ifaddr *)arg)->ifa_addr->sa_family != AF_INET)
161 if (((struct ifaddr *)arg)->ifa_addr.sa_family != AF_INET)
166 * Make sure i/f is there
168 ia = (struct in_ifaddr *)arg;
170 panic("ipatm_nifstat: setaddr missing ip_nif");
173 * Process new address
175 switch (inp->inf_state) {
182 * If signalling manager is not set, wait for it
184 sip = nip->nif_pif->pif_siginst;
186 inp->inf_state = IPNIF_SIGMGR;
191 * Otherwise, everything's set
193 inp->inf_state = IPNIF_ACTIVE;
196 * Tell interface service we're around
198 if (sip->si_ipserv) {
199 inp->inf_serv = sip->si_ipserv;
200 err = (*inp->inf_serv->is_ifact)(inp);
204 * Reset state if there's been a problem
207 inp->inf_serv = NULL;
208 inp->inf_addr = NULL;
209 inp->inf_state = IPNIF_ADDR;
215 * We dont support an address change
224 * Make sure i/f is attached
232 * Are we waiting for the sigmgr attach??
234 if (inp->inf_state != IPNIF_SIGMGR) {
236 * No, nothing else to do
242 * OK, everything's set
244 inp->inf_state = IPNIF_ACTIVE;
247 * Tell interface service we're around
249 sip = nip->nif_pif->pif_siginst;
250 if (sip->si_ipserv) {
251 inp->inf_serv = sip->si_ipserv;
252 err = (*inp->inf_serv->is_ifact)(inp);
256 * Just report any problems, since a NCM_SIGDETACH will
257 * be coming down immediately
263 * Make sure i/f is attached
271 * Are we currently active??
273 if (inp->inf_state != IPNIF_ACTIVE) {
275 * No, nothing else to do
281 * Close all the IP VCCs for this interface
286 * Tell interface service that i/f has gone down
289 (void) (*inp->inf_serv->is_ifdact)(inp);
292 * Just have to wait for another sigattach
294 inp->inf_serv = NULL;
295 inp->inf_state = IPNIF_SIGMGR;
299 log(LOG_ERR, "ipatm_nifstat: unknown command %d\n", cmd);
307 * Close all VCCs on a Network Interface
312 * inp pointer to IP network interface
322 struct ipvcc *ivp, *inext;
325 * Close each IP VCC on this interface
327 for (ivp = Q_HEAD(inp->inf_vcq, struct ipvcc); ivp; ivp = inext) {
329 inext = Q_NEXT(ivp, struct ipvcc, iv_elem);
331 (void) ipatm_closevc(ivp, T_ATM_CAUSE_UNSPECIFIED_NORMAL);