]> git.ozlabs.org Git - ppp.git/blobdiff - freebsd-2.0/if_ppp.c
fix compilation problems
[ppp.git] / freebsd-2.0 / if_ppp.c
index 23a95b4d064eedd5266889f8fa765deb86e133cd..6e450ea5687968e15a7932b60d1dcc1d1b9845f4 100644 (file)
@@ -69,7 +69,7 @@
  * Paul Mackerras (paulus@cs.anu.edu.au).
  */
 
-/* $Id: if_ppp.c,v 1.7 1996/07/01 01:00:27 paulus Exp $ */
+/* $Id: if_ppp.c,v 1.11 1997/03/04 03:27:28 paulus Exp $ */
 /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
 /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
 
 #include <net/if_pppvar.h>
 #include <machine/cpu.h>
 
+#define splsoftnet     splnet
+
 #ifndef NETISR_PPP
 /* This definition should be moved to net/netisr.h */
 #define NETISR_PPP     26      /* PPP software interrupt */
 #include <net/ppp-comp.h>
 #endif
 
+static int     pppsioctl __P((struct ifnet *, int, caddr_t));
+static int     pppoutput __P((struct ifnet *, struct mbuf *,
+                              struct sockaddr *, struct rtentry *));
 static void    ppp_requeue __P((struct ppp_softc *));
 static void    ppp_outpkt __P((struct ppp_softc *));
 static void    ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd));
@@ -232,7 +237,7 @@ pppalloc(pid)
     sc->sc_relinq = NULL;
     bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats));
 #ifdef VJC
-    MALLOC(sc->sc_comp, struct slcompress *, sizeof(struct slcompress),
+    MALLOC(sc->sc_comp, struct vjcompress *, sizeof(struct vjcompress),
           M_DEVBUF, M_NOWAIT);
     if (sc->sc_comp)
        vj_compress_init(sc->sc_comp, -1);
@@ -251,7 +256,7 @@ pppalloc(pid)
 }
 
 /*
- * Deallocate a ppp unit.  Must be called at splnet or higher.
+ * Deallocate a ppp unit.  Must be called at splsoftnet or higher.
  */
 void
 pppdealloc(sc)
@@ -308,7 +313,7 @@ pppdealloc(sc)
 int
 pppioctl(sc, cmd, data, flag, p)
     struct ppp_softc *sc;
-    u_long cmd;
+    int cmd;
     caddr_t data;
     int flag;
     struct proc *p;
@@ -339,7 +344,7 @@ pppioctl(sc, cmd, data, flag, p)
        if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
            return (error);
        flags = *(int *)data & SC_MASK;
-       s = splnet();
+       s = splsoftnet();
 #ifdef PPP_COMPRESS
        if (sc->sc_flags & SC_CCP_OPEN && !(flags & SC_CCP_OPEN))
            ppp_ccp_closed(sc);
@@ -366,7 +371,7 @@ pppioctl(sc, cmd, data, flag, p)
        if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
            return (error);
        if (sc->sc_comp) {
-           s = splnet();
+           s = splsoftnet();
            vj_compress_init(sc->sc_comp, *(int *)data);
            splx(s);
        }
@@ -399,7 +404,7 @@ pppioctl(sc, cmd, data, flag, p)
                 */
                error = 0;
                if (odp->transmit) {
-                   s = splnet();
+                   s = splsoftnet();
                    if (sc->sc_xc_state != NULL)
                        (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
                    sc->sc_xcomp = *cp;
@@ -414,7 +419,7 @@ pppioctl(sc, cmd, data, flag, p)
                    sc->sc_flags &= ~SC_COMP_RUN;
                    splx(s);
                } else {
-                   s = splnet();
+                   s = splsoftnet();
                    if (sc->sc_rc_state != NULL)
                        (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
                    sc->sc_rcomp = *cp;
@@ -454,7 +459,7 @@ pppioctl(sc, cmd, data, flag, p)
            if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
                return (error);
            if (npi->mode != sc->sc_npmode[npx]) {
-               s = splnet();
+               s = splsoftnet();
                sc->sc_npmode[npx] = npi->mode;
                if (npi->mode != NPMODE_QUEUE) {
                    ppp_requeue(sc);
@@ -466,7 +471,7 @@ pppioctl(sc, cmd, data, flag, p)
        break;
 
     case PPPIOCGIDLE:
-       s = splnet();
+       s = splsoftnet();
        t = time.tv_sec;
        ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
        ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
@@ -485,7 +490,7 @@ pppioctl(sc, cmd, data, flag, p)
 int
 pppsioctl(ifp, cmd, data)
     register struct ifnet *ifp;
-    u_long cmd;
+    int cmd;
     caddr_t data;
 {
     struct proc *p = curproc;  /* XXX */
@@ -595,6 +600,8 @@ pppoutput(ifp, m0, dst, rtp)
     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)) {
@@ -668,6 +675,10 @@ pppoutput(ifp, m0, dst, rtp)
     *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);
@@ -691,7 +702,7 @@ pppoutput(ifp, m0, dst, rtp)
     /*
      * Put the packet on the appropriate queue.
      */
-    s = splnet();
+    s = splsoftnet();
     if (mode == NPMODE_QUEUE) {
        /* XXX we should limit the number of packets on this queue */
        *sc->sc_npqtail = m0;
@@ -725,7 +736,7 @@ bad:
 /*
  * After a change in the NPmode for some NP, move packets from the
  * npqueue to the send queue or the fast queue as appropriate.
- * Should be called at splnet.
+ * Should be called at splsoftnet.
  */
 static void
 ppp_requeue(sc)
@@ -776,7 +787,7 @@ ppp_requeue(sc)
 
 /*
  * Transmitter has finished outputting some stuff;
- * remember to call sc->sc_start later at splnet.
+ * remember to call sc->sc_start later at splsoftnet.
  */
 void
 ppp_restart(sc)
@@ -791,7 +802,7 @@ ppp_restart(sc)
 
 /*
  * Get a packet to send.  This procedure is intended to be called at
- * splnet, since it may involve time-consuming operations such as
+ * splsoftnet, since it may involve time-consuming operations such as
  * applying VJ compression, packet compression, address/control and/or
  * protocol field compression to the packet.
  */
@@ -882,13 +893,18 @@ ppp_dequeue(sc)
        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) {
-           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 */
@@ -917,7 +933,7 @@ ppp_dequeue(sc)
 }
 
 /*
- * Software interrupt routine, called at splnet.
+ * Software interrupt routine, called at splsoftnet.
  */
 void
 pppintr()
@@ -927,7 +943,7 @@ pppintr()
     struct mbuf *m;
 
     sc = ppp_softc;
-    s = splnet();
+    s = splsoftnet();
     for (i = 0; i < NPPP; ++i, ++sc) {
        if (!(sc->sc_flags & SC_TBUSY)
            && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
@@ -1088,7 +1104,7 @@ ppppktin(sc, m, lost)
 
 /*
  * Process a received PPP packet, doing decompression as necessary.
- * Should be called at splnet.
+ * Should be called at splsoftnet.
  */
 #define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \
                         TYPE_UNCOMPRESSED_TCP)