Pre-2.0 release: Sync with HAMMER 65 - simplify PFS operations.
[dragonfly.git] / sys / netproto / atm / uni / uniip.c
blobc8dbd70dd180b9f255a906cea7bf9ba7858a5e17
1 /*
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/uniip.c,v 1.4 1999/08/28 00:49:03 peter Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/uni/uniip.c,v 1.6 2006/01/14 13:36:39 swildner Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * UNI IP interface module
38 #include <netproto/atm/kern_include.h>
40 #include <netproto/atm/ipatm/ipatm_var.h>
41 #include <netproto/atm/ipatm/ipatm_serv.h>
42 #include "uniip_var.h"
45 * Local functions
47 static int uniip_ipact (struct ip_nif *);
48 static int uniip_ipdact (struct ip_nif *);
52 * Global variables
54 struct uniip *uniip_head = NULL;
56 struct ip_serv uniip_ipserv = {
57 uniip_ipact,
58 uniip_ipdact,
59 uniarp_ioctl,
60 uniarp_pvcopen,
61 uniarp_svcout,
62 uniarp_svcin,
63 uniarp_svcactive,
64 uniarp_vcclose,
65 NULL,
66 { { ATM_AAL5, ATM_ENC_LLC} },
71 * Local variables
73 static struct sp_info uniip_pool = {
74 "uni ip pool", /* si_name */
75 sizeof(struct uniip), /* si_blksiz */
76 2, /* si_blkcnt */
77 100 /* si_maxallow */
82 * Process module loading notification
84 * Called whenever the uni module is initializing.
86 * Arguments:
87 * none
89 * Returns:
90 * 0 initialization successful
91 * errno initialization failed - reason indicated
94 int
95 uniip_start(void)
97 int err;
100 * Tell arp to initialize stuff
102 err = uniarp_start();
104 return (err);
109 * Process module unloading notification
111 * Called whenever the uni module is about to be unloaded. All signalling
112 * instances will have been previously detached. All uniip resources
113 * must be freed now.
115 * Arguments:
116 * none
118 * Returns:
119 * 0 shutdown was successful
120 * errno shutdown failed - reason indicated
124 uniip_stop(void)
128 * All IP interfaces should be gone
130 if (uniip_head)
131 return (EBUSY);
134 * Tell arp to stop
136 uniarp_stop();
139 * Free our storage pools
141 atm_release_pool(&uniip_pool);
143 return (0);
148 * Process IP Network Interface Activation
150 * Called whenever an IP network interface becomes active.
152 * Called at splnet.
154 * Arguments:
155 * inp pointer to IP network interface
157 * Returns:
158 * 0 command successful
159 * errno command failed - reason indicated
162 static int
163 uniip_ipact(struct ip_nif *inp)
165 struct uniip *uip;
168 * Make sure we don't already have this interface
170 for (uip = uniip_head; uip; uip = uip->uip_next) {
171 if (uip->uip_ipnif == inp)
172 return (EEXIST);
176 * Get a new interface control block
178 uip = (struct uniip *)atm_allocate(&uniip_pool);
179 if (uip == NULL)
180 return (ENOMEM);
183 * Initialize and link up
185 uip->uip_ipnif = inp;
186 LINK2TAIL(uip, struct uniip, uniip_head, uip_next);
189 * Link from IP world
191 inp->inf_isintf = (caddr_t)uip;
194 * Tell arp about new interface
196 uniarp_ipact(uip);
198 return (0);
203 * Process IP Network Interface Deactivation
205 * Called whenever an IP network interface becomes inactive.
207 * Called at splnet.
209 * Arguments:
210 * inp pointer to IP network interface
212 * Returns:
213 * 0 command successful
214 * errno command failed - reason indicated
217 static int
218 uniip_ipdact(struct ip_nif *inp)
220 struct uniip *uip;
223 * Get the appropriate IP interface block
225 uip = (struct uniip *)inp->inf_isintf;
226 if (uip == NULL)
227 return (ENXIO);
230 * Let arp know about this
232 uniarp_ipdact(uip);
235 * Free interface info
237 UNLINK(uip, struct uniip, uniip_head, uip_next);
238 if (uip->uip_prefix != NULL)
239 KM_FREE(uip->uip_prefix,
240 uip->uip_nprefix * sizeof(struct uniarp_prf), M_DEVBUF);
241 atm_free((caddr_t)uip);
243 return (0);