fcstab and some ideas nicked from if_ppp.c from cmu.
See copyright notice in if_ppp.h and NOTES
- $Id: ppp_async.c,v 1.2 1994/12/05 00:54:58 paulus Exp $
+ $Id: ppp_async.c,v 1.3 1995/04/26 04:15:48 paulus Exp $
*/
#include <sys/types.h>
int x, flags;
switch (mp->b_datap->db_type) {
-
+
+ case M_CTL:
+ switch (*(u_char *)mp->b_rptr) {
+ case IF_GET_CSTATS:
+ /* trap this and remove it */
+ freemsg(mp);
+ break;
+ default:
+ putnext(q, mp);
+ }
+ break;
+
case M_FLUSH :
if (*mp->b_rptr & FLUSHW)
flushq(q, FLUSHDATA);
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
* OR MODIFICATIONS.
*
- * $Id: ppp_comp.c,v 1.2 1994/12/05 00:55:24 paulus Exp $
+ * $Id: ppp_comp.c,v 1.3 1995/04/26 04:15:48 paulus Exp $
*/
#include <net/net_globals.h>
int error, len, proto, state;
struct ppp_option_data *odp;
struct compressor **comp;
+ struct ppp_comp_stats *pcp;
cp = (struct ppp_comp_state *) q->q_ptr;
switch (mp->b_datap->db_type) {
+ case M_CTL:
+ switch (*(u_char *) mp->b_rptr) {
+ case IF_GET_CSTATS:
+ freemsg(mp);
+ mp = allocb(sizeof(struct ppp_comp_stats) + sizeof(u_long),
+ BPRI_HI);
+ if (mp != NULL) {
+ *(u_char *) mp->b_wptr = IF_CSTATS;
+ mp->b_wptr += sizeof(u_long); /* should be enough alignment */
+ pcp = (struct ppp_comp_stats *) mp->b_wptr;
+ mp->b_wptr += sizeof(struct ppp_comp_stats);
+ bzero(pcp, sizeof(struct ppp_comp_stats));
+ if (cp->xstate != NULL)
+ (*cp->xcomp->comp_stat)(cp->xstate, &pcp->c);
+ if (cp->rstate != NULL)
+ (*cp->rcomp->decomp_stat)(cp->rstate, &pcp->d);
+ qreply(q, mp);
+ }
+ break;
+ default:
+ putnext(q, mp);
+ }
+ break;
+
case M_DATA:
/* first find out what the protocol is */
if (mp->b_wptr - mp->b_rptr >= PPP_HDRLEN
#endif
#ifdef PPP_STATS
struct pppstat pii_stats;
+ struct ppp_comp_stats pii_cstats;
#endif
};
queue_t *q;
register mblk_t *mp;
{
- register u_char c;
register PII *p;
switch (mp->b_datap->db_type) {
case M_CTL:
p = (PII *) q->q_ptr;
if (p != NULL) {
- c = *(u_char *) mp->b_rptr;
- switch (c) {
+ switch (*(u_char *) mp->b_rptr) {
case IF_INPUT_ERROR :
p->pii_ifnet.if_ierrors++;
INCR(ppp_ierrors);
DLOG("ppp_if: output error inc to %d\n",
p->pii_ifnet.if_oerrors);
break;
- }
+ case IF_CSTATS:
+ bcopy(mp->b_rptr + sizeof(u_long), &p->pii_cstats,
+ sizeof(struct ppp_comp_stats));
+ freemsg(mp);
+ break;
+ default:
+ putnext(q, mp); /* send it up to pppd */
+ break;
+ }
}
- putnext(q, mp); /* send it up to pppd */
break;
default:
int len, xlen, count, s, pklen;
u_char *rptr;
int address, control;
+ int dlen;
p = (PII *) q->q_ptr;
}
len = msgdsize(mp);
+ dlen = len - PPP_HDRLEN;
#ifdef PPP_STATS
p->pii_stats.ppp_ibytes += len;
#endif
freemsg(mp);
continue;
}
+ dlen = len - xlen + hlen;
cp = mvjc->b_rptr;
cp[0] = address;
cp[1] = control;
mvjc->b_cont = mp;
mp->b_rptr += xlen;
m0 = mp = mvjc;
- len += PPP_HDRLEN + hlen;
break;
case PPP_VJC_UNCOMP :
continue;
}
len = MHLEN;
+ mb1->m_pkthdr.rcvif = &(p->pii_ifnet);
+ mb1->m_pkthdr.len = dlen;
mbtail = mb2 = mb1;
- pklen = 0;
+ mb1->m_len = 0;
rptr = mp->b_rptr + PPP_HDRLEN;
xlen = mp->b_wptr - rptr;
rptr += count;
len -= count;
xlen -= count;
- pklen += count;
mb2->m_len += count;
}
}
else {
*/
- ifp = &p->pii_ifnet;
- mb1->m_pkthdr.len = pklen;
- mb1->m_pkthdr.rcvif = ifp;
find_input_type(0x0800, mb1, ifp, 0);
}
} /* end while */
struct ppp_stats *psp;
struct ppp_comp_stats *pcp;
PII *p;
+ queue_t *q;
int error = 0;
switch (cmd) {
case SIOCGPPPCSTATS:
p = &pii[ifp->if_unit];
+ bzero(&p->pii_cstats, sizeof(struct ppp_comp_stats));
+
+ /* Make a message to send on the interface's write stream */
+ q = p->pii_writeq;
+ if (q != NULL) {
+ putctl1(q, M_CTL, IF_GET_CSTATS);
+ /*
+ * We assume the message gets passed along immediately, so
+ * by the time the putctl1 returns, the request has been
+ * processed, the values returned and p->pii_cstats has
+ * been updated. If not, we just get zeroes.
+ */
+ }
pcp = (struct ppp_comp_stats *)&((struct ifpppcstatsreq *)data)->stats;
- bzero(pcp, sizeof(struct ppp_comp_stats));
- /* XXX we need to fill in the compression stats */
+ bcopy(&p->pii_cstats, pcp, sizeof(struct ppp_comp_stats));
break;
- default :
- error = EINVAL;
- break;
+ default:
+ error = EINVAL;
+ break;
}
+
return(error);
}