flags masked incorrectly
[unix-history] / usr / src / sys / vax / if / if_en.c
index 87ab21d..4b59e35 100644 (file)
@@ -1,6 +1,7 @@
-/*     if_en.c 4.45    82/03/30        */
+/*     if_en.c 4.49    82/04/01        */
 
 #include "en.h"
 
 #include "en.h"
+#include "imp.h"
 
 /*
  * Xerox prototype (3 Mb) Ethernet interface driver.
 
 /*
  * Xerox prototype (3 Mb) Ethernet interface driver.
@@ -101,7 +102,7 @@ COUNT(ENATTACH);
        es->es_if.if_unit = ui->ui_unit;
        es->es_if.if_name = "en";
        es->es_if.if_mtu = ENMTU;
        es->es_if.if_unit = ui->ui_unit;
        es->es_if.if_name = "en";
        es->es_if.if_mtu = ENMTU;
-       es->es_if.if_net = ui->ui_flags;
+       es->es_if.if_net = ui->ui_flags & 0xff;
        es->es_if.if_host[0] =
         (~(((struct endevice *)eninfo[ui->ui_unit]->ui_addr)->en_addr)) & 0xff;
        sin = (struct sockaddr_in *)&es->es_if.if_addr;
        es->es_if.if_host[0] =
         (~(((struct endevice *)eninfo[ui->ui_unit]->ui_addr)->en_addr)) & 0xff;
        sin = (struct sockaddr_in *)&es->es_if.if_addr;
@@ -116,6 +117,10 @@ COUNT(ENATTACH);
        es->es_if.if_ubareset = enreset;
        es->es_ifuba.ifu_flags = UBA_NEEDBDP | UBA_NEED16;
        if_attach(&es->es_if);
        es->es_if.if_ubareset = enreset;
        es->es_ifuba.ifu_flags = UBA_NEEDBDP | UBA_NEED16;
        if_attach(&es->es_if);
+#if NIMP == 0
+       /* here's one for you john baby.... */
+       enlhinit((ui->ui_flags &~ 0xff) | 0x0a);
+#endif
 }
 
 /*
 }
 
 /*
@@ -376,16 +381,12 @@ COUNT(ENRINT);
        case ENPUP_IPTYPE:
                len = htons((u_short)endataaddr(en,
                        off ? off + sizeof (u_short) : 0, struct ip *)->ip_len);
        case ENPUP_IPTYPE:
                len = htons((u_short)endataaddr(en,
                        off ? off + sizeof (u_short) : 0, struct ip *)->ip_len);
-               if (off)
-                       len += sizeof (u_short);
                break;
 #endif
 #ifdef PUP
        case ENPUP_PUPTYPE:
                len = endataaddr(en, off ? off + sizeof (u_short) : 0,
                        struct pup_header *)->pup_length;
                break;
 #endif
 #ifdef PUP
        case ENPUP_PUPTYPE:
                len = endataaddr(en, off ? off + sizeof (u_short) : 0,
                        struct pup_header *)->pup_length;
-               if (off)
-                       len -= sizeof (u_short);
                break;
 #endif
                
                break;
 #endif
                
@@ -393,6 +394,8 @@ COUNT(ENRINT);
                printf("en%d: unknown pkt type 0x%x\n", unit, en->en_type);
                goto setup;
        }
                printf("en%d: unknown pkt type 0x%x\n", unit, en->en_type);
                goto setup;
        }
+       if (off)
+               len += sizeof (u_short);
        if (len == 0)
                goto setup;
 
        if (len == 0)
                goto setup;
 
@@ -558,3 +561,51 @@ gottype:
        splx(s);
        return (1);
 }
        splx(s);
        return (1);
 }
+
+#if NIMP == 0 && NEN > 0
+/*
+ * Logical host interface driver.
+ * Allows host to appear as an ARPAnet
+ * logical host.  Must also have routing
+ * table entry set up to forward packets
+ * to appropriate gateway on localnet.
+ */
+
+struct ifnet enlhif;
+int    enlhoutput();
+
+/*
+ * Called by localnet interface to allow logical
+ * host interface to "attach".  Nothing should ever
+ * be sent locally to this interface, it's purpose
+ * is simply to establish the host's arpanet address.
+ */
+enlhinit(addr)
+       int addr;
+{
+       register struct ifnet *ifp = &enlhif;
+       register struct sockaddr_in *sin;
+
+COUNT(ENLHINIT);
+       ifp->if_name = "lh";
+       ifp->if_mtu = ENMTU;
+       sin = (struct sockaddr_in *)&ifp->if_addr;
+       sin->sin_family = AF_INET;
+       sin->sin_addr.s_addr = addr;
+       ifp->if_net = sin->sin_addr.s_net;
+       ifp->if_flags = IFF_UP;
+       ifp->if_output = enlhoutput;    /* should never be used */
+       if_attach(ifp);
+}
+
+enlhoutput(ifp, m0, dst)
+       struct ifnet *ifp;
+       struct mbuf *m0;
+       struct sockaddr *dst;
+{
+COUNT(ENLHOUTPUT);
+       ifp->if_oerrors++;
+       m_freem(m0);
+       return (0);
+}
+#endif