386BSD 0.1 development
[unix-history] / usr / src / sbin / ifconfig / ifconfig.c
index dbd7dcc..b14fb46 100644 (file)
@@ -2,19 +2,33 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -24,16 +38,18 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)ifconfig.c 4.30 (Berkeley) 6/14/90";
+static char sccsid[] = "@(#)ifconfig.c 5.1 (Berkeley) 2/28/91";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 
 #include <net/if.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 
 #include <net/if.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 
 
+#ifdef notdef
 #define        NSIP
 #include <netns/ns.h>
 #include <netns/ns_if.h>
 #define        NSIP
 #include <netns/ns.h>
 #include <netns/ns_if.h>
@@ -41,18 +57,23 @@ static char sccsid[] = "@(#)ifconfig.c      4.30 (Berkeley) 6/14/90";
 #define EON
 #include <netiso/iso.h>
 #include <netiso/iso_var.h>
 #define EON
 #include <netiso/iso.h>
 #include <netiso/iso_var.h>
+#endif
+#include <netdb.h>
 #include <sys/protosw.h>
 
 #include <sys/protosw.h>
 
+#include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
-#include <netdb.h>
+#include <stdlib.h>
+#include <string.h>
 
 
-extern int errno;
 struct ifreq           ifr, ridreq;
 struct ifaliasreq      addreq;
 struct ifreq           ifr, ridreq;
 struct ifaliasreq      addreq;
+#ifdef EON
 struct iso_ifreq       iso_ridreq;
 struct iso_aliasreq    iso_addreq;
 struct iso_ifreq       iso_ridreq;
 struct iso_aliasreq    iso_addreq;
+#endif
 struct sockaddr_in     netmask;
 
 char   name[30];
 struct sockaddr_in     netmask;
 
 char   name[30];
@@ -110,8 +131,12 @@ struct     cmd {
  * principally by James O'Toole and Chris Torek.
  */
 int    in_status(), in_getaddr();
  * principally by James O'Toole and Chris Torek.
  */
 int    in_status(), in_getaddr();
+#ifdef NSIP
 int    xns_status(), xns_getaddr();
 int    xns_status(), xns_getaddr();
+#endif
+#ifdef EON
 int    iso_status(), iso_getaddr();
 int    iso_status(), iso_getaddr();
+#endif
 
 /* Known address families */
 struct afswtch {
 
 /* Known address families */
 struct afswtch {
@@ -127,10 +152,14 @@ struct afswtch {
 #define C(x) ((caddr_t) &x)
        { "inet", AF_INET, in_status, in_getaddr,
             SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
 #define C(x) ((caddr_t) &x)
        { "inet", AF_INET, in_status, in_getaddr,
             SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
+#ifdef NSIP
        { "ns", AF_NS, xns_status, xns_getaddr,
             SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
        { "ns", AF_NS, xns_status, xns_getaddr,
             SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
+#endif
+#ifdef EON
        { "iso", AF_ISO, iso_status, iso_getaddr,
             SIOCDIFADDR_ISO, SIOCAIFADDR_ISO, C(iso_ridreq), C(iso_addreq) },
        { "iso", AF_ISO, iso_status, iso_getaddr,
             SIOCDIFADDR_ISO, SIOCAIFADDR_ISO, C(iso_ridreq), C(iso_addreq) },
+#endif
        { 0,    0,          0,          0 }
 };
 
        { 0,    0,          0,          0 }
 };
 
@@ -203,6 +232,7 @@ main(argc, argv)
        }
        if (af == AF_ISO)
                adjust_nsellength();
        }
        if (af == AF_ISO)
                adjust_nsellength();
+#ifdef NSIP
        if (setipdst && af==AF_NS) {
                struct nsip_req rq;
                int size = sizeof(rq);
        if (setipdst && af==AF_NS) {
                struct nsip_req rq;
                int size = sizeof(rq);
@@ -213,6 +243,7 @@ main(argc, argv)
                if (setsockopt(s, 0, SO_NSIP_ROUTE, &rq, size) < 0)
                        Perror("Encapsulation Routing");
        }
                if (setsockopt(s, 0, SO_NSIP_ROUTE, &rq, size) < 0)
                        Perror("Encapsulation Routing");
        }
+#endif
        if (clearaddr) {
                int ret;
                strncpy(rafp->af_ridreq, name, sizeof ifr.ifr_name);
        if (clearaddr) {
                int ret;
                strncpy(rafp->af_ridreq, name, sizeof ifr.ifr_name);
@@ -329,7 +360,9 @@ setifmetric(val)
 setsnpaoffset(val)
        char *val;
 {
 setsnpaoffset(val)
        char *val;
 {
+#ifdef EON
        iso_addreq.ifra_snpaoffset = atoi(val);
        iso_addreq.ifra_snpaoffset = atoi(val);
+#endif
 }
 
 #define        IFFBITS \
 }
 
 #define        IFFBITS \
@@ -410,6 +443,7 @@ in_status(force)
        putchar('\n');
 }
 
        putchar('\n');
 }
 
+#ifdef NSIP
 
 xns_status(force)
        int force;
 
 xns_status(force)
        int force;
@@ -449,6 +483,8 @@ xns_status(force)
        putchar('\n');
 }
 
        putchar('\n');
 }
 
+#endif
+#ifdef EON
 iso_status(force)
        int force;
 {
 iso_status(force)
        int force;
 {
@@ -497,6 +533,7 @@ iso_status(force)
        }
        putchar('\n');
 }
        }
        putchar('\n');
 }
