mbuf and big sockaddr changes
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Tue, 22 Aug 1989 05:07:40 +0000 (21:07 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Tue, 22 Aug 1989 05:07:40 +0000 (21:07 -0800)
SCCS-vsn: sbin/XNSrouted/input.c 5.8
SCCS-vsn: sbin/XNSrouted/main.c 5.8
SCCS-vsn: sbin/XNSrouted/startup.c 5.8
SCCS-vsn: sbin/XNSrouted/af.c 5.9

usr/src/sbin/XNSrouted/af.c
usr/src/sbin/XNSrouted/input.c
usr/src/sbin/XNSrouted/main.c
usr/src/sbin/XNSrouted/startup.c

index 4cef5f2..e2a30c6 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)af.c       5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)af.c       5.9 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "defs.h"
 #endif /* not lint */
 
 #include "defs.h"
@@ -45,7 +45,7 @@ int   xnnet_hash(), xnnet_netmatch(), xnnet_output(),
 struct afswitch afswitch[AF_MAX] =
        { NIL, NIL, NIL, NIL, NIL, NIL, XNSNET, NIL, NIL, NIL, NIL };
 
 struct afswitch afswitch[AF_MAX] =
        { NIL, NIL, NIL, NIL, NIL, NIL, XNSNET, NIL, NIL, NIL, NIL };
 
-struct sockaddr_ns xnnet_default = { AF_NS };
+struct sockaddr_ns xnnet_default = { sizeof(struct sockaddr_ns), AF_NS };
 
 union ns_net ns_anynet;
 union ns_net ns_zeronet;
 
 union ns_net ns_anynet;
 union ns_net ns_zeronet;
index 6f846be..77bd3bf 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)input.c    5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)input.c    5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -36,6 +36,7 @@ union ns_net net;
        
        bzero(&sxn, sizeof (struct sockaddr_ns));
        sxn.sns_family = AF_NS;
        
        bzero(&sxn, sizeof (struct sockaddr_ns));
        sxn.sns_family = AF_NS;
+       sxn.sns_len = sizeof (sxn);
        sxn.sns_addr.x_net = net;
        sxn.sns_addr.x_host = *(union ns_host *)ether_broadcast_addr;
        return( (struct sockaddr *)&sxn);
        sxn.sns_addr.x_net = net;
        sxn.sns_addr.x_host = *(union ns_host *)ether_broadcast_addr;
        return( (struct sockaddr *)&sxn);
index 799fa81..488b098 100644 (file)
@@ -25,7 +25,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -119,6 +119,7 @@ main(argc, argv)
 
        ns_anynet.s_net[0] = -1; ns_anynet.s_net[1] = -1;
        addr.sns_family = AF_NS;
 
        ns_anynet.s_net[0] = -1; ns_anynet.s_net[1] = -1;
        addr.sns_family = AF_NS;
+       addr.sns_len = sizeof(addr);
        addr.sns_port = htons(IDPPORT_RIF);
        s = getsocket(SOCK_DGRAM, 0, &addr);
        if (s < 0)
        addr.sns_port = htons(IDPPORT_RIF);
        s = getsocket(SOCK_DGRAM, 0, &addr);
        if (s < 0)
index 109cd67..2792428 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)startup.c  5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)startup.c  5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -48,9 +48,9 @@ char ether_broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 ifinit()
 {
        struct interface ifs, *ifp;
 ifinit()
 {
        struct interface ifs, *ifp;
-       int s, n;
+       int s;
         struct ifconf ifc;
         struct ifconf ifc;
-       char buf[(sizeof (struct ifreq ) * 20)];
+       char buf[BUFSIZ], *cp, *cplim;
         struct ifreq ifreq, *ifr;
        u_long i;
 
         struct ifreq ifreq, *ifr;
        u_long i;
 
@@ -67,7 +67,15 @@ ifinit()
         }
         ifr = ifc.ifc_req;
        lookforinterfaces = 0;
         }
         ifr = ifc.ifc_req;
        lookforinterfaces = 0;
-        for (n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++) {
+#ifdef RTM_ADD
+#define max(a, b) (a > b ? a : b)
+#define size(p)        max((p).sa_len, sizeof(p))
+#else
+#define size(p) (sizeof (p))
+#endif
+       cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
+       for (cp = buf; cp < cplim;
+                       cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) {
                bzero((char *)&ifs, sizeof(ifs));
                ifs.int_addr = ifr->ifr_addr;
                ifreq = *ifr;
                bzero((char *)&ifs, sizeof(ifs));
                ifs.int_addr = ifr->ifr_addr;
                ifreq = *ifr;