BSD 4_3_Reno release
[unix-history] / usr / src / sys / vaxif / if_en.c
index a33559c..5327da4 100644 (file)
@@ -1,9 +1,23 @@
 /*
  * Copyright (c) 1982, 1986 Regents of the University of California.
 /*
  * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
  *
  *
- *     @(#)if_en.c     7.1 (Berkeley) 6/5/86
+ * Redistribution is only permitted until one year after the first shipment
+ * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
+ * binary forms are permitted provided that: (1) source distributions retain
+ * this entire copyright notice and comment, and (2) distributions including
+ * binaries display the following acknowledgement:  This product includes
+ * software developed by the University of California, Berkeley and its
+ * contributors'' in the documentation or other materials provided with the
+ * distribution and in all advertising materials mentioning features or use
+ * of this software.  Neither the name of the University nor the names of
+ * its contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *     @(#)if_en.c     7.6 (Berkeley) 6/28/90
  */
 
 #include "en.h"
  */
 
 #include "en.h"
@@ -12,7 +26,7 @@
 /*
  * Xerox prototype (3 Mb) Ethernet interface driver.
  */
 /*
  * Xerox prototype (3 Mb) Ethernet interface driver.
  */
-#include "../machine/pte.h"
+#include "machine/pte.h"
 
 #include "param.h"
 #include "systm.h"
 
 #include "param.h"
 #include "systm.h"
@@ -63,7 +77,7 @@ struct        uba_driver endriver =
        { enprobe, 0, enattach, 0, enstd, "en", eninfo };
 #define        ENUNIT(x)       minor(x)
 
        { enprobe, 0, enattach, 0, enstd, "en", eninfo };
 #define        ENUNIT(x)       minor(x)
 
-int    eninit(),enoutput(),enreset(),enioctl();
+int    eninit(),oldenoutput(),enreset(),enioctl(), enstart();
 
 #ifdef notdef
 /*
 
 #ifdef notdef
 /*
@@ -135,7 +149,8 @@ enattach(ui)
        es->es_if.if_mtu = ENMTU;
        es->es_if.if_flags = IFF_BROADCAST;
        es->es_if.if_init = eninit;
        es->es_if.if_mtu = ENMTU;
        es->es_if.if_flags = IFF_BROADCAST;
        es->es_if.if_init = eninit;
-       es->es_if.if_output = enoutput;
+       es->es_if.if_output = oldenoutput;
+       es->es_if.if_start = enstart;
        es->es_if.if_ioctl = enioctl;
        es->es_if.if_reset = enreset;
        es->es_ifuba.ifu_flags = UBA_NEEDBDP | UBA_NEED16 | UBA_CANTWAIT;
        es->es_if.if_ioctl = enioctl;
        es->es_if.if_reset = enreset;
        es->es_ifuba.ifu_flags = UBA_NEEDBDP | UBA_NEED16 | UBA_CANTWAIT;
@@ -361,8 +376,8 @@ endocoll(unit)
 
 #ifdef notdef
 struct sockproto enproto = { AF_ETHERLINK };
 
 #ifdef notdef
 struct sockproto enproto = { AF_ETHERLINK };
-struct sockaddr_en endst = { AF_ETHERLINK };
-struct sockaddr_en ensrc = { AF_ETHERLINK };
+struct sockaddr_en endst = { sizeof(endst), AF_ETHERLINK };
+struct sockaddr_en ensrc = { sizeof(ensrc), AF_ETHERLINK };
 #endif
 /*
  * Ethernet interface receiver interrupt.
 #endif
 /*
  * Ethernet interface receiver interrupt.
@@ -440,14 +455,6 @@ enrint(unit)
        m = if_rubaget(&es->es_ifuba, len, off, &es->es_if);
        if (m == 0)
                goto setup;
        m = if_rubaget(&es->es_ifuba, len, off, &es->es_if);
        if (m == 0)
                goto setup;
-       if (off) {
-               struct ifnet *ifp;
-
-               ifp = *(mtod(m, struct ifnet **));
-               m->m_off += 2 * sizeof (u_short);
-               m->m_len -= 2 * sizeof (u_short);
-               *(mtod(m, struct ifnet **)) = ifp;
-       }
        switch (en->en_type) {
 
 #ifdef INET
        switch (en->en_type) {
 
 #ifdef INET
@@ -510,7 +517,7 @@ setup:
  * Use trailer local net encapsulation if enough data in first
  * packet leaves a multiple of 512 bytes of data in remainder.
  */
  * Use trailer local net encapsulation if enough data in first
  * packet leaves a multiple of 512 bytes of data in remainder.
  */