+#endif
 
 Perror(cmd)
        char *cmd;
 
 Perror(cmd)
        char *cmd;
@@ -583,6 +620,7 @@ printb(s, v, bits)
                putchar('>');
        }
 }
                putchar('>');
        }
 }
+#ifdef NSIP
 
 #define SNS(x) ((struct sockaddr_ns *) &(x))
 struct sockaddr_ns *snstab[] = {
 
 #define SNS(x) ((struct sockaddr_ns *) &(x))
 struct sockaddr_ns *snstab[] = {
@@ -602,6 +640,8 @@ char *addr;
                printf("Attempt to set XNS netmask will be ineffectual\n");
 }
 
                printf("Attempt to set XNS netmask will be ineffectual\n");
 }
 
+#endif
+#ifdef EON
 #define SISO(x) ((struct sockaddr_iso *) &(x))
 struct sockaddr_iso *sisotab[] = {
 SISO(iso_ridreq.ifr_Addr), SISO(iso_addreq.ifra_addr),
 #define SISO(x) ((struct sockaddr_iso *) &(x))
 struct sockaddr_iso *sisotab[] = {
 SISO(iso_ridreq.ifr_Addr), SISO(iso_addreq.ifra_addr),
@@ -622,6 +662,7 @@ char *addr;
                siso->siso_family = AF_ISO;
        }
 }
                siso->siso_family = AF_ISO;
        }
 }
+#endif
 
 setnsellength(val)
        char *val;
 
 setnsellength(val)
        char *val;
@@ -637,6 +678,7 @@ setnsellength(val)
        }
 }
 
        }
 }
 
+#ifdef notdef
 fixnsel(s)
 register struct sockaddr_iso *s;
 {
 fixnsel(s)
 register struct sockaddr_iso *s;
 {
@@ -644,10 +686,13 @@ register struct sockaddr_iso *s;
                return;
        s->siso_tlen = nsellength;
 }
                return;
        s->siso_tlen = nsellength;
 }
+#endif
 
 adjust_nsellength()
 {
 
 adjust_nsellength()
 {
+#ifdef notdef
        fixnsel(sisotab[RIDADDR]);
        fixnsel(sisotab[ADDR]);
        fixnsel(sisotab[DSTADDR]);
        fixnsel(sisotab[RIDADDR]);
        fixnsel(sisotab[ADDR]);
        fixnsel(sisotab[DSTADDR]);
+#endif
 }
 }