]> git.ozlabs.org Git - ppp.git/blobdiff - modules/ppp.c
Previously, 64-bit compilation was dependent upon the version of the OS,
[ppp.git] / modules / ppp.c
index c99c1416c42d51caeec74df27546d40e5baf2d18..f0318f12ebb3998733f3d1a77b56aa172444756d 100644 (file)
@@ -24,7 +24,7 @@
  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
  * OR MODIFICATIONS.
  *
- * $Id: ppp.c,v 1.16 1999/02/26 10:52:06 paulus Exp $
+ * $Id: ppp.c,v 1.22 1999/09/17 05:59:00 paulus Exp $
  */
 
 /*
@@ -140,8 +140,8 @@ krwlock_t ppp_lower_lock;
 #define LOCK_LOWER_R   0
 #define TRYLOCK_LOWER_R        1
 #define UNLOCK_LOWER   0
-#define MUTEX_ENTER(x) 0
-#define MUTEX_EXIT(x)  0
+#define MT_ENTER(x)    0
+#define MT_EXIT(x)     0
 
 #endif /* SOL2 */
 
@@ -255,7 +255,9 @@ static upperstr_t *find_dest __P((upperstr_t *, int));
 static int putctl2 __P((queue_t *, int, int, int));
 static int putctl4 __P((queue_t *, int, int, int));
 static int pass_packet __P((upperstr_t *ppa, mblk_t *mp, int outbound));
+#ifdef FILTER_PACKETS
 static int ip_hard_filter __P((upperstr_t *ppa, mblk_t *mp, int outbound));
+#endif /* FILTER_PACKETS */
 
 #define PPP_ID 0xb1a6
 static struct module_info ppp_info = {
@@ -468,7 +470,7 @@ pppclose(q, flag)
 #endif
        if (up->lowerq != 0) {
            /* Gack! the lower stream should have be unlinked earlier! */
-           cmn_err(CE_WARN, "ppp%d: lower stream still connected on close?\n",
+           DPRINT1("ppp%d: lower stream still connected on close?\n",
                    up->mn);
            LOCK_LOWER_W;
            up->lowerq->q_ptr = 0;
@@ -556,7 +558,7 @@ pppuwput(q, mp)
     queue_t *q;
     mblk_t *mp;
 {
-    upperstr_t *us, *usnext, *ppa, *os, *nps;
+    upperstr_t *us, *ppa, *nps;
     struct iocblk *iop;
     struct linkblk *lb;
 #ifdef LACHTCP
@@ -567,10 +569,12 @@ pppuwput(q, mp)
     int error, n, sap;
     mblk_t *mq;
     struct ppp_idle *pip;
-    int len;
 #ifdef PRIOQ
     queue_t *tlq;
 #endif /* PRIOQ */
+#ifdef NO_DLPI
+    upperstr_t *os;
+#endif
 
     us = (upperstr_t *) q->q_ptr;
     if (us == 0) {
@@ -809,7 +813,7 @@ pppuwput(q, mp)
            if (n == PPPDBG_DUMP + PPPDBG_DRIVER) {
                qwriter(q, NULL, debug_dump, PERIM_OUTER);
                iop->ioc_count = 0;
-               error = 0;
+               error = -1;
            } else if (n == PPPDBG_LOG + PPPDBG_DRIVER) {
                DPRINT1("ppp/%d: debug log enabled\n", us->mn);
                us->flags |= US_DBGLOG;
@@ -1042,7 +1046,7 @@ dlpi_request(q, mp, us)
     int size = mp->b_wptr - mp->b_rptr;
     mblk_t *reply, *np;
     upperstr_t *ppa, *os;
-    int sap, *ip, len;
+    int sap, len;
     dl_info_ack_t *info;
     dl_bind_ack_t *ackp;
 
@@ -1098,7 +1102,7 @@ dlpi_request(q, mp, us)
        }
        us->ppa = ppa;
        qwriter(q, mp, attach_ppa, PERIM_OUTER);
-       break;
+       return;
 
     case DL_DETACH_REQ:
        if (size < sizeof(dl_detach_req_t))
@@ -1108,7 +1112,7 @@ dlpi_request(q, mp, us)
            break;
        }
        qwriter(q, mp, detach_ppa, PERIM_OUTER);
-       break;
+       return;
 
     case DL_BIND_REQ:
        if (size < sizeof(dl_bind_req_t))
@@ -1129,6 +1133,18 @@ dlpi_request(q, mp, us)
           except that we accept ETHERTYPE_IP in place of PPP_IP. */
        sap = d->bind_req.dl_sap;
        us->req_sap = sap;
+
+#ifdef SOL2
+        /* 
+        * ip will send a sap value of 0 (post-Solaris 7), or
+        * ETHERTYPE_IP (0x800) (pre-Solaris 8) due to how the
+        * ppp DLPI provider declares its characteristics.
+        * <adi.masputra@sun.com>
+        */
+       if (sap == 0)
+            sap = ETHERTYPE_IP;
+#endif /* SOL2 */
+
        if (sap == ETHERTYPE_IP)
            sap = PPP_IP;
        if (sap < 0x21 || sap > 0x3fff || (sap & 0x101) != 1) {
@@ -1423,7 +1439,6 @@ send_data(mp, us)
     mblk_t *mp;
     upperstr_t *us;
 {
-    queue_t *q;
     upperstr_t *ppa;
 
     if ((us->flags & US_BLOCKED) || us->npmode == NPMODE_QUEUE)
@@ -1435,7 +1450,7 @@ send_data(mp, us)
        freemsg(mp);
        return 1;
     }
-    if ((q = ppa->lowerq) == 0) {
+    if (ppa->lowerq == 0) {
        /* try to send it up the control stream */
         if (bcanputnext(ppa->q, mp->b_band)) {
            /*
@@ -1699,9 +1714,7 @@ pppurput(q, mp)
     mblk_t *mp;
 {
     upperstr_t *ppa, *us;
-    queue_t *uq;
     int proto, len;
-    mblk_t *np;
     struct iocblk *iop;
 
     ppa = (upperstr_t *) q->q_ptr;
@@ -1967,6 +1980,25 @@ ppplrput(q, mp)
     mblk_t *mp;
 {
     queue_t *uq;
+    struct iocblk *iop;
+
+    switch (mp->b_datap->db_type) {
+    case M_IOCTL:
+       iop = (struct iocblk *) mp->b_rptr;
+       iop->ioc_error = EINVAL;
+       mp->b_datap->db_type = M_IOCNAK;
+       qreply(q, mp);
+       return 0;
+    case M_FLUSH:
+       if (*mp->b_rptr & FLUSHR)
+           flushq(q, FLUSHDATA);
+       if (*mp->b_rptr & FLUSHW) {
+           *mp->b_rptr &= ~FLUSHR;
+           qreply(q, mp);
+       } else
+           freemsg(mp);
+       return 0;
+    }
 
     /*
      * If we can't get the lower lock straight away, queue this one
@@ -2073,8 +2105,8 @@ putctl4(q, type, code, val)
 
 static void
 debug_dump(q, mp)
-    queue_t *q;                        /* not used */
-    mblk_t *mp;                        /* not used either */
+    queue_t *q;
+    mblk_t *mp;
 {
     upperstr_t *us;
     queue_t *uq, *lq;
@@ -2100,6 +2132,8 @@ debug_dump(q, mp)
                    (lq? qsize(lq): 0), us->mru, us->mtu);
        }
     }
+    mp->b_datap->db_type = M_IOCACK;
+    qreply(q, mp);
 }
 
 #ifdef FILTER_PACKETS