use shorts to move data
[unix-history] / usr / src / sys / vax / if / if_ec.c
index e788a51..3aa5f69 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_ec.c 4.9     82/05/21        */
+/*     if_ec.c 4.12    82/05/27        */
 
 #include "ec.h"
 #include "imp.h"
 
 #include "ec.h"
 #include "imp.h"
@@ -186,7 +186,7 @@ COUNT(ECATTACH);
 #if NIMP == 0
        /* here's one for you john baby.... */
        if (ui->ui_flags &~ 0xff)
 #if NIMP == 0
        /* here's one for you john baby.... */
        if (ui->ui_flags &~ 0xff)
-               eclhinit((ui->ui_flags &~ 0xff) | 0x0a);
+               eclhinit(&es->es_if, (ui->ui_flags &~ 0xff) | 0x0a);
 #endif
 }
 
 #endif
 }
 
@@ -655,7 +655,19 @@ COUNT(ECPUT);
        mp = m;
        while (mp) {
                mcp = mtod(mp, char *);
        mp = m;
        while (mp) {
                mcp = mtod(mp, char *);
+               i = 0;
+               if ((int)bp&1) {
+                       *bp++ = *mcp++;
+                       i++;
+               }
                for (i=0; i<mp->m_len; i++)
                for (i=0; i<mp->m_len; i++)
+               while (i < mp->m_len) {
+                       *(short *)bp = *(short *)mcp;
+                       bp += 2;
+                       mcp += 2;
+                       i += 2;
+               }
+               if (mp->m_len&1)
                        *bp++ = *mcp++;
                mp = m_free(mp);
        }
                        *bp++ = *mcp++;
                mp = m_free(mp);
        }
@@ -666,6 +678,9 @@ COUNT(ECPUT);
 /*
  * Routine to copy from UNIBUS memory into mbufs.
  * Similar in spirit to if_rubaget.
 /*
  * Routine to copy from UNIBUS memory into mbufs.
  * Similar in spirit to if_rubaget.
+ *
+ * Warning: This makes the fairly safe assumption that
+ * mbufs have even lengths.
  */
 struct mbuf *
 ecget(ecbuf, totlen, off0)
  */
 struct mbuf *
 ecget(ecbuf, totlen, off0)
@@ -707,7 +722,12 @@ COUNT(ECGET);
                        m->m_off = MMINOFF;
                }
                mcp = mtod(m, char *);
                        m->m_off = MMINOFF;
                }
                mcp = mtod(m, char *);
-               for (i=0; i<len; i++)
+               for (i=0; i<len; i+=2) {
+                       *(short *)mcp = *(short *)cp;
+                       mcp += 2;
+                       cp += 2;
+               }
+               if (len&1)
                        *mcp++ = *cp++;
                *mp = m;
                mp = &m->m_next;
                        *mcp++ = *cp++;
                *mp = m;
                mp = &m->m_next;
@@ -738,15 +758,15 @@ bad:
  */
 
 struct ifnet eclhif;
  */
 
 struct ifnet eclhif;
-int    eclhoutput();
+int    looutput();
 
 /*
  * Called by localnet interface to allow logical
 
 /*
  * Called by localnet interface to allow logical
- * host interface to "attach".  Nothing should ever
- * be sent locally to this interface, it's purpose
+ * host interface to "attach", it's purpose
  * is simply to establish the host's arpanet address.
  */
  * is simply to establish the host's arpanet address.
  */
-eclhinit(addr)
+eclhinit(ecifp, addr)
+       struct ifnet *ecifp;
        int addr;
 {
        register struct ifnet *ifp = &eclhif;
        int addr;
 {
        register struct ifnet *ifp = &eclhif;
@@ -758,20 +778,12 @@ COUNT(ECLHINIT);
        sin = (struct sockaddr_in *)&ifp->if_addr;
        sin->sin_family = AF_INET;
        sin->sin_addr.s_addr = addr;
        sin = (struct sockaddr_in *)&ifp->if_addr;
        sin->sin_family = AF_INET;
        sin->sin_addr.s_addr = addr;
+       sin->sin_addr.s_lh = ecifp->if_host[0];
        ifp->if_net = sin->sin_addr.s_net;
        ifp->if_net = sin->sin_addr.s_net;
-       ifp->if_flags = IFF_UP;
-       ifp->if_output = eclhoutput;    /* should never be used */
+       ifp->if_dstaddr = ifp->if_addr;
+       ifp->if_flags = IFF_UP|IFF_POINTOPOINT;
+       ifp->if_output = looutput;
        if_attach(ifp);
        if_attach(ifp);
-}
-
-eclhoutput(ifp, m0, dst)
-       struct ifnet *ifp;
-       struct mbuf *m0;
-       struct sockaddr *dst;
-{
-COUNT(ECLHOUTPUT);
-       ifp->if_oerrors++;
-       m_freem(m0);
-       return (0);
+       rtinit(&ifp->if_addr, &ifp->if_addr, RTF_UP|RTF_DIRECT|RTF_HOST);
 }
 #endif
 }
 #endif