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_usrreq.c,v 1.5.2.1 2003/02/15 09:25:13 phk Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/ipatm/ipatm_usrreq.c,v 1.2 2003/06/17 04:28:49 dillon Exp $
34 * Process user requests
38 #include <netatm/kern_include.h>
40 #include <netatm/ipatm/ipatm_var.h>
41 #include <netatm/ipatm/ipatm_serv.h>
44 * Process IP PF_ATM ioctls
49 * code PF_ATM sub-operation code
50 * data pointer to code specific parameter data area
51 * arg1 pointer to code specific argument
55 * errno error processing request - reason indicated
59 ipatm_ioctl(code, data, arg1)
64 struct atmaddreq *aap;
65 struct atmdelreq *adp;
66 struct atminfreq *aip;
67 struct air_ip_vcc_rsp aivr;
84 aap = (struct atmaddreq *)data;
87 * Find the IP network interface
89 if ((nip = atm_nifname(aap->aar_pvc_intf)) == NULL) {
94 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
95 if (inp->inf_nif == nip)
104 * Validate PVC params
106 if (aap->aar_pvc_aal == ATM_AAL5) {
107 if ((aap->aar_pvc_encaps != ATM_ENC_LLC) &&
108 (aap->aar_pvc_encaps != ATM_ENC_NULL)) {
112 } else if (aap->aar_pvc_aal == ATM_AAL3_4) {
113 if (aap->aar_pvc_encaps != ATM_ENC_NULL) {
122 if (aap->aar_pvc_flags & PVC_DYN) {
124 * For dynamic PVC destination addressing, the
125 * network interface must have support for this
127 if ((inp->inf_serv == NULL) ||
128 (inp->inf_serv->is_arp_pvcopen == NULL)) {
133 u_long dst = ((struct sockaddr_in *)&aap->aar_pvc_dst)
136 if (dst == INADDR_ANY) {
143 * Build connection request
146 pv.ipp_vpi = aap->aar_pvc_vpi;
147 pv.ipp_vci = aap->aar_pvc_vci;
148 pv.ipp_encaps = aap->aar_pvc_encaps;
149 pv.ipp_aal = aap->aar_pvc_aal;
150 if (aap->aar_pvc_flags & PVC_DYN) {
151 pv.ipp_dst.sin_addr.s_addr = INADDR_ANY;
153 pv.ipp_dst = *(struct sockaddr_in *)&aap->aar_pvc_dst;
158 err = ipatm_openpvc(&pv, &ivp);
165 aap = (struct atmaddreq *)data;
168 * Validate IP address
170 if (aap->aar_arp_dst.sa_family != AF_INET) {
174 ip = SATOSIN(&aap->aar_arp_dst)->sin_addr;
176 if (aap->aar_arp_intf[0] == '\0') {
178 * Find the IP network interface associated with
179 * the supplied IP address
181 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
182 if (ipatm_chknif(ip, inp) == 0)
191 * Find the specified IP network interface
193 if ((nip = atm_nifname(aap->aar_arp_intf)) == NULL) {
197 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
198 if (inp->inf_nif == nip)
207 if ((ip.s_addr == INADDR_ANY) ||
208 #if (defined(BSD) && (BSD >= 199306))
209 in_broadcast(ip, &inp->inf_nif->nif_if) ||
213 IN_MULTICAST(ntohl(ip.s_addr))) {
219 * Notify the responsible ARP service
221 * XXX: if there is one. No idea how this happens, but at
222 * least don't panic on a NULL pointer if it does.
224 if (inp->inf_serv == NULL) {
228 err = (*inp->inf_serv->is_ioctl)(code, data, inp->inf_isintf);
233 * Delete an ARP mapping
235 adp = (struct atmdelreq *)data;
238 * Validate IP address
240 if (adp->adr_arp_dst.sa_family != AF_INET) {
244 ip = SATOSIN(&adp->adr_arp_dst)->sin_addr;
246 if (adp->adr_arp_intf[0] == '\0') {
248 * Find the IP network interface associated with
249 * the supplied IP address
251 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
252 if (ipatm_chknif(ip, inp) == 0)
261 * Find the specified IP network interface
263 if ((nip = atm_nifname(adp->adr_arp_intf)) == NULL) {
267 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
268 if (inp->inf_nif == nip)
277 if ((ip.s_addr == INADDR_ANY) ||
278 #if (defined(BSD) && (BSD >= 199306))
279 in_broadcast(ip, &inp->inf_nif->nif_if) ||
283 IN_MULTICAST(ntohl(ip.s_addr))) {
289 * Notify the responsible ARP service
291 err = (*inp->inf_serv->is_ioctl)(code, data, inp->inf_isintf);
296 * Get IP VCC information
298 aip = (struct atminfreq *)data;
300 if (aip->air_ip_addr.sa_family != AF_INET)
302 ip = SATOSIN(&aip->air_ip_addr)->sin_addr;
304 cp = aip->air_buf_addr;
305 space = aip->air_buf_len;
308 * Loop through all our interfaces
310 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
314 for (ivp = Q_HEAD(inp->inf_vcq, struct ipvcc); ivp;
315 ivp = Q_NEXT(ivp, struct ipvcc, iv_elem)) {
317 if ((ip.s_addr != INADDR_ANY) &&
318 (ip.s_addr != ivp->iv_dst.s_addr))
322 * Make sure there's room in user buffer
324 if (space < sizeof(aivr)) {
330 * Fill in info to be returned
332 KM_ZERO((caddr_t)&aivr, sizeof(aivr));
333 SATOSIN(&aivr.aip_dst_addr)->sin_family =
335 SATOSIN(&aivr.aip_dst_addr)->sin_addr.s_addr =
337 (void) snprintf(aivr.aip_intf,
338 sizeof(aivr.aip_intf), "%s%d",
339 inp->inf_nif->nif_if.if_name,
340 inp->inf_nif->nif_if.if_unit);
341 if ((ivp->iv_conn) &&
342 (ivp->iv_conn->co_connvc) &&
343 (vcp = ivp->iv_conn->co_connvc->cvc_vcc)) {
344 aivr.aip_vpi = vcp->vc_vpi;
345 aivr.aip_vci = vcp->vc_vci;
346 aivr.aip_sig_proto = vcp->vc_proto;
348 aivr.aip_flags = ivp->iv_flags;
349 aivr.aip_state = ivp->iv_state;
352 * Copy data to user buffer and
353 * update buffer controls
355 err = copyout((caddr_t)&aivr, cp, sizeof(aivr));
359 space -= sizeof(aivr);
366 * Update buffer pointer/count
368 aip->air_buf_addr = cp;
369 aip->air_buf_len = space;
381 * Get Connection's Application/Owner Name
384 * tok ipatm connection token (pointer to ipvcc)
387 * addr pointer to string containing our name