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 $
27 * @(#) $DragonFly: src/sys/netproto/atm/ipatm/ipatm_if.c,v 1.5 2003/08/23 10:06:22 rob Exp $
38 #include <netproto/atm/kern_include.h>
40 #include "ipatm_var.h"
41 #include "ipatm_serv.h"
46 static void ipatm_closenif (struct ip_nif *);
50 * Process Network Interface status change
52 * Called whenever a network interface status change is requested.
58 * nip pointer to atm network interface control block
59 * arg command specific parameter
62 * 0 command successful
63 * errno command failed - reason indicated
67 ipatm_nifstat(cmd, nip, arg)
78 * Look for corresponding IP interface
80 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
81 if (inp->inf_nif == nip)
92 * Make sure i/f isn't already attached
100 * Get a new interface block
102 inp = (struct ip_nif *)atm_allocate(&ipatm_nifpool);
108 inp->inf_state = IPNIF_ADDR;
109 inp->inf_arpnotify = ipatm_arpnotify;
110 inp->inf_ipinput = ipatm_ipinput;
111 inp->inf_createsvc = ipatm_createsvc;
112 LINK2TAIL(inp, struct ip_nif, ipatm_nif_head, inf_next);
117 * Make sure i/f is attached
125 * Validate interface stuff
127 if (Q_HEAD(inp->inf_vcq, struct ipvcc))
128 panic("ipatm_nifstat: ipvcc queue not empty");
131 * If we're active, close all our VCCs and tell the
132 * interface service about the deactivation
134 if (inp->inf_state == IPNIF_ACTIVE) {
139 (void) (*inp->inf_serv->is_ifdact)(inp);
143 * Clean up and free block
145 UNLINK(inp, struct ip_nif, ipatm_nif_head, inf_next);
146 atm_free((caddr_t)inp);
151 * We only care about IP addresses
153 #if (defined(BSD) && (BSD >= 199103))
154 if (((struct ifaddr *)arg)->ifa_addr->sa_family != AF_INET)
156 if (((struct ifaddr *)arg)->ifa_addr.sa_family != AF_INET)
161 * Make sure i/f is there
163 ia = (struct in_ifaddr *)arg;
165 panic("ipatm_nifstat: setaddr missing ip_nif");
168 * Process new address
170 switch (inp->inf_state) {
177 * If signalling manager is not set, wait for it
179 sip = nip->nif_pif->pif_siginst;
181 inp->inf_state = IPNIF_SIGMGR;
186 * Otherwise, everything's set
188 inp->inf_state = IPNIF_ACTIVE;
191 * Tell interface service we're around
193 if (sip->si_ipserv) {
194 inp->inf_serv = sip->si_ipserv;
195 err = (*inp->inf_serv->is_ifact)(inp);
199 * Reset state if there's been a problem
202 inp->inf_serv = NULL;
203 inp->inf_addr = NULL;
204 inp->inf_state = IPNIF_ADDR;
210 * We dont support an address change
219 * Make sure i/f is attached
227 * Are we waiting for the sigmgr attach??
229 if (inp->inf_state != IPNIF_SIGMGR) {
231 * No, nothing else to do
237 * OK, everything's set
239 inp->inf_state = IPNIF_ACTIVE;
242 * Tell interface service we're around
244 sip = nip->nif_pif->pif_siginst;
245 if (sip->si_ipserv) {
246 inp->inf_serv = sip->si_ipserv;
247 err = (*inp->inf_serv->is_ifact)(inp);
251 * Just report any problems, since a NCM_SIGDETACH will
252 * be coming down immediately
258 * Make sure i/f is attached
266 * Are we currently active??
268 if (inp->inf_state != IPNIF_ACTIVE) {
270 * No, nothing else to do
276 * Close all the IP VCCs for this interface
281 * Tell interface service that i/f has gone down
284 (void) (*inp->inf_serv->is_ifdact)(inp);
287 * Just have to wait for another sigattach
289 inp->inf_serv = NULL;
290 inp->inf_state = IPNIF_SIGMGR;
294 log(LOG_ERR, "ipatm_nifstat: unknown command %d\n", cmd);
302 * Close all VCCs on a Network Interface
307 * inp pointer to IP network interface
317 struct ipvcc *ivp, *inext;
320 * Close each IP VCC on this interface
322 for (ivp = Q_HEAD(inp->inf_vcq, struct ipvcc); ivp; ivp = inext) {
324 inext = Q_NEXT(ivp, struct ipvcc, iv_elem);
326 (void) ipatm_closevc(ivp, T_ATM_CAUSE_UNSPECIFIED_NORMAL);