]> git.ozlabs.org Git - ppp.git/blobdiff - freebsd-2.0/if_ppp.c
updated cpp defines
[ppp.git] / freebsd-2.0 / if_ppp.c
index f6f4e84ce99df7a365e0204d0b03d00ad7e723a5..702bcca74c538133e584c5558f40fd41059ad28e 100644 (file)
@@ -69,7 +69,7 @@
  * Paul Mackerras (paulus@cs.anu.edu.au).
  */
 
  * Paul Mackerras (paulus@cs.anu.edu.au).
  */
 
-/* $Id: if_ppp.c,v 1.4 1995/07/11 06:37:41 paulus Exp $ */
+/* $Id: if_ppp.c,v 1.6 1995/10/27 03:34:42 paulus Exp $ */
 /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
 
 #include "ppp.h"
 /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
 
 #include "ppp.h"
 #endif
 
 void   pppattach __P((void));
 #endif
 
 void   pppattach __P((void));
-int    pppioctl __P((struct ppp_softc *sc, int cmd, caddr_t data, int flag,
+int    pppioctl __P((struct ppp_softc *sc, u_long cmd, caddr_t data, int flag,
                      struct proc *));
 int    pppoutput __P((struct ifnet *ifp, struct mbuf *m0,
                       struct sockaddr *dst, struct rtentry *rtp));
                      struct proc *));
 int    pppoutput __P((struct ifnet *ifp, struct mbuf *m0,
                       struct sockaddr *dst, struct rtentry *rtp));
-int    pppsioctl __P((struct ifnet *ifp, int cmd, caddr_t data));
+int    pppsioctl __P((struct ifnet *ifp, u_long cmd, caddr_t data));
 void   pppintr __P((void));
 
 static void    ppp_requeue __P((struct ppp_softc *));
 void   pppintr __P((void));
 
 static void    ppp_requeue __P((struct ppp_softc *));
@@ -191,7 +191,7 @@ pppattach()
        sc->sc_if.if_name = "ppp";
        sc->sc_if.if_unit = i++;
        sc->sc_if.if_mtu = PPP_MTU;
        sc->sc_if.if_name = "ppp";
        sc->sc_if.if_unit = i++;
        sc->sc_if.if_mtu = PPP_MTU;
-       sc->sc_if.if_flags = IFF_POINTOPOINT;
+       sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
        sc->sc_if.if_type = IFT_PPP;
        sc->sc_if.if_hdrlen = PPP_HDRLEN;
        sc->sc_if.if_ioctl = pppsioctl;
        sc->sc_if.if_type = IFT_PPP;
        sc->sc_if.if_hdrlen = PPP_HDRLEN;
        sc->sc_if.if_ioctl = pppsioctl;
@@ -205,7 +205,7 @@ 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
     }
-    netisrs[NETISR_PPP] = ppp_intr;
+    netisrs[NETISR_PPP] = pppintr;
 }
 
 /*
 }
 
 /*
@@ -300,8 +300,9 @@ pppdealloc(sc)
 int
 pppioctl(sc, cmd, data, flag, p)
     struct ppp_softc *sc;
 int
 pppioctl(sc, cmd, data, flag, p)
     struct ppp_softc *sc;
+    u_long cmd;
     caddr_t data;
     caddr_t data;
-    int cmd, flag;
+    int flag;
     struct proc *p;
 {
     int s, error, flags, mru, nb, npx;
     struct proc *p;
 {
     int s, error, flags, mru, nb, npx;
@@ -387,8 +388,8 @@ pppioctl(sc, cmd, data, flag, p)
                 * a compressor or decompressor.
                 */
                error = 0;
                 * a compressor or decompressor.
                 */
                error = 0;
