getting reassembly to work
[unix-history] / usr / src / sys / vax / if / if_en.c
index 33ed9e9..c99388d 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_en.c 4.19    81/12/09        */
+/*     if_en.c 4.33    82/02/05        */
 
 #include "en.h"
 
 
 #include "en.h"
 
@@ -101,11 +101,18 @@ COUNT(ENATTACH);
        es->es_if.if_net = ui->ui_flags;
        es->es_if.if_host[0] =
            (~(((struct endevice *)eninfo[ui->ui_unit]->ui_addr)->en_addr)) & 0xff;
        es->es_if.if_net = ui->ui_flags;
        es->es_if.if_host[0] =
            (~(((struct endevice *)eninfo[ui->ui_unit]->ui_addr)->en_addr)) & 0xff;
+#ifdef ENKLUDGE
+       if (es->es_if.if_net == 10) {
+               es->es_if.if_host[0] <<= 16;
+               es->es_if.if_host[0] |= 0x4e;
+       }
+#endif
        es->es_if.if_addr =
            if_makeaddr(es->es_if.if_net, es->es_if.if_host[0]);
        es->es_if.if_init = eninit;
        es->es_if.if_output = enoutput;
        es->es_if.if_ubareset = enreset;
        es->es_if.if_addr =
            if_makeaddr(es->es_if.if_net, es->es_if.if_host[0]);
        es->es_if.if_init = eninit;
        es->es_if.if_output = enoutput;
        es->es_if.if_ubareset = enreset;
+       es->es_ifuba.ifu_flags = UBA_NEEDBDP | UBA_NEED16;
        if_attach(&es->es_if);
 }
 
        if_attach(&es->es_if);
 }
 
@@ -139,7 +146,7 @@ eninit(unit)
        int s;
 
        if (if_ubainit(&es->es_ifuba, ui->ui_ubanum,
        int s;
 
        if (if_ubainit(&es->es_ifuba, ui->ui_ubanum,
-           sizeof (struct en_header), (int)btop(ENMTU)) == 0) { 
+           sizeof (struct en_header), (int)btoc(ENMTU)) == 0) { 
                printf("en%d: can't initialize\n", unit);
                return;
        }
                printf("en%d: can't initialize\n", unit);
                return;
        }
@@ -240,14 +247,15 @@ COUNT(ENXINT);
        es->es_oactive = 0;
        es->es_delay = 0;
        es->es_mask = ~0;
        es->es_oactive = 0;
        es->es_delay = 0;
        es->es_mask = ~0;
-       if (addr->en_ostat&EN_OERROR)
+       if (addr->en_ostat&EN_OERROR) {
+               es->es_if.if_oerrors++;
                printf("en%d: output error\n", unit);
                printf("en%d: output error\n", unit);
+       }
+       if (es->es_ifuba.ifu_xtofree) {
+               m_freem(es->es_ifuba.ifu_xtofree);
+               es->es_ifuba.ifu_xtofree = 0;
+       }
        if (es->es_if.if_snd.ifq_head == 0) {
        if (es->es_if.if_snd.ifq_head == 0) {
-               es->es_if.if_oerrors++;
-               if (es->es_ifuba.ifu_xtofree) {
-                       m_freem(es->es_ifuba.ifu_xtofree);
-                       es->es_ifuba.ifu_xtofree = 0;
-               }
                es->es_lastx = 0;
                return;
        }
                es->es_lastx = 0;
                return;
        }
@@ -287,6 +295,7 @@ COUNT(ENCOLLIDE);
        enstart(unit);
 }
 
        enstart(unit);
 }
 
