From 411675bae35766a6137a33683240c043896ea3da Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Wed, 2 Jun 1999 15:59:09 +0000 Subject: [PATCH] o Alter the mbuf type as it's processed by different layers. o Show more information about missing MP fragments in ``show mp''. o Do away with mbuf_Log(). It was showing mbuf stats twice on receipt of LCP/CCP/IPCP packets.... ???!!? o Pre-allocate a bit extra when creating LQR packets to avoid having to allocate another mbuf in mbuf_Prepend(). --- usr.sbin/ppp/acf.c | 8 ++++-- usr.sbin/ppp/alias_cmd.c | 9 ++++--- usr.sbin/ppp/async.c | 6 ++--- usr.sbin/ppp/cbcp.c | 5 ++-- usr.sbin/ppp/ccp.c | 43 +++++++++++++++++++++++-------- usr.sbin/ppp/chap.c | 5 ++-- usr.sbin/ppp/deflate.c | 14 +++++----- usr.sbin/ppp/fsm.c | 31 +++++++++++----------- usr.sbin/ppp/fsm.h | 4 +-- usr.sbin/ppp/hdlc.c | 8 +++--- usr.sbin/ppp/ip.c | 5 ++-- usr.sbin/ppp/ipcp.c | 8 +++--- usr.sbin/ppp/lcp.c | 11 +++++--- usr.sbin/ppp/link.c | 4 +-- usr.sbin/ppp/lqr.c | 27 ++++++++++++++++---- usr.sbin/ppp/mbuf.c | 53 ++++++++++++++++++++++---------------- usr.sbin/ppp/mbuf.h | 55 ++++++++++++++++++++++++++++++---------- usr.sbin/ppp/mp.c | 31 +++++++++++++++++----- usr.sbin/ppp/nat_cmd.c | 9 ++++--- usr.sbin/ppp/pap.c | 7 ++--- usr.sbin/ppp/pred.c | 6 ++--- usr.sbin/ppp/proto.c | 5 ++-- usr.sbin/ppp/sync.c | 4 ++- usr.sbin/ppp/vjcomp.c | 10 +++++--- 24 files changed, 241 insertions(+), 127 deletions(-) diff --git a/usr.sbin/ppp/acf.c b/usr.sbin/ppp/acf.c index 2839ca29405b..450ea0ca877c 100644 --- a/usr.sbin/ppp/acf.c +++ b/usr.sbin/ppp/acf.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id:$ + * $Id: acf.c,v 1.1 1999/05/08 11:05:57 brian Exp $ */ #include @@ -61,8 +61,10 @@ acf_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp, { const u_char cp[2] = { HDLC_ADDR, HDLC_UI }; - if (*proto == PROTO_LCP || l->lcp.his_acfcomp == 0) + if (*proto == PROTO_LCP || l->lcp.his_acfcomp == 0) { bp = mbuf_Prepend(bp, cp, 2, 0); + mbuf_SetType(bp, MB_ACFOUT); + } return bp; } @@ -96,12 +98,14 @@ acf_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, u_short *proto) mbuf_Free(bp); return NULL; } + mbuf_SetType(bp, MB_ACFIN); } else if (cp[0] == HDLC_ADDR && cp[1] == HDLC_UI) { /* * We can receive compressed packets, but the peer still sends * uncompressed packets (or maybe this is a PROTO_LCP packet) ! */ bp = mbuf_Read(bp, cp, 2); + mbuf_SetType(bp, MB_ACFIN); } } diff --git a/usr.sbin/ppp/alias_cmd.c b/usr.sbin/ppp/alias_cmd.c index 07180a62c1b7..f823ff4e8e38 100644 --- a/usr.sbin/ppp/alias_cmd.c +++ b/usr.sbin/ppp/alias_cmd.c @@ -2,7 +2,7 @@ * The code in this file was written by Eivind Eklund , * who places it in the public domain without restriction. * - * $Id: alias_cmd.c,v 1.24 1999/05/08 11:05:59 brian Exp $ + * $Id: alias_cmd.c,v 1.25 1999/05/12 09:48:39 brian Exp $ */ #include @@ -313,6 +313,7 @@ alias_PadMbuf(struct mbuf *bp, int type) struct mbuf **last; int len; + mbuf_SetType(bp, type); for (last = &bp, len = 0; *last != NULL; last = &(*last)->next) len += (*last)->cnt; @@ -330,7 +331,7 @@ alias_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, return bp; log_Printf(LogDEBUG, "alias_LayerPush: PROTO_IP -> PROTO_IP\n"); - bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_IPQ)); + bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_ALIASOUT)); PacketAliasOut(MBUF_CTOP(bp), bp->cnt); bp->cnt = ntohs(((struct ip *)MBUF_CTOP(bp))->ip_len); @@ -350,7 +351,7 @@ alias_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp, return bp; log_Printf(LogDEBUG, "alias_LayerPull: PROTO_IP -> PROTO_IP\n"); - bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_IPIN)); + bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_ALIASIN)); pip = (struct ip *)MBUF_CTOP(bp); piip = (struct ip *)((char *)pip + (pip->ip_hl << 2)); @@ -383,7 +384,7 @@ alias_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp, last = &bp->pnext; while ((fptr = PacketAliasGetFragment(MBUF_CTOP(bp))) != NULL) { PacketAliasFragmentIn(MBUF_CTOP(bp), fptr); - *last = mbuf_Alloc(ntohs(((struct ip *)fptr)->ip_len), MB_IPIN); + *last = mbuf_Alloc(ntohs(((struct ip *)fptr)->ip_len), MB_ALIASIN); memcpy(MBUF_CTOP(*last), fptr, (*last)->cnt); free(fptr); last = &(*last)->pnext; diff --git a/usr.sbin/ppp/async.c b/usr.sbin/ppp/async.c index 4d7160f19790..c8b93c8c0438 100644 --- a/usr.sbin/ppp/async.c +++ b/usr.sbin/ppp/async.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: async.c,v 1.19 1999/05/08 11:06:03 brian Exp $ + * $Id: async.c,v 1.20 1999/05/12 09:48:40 brian Exp $ * */ #include @@ -116,7 +116,7 @@ async_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, cnt = cp - p->async.xbuff; mbuf_Free(bp); - bp = mbuf_Alloc(cnt, MB_ASYNC); + bp = mbuf_Alloc(cnt, MB_ASYNCOUT); memcpy(MBUF_CTOP(bp), p->async.xbuff, cnt); log_DumpBp(LogASYNC, "Write", bp); @@ -135,7 +135,7 @@ async_Decode(struct async *async, u_char c) case HDLC_SYN: async->mode &= ~MODE_HUNT; if (async->length) { /* packet is ready. */ - bp = mbuf_Alloc(async->length, MB_ASYNC); + bp = mbuf_Alloc(async->length, MB_ASYNCIN); mbuf_Write(bp, async->hbuff, async->length); async->length = 0; return bp; diff --git a/usr.sbin/ppp/cbcp.c b/usr.sbin/ppp/cbcp.c index bea92f394420..1c4d3cc53888 100644 --- a/usr.sbin/ppp/cbcp.c +++ b/usr.sbin/ppp/cbcp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cbcp.c,v 1.11 1999/03/29 08:21:26 brian Exp $ + * $Id: cbcp.c,v 1.12 1999/05/08 11:06:10 brian Exp $ */ #include @@ -195,7 +195,7 @@ cbcp_Output(struct cbcp *cbcp, u_char code, struct cbcp_data *data) struct cbcp_header *head; struct mbuf *bp; - bp = mbuf_Alloc(sizeof *head + data->length, MB_CBCP); + bp = mbuf_Alloc(sizeof *head + data->length, MB_CBCPOUT); head = (struct cbcp_header *)MBUF_CTOP(bp); head->code = code; head->id = cbcp->fsm.id; @@ -630,6 +630,7 @@ cbcp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) mbuf_Free(bp); return NULL; } + mbuf_SetType(bp, MB_CBCPIN); /* XXX check the id */ diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index 03328648163d..f29a5fc61b5f 100644 --- a/usr.sbin/ppp/ccp.c +++ b/usr.sbin/ppp/ccp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.c,v 1.48 1999/05/09 20:02:17 brian Exp $ + * $Id: ccp.c,v 1.49 1999/05/12 09:48:43 brian Exp $ * * TODO: * o Support other compression protocols @@ -282,7 +282,7 @@ CcpSendConfigReq(struct fsm *fp) o = &(*o)->next; } - fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, cp - buff); + fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, cp - buff, MB_CCPOUT); } void @@ -293,7 +293,7 @@ ccp_SendResetReq(struct fsm *fp) ccp->reset_sent = fp->reqid; ccp->last_reset = -1; - fsm_Output(fp, CODE_RESETREQ, fp->reqid, NULL, 0); + fsm_Output(fp, CODE_RESETREQ, fp->reqid, NULL, 0, MB_CCPOUT); } static void @@ -306,7 +306,7 @@ static void CcpSendTerminateAck(struct fsm *fp, u_char id) { /* Send Term ACK please */ - fsm_Output(fp, CODE_TERMACK, id, NULL, 0); + fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_CCPOUT); } static void @@ -534,6 +534,7 @@ extern struct mbuf * ccp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) { /* Got PROTO_CCP from link */ + mbuf_SetType(bp, MB_CCPIN); if (bundle_Phase(bundle) == PHASE_NETWORK) fsm_Input(&l->ccp.fsm, bp); else { @@ -578,9 +579,18 @@ ccp_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp, int pri, u_short *proto) { if (PROTO_COMPRESSIBLE(*proto) && l->ccp.fsm.state == ST_OPENED && - l->ccp.out.state != NULL) - return (*algorithm[l->ccp.out.algorithm]->o.Write) - (l->ccp.out.state, &l->ccp, l, pri, proto, bp); + l->ccp.out.state != NULL) { + bp = (*algorithm[l->ccp.out.algorithm]->o.Write) + (l->ccp.out.state, &l->ccp, l, pri, proto, bp); + switch (*proto) { + case PROTO_ICOMPD: + mbuf_SetType(bp, MB_ICOMPDOUT); + break; + case PROTO_COMPD: + mbuf_SetType(bp, MB_COMPDOUT); + break; + } + } return bp; } @@ -599,10 +609,21 @@ ccp_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, u_short *proto) /* Decompress incoming data */ if (l->ccp.reset_sent != -1) /* Send another REQ and put the packet in the bit bucket */ - fsm_Output(&l->ccp.fsm, CODE_RESETREQ, l->ccp.reset_sent, NULL, 0); - else if (l->ccp.in.state != NULL) - return (*algorithm[l->ccp.in.algorithm]->i.Read) - (l->ccp.in.state, &l->ccp, proto, bp); + fsm_Output(&l->ccp.fsm, CODE_RESETREQ, l->ccp.reset_sent, NULL, 0, + MB_CCPOUT); + else if (l->ccp.in.state != NULL) { + bp = (*algorithm[l->ccp.in.algorithm]->i.Read) + (l->ccp.in.state, &l->ccp, proto, bp); + switch (*proto) { + case PROTO_ICOMPD: + mbuf_SetType(bp, MB_ICOMPDIN); + break; + case PROTO_COMPD: + mbuf_SetType(bp, MB_COMPDIN); + break; + } + return bp; + } mbuf_Free(bp); bp = NULL; } else if (PROTO_COMPRESSIBLE(*proto) && l->ccp.in.state != NULL) { diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index 541a71d3ca39..1ae6d8e6d8a9 100644 --- a/usr.sbin/ppp/chap.c +++ b/usr.sbin/ppp/chap.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.c,v 1.49 1999/04/21 08:03:51 brian Exp $ + * $Id: chap.c,v 1.50 1999/05/08 11:06:15 brian Exp $ * * TODO: */ @@ -93,7 +93,7 @@ ChapOutput(struct physical *physical, u_int code, u_int id, lh.code = code; lh.id = id; lh.length = htons(plen); - bp = mbuf_Alloc(plen, MB_FSM); + bp = mbuf_Alloc(plen, MB_CHAPOUT); memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader)); if (count) memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count); @@ -559,6 +559,7 @@ chap_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) return NULL; } + mbuf_SetType(bp, MB_CHAPIN); if ((bp = auth_ReadHeader(&chap->auth, bp)) == NULL && ntohs(chap->auth.in.hdr.length) == 0) log_Printf(LogWARN, "Chap Input: Truncated header !\n"); diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c index 261d3e2a7452..b8ac7f0744af 100644 --- a/usr.sbin/ppp/deflate.c +++ b/usr.sbin/ppp/deflate.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: deflate.c,v 1.12 1999/03/11 01:49:15 brian Exp $ + * $Id: deflate.c,v 1.13 1999/05/08 11:06:25 brian Exp $ */ #include @@ -82,7 +82,7 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short *proto, log_DumpBp(LogDEBUG, "DeflateOutput: Compress packet:", mp); /* Stuff the protocol in front of the input */ - mi_head = mi = mbuf_Alloc(2, MB_HDLCOUT); + mi_head = mi = mbuf_Alloc(2, MB_CCPOUT); mi->next = mp; rp = MBUF_CTOP(mi); if (*proto < 0x100) { /* Compress the protocol */ @@ -95,7 +95,7 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short *proto, } /* Allocate the initial output mbuf */ - mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_HDLCOUT); + mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_CCPOUT); mo->cnt = 2; wp = MBUF_CTOP(mo); *wp++ = state->seqno >> 8; @@ -135,7 +135,7 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short *proto, } if (state->cx.avail_out == 0) { - mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_HDLCOUT); + mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_CCPOUT); olen += (mo->cnt = DEFLATE_CHUNK_LEN); mo = mo->next; mo->cnt = 0; @@ -234,7 +234,7 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi) state->uncomp_rec = 0; /* Allocate an output mbuf */ - mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_IPIN); + mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_CCPIN); /* Our proto starts with 0 if it's compressed */ wp = MBUF_CTOP(mo); @@ -291,7 +291,7 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi) first = 0; } else { olen += (mo->cnt = DEFLATE_CHUNK_LEN); - mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_IPIN); + mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_CCPIN); mo = mo->next; state->cx.next_out = MBUF_CTOP(mo); state->cx.avail_out = DEFLATE_CHUNK_LEN; @@ -350,7 +350,7 @@ DeflateDictSetup(void *v, struct ccp *ccp, u_short proto, struct mbuf *mi) * Stuff an ``uncompressed data'' block header followed by the * protocol in front of the input */ - mi_head = mbuf_Alloc(7, MB_HDLCOUT); + mi_head = mbuf_Alloc(7, MB_CCPOUT); mi_head->next = mi; len = mbuf_Length(mi); mi = mi_head; diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 034d971f6677..50b82102d6ee 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.43 1999/05/09 20:02:18 brian Exp $ + * $Id: fsm.c,v 1.44 1999/05/14 09:36:04 brian Exp $ * * TODO: */ @@ -175,7 +175,8 @@ NewState(struct fsm *fp, int new) } void -fsm_Output(struct fsm *fp, u_int code, u_int id, u_char *ptr, int count) +fsm_Output(struct fsm *fp, u_int code, u_int id, u_char *ptr, int count, + int mtype) { int plen; struct fsmheader lh; @@ -200,7 +201,7 @@ fsm_Output(struct fsm *fp, u_int code, u_int id, u_char *ptr, int count) lh.code = code; lh.id = id; lh.length = htons(plen); - bp = mbuf_Alloc(plen, MB_FSM); + bp = mbuf_Alloc(plen, mtype); memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader)); if (count) memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count); @@ -379,7 +380,7 @@ FsmSendConfigReq(struct fsm *fp) static void FsmSendTerminateReq(struct fsm *fp) { - fsm_Output(fp, CODE_TERMREQ, fp->reqid, NULL, 0); + fsm_Output(fp, CODE_TERMREQ, fp->reqid, NULL, 0, MB_UNKNOWN); (*fp->fn->SentTerminateReq)(fp); timer_Start(&fp->FsmTimer); /* Start restart timer */ fp->restart--; /* Decrement restart counter */ @@ -520,11 +521,14 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) } if (dec.rejend != dec.rej) - fsm_Output(fp, CODE_CONFIGREJ, lhp->id, dec.rej, dec.rejend - dec.rej); + fsm_Output(fp, CODE_CONFIGREJ, lhp->id, dec.rej, dec.rejend - dec.rej, + MB_UNKNOWN); if (dec.nakend != dec.nak) - fsm_Output(fp, CODE_CONFIGNAK, lhp->id, dec.nak, dec.nakend - dec.nak); + fsm_Output(fp, CODE_CONFIGNAK, lhp->id, dec.nak, dec.nakend - dec.nak, + MB_UNKNOWN); if (ackaction) - fsm_Output(fp, CODE_CONFIGACK, lhp->id, dec.ack, dec.ackend - dec.ack); + fsm_Output(fp, CODE_CONFIGACK, lhp->id, dec.ack, dec.ackend - dec.ack, + MB_UNKNOWN); switch (fp->state) { case ST_STOPPED: @@ -881,6 +885,7 @@ FsmRecvEchoReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) u_char *cp; u_int32_t magic; + mbuf_SetType(bp, MB_ECHOIN); if (lcp && mbuf_Length(bp) >= 4) { cp = MBUF_CTOP(bp); ua_ntohl(cp, &magic); @@ -891,7 +896,7 @@ FsmRecvEchoReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) } if (fp->state == ST_OPENED) { ua_htonl(&lcp->want_magic, cp); /* local magic */ - fsm_Output(fp, CODE_ECHOREP, lhp->id, cp, mbuf_Length(bp)); + fsm_Output(fp, CODE_ECHOREP, lhp->id, cp, mbuf_Length(bp), MB_ECHOOUT); } } mbuf_Free(bp); @@ -934,7 +939,7 @@ FsmRecvResetReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) * at the peer before our ResetAck. */ link_SequenceQueue(fp->link); - fsm_Output(fp, CODE_RESETACK, lhp->id, NULL, 0); + fsm_Output(fp, CODE_RESETACK, lhp->id, NULL, 0, MB_CCPOUT); mbuf_Free(bp); } @@ -968,7 +973,7 @@ fsm_Input(struct fsm *fp, struct mbuf *bp) bp = mbuf_Prepend(bp, &lh, sizeof lh, 0); bp = mbuf_Contiguous(bp); - fsm_Output(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->cnt); + fsm_Output(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->cnt, MB_UNKNOWN); mbuf_Free(bp); return; } @@ -984,17 +989,11 @@ fsm_Input(struct fsm *fp, struct mbuf *bp) log_Printf(fp->LogLevel, "%s: Recv%s(%d) state = %s\n", fp->link->name, codep->name, lh.id, State2Nam(fp->state)); - if (log_IsKept(LogDEBUG)) - mbuf_Log(); - if (codep->inc_reqid && (lh.id == fp->reqid || (!Enabled(fp->bundle, OPT_IDCHECK) && codep->check_reqid))) fp->reqid++; /* That's the end of that ``exchange''.... */ (*codep->recv)(fp, &lh, bp); - - if (log_IsKept(LogDEBUG)) - mbuf_Log(); } void diff --git a/usr.sbin/ppp/fsm.h b/usr.sbin/ppp/fsm.h index c25a6ba87706..1d38a140486b 100644 --- a/usr.sbin/ppp/fsm.h +++ b/usr.sbin/ppp/fsm.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.h,v 1.19 1998/06/25 22:33:24 brian Exp $ + * $Id: fsm.h,v 1.20 1999/02/26 21:28:11 brian Exp $ * * TODO: */ @@ -160,7 +160,7 @@ struct fsmconfig { extern void fsm_Init(struct fsm *, const char *, u_short, int, int, int, struct bundle *, struct link *, const struct fsm_parent *, struct fsm_callbacks *, const char *[3]); -extern void fsm_Output(struct fsm *, u_int, u_int, u_char *, int); +extern void fsm_Output(struct fsm *, u_int, u_int, u_char *, int, int); extern void fsm_Open(struct fsm *); extern void fsm_Up(struct fsm *); extern void fsm_Down(struct fsm *); diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c index a2042ff48705..f9696455bbc6 100644 --- a/usr.sbin/ppp/hdlc.c +++ b/usr.sbin/ppp/hdlc.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: hdlc.c,v 1.41 1999/04/03 11:54:00 brian Exp $ + * $Id: hdlc.c,v 1.42 1999/05/08 11:06:36 brian Exp $ * * TODO: */ @@ -158,6 +158,7 @@ hdlc_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, u_char *cp; u_short fcs; + mbuf_SetType(bp, MB_HDLCOUT); fcs = HdlcFcsBuf(INITFCS, bp); fcs = ~fcs; @@ -344,13 +345,12 @@ hdlc_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, } bp = mbuf_Truncate(bp, len - 2); /* discard the FCS */ + mbuf_SetType(bp, MB_HDLCIN); return bp; } -/* - * Detect a HDLC frame - */ +/* Detect a HDLC frame */ static const struct frameheader { const u_char *data; diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index 8bc72a13acc5..9336b9b0713f 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.c,v 1.61 1999/05/14 09:35:51 brian Exp $ + * $Id: ip.c,v 1.62 1999/05/31 23:57:39 brian Exp $ * * TODO: * o Return ICMP message for filterd packet @@ -393,6 +393,7 @@ ip_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) return NULL; } + mbuf_SetType(bp, MB_IPIN); tun_fill_header(tun, AF_INET); nb = mbuf_Length(bp); if (nb > sizeof tun.data) { @@ -439,7 +440,7 @@ ip_Enqueue(struct ipcp *ipcp, int pri, char *ptr, int count) * mbuf_Prepend() in acf_LayerPush() and proto_LayerPush() and * appending in hdlc_LayerPush(). */ - bp = mbuf_Alloc(count + 6, MB_IPQ); + bp = mbuf_Alloc(count + 6, MB_IPOUT); bp->offset += 4; bp->cnt -= 6; memcpy(MBUF_CTOP(bp), ptr, count); diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index bcd040398e0a..5d72e3ff77e6 100644 --- a/usr.sbin/ppp/ipcp.c +++ b/usr.sbin/ppp/ipcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.c,v 1.77 1999/05/09 20:02:19 brian Exp $ + * $Id: ipcp.c,v 1.78 1999/05/31 23:57:40 brian Exp $ * * TODO: * o Support IPADDRS properly @@ -640,7 +640,8 @@ IpcpSendConfigReq(struct fsm *fp) INC_LCP_OPT(TY_SECONDARY_DNS, 6, o); } - fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff); + fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff, + MB_IPCPOUT); } static void @@ -653,7 +654,7 @@ static void IpcpSendTerminateAck(struct fsm *fp, u_char id) { /* Send Term ACK please */ - fsm_Output(fp, CODE_TERMACK, id, NULL, 0); + fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_IPCPOUT); } static void @@ -1144,6 +1145,7 @@ extern struct mbuf * ipcp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) { /* Got PROTO_IPCP from link */ + mbuf_SetType(bp, MB_IPCPIN); if (bundle_Phase(bundle) == PHASE_NETWORK) fsm_Input(&bundle->ncp.ipcp.fsm, bp); else { diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index c7f059db275b..e225f5c69a11 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.73 1999/05/08 11:06:51 brian Exp $ + * $Id: lcp.c,v 1.74 1999/05/09 20:02:21 brian Exp $ * */ @@ -430,14 +430,16 @@ LcpSendConfigReq(struct fsm *fp) INC_LCP_OPT(TY_ENDDISC, mp->cfg.enddisc.len + 3, o); } - fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff); + fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff, + MB_LCPOUT); } void lcp_SendProtoRej(struct lcp *lcp, u_char *option, int count) { /* Don't understand `option' */ - fsm_Output(&lcp->fsm, CODE_PROTOREJ, lcp->fsm.reqid, option, count); + fsm_Output(&lcp->fsm, CODE_PROTOREJ, lcp->fsm.reqid, option, count, + MB_LCPOUT); } static void @@ -455,7 +457,7 @@ LcpSendTerminateAck(struct fsm *fp, u_char id) if (p && p->dl->state == DATALINK_CBCP) cbcp_ReceiveTerminateReq(p); - fsm_Output(fp, CODE_TERMACK, id, NULL, 0); + fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_LCPOUT); } static void @@ -1148,6 +1150,7 @@ extern struct mbuf * lcp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) { /* Got PROTO_LCP from link */ + mbuf_SetType(bp, MB_LCPIN); fsm_Input(&l->lcp.fsm, bp); return NULL; } diff --git a/usr.sbin/ppp/link.c b/usr.sbin/ppp/link.c index 9cc1d51dc408..e4ba819708c7 100644 --- a/usr.sbin/ppp/link.c +++ b/usr.sbin/ppp/link.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: link.c,v 1.10 1999/05/12 09:48:51 brian Exp $ + * $Id: link.c,v 1.11 1999/05/15 02:24:18 brian Exp $ * */ @@ -245,7 +245,7 @@ link_PullPacket(struct link *l, char *buf, size_t len, struct bundle *b) link_AddInOctets(l, len); memset(lbp, '\0', sizeof lbp); - lbp[0] = mbuf_Alloc(len, MB_ASYNC); + lbp[0] = mbuf_Alloc(len, MB_UNKNOWN); memcpy(MBUF_CTOP(lbp[0]), buf, len); lproto[0] = 0; layer = 0; diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c index 31e40e3cd4ba..541021b9f2ab 100644 --- a/usr.sbin/ppp/lqr.c +++ b/usr.sbin/ppp/lqr.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lqr.c,v 1.34 1999/05/09 20:02:23 brian Exp $ + * $Id: lqr.c,v 1.35 1999/05/14 09:36:06 brian Exp $ * * o LQR based on RFC1333 * @@ -75,7 +75,7 @@ SendEchoReq(struct lcp *lcp) echo.signature = htonl(SIGNATURE); echo.sequence = htonl(hdlc->lqm.echo.seq_sent); fsm_Output(&lcp->fsm, CODE_ECHOREQ, hdlc->lqm.echo.seq_sent++, - (u_char *)&echo, sizeof echo); + (u_char *)&echo, sizeof echo, MB_ECHOOUT); } struct mbuf * @@ -132,8 +132,13 @@ static void SendLqrData(struct lcp *lcp) { struct mbuf *bp; + int extra; - bp = mbuf_Alloc(sizeof(struct lqrdata), MB_LQR); + extra = proto_WrapperOctets(lcp, PROTO_LQR) + + acf_WrapperOctets(lcp, PROTO_LQR); + bp = mbuf_Alloc(sizeof(struct lqrdata) + extra, MB_LQROUT); + bp->cnt -= extra; + bp->offset += extra; link_PushPacket(lcp->fsm.link, bp, lcp->fsm.bundle, PRI_LINK, PROTO_LQR); } @@ -383,7 +388,7 @@ lqr_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp, p->hdlc.lqm.OutPackets++; if (*proto == PROTO_LQR) { - /* Overwrite the entire packet */ + /* Overwrite the entire packet (created in SendLqrData()) */ struct lqrdata lqr; lqr.MagicNumber = p->link.lcp.want_magic; @@ -414,9 +419,21 @@ lqr_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp, return bp; } +static struct mbuf * +lqr_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, u_short *proto) +{ + /* + * We mark the packet as ours but don't do anything 'till it's dispatched + * to lqr_Input() + */ + if (*proto == PROTO_LQR) + mbuf_SetType(bp, MB_LQRIN); + return bp; +} + /* * Statistics for pulled packets are recorded either in hdlc_PullPacket() * or sync_PullPacket() */ -struct layer lqrlayer = { LAYER_LQR, "lqr", lqr_LayerPush, NULL }; +struct layer lqrlayer = { LAYER_LQR, "lqr", lqr_LayerPush, lqr_LayerPull }; diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c index 1dea2e2801ac..49969d179a6a 100644 --- a/usr.sbin/ppp/mbuf.c +++ b/usr.sbin/ppp/mbuf.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.c,v 1.25 1999/05/08 11:07:07 brian Exp $ + * $Id: mbuf.c,v 1.26 1999/05/09 20:02:24 brian Exp $ * */ #include @@ -39,7 +39,7 @@ static struct memmap { struct mbuf *queue; int fragments, octets; -} MemMap[MB_MAX + 2]; +} MemMap[MB_MAX + 1]; static int totalalloced; static unsigned long long mbuf_Mallocs, mbuf_Frees; @@ -59,8 +59,10 @@ mbuf_Alloc(int cnt, int type) { struct mbuf *bp; - if (type > MB_MAX) + if (type > MB_MAX) { log_Printf(LogERROR, "Bad mbuf type %d\n", type); + type = MB_UNKNOWN; + } bp = malloc(sizeof(struct mbuf) + cnt); if (bp == NULL) { log_Printf(LogALERT, "failed to allocate memory: %ld\n", @@ -168,7 +170,7 @@ mbuf_Prepend(struct mbuf *bp, const void *ptr, size_t len, size_t extra) bp->offset = 0; } - head = mbuf_Alloc(len + extra, bp ? bp->type : MB_FSM); + head = mbuf_Alloc(len + extra, bp ? bp->type : MB_UNKNOWN); head->offset = extra; head->cnt -= extra; memcpy(MBUF_CTOP(head), ptr, len); @@ -219,18 +221,24 @@ mbuf_Show(struct cmdargs const *arg) { int i; static const char *mbuftype[] = { - "async", "fsm", "cbcp", "hdlcout", "ipin", "echo", "lqr", "vjcomp", - "ipq", "mp" }; + "ip in", "ip out", "alias in", "alias out", "mp in", "mp out", + "vj in", "vj out", "icompd in", "icompd out", "compd in", "compd out", + "lqr in", "lqr out", "echo in", "echo out", "proto in", "proto out", + "acf in", "acf out", "sync in", "sync out", "hdlc in", "hdlc out", + "async in", "async out", "cbcp in", "cbcp out", "chap in", "chap out", + "pap in", "pap out", "ccp in", "ccp out", "ipcp in", "ipcp out", + "lcp in", "lcp out", "unknown" + }; prompt_Printf(arg->prompt, "Fragments (octets) in use:\n"); - for (i = 1; i < MB_MAX; i += 2) + for (i = 0; i < MB_MAX; i += 2) prompt_Printf(arg->prompt, "%10.10s: %04d (%06d)\t%10.10s: %04d (%06d)\n", - mbuftype[i-1], MemMap[i].fragments, MemMap[i].octets, mbuftype[i], - MemMap[i+1].fragments, MemMap[i+1].octets); + mbuftype[i], MemMap[i].fragments, MemMap[i].octets, + mbuftype[i+1], MemMap[i+1].fragments, MemMap[i+1].octets); if (i == MB_MAX) prompt_Printf(arg->prompt, "%10.10s: %04d (%06d)\n", - mbuftype[i-1], MemMap[i].fragments, MemMap[i].octets); + mbuftype[i], MemMap[i].fragments, MemMap[i].octets); prompt_Printf(arg->prompt, "Mallocs: %qu, Frees: %qu\n", mbuf_Mallocs, mbuf_Frees); @@ -238,18 +246,6 @@ mbuf_Show(struct cmdargs const *arg) return 0; } -void -mbuf_Log() -{ - log_Printf(LogDEBUG, "mbuf_Log: mem alloced: %d\n", totalalloced); - log_Printf(LogDEBUG, "mbuf_Log: 1: %d 2: %d 3: %d 4: %d\n", - MemMap[1].octets, MemMap[2].octets, MemMap[3].octets, MemMap[4].octets); - log_Printf(LogDEBUG, "mbuf_Log: 5: %d 6: %d 7: %d 8: %d\n", - MemMap[5].octets, MemMap[6].octets, MemMap[7].octets, MemMap[8].octets); - log_Printf(LogDEBUG, "mbuf_Log: 9: %d 10: %d 11: %d\n", - MemMap[9].octets, MemMap[10].octets, MemMap[11].octets); -} - struct mbuf * mbuf_Dequeue(struct mqueue *q) { @@ -313,3 +309,16 @@ mbuf_Contiguous(struct mbuf *bp) return bp; } + +void +mbuf_SetType(struct mbuf *bp, int type) +{ + for (; bp; bp = bp->next) + if (type != bp->type) { + MemMap[bp->type].fragments--; + MemMap[bp->type].octets -= bp->size; + bp->type = type; + MemMap[type].fragments++; + MemMap[type].octets += bp->size; + } +} diff --git a/usr.sbin/ppp/mbuf.h b/usr.sbin/ppp/mbuf.h index f18f69332ebc..ad76cf695fce 100644 --- a/usr.sbin/ppp/mbuf.h +++ b/usr.sbin/ppp/mbuf.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.h,v 1.16 1999/05/08 11:07:09 brian Exp $ + * $Id: mbuf.h,v 1.17 1999/05/09 20:02:25 brian Exp $ * * TODO: */ @@ -42,17 +42,46 @@ struct mqueue { #define CONST_MBUF_CTOP(bp) \ ((bp) ? (const u_char *)((bp)+1) + (bp)->offset : NULL) -#define MB_ASYNC 1 -#define MB_FSM 2 -#define MB_CBCP 3 -#define MB_HDLCOUT 4 -#define MB_IPIN 5 -#define MB_ECHO 6 -#define MB_LQR 7 -#define MB_VJCOMP 8 -#define MB_IPQ 9 -#define MB_MP 10 -#define MB_MAX MB_MP +#define MB_IPIN 0 +#define MB_IPOUT 1 +#define MB_ALIASIN 2 +#define MB_ALIASOUT 3 +#define MB_MPIN 4 +#define MB_MPOUT 5 +#define MB_VJIN 6 +#define MB_VJOUT 7 +#define MB_ICOMPDIN 8 +#define MB_ICOMPDOUT 9 +#define MB_COMPDIN 10 +#define MB_COMPDOUT 11 +#define MB_LQRIN 12 +#define MB_LQROUT 13 +#define MB_ECHOIN 14 +#define MB_ECHOOUT 15 +#define MB_PROTOIN 16 +#define MB_PROTOOUT 17 +#define MB_ACFIN 18 +#define MB_ACFOUT 19 +#define MB_SYNCIN 20 +#define MB_SYNCOUT 21 +#define MB_HDLCIN 22 +#define MB_HDLCOUT 23 +#define MB_ASYNCIN 24 +#define MB_ASYNCOUT 25 +#define MB_CBCPIN 26 +#define MB_CBCPOUT 27 +#define MB_CHAPIN 28 +#define MB_CHAPOUT 29 +#define MB_PAPIN 30 +#define MB_PAPOUT 31 +#define MB_CCPIN 32 +#define MB_CCPOUT 33 +#define MB_IPCPIN 34 +#define MB_IPCPOUT 35 +#define MB_LCPIN 36 +#define MB_LCPOUT 37 +#define MB_UNKNOWN 38 +#define MB_MAX MB_UNKNOWN struct cmdargs; @@ -65,8 +94,8 @@ extern struct mbuf *mbuf_Read(struct mbuf *, void *, size_t); extern size_t mbuf_View(struct mbuf *, void *, size_t); extern struct mbuf *mbuf_Prepend(struct mbuf *, const void *, size_t, size_t); extern struct mbuf *mbuf_Truncate(struct mbuf *, size_t); -extern void mbuf_Log(void); extern int mbuf_Show(struct cmdargs const *); extern void mbuf_Enqueue(struct mqueue *, struct mbuf *); extern struct mbuf *mbuf_Dequeue(struct mqueue *); extern struct mbuf *mbuf_Contiguous(struct mbuf *); +extern void mbuf_SetType(struct mbuf *, int); diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index 2f206de4e6b3..373957b2d0f6 100644 --- a/usr.sbin/ppp/mp.c +++ b/usr.sbin/ppp/mp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp.c,v 1.20 1999/05/12 09:48:55 brian Exp $ + * $Id: mp.c,v 1.21 1999/05/28 08:03:24 brian Exp $ */ #include @@ -537,8 +537,10 @@ mp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) if (p == NULL) { log_Printf(LogWARN, "DecodePacket: Can't do MP inside MP !\n"); mbuf_Free(bp); - } else + } else { + mbuf_SetType(bp, MB_MPIN); mp_Assemble(&bundle->ncp.mp, bp, p); + } return NULL; } @@ -550,7 +552,7 @@ mp_Output(struct mp *mp, struct bundle *bundle, struct link *l, struct mbuf *mo; /* Stuff an MP header on the front of our packet and send it */ - mo = mbuf_Alloc(4, MB_MP); + mo = mbuf_Alloc(4, MB_MPOUT); mo->next = m; if (mp->peer_is12bit) { u_int16_t val; @@ -639,8 +641,9 @@ mp_FillQueues(struct bundle *bundle) */ mo = m; end = 1; + mbuf_SetType(mo, MB_MPOUT); } else { - mo = mbuf_Alloc(dl->mp.weight, MB_MP); + mo = mbuf_Alloc(dl->mp.weight, MB_MPOUT); mo->cnt = dl->mp.weight; len -= mo->cnt; m = mbuf_Read(m, MBUF_CTOP(mo), mo->cnt); @@ -690,14 +693,28 @@ mp_ShowStatus(struct cmdargs const *arg) prompt_Printf(arg->prompt, "Multilink is %sactive\n", mp->active ? "" : "in"); if (mp->active) { - struct mbuf *m; + struct mbuf *m, *lm; int bufs = 0; prompt_Printf(arg->prompt, "Socket: %s\n", mp->server.socket.sun_path); - for (m = mp->inbufs; m; m = m->pnext) + for (m = mp->inbufs; m; m = m->pnext) { bufs++; - prompt_Printf(arg->prompt, "Pending frags: %d\n", bufs); + lm = m; + } + prompt_Printf(arg->prompt, "Pending frags: %d", bufs); + if (bufs) { + struct mp_header mh; + unsigned long first, last; + + first = mp_ReadHeader(mp, mp->inbufs, &mh) ? mh.seq : 0; + last = mp_ReadHeader(mp, lm, &mh) ? mh.seq : 0; + prompt_Printf(arg->prompt, " (Have %lu - %lu, want %lu, lowest %lu)", + first, last, (unsigned long)mp->seq.next_in, + (unsigned long)mp->seq.min_in); + prompt_Printf(arg->prompt, " first is %d, %d", mh.begin ? 1 : 0, mh.end ? 1 : 0); + } + prompt_Printf(arg->prompt, "\n"); } prompt_Printf(arg->prompt, "\nMy Side:\n"); diff --git a/usr.sbin/ppp/nat_cmd.c b/usr.sbin/ppp/nat_cmd.c index 07180a62c1b7..f823ff4e8e38 100644 --- a/usr.sbin/ppp/nat_cmd.c +++ b/usr.sbin/ppp/nat_cmd.c @@ -2,7 +2,7 @@ * The code in this file was written by Eivind Eklund , * who places it in the public domain without restriction. * - * $Id: alias_cmd.c,v 1.24 1999/05/08 11:05:59 brian Exp $ + * $Id: alias_cmd.c,v 1.25 1999/05/12 09:48:39 brian Exp $ */ #include @@ -313,6 +313,7 @@ alias_PadMbuf(struct mbuf *bp, int type) struct mbuf **last; int len; + mbuf_SetType(bp, type); for (last = &bp, len = 0; *last != NULL; last = &(*last)->next) len += (*last)->cnt; @@ -330,7 +331,7 @@ alias_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, return bp; log_Printf(LogDEBUG, "alias_LayerPush: PROTO_IP -> PROTO_IP\n"); - bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_IPQ)); + bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_ALIASOUT)); PacketAliasOut(MBUF_CTOP(bp), bp->cnt); bp->cnt = ntohs(((struct ip *)MBUF_CTOP(bp))->ip_len); @@ -350,7 +351,7 @@ alias_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp, return bp; log_Printf(LogDEBUG, "alias_LayerPull: PROTO_IP -> PROTO_IP\n"); - bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_IPIN)); + bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_ALIASIN)); pip = (struct ip *)MBUF_CTOP(bp); piip = (struct ip *)((char *)pip + (pip->ip_hl << 2)); @@ -383,7 +384,7 @@ alias_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp, last = &bp->pnext; while ((fptr = PacketAliasGetFragment(MBUF_CTOP(bp))) != NULL) { PacketAliasFragmentIn(MBUF_CTOP(bp), fptr); - *last = mbuf_Alloc(ntohs(((struct ip *)fptr)->ip_len), MB_IPIN); + *last = mbuf_Alloc(ntohs(((struct ip *)fptr)->ip_len), MB_ALIASIN); memcpy(MBUF_CTOP(*last), fptr, (*last)->cnt); free(fptr); last = &(*last)->pnext; diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index d9ada44919b7..2976f66f7850 100644 --- a/usr.sbin/ppp/pap.c +++ b/usr.sbin/ppp/pap.c @@ -18,7 +18,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pap.c,v 1.34 1999/04/01 11:05:23 brian Exp $ + * $Id: pap.c,v 1.35 1999/05/08 11:07:20 brian Exp $ * * TODO: */ @@ -86,7 +86,7 @@ pap_Req(struct authinfo *authp) lh.code = PAP_REQUEST; lh.id = authp->id; lh.length = htons(plen + sizeof(struct fsmheader)); - bp = mbuf_Alloc(plen + sizeof(struct fsmheader), MB_FSM); + bp = mbuf_Alloc(plen + sizeof(struct fsmheader), MB_PAPOUT); memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader)); cp = MBUF_CTOP(bp) + sizeof(struct fsmheader); *cp++ = namelen; @@ -110,7 +110,7 @@ SendPapCode(struct authinfo *authp, int code, const char *message) mlen = strlen(message); plen = mlen + 1; lh.length = htons(plen + sizeof(struct fsmheader)); - bp = mbuf_Alloc(plen + sizeof(struct fsmheader), MB_FSM); + bp = mbuf_Alloc(plen + sizeof(struct fsmheader), MB_PAPOUT); memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader)); cp = MBUF_CTOP(bp) + sizeof(struct fsmheader); *cp++ = mlen; @@ -191,6 +191,7 @@ pap_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) mbuf_Free(bp); return NULL; } + mbuf_SetType(bp, MB_PAPIN); authp->id = authp->in.hdr.id; /* We respond with this id */ if (bp) { diff --git a/usr.sbin/ppp/pred.c b/usr.sbin/ppp/pred.c index df4d604c9e35..1982caeb1d3a 100644 --- a/usr.sbin/ppp/pred.c +++ b/usr.sbin/ppp/pred.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pred.c,v 1.25 1999/05/08 11:07:28 brian Exp $ + * $Id: pred.c,v 1.26 1999/05/09 20:02:25 brian Exp $ */ #include @@ -180,7 +180,7 @@ Pred1Output(void *v, struct ccp *ccp, struct link *l, int pri, u_short *proto, u_short fcs; orglen = mbuf_Length(bp) + 2; /* add count of proto */ - mwp = mbuf_Alloc((orglen + 2) / 8 * 9 + 12, MB_HDLCOUT); + mwp = mbuf_Alloc((orglen + 2) / 8 * 9 + 12, MB_CCPOUT); hp = wp = MBUF_CTOP(mwp); cp = bufp; *wp++ = *cp++ = orglen >> 8; @@ -221,7 +221,7 @@ Pred1Input(void *v, struct ccp *ccp, u_short *proto, struct mbuf *bp) u_char *bufp; u_short fcs; - wp = mbuf_Alloc(MAX_MRU + 2, MB_IPIN); + wp = mbuf_Alloc(MAX_MRU + 2, MB_CCPIN); cp = MBUF_CTOP(bp); olen = mbuf_Length(bp); pp = bufp = MBUF_CTOP(wp); diff --git a/usr.sbin/ppp/proto.c b/usr.sbin/ppp/proto.c index d6d34d700876..2a64473a4393 100644 --- a/usr.sbin/ppp/proto.c +++ b/usr.sbin/ppp/proto.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: proto.c,v 1.1 1999/05/08 11:07:32 brian Exp $ + * $Id: proto.c,v 1.2 1999/05/12 09:49:01 brian Exp $ */ #include @@ -75,6 +75,7 @@ proto_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp, log_Printf(LogDEBUG, "proto_LayerPush: Using 0x%04x\n", *proto); bp = proto_Prepend(bp, *proto, l->lcp.his_protocomp, acf_WrapperOctets(&l->lcp, *proto)); + mbuf_SetType(bp, MB_PROTOOUT); link_ProtocolRecord(l, *proto, PROTO_OUT); return bp; @@ -104,7 +105,7 @@ proto_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, bp = mbuf_Read(bp, cp, 1); log_Printf(LogDEBUG, "proto_LayerPull: unknown -> 0x%04x\n", *proto); - + mbuf_SetType(bp, MB_PROTOIN); link_ProtocolRecord(l, *proto, PROTO_IN); return bp; diff --git a/usr.sbin/ppp/sync.c b/usr.sbin/ppp/sync.c index 4f6afe0fcf55..77f6e4755eab 100644 --- a/usr.sbin/ppp/sync.c +++ b/usr.sbin/ppp/sync.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sync.c,v 1.2 1999/05/12 09:49:02 brian Exp $ + * $Id: sync.c,v 1.3 1999/05/12 09:54:33 brian Exp $ */ #include @@ -53,6 +53,7 @@ sync_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, int pri, u_short *proto) { log_DumpBp(LogSYNC, "Write", bp); + mbuf_SetType(bp, MB_SYNCOUT); return bp; } @@ -70,6 +71,7 @@ sync_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, /* Either done here or by the HDLC layer */ p->hdlc.lqm.SaveInOctets += mbuf_Length(bp) + 1; p->hdlc.lqm.SaveInPackets++; + mbuf_SetType(bp, MB_SYNCIN); } return bp; diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c index 6de5d5673fdb..a9783cefacf5 100644 --- a/usr.sbin/ppp/vjcomp.c +++ b/usr.sbin/ppp/vjcomp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vjcomp.c,v 1.29 1999/05/09 20:02:29 brian Exp $ + * $Id: vjcomp.c,v 1.30 1999/05/12 09:49:12 brian Exp $ * * TODO: */ @@ -81,11 +81,13 @@ vj_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, int pri, case TYPE_UNCOMPRESSED_TCP: *proto = PROTO_VJUNCOMP; log_Printf(LogDEBUG, "vj_LayerPush: PROTO_IP -> PROTO_VJUNCOMP\n"); + mbuf_SetType(bp, MB_VJOUT); break; case TYPE_COMPRESSED_TCP: *proto = PROTO_VJCOMP; log_Printf(LogDEBUG, "vj_LayerPush: PROTO_IP -> PROTO_VJUNCOMP\n"); + mbuf_SetType(bp, MB_VJOUT); break; default: @@ -119,7 +121,8 @@ VjUncompressTcp(struct ipcp *ipcp, struct mbuf *bp, u_char type) if (len <= 0) { mbuf_Free(bp); bp = NULL; - } + } else + mbuf_SetType(bp, MB_VJIN); return bp; } @@ -141,8 +144,9 @@ VjUncompressTcp(struct ipcp *ipcp, struct mbuf *bp, u_char type) } len -= olen; len += rlen; - nbp = mbuf_Alloc(len, MB_VJCOMP); + nbp = mbuf_Alloc(len, MB_VJIN); memcpy(MBUF_CTOP(nbp), bufp, len); + mbuf_SetType(bp, MB_VJIN); nbp->next = bp; return nbp; }