+ LOCK_LOWER_R;
+ uq = (queue_t *) q->q_ptr;
+ if (uq != 0)
+ qenable(uq);
+ UNLOCK_LOWER;
+ return 0;
+}
+
+/*
+ * This should only get called for control streams.
+ */
+static int
+pppurput(q, mp)
+ queue_t *q;
+ 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;
+ if (ppa == 0) {
+ DPRINT("pppurput: q_ptr = 0!\n");
+ return 0;
+ }
+
+ switch (mp->b_datap->db_type) {
+ case M_CTL:
+ MT_ENTER(&ppa->stats_lock);
+ switch (*mp->b_rptr) {
+ case PPPCTL_IERROR:
+#ifdef INCR_IERRORS
+ INCR_IERRORS(ppa);
+#endif
+ ppa->stats.ppp_ierrors++;
+ break;
+ case PPPCTL_OERROR:
+#ifdef INCR_OERRORS
+ INCR_OERRORS(ppa);
+#endif
+ ppa->stats.ppp_oerrors++;
+ break;
+ }
+ MT_EXIT(&ppa->stats_lock);
+ freemsg(mp);
+ break;
+
+ case M_IOCACK:
+ case M_IOCNAK:
+ /*
+ * Attempt to match up the response with the stream
+ * that the request came from.
+ */
+ iop = (struct iocblk *) mp->b_rptr;
+ for (us = ppa; us != 0; us = us->next)
+ if (us->ioc_id == iop->ioc_id)
+ break;
+ if (us == 0)
+ freemsg(mp);
+ else
+ putnext(us->q, mp);
+ break;
+
+ case M_HANGUP:
+ /*
+ * The serial device has hung up. We don't want to send
+ * the M_HANGUP message up to pppd because that will stop
+ * us from using the control stream any more. Instead we
+ * send a zero-length message as an end-of-file indication.
+ */
+ freemsg(mp);
+ mp = allocb(1, BPRI_HI);
+ if (mp == 0) {
+ DPRINT1("ppp/%d: couldn't allocate eof message!\n", ppa->mn);
+ break;
+ }
+ putnext(ppa->q, mp);
+ break;
+
+ default:
+ if (mp->b_datap->db_type == M_DATA) {
+ len = msgdsize(mp);
+ if (mp->b_wptr - mp->b_rptr < PPP_HDRLEN) {
+ PULLUP(mp, PPP_HDRLEN);
+ if (mp == 0) {
+ DPRINT1("ppp_urput: msgpullup failed (len=%d)\n", len);
+ break;
+ }
+ }
+ MT_ENTER(&ppa->stats_lock);
+ ppa->stats.ppp_ipackets++;
+ ppa->stats.ppp_ibytes += len;
+#ifdef INCR_IPACKETS
+ INCR_IPACKETS(ppa);
+#endif
+ MT_EXIT(&ppa->stats_lock);
+
+ proto = PPP_PROTOCOL(mp->b_rptr);
+ if (proto < 0x8000 && (us = find_dest(ppa, proto)) != 0) {
+ /*
+ * A data packet for some network protocol.
+ * Queue it on the upper stream for that protocol.
+ * XXX could we just putnext it? (would require thought)
+ * The rblocked flag is there to ensure that we keep
+ * messages in order for each network protocol.
+ */
+ if (!pass_packet(us, mp, 0))
+ break;
+ if (!us->rblocked && !canput(us->q))
+ us->rblocked = 1;
+ if (!us->rblocked)
+ putq(us->q, mp);
+ else
+ putq(q, mp);
+ break;
+ }
+ }
+ /*
+ * A control frame, a frame for an unknown protocol,
+ * or some other message type.
+ * Send it up to pppd via the control stream.
+ */
+ if (queclass(mp) == QPCTL || canputnext(ppa->q))
+ putnext(ppa->q, mp);
+ else
+ putq(q, mp);
+ break;
+ }
+