+int    enprintierrors;
 /*
  * Ethernet interface receiver interrupt.
  * If input error just drop packet.
 /*
  * Ethernet interface receiver interrupt.
  * If input error just drop packet.
@@ -316,6 +325,7 @@ COUNT(ENRINT);
        UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_r.ifrw_bdp);
        if (addr->en_istat&EN_IERROR) {
                es->es_if.if_ierrors++;
        UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_r.ifrw_bdp);
        if (addr->en_istat&EN_IERROR) {
                es->es_if.if_ierrors++;
+               if (enprintierrors)
                printf("en%d: input error\n", unit);
                goto setup;
        }
                printf("en%d: input error\n", unit);
                goto setup;
        }
@@ -345,7 +355,9 @@ COUNT(ENRINT);
 
 #ifdef INET
        case ENPUP_IPTYPE:
 
 #ifdef INET
        case ENPUP_IPTYPE:
-               len = htons(endataaddr(en, off+2, struct ip *)->ip_len)+2;
+               len = htons((u_short)endataaddr(en, off ? off+2 : 0, struct ip *)->ip_len);
+               if (off)
+                       len += 2;
                setipintr();
                inq = &ipintrq;
                break;
                setipintr();
                inq = &ipintrq;
                break;
@@ -367,8 +379,6 @@ COUNT(ENRINT);
        m = if_rubaget(&es->es_ifuba, len, off);
        if (m == 0)
                goto setup;
        m = if_rubaget(&es->es_ifuba, len, off);
        if (m == 0)
                goto setup;
-       printf("rubaget returns m %x\n", m);
-       asm("halt");
        if (off) {
                m->m_off += 2;
                m->m_len -= 2;
        if (off) {
                m->m_off += 2;
                m->m_len -= 2;
@@ -407,8 +417,13 @@ enoutput(ifp, m0, pf)
                register struct ip *ip = mtod(m0, struct ip *);
                int off;
 
                register struct ip *ip = mtod(m0, struct ip *);
                int off;
 
+#ifndef ENKLUDGE
                dest = ip->ip_dst.s_addr >> 24;
                dest = ip->ip_dst.s_addr >> 24;
-               off = ntohs(ip->ip_len) - m->m_len;
+#else
+               dest = (ip->ip_dst.s_addr >> 8) & 0xff;
+#endif
+               off = ntohs((u_short)ip->ip_len) - m->m_len;
+#ifndef ENKLUDGE
                if (off > 0 && (off & 0x1ff) == 0 && m->m_off >= MMINOFF + 2) {
                        type = ENPUP_TRAIL + (off>>9);
                        m->m_off -= 2;
                if (off > 0 && (off & 0x1ff) == 0 && m->m_off >= MMINOFF + 2) {
                        type = ENPUP_TRAIL + (off>>9);
                        m->m_off -= 2;
@@ -416,6 +431,7 @@ enoutput(ifp, m0, pf)
                        *mtod(m, u_short *) = ENPUP_IPTYPE;
                        goto gottrailertype;
                }
                        *mtod(m, u_short *) = ENPUP_IPTYPE;
                        goto gottrailertype;
                }
+#endif
                type = ENPUP_IPTYPE;
                off = 0;
                goto gottype;
                type = ENPUP_IPTYPE;
                off = 0;
                goto gottype;
@@ -447,7 +463,7 @@ gottype:
         */
        if (m->m_off > MMAXOFF ||
            MMINOFF + sizeof (struct en_header) > m->m_off) {
         */
        if (m->m_off > MMAXOFF ||
            MMINOFF + sizeof (struct en_header) > m->m_off) {
-               m = m_get(0);
+               m = m_get(M_DONTWAIT);
                if (m == 0) {
                        m_freem(m0);
                        return (0);
                if (m == 0) {
                        m_freem(m0);
                        return (0);
@@ -470,8 +486,8 @@ gottype:
         */
        s = splimp();
        IF_ENQUEUE(&ifp->if_snd, m);
         */
        s = splimp();
        IF_ENQUEUE(&ifp->if_snd, m);
-       splx(s);
        if (en_softc[ifp->if_unit].es_oactive == 0)
                enstart(ifp->if_unit);
        if (en_softc[ifp->if_unit].es_oactive == 0)
                enstart(ifp->if_unit);
+       splx(s);
        return (1);
 }
        return (1);
 }