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/sbin/atm/atm/atm_inet.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $
27 * @(#) $DragonFly: src/sbin/atm/atm/atm_inet.c,v 1.4 2006/10/16 00:15:35 pavalos Exp $
31 * User configuration and display program
32 * --------------------------------------
38 #include <sys/param.h>
39 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <netatm/port.h>
43 #include <netatm/atm.h>
44 #include <netatm/atm_if.h>
45 #include <netatm/atm_sap.h>
46 #include <netatm/atm_sys.h>
47 #include <netatm/atm_ioctl.h>
58 * Process add command for a TCP/IP PVC
61 * atm add pvc <intf> <vpi> <vci> <aal> <encaps> IP <netif>
65 * argc number of remaining arguments to command
66 * argv pointer to remaining argument strings
67 * cmdp pointer to command description
68 * app pointer to AIOCAPVC structure
69 * intp pointer to air_int_rsp structure with information
70 * about the physical interface that is the PVC is for.
77 ip_pvcadd(int argc, char **argv, const struct cmd *cmdp, struct atmaddreq *app,
78 struct air_int_rsp *intp)
83 unsigned int i, netif_pref_len;
89 strcpy(nhelp, cmdp->help);
90 cp = strstr(nhelp, "<netif>");
92 strcpy(cp, "ip {dyn|<dst>}");
93 fprintf(stderr, "%s: Invalid number of arguments:\n",
95 fprintf(stderr, "\tformat is: %s%s %s\n",
96 prefix, cmdp->name, nhelp);
101 * Validate and set network interface
103 UM_ZERO(app->aar_pvc_intf, sizeof(app->aar_pvc_intf));
104 netif_pref_len = strlen(intp->anp_nif_pref);
105 cp = &argv[0][netif_pref_len];
107 for (i=0; i<strlen(cp); i++) {
108 if (cp[i] < '0' || cp[i] > '9') {
113 if ((strlen(argv[0]) > sizeof(app->aar_pvc_intf) - 1) ||
115 fprintf(stderr, "%s: Illegal network interface name\n",
119 if (strncasecmp(intp->anp_nif_pref, argv[0], netif_pref_len) ||
120 strlen (argv[0]) <= netif_pref_len ||
121 netif_no > intp->anp_nif_cnt - 1) {
122 fprintf(stderr, "%s: network interface %s is not associated with interface %s\n",
128 strcpy(app->aar_pvc_intf, argv[0]);
132 * Set PVC destination address
134 UM_ZERO(&app->aar_pvc_dst, sizeof(struct sockaddr));
135 if (strcasecmp(argv[0], "dynamic") == 0 ||
136 strcasecmp(argv[0], "dyn") == 0) {
139 * Destination is dynamically determined
141 app->aar_pvc_flags |= PVC_DYN;
145 * Get destination IP address
147 struct sockaddr_in *sin;
149 sin = (struct sockaddr_in *) &app->aar_pvc_dst;
150 sin->sin_addr.s_addr =
151 get_ip_addr(argv[0])->sin_addr.s_addr;