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 $
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 __RCSID("@(#) $FreeBSD: src/sys/netatm/ipatm/ipatm_usrreq.c,v 1.5.2.1 2003/02/15 09:25:13 phk Exp $");
49 * Process IP PF_ATM ioctls
54 * code PF_ATM sub-operation code
55 * data pointer to code specific parameter data area
56 * arg1 pointer to code specific argument
60 * errno error processing request - reason indicated
64 ipatm_ioctl(code, data, arg1)
69 struct atmaddreq *aap;
70 struct atmdelreq *adp;
71 struct atminfreq *aip;
72 struct air_ip_vcc_rsp aivr;
89 aap = (struct atmaddreq *)data;
92 * Find the IP network interface
94 if ((nip = atm_nifname(aap->aar_pvc_intf)) == NULL) {
99 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
100 if (inp->inf_nif == nip)
109 * Validate PVC params
111 if (aap->aar_pvc_aal == ATM_AAL5) {
112 if ((aap->aar_pvc_encaps != ATM_ENC_LLC) &&
113 (aap->aar_pvc_encaps != ATM_ENC_NULL)) {
117 } else if (aap->aar_pvc_aal == ATM_AAL3_4) {
118 if (aap->aar_pvc_encaps != ATM_ENC_NULL) {
127 if (aap->aar_pvc_flags & PVC_DYN) {
129 * For dynamic PVC destination addressing, the
130 * network interface must have support for this
132 if ((inp->inf_serv == NULL) ||
133 (inp->inf_serv->is_arp_pvcopen == NULL)) {
138 u_long dst = ((struct sockaddr_in *)&aap->aar_pvc_dst)
141 if (dst == INADDR_ANY) {
148 * Build connection request
151 pv.ipp_vpi = aap->aar_pvc_vpi;
152 pv.ipp_vci = aap->aar_pvc_vci;
153 pv.ipp_encaps = aap->aar_pvc_encaps;
154 pv.ipp_aal = aap->aar_pvc_aal;
155 if (aap->aar_pvc_flags & PVC_DYN) {
156 pv.ipp_dst.sin_addr.s_addr = INADDR_ANY;
158 pv.ipp_dst = *(struct sockaddr_in *)&aap->aar_pvc_dst;
163 err = ipatm_openpvc(&pv, &ivp);
170 aap = (struct atmaddreq *)data;
173 * Validate IP address
175 if (aap->aar_arp_dst.sa_family != AF_INET) {
179 ip = SATOSIN(&aap->aar_arp_dst)->sin_addr;
181 if (aap->aar_arp_intf[0] == '\0') {
183 * Find the IP network interface associated with
184 * the supplied IP address
186 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
187 if (ipatm_chknif(ip, inp) == 0)
196 * Find the specified IP network interface
198 if ((nip = atm_nifname(aap->aar_arp_intf)) == NULL) {
202 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
203 if (inp->inf_nif == nip)
212 if ((ip.s_addr == INADDR_ANY) ||
213 #if (defined(BSD) && (BSD >= 199306))
214 in_broadcast(ip, &inp->inf_nif->nif_if) ||
218 IN_MULTICAST(ntohl(ip.s_addr))) {
224 * Notify the responsible ARP service
226 * XXX: if there is one. No idea how this happens, but at
227 * least don't panic on a NULL pointer if it does.
229 if (inp->inf_serv == NULL) {
233 err = (*inp->inf_serv->is_ioctl)(code, data, inp->inf_isintf);
238 * Delete an ARP mapping
240 adp = (struct atmdelreq *)data;
243 * Validate IP address
245 if (adp->adr_arp_dst.sa_family != AF_INET) {
249 ip = SATOSIN(&adp->adr_arp_dst)->sin_addr;
251 if (adp->adr_arp_intf[0] == '\0') {
253 * Find the IP network interface associated with
254 * the supplied IP address
256 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
257 if (ipatm_chknif(ip, inp) == 0)
266 * Find the specified IP network interface
268 if ((nip = atm_nifname(adp->adr_arp_intf)) == NULL) {
272 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
273 if (inp->inf_nif == nip)
282 if ((ip.s_addr == INADDR_ANY) ||
283 #if (defined(BSD) && (BSD >= 199306))
284 in_broadcast(ip, &inp->inf_nif->nif_if) ||
288 IN_MULTICAST(ntohl(ip.s_addr))) {
294 * Notify the responsible ARP service
296 err = (*inp->inf_serv->is_ioctl)(code, data, inp->inf_isintf);
301 * Get IP VCC information
303 aip = (struct atminfreq *)data;
305 if (aip->air_ip_addr.sa_family != AF_INET)
307 ip = SATOSIN(&aip->air_ip_addr)->sin_addr;
309 cp = aip->air_buf_addr;
310 space = aip->air_buf_len;
313 * Loop through all our interfaces
315 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
319 for (ivp = Q_HEAD(inp->inf_vcq, struct ipvcc); ivp;
320 ivp = Q_NEXT(ivp, struct ipvcc, iv_elem)) {
322 if ((ip.s_addr != INADDR_ANY) &&
323 (ip.s_addr != ivp->iv_dst.s_addr))
327 * Make sure there's room in user buffer
329 if (space < sizeof(aivr)) {
335 * Fill in info to be returned
337 KM_ZERO((caddr_t)&aivr, sizeof(aivr));
338 SATOSIN(&aivr.aip_dst_addr)->sin_family =
340 SATOSIN(&aivr.aip_dst_addr)->sin_addr.s_addr =
342 (void) snprintf(aivr.aip_intf,
343 sizeof(aivr.aip_intf), "%s%d",
344 inp->inf_nif->nif_if.if_name,
345 inp->inf_nif->nif_if.if_unit);
346 if ((ivp->iv_conn) &&
347 (ivp->iv_conn->co_connvc) &&
348 (vcp = ivp->iv_conn->co_connvc->cvc_vcc)) {
349 aivr.aip_vpi = vcp->vc_vpi;
350 aivr.aip_vci = vcp->vc_vci;
351 aivr.aip_sig_proto = vcp->vc_proto;
353 aivr.aip_flags = ivp->iv_flags;
354 aivr.aip_state = ivp->iv_state;
357 * Copy data to user buffer and
358 * update buffer controls
360 err = copyout((caddr_t)&aivr, cp, sizeof(aivr));
364 space -= sizeof(aivr);
371 * Update buffer pointer/count
373 aip->air_buf_addr = cp;
374 aip->air_buf_len = space;
386 * Get Connection's Application/Owner Name
389 * tok ipatm connection token (pointer to ipvcc)
392 * addr pointer to string containing our name