-               s = splnet();
                if (odp->transmit) {
                if (odp->transmit) {
+                   s = splnet();
                    if (sc->sc_xc_state != NULL)
                        (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
                    sc->sc_xcomp = *cp;
                    if (sc->sc_xc_state != NULL)
                        (*sc->sc_xcomp->comp_free)(sc->sc_xc_state);
                    sc->sc_xcomp = *cp;
@@ -401,7 +402,9 @@ pppioctl(sc, cmd, data, flag, p)
                    }
                    splimp();
                    sc->sc_flags &= ~SC_COMP_RUN;
                    }
                    splimp();
                    sc->sc_flags &= ~SC_COMP_RUN;
+                   splx(s);
                } else {
                } else {
+                   s = splnet();
                    if (sc->sc_rc_state != NULL)
                        (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
                    sc->sc_rcomp = *cp;
                    if (sc->sc_rc_state != NULL)
                        (*sc->sc_rcomp->decomp_free)(sc->sc_rc_state);
                    sc->sc_rcomp = *cp;
@@ -414,8 +417,8 @@ pppioctl(sc, cmd, data, flag, p)
                    }
                    splimp();
                    sc->sc_flags &= ~SC_DECOMP_RUN;
                    }
                    splimp();
                    sc->sc_flags &= ~SC_DECOMP_RUN;
+                   splx(s);
                }
                }
-               splx(s);
                return (error);
            }
        if (sc->sc_flags & SC_DEBUG)
                return (error);
            }
        if (sc->sc_flags & SC_DEBUG)
