this version supports TCP between two workstations on the same ethernet
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Thu, 26 Nov 1992 12:09:39 +0000 (04:09 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Thu, 26 Nov 1992 12:09:39 +0000 (04:09 -0800)
SCCS-vsn: sys/netiso/tuba_subr.c 7.11
SCCS-vsn: sys/netiso/tuba_table.c 7.9
SCCS-vsn: sys/netiso/tuba_table.h 7.9
SCCS-vsn: sys/netiso/tuba_usrreq.c 7.8

usr/src/sys/netiso/tuba_subr.c
usr/src/sys/netiso/tuba_table.c
usr/src/sys/netiso/tuba_table.h
usr/src/sys/netiso/tuba_usrreq.c

index 1deb326..0bcf653 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tuba_subr.c 7.10 (Berkeley) %G%
+ *     @(#)tuba_subr.c 7.11 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -145,10 +145,10 @@ tuba_refcnt(isop, delta)
            (delta == 1 && isop->isop_tuba_cached != 0))
                return;
        isop->isop_tuba_cached = (delta == 1);
            (delta == 1 && isop->isop_tuba_cached != 0))
                return;
        isop->isop_tuba_cached = (delta == 1);
-       if ((index = tuba_lookup(&isop->isop_sfaddr.siso_addr, M_DONTWAIT)) != 0 &&
+       if ((index = tuba_lookup(isop->isop_faddr, M_DONTWAIT)) != 0 &&
            (tc = tuba_table[index]) != 0 && (delta == 1 || tc->tc_refcnt > 0))
                tc->tc_refcnt += delta;
            (tc = tuba_table[index]) != 0 && (delta == 1 || tc->tc_refcnt > 0))
                tc->tc_refcnt += delta;
-       if ((index = tuba_lookup(&isop->isop_sladdr.siso_addr, M_DONTWAIT)) != 0 &&
+       if ((index = tuba_lookup(isop->isop_laddr, M_DONTWAIT)) != 0 &&
            (tc = tuba_table[index]) != 0 && (delta == 1 || tc->tc_refcnt > 0))
                tc->tc_refcnt += delta;
 }
            (tc = tuba_table[index]) != 0 && (delta == 1 || tc->tc_refcnt > 0))
                tc->tc_refcnt += delta;
 }
