]> git.ozlabs.org Git - ppp.git/blobdiff - ultrix/if_ppp.c
added definitions for Deflate and Predictor
[ppp.git] / ultrix / if_ppp.c
index 981d1318129b7a26261d5f6e821dec0e53e2d6dc..9fd9b3151dac89cd3cb6eebddca1d966e13b4d35 100644 (file)
@@ -72,7 +72,7 @@
  * Robert Olsson <robert@robur.slu.se> and Paul Mackerras.
  */
 
-/* $Id: if_ppp.c,v 1.4 1994/12/08 00:32:59 paulus Exp $ */
+/* $Id: if_ppp.c,v 1.8 1995/07/11 07:00:49 paulus Exp $ */
 /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
 
 #include "ppp.h"
@@ -169,7 +169,9 @@ static u_short interactive_ports[8] = {
 extern struct compressor ppp_bsd_compress;
 
 struct compressor *ppp_compressors[] = {
+#if DO_BSD_COMPRESS
     &ppp_bsd_compress,
+#endif
     NULL
 };
 #endif /* PPP_COMPRESS */
@@ -273,7 +275,7 @@ pppdealloc(sc)
        m_freem(m);
     }
     while ((m = sc->sc_npqueue) != NULL) {
-       sc->sc_npqueue = m->m_nextpkt;
+       sc->sc_npqueue = m->m_act;
        m_freem(m);
     }
     if (sc->sc_togo != NULL) {
@@ -297,7 +299,7 @@ pppioctl(sc, cmd, data, flag)
     int cmd, flag;
 {
     struct proc *p = u.u_procp;
-    int s, error, flags, mru, nb, npx;
+    int s, error, flags, mru, mtu, nb, npx;
     struct ppp_option_data *odp;
     struct compressor **cp;
     struct npioctl *npi;
@@ -340,6 +342,27 @@ pppioctl(sc, cmd, data, flag)
        *(int *)data = sc->sc_mru;
        break;
 
+    /*
+     * PPPIOC[GS]MTU are implemented here, instead of supporting
+     * SIOC[GS]IFMTU in pppsioctl, because under Ultrix, we can't get an
+     * interface ioctl through to the interface until it has an IP
+     * address set.
+     */
+    case PPPIOCSMTU:
+       if (!suser())
+           return EPERM;
+       mtu = *(int *) data;
+       if (mtu <= 0 || mtu > PPP_MAXMRU)
+           return EINVAL;
+       s = splimp();
+       sc->sc_if.if_mtu = mtu;
+       splx(s);
+       break;
+
+    case PPPIOCGMTU:
+       *(int *) data = sc->sc_if.if_mtu;
+       break;
+
 #ifdef VJC
     case PPPIOCSMAXCID:
        if (!suser())
@@ -479,6 +502,12 @@ pppsioctl(ifp, cmd, data)
            error = EAFNOSUPPORT;
        break;
 
+/*
+ * Ioctls other than the above don't get through until the
+ * interface has its IP addresses set :-(
+ */
+
+#if 0
     case SIOCSIFMTU:
        if (!suser())
            return EPERM;
@@ -488,6 +517,7 @@ pppsioctl(ifp, cmd, data)
     case SIOCGIFMTU:
        ifr->ifr_mtu = sc->sc_if.if_mtu;
        break;
+#endif
 
     case SIOCGPPPSTATS:
        psp = &((struct ifpppstatsreq *) data)->stats;
@@ -646,8 +676,8 @@ pppoutput(ifp, m0, dst)
     if (mode == NPMODE_QUEUE) {
        /* XXX we should limit the number of packets on this queue */
        *sc->sc_npqtail = m0;
-       m0->m_nextpkt = NULL;
-       sc->sc_npqtail = &m0->m_nextpkt;
+       m0->m_act = NULL;
+       sc->sc_npqtail = &m0->m_act;
     } else {
        ifq = m0->m_context? &sc->sc_fastq: &ifp->if_snd;
        if (IF_QFULL(ifq)) {
@@ -696,9 +726,9 @@ ppp_requeue(sc)
            /*
             * This packet can now go on one of the queues to be sent.
             */
-           *mpp = m->m_nextpkt;
-           m->m_nextpkt = NULL;
-           ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_if.if_snd;
+           *mpp = m->m_act;
+           m->m_act = NULL;
+           ifq = m->m_context? &sc->sc_fastq: &sc->sc_if.if_snd;
            if (IF_QFULL(ifq)) {
                IF_DROP(ifq);
                sc->sc_if.if_oerrors++;
@@ -708,12 +738,12 @@ ppp_requeue(sc)
 
        case NPMODE_DROP:
        case NPMODE_ERROR:
-           *mpp = m->m_nextpkt;
+           *mpp = m->m_act;
            m_freem(m);
            break;
 
        case NPMODE_QUEUE:
-           mpp = &m->m_nextpkt;
+           mpp = &m->m_act;
            break;
        }
     }
@@ -968,7 +998,7 @@ ppp_ccp(sc, m, rcvd)
                if (sc->sc_xc_state != NULL
                    && (*sc->sc_xcomp->comp_init)
                        (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN,
-                        sc->sc_if.if_unit, sc->sc_flags & SC_DEBUG)) {
+                        sc->sc_if.if_unit, 0, sc->sc_flags & SC_DEBUG)) {
                    s = splimp();
                    sc->sc_flags |= SC_COMP_RUN;
                    splx(s);
@@ -1056,7 +1086,7 @@ ppp_inproc(sc, m)
     struct ppp_softc *sc;
     struct mbuf *m;
 {
-    struct ifqueue *inq;
+    struct ifqueue *inq, *lock;
     int s, ilen, xlen, proto, rv;
     u_char *cp, adrs, ctrl;
     struct mbuf *mp, *dmp, *pc;
@@ -1090,32 +1120,30 @@ ppp_inproc(sc, m)
        && !(sc->sc_flags & SC_DC_ERROR) && !(sc->sc_flags & SC_DC_FERROR)) {
        /* decompress this packet */
        rv = (*sc->sc_rcomp->decompress)(sc->sc_rc_state, m, &dmp);
-       if (dmp != NULL) {
+       if (rv == DECOMP_OK) {
            m_freem(m);
+           if (dmp == NULL) {
+               /* no error, but no decompressed packet produced */
+               return;
+           }
            m = dmp;
            cp = mtod(m, u_char *);
            proto = PPP_PROTOCOL(cp);
 
        } else {
-           /* pass the compressed packet up to pppd, which may take
-              CCP down or issue a Reset-Req. */
+           /*
+            * An error has occurred in decompression.
+            * Pass the compressed packet up to pppd, which may take
+            * CCP down or issue a Reset-Req.
+            */
            if (sc->sc_flags & SC_DEBUG)
                printf("ppp%d: decompress failed %d\n", sc->sc_if.if_unit, rv);
-           s = splimp();
+           s = splhigh();
            sc->sc_flags |= SC_VJ_RESET;
-           switch (rv) {
-           case DECOMP_OK:
-               /* no error, but no decompressed packet produced */
-               splx(s);
-               m_freem(m);
-               return;
-           case DECOMP_ERROR:
+           if (rv == DECOMP_ERROR)
                sc->sc_flags |= SC_DC_ERROR;
-               break;
-           case DECOMP_FATALERROR:
+           else
                sc->sc_flags |= SC_DC_FERROR;
-               break;
-           }
            splx(s);
        }