@@ -441,7 +444,7 @@ pppioctl(sc, cmd, data, flag, p)
            if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
            if (npi->mode != sc->sc_npmode[npx]) {
            if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
            if (npi->mode != sc->sc_npmode[npx]) {
-               s = splimp();
+               s = splnet();
                sc->sc_npmode[npx] = npi->mode;
                if (npi->mode != NPMODE_QUEUE) {
                    ppp_requeue(sc);
                sc->sc_npmode[npx] = npi->mode;
                if (npi->mode != NPMODE_QUEUE) {
                    ppp_requeue(sc);
@@ -453,7 +456,7 @@ pppioctl(sc, cmd, data, flag, p)
        break;
 
     case PPPIOCGIDLE:
        break;
 
     case PPPIOCGIDLE:
-       s = splimp();
+       s = splnet();
        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;
        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;
@@ -472,7 +475,7 @@ pppioctl(sc, cmd, data, flag, p)
 int
 pppsioctl(ifp, cmd, data)
     register struct ifnet *ifp;
 int
 pppsioctl(ifp, cmd, data)
     register struct ifnet *ifp;
-    int cmd;
+    u_long cmd;
     caddr_t data;
 {
     struct proc *p = curproc;  /* XXX */
     caddr_t data;
 {
     struct proc *p = curproc;  /* XXX */
@@ -511,6 +514,19 @@ pppsioctl(ifp, cmd, data)
        ifr->ifr_mtu = sc->sc_if.if_mtu;
        break;
 
        ifr->ifr_mtu = sc->sc_if.if_mtu;
        break;
 
+    case SIOCADDMULTI:
+    case SIOCDELMULTI:
+       switch(ifr->ifr_addr.sa_family) {
+#ifdef INET
+       case AF_INET:
+           break;
+#endif
+       default:
+           error = EAFNOSUPPORT;
+           break;
+       }
+       break;
+
     case SIOCGPPPSTATS:
        psp = &((struct ifpppstatsreq *) data)->stats;
        bzero(psp, sizeof(*psp));
     case SIOCGPPPSTATS:
        psp = &((struct ifpppstatsreq *) data)->stats;
        bzero(psp, sizeof(*psp));
@@ -658,7 +674,7 @@ pppoutput(ifp, m0, dst, rtp)
     /*
      * Put the packet on the appropriate queue.
      */
     /*
      * Put the packet on the appropriate queue.
      */
-    s = splimp();              /* splnet should be OK now */
+    s = splnet();
     if (mode == NPMODE_QUEUE) {
        /* XXX we should limit the number of packets on this queue */
        *sc->sc_npqtail = m0;
     if (mode == NPMODE_QUEUE) {
        /* XXX we should limit the number of packets on this queue */
        *sc->sc_npqtail = m0;
@@ -666,7 +682,7 @@ pppoutput(ifp, m0, dst, rtp)
        sc->sc_npqtail = &m0->m_nextpkt;
     } else {
        ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd;
        sc->sc_npqtail = &m0->m_nextpkt;
     } else {
        ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd;
-       if (IF_QFULL(ifq)) {
+       if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
            IF_DROP(ifq);
            splx(s);
            sc->sc_if.if_oerrors++;
            IF_DROP(ifq);
            splx(s);
            sc->sc_if.if_oerrors++;
@@ -688,7 +704,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.
 /*
  * 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 splimp (actually splnet would probably suffice).
+ * Should be called at splnet.
  */
 static void
 ppp_requeue(sc)
  */
 static void
 ppp_requeue(sc)
@@ -737,11 +753,11 @@ ppp_requeue(sc)
 }
 
 /*
 }
 
 /*
- * Get a packet to send.  This procedure is intended to be called
- * at spltty()/splimp(), so it takes little time.  If there isn't
- * a packet waiting to go out, it schedules a software interrupt
- * to prepare a new packet; the device start routine gets called
- * again when a packet is ready.
+ * Get a packet to send.  This procedure is intended to be called at
+ * spltty or splimp, so it takes little time.  If there isn't a packet
+ * waiting to go out, it schedules a software interrupt to prepare a
+ * new packet; the device start routine gets called again when a
+ * packet is ready.
  */
 struct mbuf *
 ppp_dequeue(sc)
  */
 struct mbuf *
 ppp_dequeue(sc)
@@ -786,7 +802,9 @@ pppintr()
            && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head))
            ppp_outpkt(sc);
        for (;;) {
            && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head))
            ppp_outpkt(sc);
        for (;;) {
+           s = splimp();
            IF_DEQUEUE(&sc->sc_rawq, m);
            IF_DEQUEUE(&sc->sc_rawq, m);
+           splx(s);
            if (m == NULL)
                break;
            ppp_inproc(sc, m);
            if (m == NULL)
                break;
            ppp_inproc(sc, m);
@@ -922,10 +940,8 @@ ppp_outpkt(sc)
        --m->m_len;
     }
 
        --m->m_len;
     }
 
-    s = splimp();
     sc->sc_togo = m;
     (*sc->sc_start)(sc);
     sc->sc_togo = m;
     (*sc->sc_start)(sc);
-    splx(s);
 }
 
 #ifdef PPP_COMPRESS
 }
 
 #ifdef PPP_COMPRESS
@@ -1068,6 +1084,7 @@ ppppktin(sc, m, lost)
 
 /*
  * Process a received PPP packet, doing decompression as necessary.
 
 /*
  * Process a received PPP packet, doing decompression as necessary.
+ * Should be called at splnet.
  */
 #define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \
                         TYPE_UNCOMPRESSED_TCP)
  */
 #define COMPTYPE(proto)        ((proto) == PPP_VJC_COMP? TYPE_COMPRESSED_TCP: \
                         TYPE_UNCOMPRESSED_TCP)
@@ -1087,6 +1104,9 @@ ppp_inproc(sc, m)
     sc->sc_if.if_ipackets++;
 
     if (sc->sc_flags & SC_LOG_INPKT) {
     sc->sc_if.if_ipackets++;
 
     if (sc->sc_flags & SC_LOG_INPKT) {
+       ilen = 0;
+       for (mp = m; mp != NULL; mp = mp->m_next)
+           ilen += mp->m_len;
        printf("ppp%d: got %d bytes\n", sc->sc_if.if_unit, ilen);
        pppdumpm(m);
     }
        printf("ppp%d: got %d bytes\n", sc->sc_if.if_unit, ilen);
        pppdumpm(m);
     }