This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / sys / net / if_ppp.c
index 786a858..f638445 100644 (file)
@@ -70,7 +70,7 @@
  */
 
 /*
  */
 
 /*
- *     $Id: if_ppp.c,v 1.6 1993/12/19 00:52:03 wollman Exp $
+ *     $Id: if_ppp.c,v 1.11 1994/03/23 01:58:24 ache Exp $
  *     From: if_ppp.c,v 1.22 1993/08/31 23:20:40 paulus Exp
  *     From: if_ppp.c,v 1.21 1993/08/29 11:22:37 paulus Exp
  *     From: if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp 
  *     From: if_ppp.c,v 1.22 1993/08/31 23:20:40 paulus Exp
  *     From: if_ppp.c,v 1.21 1993/08/29 11:22:37 paulus Exp
  *     From: if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp 
@@ -92,6 +92,7 @@
 #include "kernel.h"
 #include "conf.h"
 #include "dkstat.h"
 #include "kernel.h"
 #include "conf.h"
 #include "dkstat.h"
+#include "pppdefs.h"
 
 #include "if.h"
 #include "if_types.h"
 
 #include "if.h"
 #include "if_types.h"
@@ -347,7 +348,7 @@ pppread(tp, uio, flag)
     register int s;
     int error = 0;
 
     register int s;
     int error = 0;
 
-    if ((tp->t_state & TS_CARR_ON)==0)
+    if (!CAN_DO_IO(tp))
        return (EIO);
     s = splimp();
     while (sc->sc_inq.ifq_head == NULL && tp->t_line == PPPDISC) {
        return (EIO);
     s = splimp();
     while (sc->sc_inq.ifq_head == NULL && tp->t_line == PPPDISC) {
@@ -355,7 +356,7 @@ pppread(tp, uio, flag)
            splx(s);
            return (EWOULDBLOCK);
        }
            splx(s);
            return (EWOULDBLOCK);
        }
-       error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI|PCATCH, ttyin, 0);
+       error = ttysleep(tp, (caddr_t)tp->t_rawq, TTIPRI|PCATCH, ttyin, 0);
        if (error)
            return error;
     }
        if (error)
            return error;
     }
@@ -365,7 +366,7 @@ pppread(tp, uio, flag)
     }
 
     /* Pull place-holder byte out of canonical queue */
     }
 
     /* Pull place-holder byte out of canonical queue */
-    getc(&tp->t_canq);
+    getc(tp->t_canq);
 
     /* Get the packet from the input queue */
     IF_DEQUEUE(&sc->sc_inq, m0);
 
     /* Get the packet from the input queue */
     IF_DEQUEUE(&sc->sc_inq, m0);
@@ -393,7 +394,7 @@ pppwrite(tp, uio, flag)
     struct ppp_header *ph1, *ph2;
     int len, error;
 
     struct ppp_header *ph1, *ph2;
     int len, error;
 
-    if ((tp->t_state & TS_CARR_ON)==0)
+    if (!CAN_DO_IO(tp))
        return (EIO);
     if (tp->t_line != PPPDISC)
        return (EINVAL);
        return (EIO);
     if (tp->t_line != PPPDISC)
        return (EINVAL);
@@ -589,7 +590,7 @@ pppoutput(ifp, m0, dst, rt)
        error = ENETDOWN;       /* sort of */
        goto bad;
     }
        error = ENETDOWN;       /* sort of */
        goto bad;
     }
-    if ((sc->sc_ttyp->t_state & TS_CARR_ON) == 0) {
+    if (!CAN_DO_IO(sc->sc_ttyp)) {
        error = EHOSTUNREACH;
        goto bad;
     }
        error = EHOSTUNREACH;
        goto bad;
     }
@@ -715,9 +716,9 @@ pppstart(tp)
         * We are being called in lieu of ttstart and must do what
         * it would.
         */
         * We are being called in lieu of ttstart and must do what
         * it would.
         */
