sundry patches to raw code after rewrite
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 12 Apr 1982 06:51:44 +0000 (22:51 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 12 Apr 1982 06:51:44 +0000 (22:51 -0800)
SCCS-vsn: sys/net/raw_cb.c 4.8
SCCS-vsn: sys/deprecated/netimp/raw_imp.c 4.11
SCCS-vsn: sys/netinet/raw_ip.c 4.11
SCCS-vsn: sys/net/raw_usrreq.c 4.14

usr/src/sys/deprecated/netimp/raw_imp.c
usr/src/sys/net/raw_cb.c
usr/src/sys/net/raw_usrreq.c
usr/src/sys/netinet/raw_ip.c

index 61082ba..03f78b9 100644 (file)
@@ -1,4 +1,4 @@
-/*     raw_imp.c       4.10    82/04/10        */
+/*     raw_imp.c       4.11    82/04/11        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
@@ -74,11 +74,15 @@ COUNT(RIMP_OUTPUT);
                len += n->m_len;
        ip->il_length = htons((u_short)(len << 3));
        sin = (struct sockaddr_in *)&rp->rcb_faddr;
                len += n->m_len;
        ip->il_length = htons((u_short)(len << 3));
        sin = (struct sockaddr_in *)&rp->rcb_faddr;
+#ifdef notdef
        ip->il_network = sin->sin_addr.s_net;
        ip->il_network = sin->sin_addr.s_net;
+#else
+       ip->il_network = 0;
+#endif
        ip->il_host = sin->sin_addr.s_host;
        ip->il_imp = sin->sin_addr.s_imp;
        /* no routing here */
        ip->il_host = sin->sin_addr.s_host;
        ip->il_imp = sin->sin_addr.s_imp;
        /* no routing here */
-       ifp = if_ifonnetof(ip->il_network);
+       ifp = if_ifonnetof(sin->sin_addr.s_net);
        if (ifp)
                return (impoutput(ifp, m, (struct sockaddr *)sin));
        error = ENETUNREACH;
        if (ifp)
                return (impoutput(ifp, m, (struct sockaddr *)sin));
        error = ENETUNREACH;
index c89bc4c..76e8563 100644 (file)
@@ -1,4 +1,4 @@
-/*     raw_cb.c        4.7     82/04/10        */
+/*     raw_cb.c        4.8     82/04/11        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -87,9 +87,10 @@ COUNT(RAW_ATTACH);
        insque(rp, &rawcb);
        so->so_pcb = (caddr_t)rp;
        rp->rcb_pcb = 0;
        insque(rp, &rawcb);
        so->so_pcb = (caddr_t)rp;
        rp->rcb_pcb = 0;
-       if (addr)
+       if (addr) {
                bcopy((caddr_t)addr, (caddr_t)&rp->rcb_laddr, sizeof(*addr));
                bcopy((caddr_t)addr, (caddr_t)&rp->rcb_laddr, sizeof(*addr));
-       rp->rcb_flags |= RAW_LADDR;
+               rp->rcb_flags |= RAW_LADDR;
+       }
        return (0);
 bad2:
        sbrelease(&so->so_snd);
        return (0);
 bad2:
        sbrelease(&so->so_snd);
index 732e6ce..37bf18d 100644 (file)
@@ -1,4 +1,4 @@
-/*     raw_usrreq.c    4.13    82/04/10        */
+/*     raw_usrreq.c    4.14    82/04/11        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
@@ -28,10 +28,10 @@ COUNT(RAW_INIT);
 /*
  * Raw protocol interface.
  */
 /*
  * Raw protocol interface.
  */
-raw_input(m0, proto, dst, src)
+raw_input(m0, proto, src, dst)
        struct mbuf *m0;
        struct sockproto *proto;
        struct mbuf *m0;
        struct sockproto *proto;
-       struct sockaddr *dst, *src;
+       struct sockaddr *src, *dst;
 {
        register struct mbuf *m;
        struct raw_header *rh;
 {
        register struct mbuf *m;
        struct raw_header *rh;
@@ -80,9 +80,8 @@ rawintr()
        int s;
        struct mbuf *m;
        register struct rawcb *rp;
        int s;
        struct mbuf *m;
        register struct rawcb *rp;
-       register struct sockaddr *laddr;
        register struct protosw *lproto;
        register struct protosw *lproto;
-       struct raw_header *rh;
+       register struct raw_header *rh;
        struct socket *last;
 
 COUNT(RAWINTR);
        struct socket *last;
 
 COUNT(RAWINTR);
@@ -93,13 +92,6 @@ next:
        if (m == 0)
                return;
        rh = mtod(m, struct raw_header *);
        if (m == 0)
                return;
        rh = mtod(m, struct raw_header *);
-
-       /*
-        * Find the appropriate socket(s) in which to place this
-        * packet.  This is done by matching the protocol and
-        * address information prepended by raw_input against
-        * the info stored in the control block structures.
-        */
        last = 0;
        for (rp = rawcb.rcb_next; rp != &rawcb; rp = rp->rcb_next) {
                lproto = rp->rcb_socket->so_proto;
        last = 0;
        for (rp = rawcb.rcb_next; rp != &rawcb; rp = rp->rcb_next) {
                lproto = rp->rcb_socket->so_proto;
@@ -108,30 +100,21 @@ next:
                if (lproto->pr_protocol &&
                    lproto->pr_protocol != rh->raw_proto.sp_protocol)
                        continue;
                if (lproto->pr_protocol &&
                    lproto->pr_protocol != rh->raw_proto.sp_protocol)
                        continue;
-               laddr = &rp->rcb_laddr;
-               if (laddr->sa_family &&
-                   laddr->sa_family != rh->raw_dst.sa_family)
-                       continue;
                /*
                 * We assume the lower level routines have
                 * placed the address in a canonical format
                 * suitable for a structure comparison.
                 */
                /*
                 * We assume the lower level routines have
                 * placed the address in a canonical format
                 * suitable for a structure comparison.
                 */
+#define equal(a1, a2) \
+       (bcmp((caddr_t)&(a1), (caddr_t)&(a2), sizeof (struct sockaddr)) == 0)
                if ((rp->rcb_flags & RAW_LADDR) &&
                if ((rp->rcb_flags & RAW_LADDR) &&
-                   bcmp(laddr->sa_data, rh->raw_dst.sa_data, 14) != 0)
+                   !equal(rp->rcb_laddr, rh->raw_dst))
                        continue;
                if ((rp->rcb_flags & RAW_FADDR) &&
                        continue;
                if ((rp->rcb_flags & RAW_FADDR) &&
-                   bcmp(rp->rcb_faddr.sa_data, rh->raw_src.sa_data, 14) != 0)
+                   !equal(rp->rcb_faddr, rh->raw_src))
                        continue;
                        continue;
-               /*
-                * To avoid extraneous packet copies, we keep
-                * track of the last socket the packet should be
-                * placed in, and make copies only after finding a
-                * socket which "collides".
-                */
                if (last) {
                        struct mbuf *n;
                if (last) {
                        struct mbuf *n;
-
                        if (n = m_copy(m->m_next, 0, (int)M_COPYALL))
                                goto nospace;
                        if (sbappendaddr(&last->so_rcv, &rh->raw_src, n)==0) {
                        if (n = m_copy(m->m_next, 0, (int)M_COPYALL))
                                goto nospace;
                        if (sbappendaddr(&last->so_rcv, &rh->raw_src, n)==0) {
index d33e352..7e30f17 100644 (file)
@@ -1,4 +1,4 @@
-/*     raw_ip.c        4.10    82/04/10        */
+/*     raw_ip.c        4.11    82/04/11        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
@@ -34,8 +34,8 @@ COUNT(RIP_INPUT);
        ripproto.sp_protocol = ip->ip_p;
        ripdst.sin_addr = ip->ip_dst;
        ripsrc.sin_addr = ip->ip_src;
        ripproto.sp_protocol = ip->ip_p;
        ripdst.sin_addr = ip->ip_dst;
        ripsrc.sin_addr = ip->ip_src;
-       raw_input(m, &ripproto, (struct sockaddr *)&ripdst,
-         (struct sockaddr *)&ripsrc);
+       raw_input(m, &ripproto, (struct sockaddr *)&ripsrc,
+         (struct sockaddr *)&ripdst);
 }
 
 /*
 }
 
 /*