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.6 2005/02/01 00:51:50 joerg 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 (((struct ifaddr *)arg)->ifa_addr->sa_family != AF_INET)
157 * Make sure i/f is there
159 ia = (struct in_ifaddr *)arg;
161 panic("ipatm_nifstat: setaddr missing ip_nif");
164 * Process new address
166 switch (inp->inf_state) {
173 * If signalling manager is not set, wait for it
175 sip = nip->nif_pif->pif_siginst;
177 inp->inf_state = IPNIF_SIGMGR;
182 * Otherwise, everything's set
184 inp->inf_state = IPNIF_ACTIVE;
187 * Tell interface service we're around
189 if (sip->si_ipserv) {
190 inp->inf_serv = sip->si_ipserv;
191 err = (*inp->inf_serv->is_ifact)(inp);
195 * Reset state if there's been a problem
198 inp->inf_serv = NULL;
199 inp->inf_addr = NULL;
200 inp->inf_state = IPNIF_ADDR;
206 * We dont support an address change
215 * Make sure i/f is attached
223 * Are we waiting for the sigmgr attach??
225 if (inp->inf_state != IPNIF_SIGMGR) {
227 * No, nothing else to do
233 * OK, everything's set
235 inp->inf_state = IPNIF_ACTIVE;
238 * Tell interface service we're around
240 sip = nip->nif_pif->pif_siginst;
241 if (sip->si_ipserv) {
242 inp->inf_serv = sip->si_ipserv;
243 err = (*inp->inf_serv->is_ifact)(inp);
247 * Just report any problems, since a NCM_SIGDETACH will
248 * be coming down immediately
254 * Make sure i/f is attached
262 * Are we currently active??
264 if (inp->inf_state != IPNIF_ACTIVE) {
266 * No, nothing else to do
272 * Close all the IP VCCs for this interface
277 * Tell interface service that i/f has gone down
280 (void) (*inp->inf_serv->is_ifdact)(inp);
283 * Just have to wait for another sigattach
285 inp->inf_serv = NULL;
286 inp->inf_state = IPNIF_SIGMGR;
290 log(LOG_ERR, "ipatm_nifstat: unknown command %d\n", cmd);
298 * Close all VCCs on a Network Interface
303 * inp pointer to IP network interface
313 struct ipvcc *ivp, *inext;
316 * Close each IP VCC on this interface
318 for (ivp = Q_HEAD(inp->inf_vcq, struct ipvcc); ivp; ivp = inext) {
320 inext = Q_NEXT(ivp, struct ipvcc, iv_elem);
322 (void) ipatm_closevc(ivp, T_ATM_CAUSE_UNSPECIFIED_NORMAL);