checkpoint at first working tp4 connection; before gnodes
[unix-history] / usr / src / sys / net / if_sl.c
index 213ab2f..88ede68 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)if_sl.c     7.9 (Berkeley) %G%
+ *     @(#)if_sl.c     7.11 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -355,13 +355,13 @@ slstart(tp)
 slinit(sc)
        register struct sl_softc *sc;
 {
 slinit(sc)
        register struct sl_softc *sc;
 {
-       struct mbuf *p;
+       register caddr_t p;
 
        if (sc->sc_buf == (char *) 0) {
 
        if (sc->sc_buf == (char *) 0) {
-               MCLALLOC(p, 1);
+               MCLALLOC(p, M_WAIT);
                if (p) {
                if (p) {
-                       sc->sc_buf = (char *)p;
-                       sc->sc_mp = sc->sc_buf + sizeof(struct ifnet *);
+                       sc->sc_buf = p;
+                       sc->sc_mp = p;
                } else {
                        printf("sl%d: can't allocate buffer\n", sc - sl_softc);
                        sc->sc_if.if_flags &= ~IFF_UP;
                } else {
                        printf("sl%d: can't allocate buffer\n", sc - sl_softc);
                        sc->sc_if.if_flags &= ~IFF_UP;
@@ -388,48 +388,40 @@ sl_btom(sc, len, ifp)
        cp = sc->sc_buf + sizeof(struct ifnet *);
        mp = ⊤
        while (len > 0) {
        cp = sc->sc_buf + sizeof(struct ifnet *);
        mp = ⊤
        while (len > 0) {
-               MGET(m, M_DONTWAIT, MT_DATA);
+               if (top == NULL) {
+                       MGETHDR(m, M_DONTWAIT, MT_DATA);
+               } else {
+                       MGET(m, M_DONTWAIT, MT_DATA);
+               }
                if ((*mp = m) == NULL) {
                        m_freem(top);
                        return (NULL);
                }
                if ((*mp = m) == NULL) {
                        m_freem(top);
                        return (NULL);
                }
-               if (ifp)
-                       m->m_off += sizeof(ifp);
+               if (top == NULL) {
+                       m->m_pkthdr.rcvif = ifp;
+                       m->m_pkthdr.len = len;
+                       m->m_len = MHLEN;
+               } else
+                       m->m_len = MLEN;
                /*
                /*
-                * If we have at least NBPG bytes,
-                * allocate a new page.  Swap the current buffer page
-                * with the new one.  We depend on having a space
-                * left at the beginning of the buffer
-                * for the interface pointer.
+                * If we have at least MINCLSIZE bytes,
+                * allocate a new page.  Swap the current
+                * buffer page with the new one.
                 */
                 */
-               if (len >= NBPG) {
-                       MCLGET(m);
-                       if (m->m_len == MCLBYTES) {
+               if (len >= MINCLSIZE) {
+                       MCLGET(m, M_DONTWAIT);
+                       if (m->m_flags & M_EXT) {
                                cp = mtod(m, char *);
                                cp = mtod(m, char *);
-                               m->m_off = (int)sc->sc_buf - (int)m;
+                               m->m_data = sc->sc_buf;
                                sc->sc_buf = cp;
                                sc->sc_buf = cp;
-                               if (ifp) {
-                                       m->m_off += sizeof(ifp);
-                                       count = MIN(len,
-                                           MCLBYTES - sizeof(struct ifnet *));
-                               } else
-                                       count = MIN(len, MCLBYTES);
+                               count = MIN(len, MCLBYTES);
                                goto nocopy;
                        }
                }
                                goto nocopy;
                        }
                }
-               if (ifp)
-                       count = MIN(len, MLEN - sizeof(ifp));
-               else
-                       count = MIN(len, MLEN);
+               count = MIN(len, m->m_len);
                bcopy(cp, mtod(m, caddr_t), count);
 nocopy:
                m->m_len = count;
                bcopy(cp, mtod(m, caddr_t), count);
 nocopy:
                m->m_len = count;
-               if (ifp) {
-                       m->m_off -= sizeof(ifp);
-                       m->m_len += sizeof(ifp);
-                       *mtod(m, struct ifnet **) = ifp;
-                       ifp = NULL;
-               }
                cp += count;
                len -= count;
                mp = &m->m_next;
                cp += count;
                len -= count;
                mp = &m->m_next;
@@ -526,14 +518,14 @@ slioctl(ifp, cmd, data)
        switch (cmd) {
 
        case SIOCSIFADDR:
        switch (cmd) {
 
        case SIOCSIFADDR:
-               if (ifa->ifa_addr.sa_family == AF_INET)
+               if (ifa->ifa_addr->sa_family == AF_INET)
                        ifp->if_flags |= IFF_UP;
                else
                        error = EAFNOSUPPORT;
                break;
 
        case SIOCSIFDSTADDR:
                        ifp->if_flags |= IFF_UP;
                else
                        error = EAFNOSUPPORT;
                break;
 
        case SIOCSIFDSTADDR:
-               if (ifa->ifa_addr.sa_family != AF_INET)
+               if (ifa->ifa_addr->sa_family != AF_INET)
                        error = EAFNOSUPPORT;
                break;
 
                        error = EAFNOSUPPORT;
                break;