-enoutput(ifp, m0, dst)
+oldenoutput(ifp, m0, dst)
        struct ifnet *ifp;
        struct mbuf *m0;
        struct sockaddr *dst;
        struct ifnet *ifp;
        struct mbuf *m0;
        struct sockaddr *dst;
@@ -541,13 +548,14 @@ enoutput(ifp, m0, dst)
                        error = EPERM;          /* ??? */
                        goto bad;
                }
                        error = EPERM;          /* ??? */
                        goto bad;
                }
-               off = ntohs((u_short)mtod(m, struct ip *)->ip_len) - m->m_len;
+               off = m->m_pkthdr.len - m->m_len;
                /* need per host negotiation */
                if ((ifp->if_flags & IFF_NOTRAILERS) == 0)
                if (off > 0 && (off & 0x1ff) == 0 &&
                /* need per host negotiation */
                if ((ifp->if_flags & IFF_NOTRAILERS) == 0)
                if (off > 0 && (off & 0x1ff) == 0 &&
-                   m->m_off >= MMINOFF + 2 * sizeof (u_short)) {
+                   (m->m_flags & M_EXT) == 0 &&
+                   m->m_data >= m->m_pktdat + 2 * sizeof (u_short)) {
                        type = ENTYPE_TRAIL + (off>>9);
                        type = ENTYPE_TRAIL + (off>>9);
-                       m->m_off -= 2 * sizeof (u_short);
+                       m->m_data -= 2 * sizeof (u_short);
                        m->m_len += 2 * sizeof (u_short);
                        *mtod(m, u_short *) = htons((u_short)ENTYPE_IP);
                        *(mtod(m, u_short *) + 1) = ntohs((u_short)m->m_len);
                        m->m_len += 2 * sizeof (u_short);
                        *mtod(m, u_short *) = htons((u_short)ENTYPE_IP);
                        *(mtod(m, u_short *) + 1) = ntohs((u_short)m->m_len);
@@ -610,20 +618,9 @@ gottype:
         * Add local net header.  If no space in first mbuf,
         * allocate another.
         */
         * Add local net header.  If no space in first mbuf,
         * allocate another.
         */
-       if (m->m_off > MMAXOFF ||
-           MMINOFF + sizeof (struct en_header) > m->m_off) {
-               MGET(m, M_DONTWAIT, MT_HEADER);
-               if (m == 0) {
-                       error = ENOBUFS;
-                       goto bad;
-               }
-               m->m_next = m0;
-               m->m_off = MMINOFF;
-               m->m_len = sizeof (struct en_header);
-       } else {
-               m->m_off -= sizeof (struct en_header);
-               m->m_len += sizeof (struct en_header);
-       }
+       M_PREPEND(m, sizeof (struct en_header), M_DONTWAIT);
+       if (m == NULL)
+               return (ENOBUFS);
        en = mtod(m, struct en_header *);
        /* add en_shost later */
        en->en_dhost = dest;
        en = mtod(m, struct en_header *);
        /* add en_shost later */
        en->en_dhost = dest;
@@ -677,7 +674,7 @@ enioctl(ifp, cmd, data)
                 * Attempt to check agreement of protocol address
                 * and board address.
                 */
                 * Attempt to check agreement of protocol address
                 * and board address.
                 */
-               switch (ifa->ifa_addr.sa_family) {
+               switch (ifa->ifa_addr->sa_family) {
                case AF_INET:
                        if (in_lnaof(IA_SIN(ifa)->sin_addr) != es->es_host)
                                return (EADDRNOTAVAIL);
                case AF_INET:
                        if (in_lnaof(IA_SIN(ifa)->sin_addr) != es->es_host)
                                return (EADDRNOTAVAIL);