]> git.ozlabs.org Git - ppp.git/blobdiff - netbsd-1.1/if_ppp.c
better way of not sending compressed packet when CCP is not up.
[ppp.git] / netbsd-1.1 / if_ppp.c
index d17cf8bde0328f5aeba725f2a9d8417a264632fd..c4f12568e7b968649f7b572c18b777d494ae16bd 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: if_ppp.c,v 1.3 1996/07/01 01:03:38 paulus Exp $    */
+/*     $Id: if_ppp.c,v 1.5 1996/09/26 06:24:14 paulus Exp $    */
 
 /*
  * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
 
 /*
  * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
 #include <sys/time.h>
 #include <sys/malloc.h>
 
 #include <sys/time.h>
 #include <sys/malloc.h>
 
+#if NetBSD1_0 && defined(i386)
+#include <machine/psl.h>
+#endif
+
 #include <net/if.h>
 #include <net/if_types.h>
 #include <net/netisr.h>
 #include <net/if.h>
 #include <net/if_types.h>
 #include <net/netisr.h>
 #include <net/if_pppvar.h>
 #include <machine/cpu.h>
 
 #include <net/if_pppvar.h>
 #include <machine/cpu.h>
 
+#if NetBSD1_0
+#define splsoftnet     splnet
+#endif
+
 #ifdef PPP_COMPRESS
 #define PACKETPTR      struct mbuf *
 #include <net/ppp-comp.h>
 #ifdef PPP_COMPRESS
 #define PACKETPTR      struct mbuf *
 #include <net/ppp-comp.h>
@@ -197,6 +205,18 @@ pppattach()
        bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
 #endif
     }
        bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
 #endif
     }
+
+#if NetBSD1_0 && defined(i386)
+    /*
+     * XXX kludge to fix the bug in the i386 interrupt handling code,
+     * where software interrupts could be taken while hardware
+     * interrupts were blocked.
+     */
+    if ((imask[IPL_TTY] & (1 << SIR_NET)) == 0) {
+       imask[IPL_TTY] |= (1 << SIR_NET);
+       intr_calculatemasks();
+    }
+#endif
 }
 
 /*
 }
 
 /*
@@ -622,6 +642,8 @@ pppoutput(ifp, m0, dst, rtp)
     struct ip *ip;
     struct ifqueue *ifq;
     enum NPmode mode;
     struct ip *ip;
     struct ifqueue *ifq;
     enum NPmode mode;
+    int len;
+    struct mbuf *m;
 
     if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
        || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
 
     if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
        || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
@@ -695,6 +717,10 @@ pppoutput(ifp, m0, dst, rtp)
     *cp++ = protocol & 0xff;
     m0->m_len += PPP_HDRLEN;
 
     *cp++ = protocol & 0xff;
     m0->m_len += PPP_HDRLEN;
 
+    len = 0;
+    for (m = m0; m != 0; m = m->m_next)
+       len += m->m_len;
+
     if (sc->sc_flags & SC_LOG_OUTPKT) {
        printf("ppp%d output: ", ifp->if_unit);
        pppdumpm(m0);
     if (sc->sc_flags & SC_LOG_OUTPKT) {
        printf("ppp%d output: ", ifp->if_unit);
        pppdumpm(m0);
@@ -909,13 +935,18 @@ ppp_dequeue(sc)
        for (mp = m; mp != NULL; mp = mp->m_next)
            slen += mp->m_len;
        clen = (*sc->sc_xcomp->compress)
        for (mp = m; mp != NULL; mp = mp->m_next)
            slen += mp->m_len;
        clen = (*sc->sc_xcomp->compress)
-           (sc->sc_xc_state, &mcomp, m, slen,
-            (sc->sc_flags & SC_CCP_UP? sc->sc_if.if_mtu: 0));
+           (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN);
        if (mcomp != NULL) {
        if (mcomp != NULL) {
-           m_freem(m);
-           m = mcomp;
-           cp = mtod(m, u_char *);
-           protocol = cp[3];
+           if (sc->sc_flags & SC_CCP_UP) {
+               /* Send the compressed packet instead of the original. */
+               m_freem(m);
+               m = mcomp;
+               cp = mtod(m, u_char *);
+               protocol = cp[3];
+           } else {
+               /* Can't transmit compressed packets until CCP is up. */
+               m_freem(mcomp);
+           }
        }
     }
 #endif /* PPP_COMPRESS */
        }
     }
 #endif /* PPP_COMPRESS */