@@ -170,20 +170,29 @@ tuba_pcbconnect(inp, nam)
        register struct inpcb *inp;
        struct mbuf *nam;
 {
        register struct inpcb *inp;
        struct mbuf *nam;
 {
-       register struct sockaddr_iso *siso = mtod(nam, struct sockaddr_iso *);
+       register struct sockaddr_iso *siso;
        struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
        struct tcpcb *tp = intotcpcb(inp);
        struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
        struct tcpcb *tp = intotcpcb(inp);
-       unsigned index = sin->sin_addr.s_addr;
-       struct tuba_cache *tc = tuba_table[index];
        struct isopcb *isop = (struct isopcb *)tp->t_tuba_pcb;
        int error;
 
        struct isopcb *isop = (struct isopcb *)tp->t_tuba_pcb;
        int error;
 
-       inp->inp_faddr.s_addr = index;
+       /* hardwire iso_pcbbind() here */
+       siso = isop->isop_laddr = &isop->isop_sladdr;
+       *siso = tuba_table[inp->inp_laddr.s_addr]->tc_siso;
+       siso->siso_tlen = sizeof(inp->inp_lport);
+       bcopy((caddr_t)&inp->inp_lport, TSEL(siso), sizeof(inp->inp_lport));
+
+       /* hardwire in_pcbconnect() here without assigning route */
        inp->inp_fport = sin->sin_port;
        inp->inp_fport = sin->sin_port;
-       *siso = tc->tc_siso;
+       inp->inp_faddr = sin->sin_addr;
+
+       /* reuse nam argument to call iso_pcbconnect() */
+       nam->m_len = sizeof(*siso);
+       siso = mtod(nam, struct sockaddr_iso *);
+       *siso = tuba_table[inp->inp_faddr.s_addr]->tc_siso;
        siso->siso_tlen = sizeof(inp->inp_fport);
        bcopy((caddr_t)&inp->inp_fport, TSEL(siso), sizeof(inp->inp_fport));
        siso->siso_tlen = sizeof(inp->inp_fport);
        bcopy((caddr_t)&inp->inp_fport, TSEL(siso), sizeof(inp->inp_fport));
-       nam->m_len = sizeof(*siso);
+
        if ((error = iso_pcbconnect(isop, nam)) == 0)
                tuba_refcnt(isop, 1);
        return (error);
        if ((error = iso_pcbconnect(isop, nam)) == 0)
                tuba_refcnt(isop, 1);
        return (error);
@@ -204,7 +213,7 @@ tuba_tcpinput(m, src, dst)
        unsigned long sum, lindex, findex;
        register struct tcpiphdr *ti;
        register struct inpcb *inp;
        unsigned long sum, lindex, findex;
        register struct tcpiphdr *ti;
        register struct inpcb *inp;
-       struct mbuf *om;
+       struct mbuf *om = 0;
        int len, tlen, off;
        register struct tcpcb *tp = 0;
        int tiflags;
        int len, tlen, off;
        register struct tcpcb *tp = 0;
        int tiflags;
@@ -221,8 +230,8 @@ tuba_tcpinput(m, src, dst)
         * If we are out of space might as well drop the packet now.
         */
        tcpstat.tcps_rcvtotal++;
         * If we are out of space might as well drop the packet now.
         */
        tcpstat.tcps_rcvtotal++;
-       lindex = tuba_lookup(&dst->siso_addr, M_DONTWAIT);
-       findex = tuba_lookup(&src->siso_addr, M_DONTWAIT);
+       lindex = tuba_lookup(dst, M_DONTWAIT);
+       findex = tuba_lookup(src, M_DONTWAIT);
        if (lindex == 0 || findex == 0)
                goto drop;
        /*
        if (lindex == 0 || findex == 0)
                goto drop;
        /*
@@ -234,6 +243,7 @@ tuba_tcpinput(m, src, dst)
        m->m_data -= sizeof(struct ip);
        m->m_len += sizeof(struct ip);
        m->m_pkthdr.len += sizeof(struct ip);
        m->m_data -= sizeof(struct ip);
        m->m_len += sizeof(struct ip);
        m->m_pkthdr.len += sizeof(struct ip);
+       m->m_flags &= ~(M_MCAST|M_BCAST); /* XXX should do this in clnp_input */
        /*
         * The reassembly code assumes it will be overwriting a useless
         * part of the packet, which is why we need to have it point
        /*
         * The reassembly code assumes it will be overwriting a useless
         * part of the packet, which is why we need to have it point
@@ -255,16 +265,17 @@ tuba_tcpinput(m, src, dst)
                }
                m->m_next = m0;
                m->m_data += max_linkhdr;
                }
                m->m_next = m0;
                m->m_data += max_linkhdr;
-               m->m_pkthdr = m->m_pkthdr;
-               m->m_flags = m->m_flags & M_COPYFLAGS;
+               m->m_pkthdr = m0->m_pkthdr;
+               m->m_flags = m0->m_flags & M_COPYFLAGS;
                if (len < sizeof(struct tcphdr)) {
                if (len < sizeof(struct tcphdr)) {
+                       m->m_len = 0;
                        if ((m = m_pullup(m, sizeof(struct tcpiphdr))) == 0) {
                                tcpstat.tcps_rcvshort++;
                                return;
                        }
                } else {
                        if ((m = m_pullup(m, sizeof(struct tcpiphdr))) == 0) {
                                tcpstat.tcps_rcvshort++;
                                return;
                        }
                } else {
-                       bcopy(mtod(m, caddr_t) + sizeof(struct ip),
-                             mtod(m0, caddr_t) + sizeof(struct ip),
+                       bcopy(mtod(m0, caddr_t) + sizeof(struct ip),
+                             mtod(m, caddr_t) + sizeof(struct ip),
                              sizeof(struct tcphdr));
                        m0->m_len -= sizeof(struct tcpiphdr);
                        m0->m_data += sizeof(struct tcpiphdr);
                              sizeof(struct tcphdr));
                        m0->m_len -= sizeof(struct tcpiphdr);
                        m0->m_data += sizeof(struct tcpiphdr);
index a25b573..e82820c 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tuba_table.c        7.8 (Berkeley) %G%
+ *     @(#)tuba_table.c        7.9 (Berkeley) %G%
  */
 #include <sys/param.h>
 #include <sys/systm.h>
  */
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -57,16 +57,16 @@ tuba_table_init()
 }
 
 int
 }
 
 int