-       if (CCOUNT(&tp->t_outq) != 0 && tp->t_oproc != NULL) {
+       if (CCOUNT(tp->t_outq) != 0 && tp->t_oproc != NULL) {
            (*tp->t_oproc)(tp);
            (*tp->t_oproc)(tp);
-           if (CCOUNT(&tp->t_outq) > PPP_HIWAT)
+           if (CCOUNT(tp->t_outq) > PPP_HIWAT)
                return;
        }
        /*
                return;
        }
        /*
@@ -809,9 +810,9 @@ pppstart(tp)
             * will flush any accumulated garbage.  We do this whenever
             * the line may have been idle for some time.
             */
             * will flush any accumulated garbage.  We do this whenever
             * the line may have been idle for some time.
             */
-           if (CCOUNT(&tp->t_outq) == 0) {
+           if (CCOUNT(tp->t_outq) == 0) {
                ++sc->sc_bytessent;
                ++sc->sc_bytessent;
-               (void) putc(PPP_FLAG, &tp->t_outq);
+               (void) putc(PPP_FLAG, tp->t_outq);
            }
 
            /* Calculate the FCS for the first mbuf's worth. */
            }
 
            /* Calculate the FCS for the first mbuf's worth. */
@@ -834,7 +835,7 @@ pppstart(tp)
                if (n) {
 #ifndef        RB_LEN
                    /* NetBSD (0.9 or later), 4.3-Reno or similar. */
                if (n) {
 #ifndef        RB_LEN
                    /* NetBSD (0.9 or later), 4.3-Reno or similar. */
-                   ndone = n - b_to_q(start, n, &tp->t_outq);
+                   ndone = n - b_to_q(start, n, tp->t_outq);
 #else
 #ifdef NetBSD
                    /* NetBSD with 2-byte ring buffer entries */
 #else
 #ifdef NetBSD
                    /* NetBSD with 2-byte ring buffer entries */
@@ -843,12 +844,12 @@ pppstart(tp)
                    /* 386BSD, FreeBSD */
                    int cc, nleft;
                    for (nleft = n; nleft > 0; nleft -= cc) {
                    /* 386BSD, FreeBSD */
                    int cc, nleft;
                    for (nleft = n; nleft > 0; nleft -= cc) {
-                       if ((cc = RB_CONTIGPUT(&tp->t_out)) == 0)
+                       if ((cc = RB_CONTIGPUT(tp->t_out)) == 0)
                            break;
                        cc = min (cc, nleft);
                            break;
                        cc = min (cc, nleft);
-                       bcopy((char *)start + n - nleft, tp->t_out.rb_tl, cc);
-                       tp->t_out.rb_tl = RB_ROLLOVER(&tp->t_out,
-                                                     tp->t_out.rb_tl + cc);
+                       bcopy((char *)start + n - nleft, tp->t_out->rb_tl, cc);
+                       tp->t_out->rb_tl = RB_ROLLOVER(tp->t_out,
+                                                     tp->t_out->rb_tl + cc);
                    }
                    ndone = n - nleft;
 #endif /* NetBSD */
                    }
                    ndone = n - nleft;
 #endif /* NetBSD */
@@ -866,10 +867,10 @@ pppstart(tp)
                 * Put it out in a different form.
                 */
                if (len) {
                 * Put it out in a different form.
                 */
                if (len) {
-                   if (putc(PPP_ESCAPE, &tp->t_outq))
+                   if (putc(PPP_ESCAPE, tp->t_outq))
                        break;
                        break;
-                   if (putc(*start ^ PPP_TRANS, &tp->t_outq)) {
-                       (void) unputc(&tp->t_outq);
+                   if (putc(*start ^ PPP_TRANS, tp->t_outq)) {
+                       (void) unputc(tp->t_outq);
                        break;
                    }
                    sc->sc_bytessent += 2;
                        break;
                    }
                    sc->sc_bytessent += 2;
@@ -912,10 +913,10 @@ pppstart(tp)
                 * don't all fit, back out.
                 */
                for (q = endseq; q < p; ++q)
                 * don't all fit, back out.
                 */
                for (q = endseq; q < p; ++q)
-                   if (putc(*q, &tp->t_outq)) {
+                   if (putc(*q, tp->t_outq)) {
                        done = 0;
                        for (; q > endseq; --q)
                        done = 0;
                        for (; q > endseq; --q)
-                           unputc(&tp->t_outq);
+                           unputc(tp->t_outq);
                        break;
                    }
            }
                        break;
                    }
            }
@@ -1213,7 +1214,7 @@ pppinput(c, tp)
             * Some other protocol - place on input queue for read().
             * Put a placeholder byte in canq for ttselect()/ttnread().
             */
             * Some other protocol - place on input queue for read().
             * Put a placeholder byte in canq for ttselect()/ttnread().
             */
-           putc(0, &tp->t_canq);
+           putc(0, tp->t_canq);
            ttwakeup(tp);
            inq = &sc->sc_inq;
            break;
            ttwakeup(tp);
            inq = &sc->sc_inq;
            break;