remove ns_netof (non-portable), add zero and broadcast ns nets to compare to.
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Tue, 4 Feb 1986 09:32:03 +0000 (01:32 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Tue, 4 Feb 1986 09:32:03 +0000 (01:32 -0800)
SCCS-vsn: sys/netns/ns.h 6.9
SCCS-vsn: sys/netns/ns.c 6.7
SCCS-vsn: sys/netns/idp_usrreq.c 6.12
SCCS-vsn: sys/netns/ns_input.c 6.12

usr/src/sys/netns/idp_usrreq.c
usr/src/sys/netns/ns.c
usr/src/sys/netns/ns.h
usr/src/sys/netns/ns_input.c

index eb6d78e..16a69b6 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- * Copyright (c) 1984,1985 Regents of the University of California.
+ * Copyright (c) 1984, 1985 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *      @(#)idp_usrreq.c       6.11 (Berkeley) %G%
+ *      @(#)idp_usrreq.c       6.12 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -49,7 +49,7 @@ idp_input(m, nsp, ifp)
         * Stuff source address and datagram in user buffer.
         */
        idp_ns.sns_addr = idp->idp_sna;
         * Stuff source address and datagram in user buffer.
         */
        idp_ns.sns_addr = idp->idp_sna;
-       if (ns_netof(idp->idp_sna)==0 && ifp) {
+       if (ns_neteqnn(idp->idp_sna.x_net, ns_zeronet) && ifp) {
                register struct ifaddr *ia;
 
                for (ia = ifp->if_addrlist; ia; ia = ia->ifa_next) {
                register struct ifaddr *ia;
 
                for (ia = ifp->if_addrlist; ia; ia = ia->ifa_next) {
@@ -162,7 +162,9 @@ idp_output(nsp, m0)
                        m_freem(m0);
                        return (ENOBUFS);
                }
                        m_freem(m0);
                        return (ENOBUFS);
                }
-               m->m_off = MMAXOFF - sizeof (struct idp);
+               m->m_off = MMAXOFF - sizeof (struct idp) - 2;
+                               /* adjust to start on longword bdry
+                                  for NSIP on gould */
                m->m_len = sizeof (struct idp);
                m->m_next = m0;
                idp = mtod(m, struct idp *);
                m->m_len = sizeof (struct idp);
                m->m_next = m0;
                idp = mtod(m, struct idp *);
index bee0dc4..3c93f5a 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ns.c        6.6 (Berkeley) %G%
+ *     @(#)ns.c        6.7 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -34,8 +34,13 @@ ns_hash(sns, hp)
 {
        register long hash = 0;
        register u_short *s =  sns->sns_addr.x_host.s_host;
 {
        register long hash = 0;
        register u_short *s =  sns->sns_addr.x_host.s_host;
+       union {
+               union ns_net    net_e;
+               long            long_e;
+       } net;
 
 
-       hp->afh_nethash = ns_netof(sns->sns_addr);
+       net.net_e = sns->sns_addr.x_net;
+       hp->afh_nethash = net.long_e;
        hash = *s++; hash <<= 8; hash += *s++; hash <<= 8; hash += *s;
        hp->afh_hosthash =  hash;
 }
        hash = *s++; hash <<= 8; hash += *s++; hash <<= 8; hash += *s;
        hp->afh_hosthash =  hash;
 }
@@ -45,7 +50,7 @@ ns_netmatch(sns1, sns2)
        struct sockaddr_ns *sns1, *sns2;
 {
 
        struct sockaddr_ns *sns1, *sns2;
 {
 
-       return (ns_netof(sns1->sns_addr) == ns_netof(sns2->sns_addr));
+       return (ns_neteq(sns1->sns_addr, sns2->sns_addr));
 }
 
 /*
 }
 
 /*
@@ -265,8 +270,7 @@ ns_iaonnetof(dst)
        register struct ns_addr *compare;
        register struct ifnet *ifp;
        struct ns_ifaddr *ia_maybe = 0;
        register struct ns_addr *compare;
        register struct ifnet *ifp;
        struct ns_ifaddr *ia_maybe = 0;
-       long net = ns_netof(*dst);
-       static struct ns_addr laddr;
+       union ns_net net = dst->x_net;
 
        for (ia = ns_ifaddr; ia; ia = ia->ia_next) {
                if (ifp = ia->ia_ifp) {
 
        for (ia = ns_ifaddr; ia; ia = ia->ia_next) {
                if (ifp = ia->ia_ifp) {
@@ -274,12 +278,10 @@ ns_iaonnetof(dst)
                                compare = &satons_addr(ia->ia_dstaddr);
                                if (ns_hosteq(*dst, *compare))
                                        return (ia);
                                compare = &satons_addr(ia->ia_dstaddr);
                                if (ns_hosteq(*dst, *compare))
                                        return (ia);
-                               laddr.x_net = ia->ia_net;
-                               if (ns_netof(laddr) == net)
+                               if (ns_neteqnn(net, ia->ia_net))
                                        ia_maybe = ia;
                        } else {
                                        ia_maybe = ia;
                        } else {
-                               laddr.x_net = ia->ia_net;
-                               if (ns_netof(laddr) == net)
+                               if (ns_neteqnn(net, ia->ia_net))
                                        return (ia);
                        }
                }
                                        return (ia);
                        }
                }
index f2907ca..fcbe351 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- * Copyright (c) 1982 Regents of the University of California.
+ * Copyright (c) 1984, 1985, 1986 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ns.h        6.8 (Berkeley) %G%
+ *     @(#)ns.h        6.9 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -85,8 +85,12 @@ struct sockaddr_ns {
 };
 #define sns_port sns_addr.x_port
 
 };
 #define sns_port sns_addr.x_port
 
-#define ns_netof(a) (*(long *) & ((a).x_net))
-#define ns_neteq(a,b) (ns_netof(a) == ns_netof(b))
+#ifdef vax
+#define ns_netof(a) (*(long *) & ((a).x_net)) /* XXX - not needed */
+#endif
+#define ns_neteqnn(a,b) (((a).s_net[0]==(b).s_net[0]) && \
+                                       ((a).s_net[0]==(b).s_net[0]))
+#define ns_neteq(a,b) ns_neteqnn((a).x_net, (b).x_net)
 #define satons_addr(sa)        (((struct sockaddr_ns *)&(sa))->sns_addr)
 #define ns_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \
        (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2])
 #define satons_addr(sa)        (((struct sockaddr_ns *)&(sa))->sns_addr)
 #define ns_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \
        (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2])
@@ -111,5 +115,7 @@ extern struct domain nsdomain;
 extern union ns_host ns_thishost;
 extern union ns_host ns_zerohost;
 extern union ns_host ns_broadhost;
 extern union ns_host ns_thishost;
 extern union ns_host ns_zerohost;
 extern union ns_host ns_broadhost;
+extern union ns_net ns_zeronet;
+extern union ns_net ns_broadnet;
 u_short ns_cksum();
 #endif
 u_short ns_cksum();
 #endif
index 19bf19e..fd3c970 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- * Copyright (c) 1982 Regents of the University of California.
+ * Copyright (c) 1984, 1985 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ns_input.c  6.11 (Berkeley) %G%
+ *     @(#)ns_input.c  6.12 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 union ns_host  ns_thishost;
 union ns_host  ns_zerohost;
 union ns_host  ns_broadhost;
 union ns_host  ns_thishost;
 union ns_host  ns_zerohost;
 union ns_host  ns_broadhost;
+union ns_net   ns_zeronet;
+union ns_net   ns_broadnet;
 
 
-static char allones[] = {-1, -1, -1, -1, -1, -1};
+static u_short allones[] = {-1, -1, -1};
 
 struct nspcb nspcb;
 struct nspcb nsrawpcb;
 
 struct nspcb nspcb;
 struct nspcb nsrawpcb;
@@ -51,6 +53,7 @@ ns_init()
        extern struct timeval time;
 
        ns_broadhost = * (union ns_host *) allones;
        extern struct timeval time;
 
        ns_broadhost = * (union ns_host *) allones;
+       ns_broadnet = * (union ns_net *) allones;
        nspcb.nsp_next = nspcb.nsp_prev = &nspcb;
        nsrawpcb.nsp_next = nsrawpcb.nsp_prev = &nsrawpcb;
        nsintrq.ifq_maxlen = nsqmaxlen;
        nspcb.nsp_next = nspcb.nsp_prev = &nspcb;
        nsrawpcb.nsp_next = nsrawpcb.nsp_prev = &nsrawpcb;
        nsintrq.ifq_maxlen = nsqmaxlen;
@@ -148,9 +151,10 @@ next:
         * Is this a directed broadcast?
         */
        if (ns_hosteqnh(ns_broadhost,idp->idp_dna.x_host)) {
         * Is this a directed broadcast?
         */
        if (ns_hosteqnh(ns_broadhost,idp->idp_dna.x_host)) {
-               if ((ns_netof(idp->idp_dna)!=ns_netof(idp->idp_sna)) &&
-                  (ns_netof(idp->idp_dna)!=-1) && (ns_netof(idp->idp_sna)!=0)
-                  && (ns_netof(idp->idp_dna)!=0)) {
+               if ((!ns_neteq(idp->idp_dna, idp->idp_sna)) &&
+                   (!ns_neteqnn(idp->idp_dna.x_net, ns_broadnet)) &&
+                   (!ns_neteqnn(idp->idp_sna.x_net, ns_zeronet)) &&
+                   (!ns_neteqnn(idp->idp_dna.x_net, ns_zeronet)) ) {
                        /*
                         * Look to see if I need to eat this packet.
                         * Algorithm is to forward all young packets
                        /*
                         * Look to see if I need to eat this packet.
                         * Algorithm is to forward all young packets