-tuba_lookup(isoa, wait)
-       register struct iso_addr *isoa;
+tuba_lookup(siso, wait)
+       register struct sockaddr_iso *siso;
 {
        struct radix_node *rn, *rn_match();
        register struct tuba_cache *tc;
        struct tuba_cache **new;
        int dupentry = 0, sum_a = 0, sum_b = 0, old_size, i;
 
 {
        struct radix_node *rn, *rn_match();
        register struct tuba_cache *tc;
        struct tuba_cache **new;
        int dupentry = 0, sum_a = 0, sum_b = 0, old_size, i;
 
-       if ((rn = rn_match((caddr_t)isoa, tuba_tree->rnh_treetop)) &&
-           ((rn->rn_flags & RNF_ROOT) == 0)) {
+       if ((rn = rn_match((caddr_t)&siso->siso_addr, tuba_tree->rnh_treetop))
+            && ((rn->rn_flags & RNF_ROOT) == 0)) {
                tc = (struct tuba_cache *)rn;
                tc->tc_time = time.tv_sec;
                return (tc->tc_index);
                tc = (struct tuba_cache *)rn;
                tc->tc_time = time.tv_sec;
                return (tc->tc_index);
@@ -75,8 +75,8 @@ tuba_lookup(isoa, wait)
                == NULL)
                return (0);
        bzero((caddr_t)tc, sizeof (*tc));
                == NULL)
                return (0);
        bzero((caddr_t)tc, sizeof (*tc));
-       bcopy((caddr_t)isoa, (caddr_t)&tc->tc_siso.siso_addr,
-               1 + isoa->isoa_len);
+       bcopy(siso->siso_data, tc->tc_siso.siso_data,
+               tc->tc_siso.siso_nlen =  siso->siso_nlen);
        rn_insert((caddr_t)&tc->tc_siso.siso_addr,
                  tuba_tree->rnh_treetop, &dupentry, tc->tc_nodes);
        if (dupentry)
        rn_insert((caddr_t)&tc->tc_siso.siso_addr,
                  tuba_tree->rnh_treetop, &dupentry, tc->tc_nodes);
        if (dupentry)
@@ -84,7 +84,7 @@ tuba_lookup(isoa, wait)
        tc->tc_siso.siso_family = AF_ISO;
        tc->tc_siso.siso_len = sizeof(tc->tc_siso);
        tc->tc_time = time.tv_sec;
        tc->tc_siso.siso_family = AF_ISO;
        tc->tc_siso.siso_len = sizeof(tc->tc_siso);
        tc->tc_time = time.tv_sec;
-       for (i = sum_a = isoa->isoa_len; --i >= 0; )
+       for (i = sum_a = tc->tc_siso.siso_nlen; --i >= 0; )
                (i & 1 ? sum_a : sum_b) += tc->tc_siso.siso_data[i];
        REDUCE(tc->tc_sum, (sum_a << 8) + sum_b);
        HTONS(tc->tc_sum);
                (i & 1 ? sum_a : sum_b) += tc->tc_siso.siso_data[i];
        REDUCE(tc->tc_sum, (sum_a << 8) + sum_b);
        HTONS(tc->tc_sum);
@@ -103,7 +103,7 @@ tuba_lookup(isoa, wait)
        if (new == 0) {
                tuba_table_size = old_size;
                rn_delete((caddr_t)&tc->tc_siso.siso_addr,
        if (new == 0) {
                tuba_table_size = old_size;
                rn_delete((caddr_t)&tc->tc_siso.siso_addr,
-                         (caddr_t)0, tuba_tree);
+                         (caddr_t)0, tuba_tree->rnh_treetop);
                free((caddr_t)tc, M_RTABLE);
                return (0);
        }
                free((caddr_t)tc, M_RTABLE);
                return (0);
        }
index d83c1ff..2b84c25 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tuba_table.h        7.8 (Berkeley) %G%
+ *     @(#)tuba_table.h        7.9 (Berkeley) %G%
  */
 
 struct tuba_cache {
  */
 
 struct tuba_cache {
@@ -23,11 +23,11 @@ struct tuba_cache {
 #define REDUCE(a, b) { union { u_short s[2]; long l;} l_util; long x; \
        l_util.l = (b); x = l_util.s[0] + l_util.s[1]; ADDCARRY(x); \
        if (x == 0) x = 0xffff; a = x;}
 #define REDUCE(a, b) { union { u_short s[2]; long l;} l_util; long x; \
        l_util.l = (b); x = l_util.s[0] + l_util.s[1]; ADDCARRY(x); \
        if (x == 0) x = 0xffff; a = x;}
-#define SWAB(a, b) { union { u_char c[2]; u_short s;} s_util; u_short x; \
-       u_char t; s_util.s = b; t = c[0]; c[0] = c[1]; c[1] = t; }
+#define SWAB(a, b) { union { u_char c[2]; u_short s;} s; u_char t; \
+       s.s = (b); t = s.c[0]; s.c[0] = s.c[1]; s.c[1] = t; a = s.s;}
 
 #ifdef KERNEL
 
 #ifdef KERNEL
-extern int     tuba_table_size;
-extern struct  tuba_cache **tuba_table;
-extern struct  radix_node_head *tuba_tree;
+extern int     tuba_table_size;
+extern struct  tuba_cache **tuba_table;
+extern struct  radix_node_head *tuba_tree;
 #endif
 #endif
index b46faac..9ab57d6 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tuba_usrreq.c       7.7 (Berkeley) %G%
+ *     @(#)tuba_usrreq.c       7.8 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -148,7 +148,7 @@ tuba_usrreq(so, req, m, nam, control)
                        break;
                bcopy(TSEL(siso), &inp->inp_lport, 2);
                if (siso->siso_nlen &&
                        break;
                bcopy(TSEL(siso), &inp->inp_lport, 2);
                if (siso->siso_nlen &&
-                   !(inp->inp_laddr.s_addr = tuba_lookup(&siso->siso_addr, M_WAITOK)))
+                   !(inp->inp_laddr.s_addr = tuba_lookup(siso, M_WAITOK)))
                        error = ENOBUFS;
                break;
 
                        error = ENOBUFS;
                break;
 
@@ -181,7 +181,7 @@ tuba_usrreq(so, req, m, nam, control)
                else
                        panic("tuba_usrreq: connect");
                siso = mtod(nam, struct sockaddr_iso *);
                else
                        panic("tuba_usrreq: connect");
                siso = mtod(nam, struct sockaddr_iso *);
-               if (!(inp->inp_faddr.s_addr = tuba_lookup(&siso->siso_addr, M_WAITOK))) {
+               if (!(inp->inp_faddr.s_addr = tuba_lookup(siso, M_WAITOK))) {
                unconnect:
                        iso_pcbdisconnect(isop);
                        error = ENOBUFS;
                unconnect:
                        iso_pcbdisconnect(isop);
                        error = ENOBUFS;
@@ -190,7 +190,7 @@ tuba_usrreq(so, req, m, nam, control)
                bcopy(TSEL(isop->isop_faddr), &inp->inp_fport, 2);
                if (inp->inp_laddr.s_addr == 0 &&
                     (inp->inp_laddr.s_addr = 
                bcopy(TSEL(isop->isop_faddr), &inp->inp_fport, 2);
                if (inp->inp_laddr.s_addr == 0 &&
                     (inp->inp_laddr.s_addr = 
-                           tuba_lookup(&isop->isop_laddr->siso_addr, M_WAITOK)) == 0)
+                           tuba_lookup(isop->isop_laddr, M_WAITOK)) == 0)
                        goto unconnect;
                if ((tp->t_template = tcp_template(tp)) == 0)
                        goto unconnect;
                        goto unconnect;
                if ((tp->t_template = tcp_template(tp)) == 0)
                        goto unconnect;
@@ -282,5 +282,5 @@ tuba_ctloutput(op, so, level, optname, mp)
        int clnp_ctloutput(), tcp_ctloutput();
 
        return ((level != IPPROTO_TCP ? clnp_ctloutput : tcp_ctloutput)
        int clnp_ctloutput(), tcp_ctloutput();
 
        return ((level != IPPROTO_TCP ? clnp_ctloutput : tcp_ctloutput)
-               (clnp_ctloutput(op, so, level, optname, mp)));
+                       (op, so, level, optname, mp));
 }
 }