diff options
author | brian <brian@FreeBSD.org> | 1999-05-08 11:07:56 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-05-08 11:07:56 +0000 |
commit | ab7d88ae2d8ea955c6193cc242b9cee4d58f8fd4 (patch) | |
tree | e79816f983bd5a5be86a78fe0aafbd00a13ac2db /usr.sbin/ppp/ccp.c | |
parent | 713dd62834d401cc7b9b394a4b916ab9e5e3d4d5 (diff) | |
download | FreeBSD-src-ab7d88ae2d8ea955c6193cc242b9cee4d58f8fd4.zip FreeBSD-src-ab7d88ae2d8ea955c6193cc242b9cee4d58f8fd4.tar.gz |
o Redesign the layering mechanism and make the aliasing code part of
the layering.
We now ``stack'' layers as soon as we open the device (when we figure
out what we're dealing with). A static set of `dispatch' routines are
also declared for dealing with incoming packets after they've been
`pulled' up through the stacked layers.
Physical devices are now assigned handlers based on the device type
when they're opened. For the moment there are three device types;
ttys, execs and tcps.
o Increment version number to 2.2
o Make an entry in [uw]tmp for non-tty -direct invocations (after
pap/chap authentication).
o Make throughput counters quad_t's
o Account for the absolute number of mbuf malloc()s and free()s in
``show mem''.
o ``show modem'' becomes ``show physical''.
Diffstat (limited to 'usr.sbin/ppp/ccp.c')
-rw-r--r-- | usr.sbin/ppp/ccp.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index e5adc98..1b84252 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.45 1999/03/31 14:21:44 brian Exp $ + * $Id: ccp.c,v 1.46 1999/05/02 14:33:39 brian Exp $ * * TODO: * o Support other compression protocols @@ -33,13 +33,14 @@ #include <string.h> #include <termios.h> +#include "layer.h" #include "defs.h" #include "command.h" #include "mbuf.h" #include "log.h" #include "timer.h" #include "fsm.h" -#include "lcpproto.h" +#include "proto.h" #include "lcp.h" #include "ccp.h" #include "pred.h" @@ -144,11 +145,13 @@ ccp_ReportStatus(struct cmdargs const *arg) prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name, State2Nam(ccp->fsm.state)); - prompt_Printf(arg->prompt, " My protocol = %s, His protocol = %s\n", - protoname(ccp->my_proto), protoname(ccp->his_proto)); - prompt_Printf(arg->prompt, " Output: %ld --> %ld, Input: %ld --> %ld\n", - ccp->uncompout, ccp->compout, - ccp->compin, ccp->uncompin); + if (ccp->fsm.state == ST_OPENED) { + prompt_Printf(arg->prompt, " My protocol = %s, His protocol = %s\n", + protoname(ccp->my_proto), protoname(ccp->his_proto)); + prompt_Printf(arg->prompt, " Output: %ld --> %ld, Input: %ld --> %ld\n", + ccp->uncompout, ccp->compout, + ccp->compin, ccp->uncompin); + } prompt_Printf(arg->prompt, "\n Defaults: "); prompt_Printf(arg->prompt, "FSM retry = %us, max %u Config" @@ -529,18 +532,19 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, } } -void -ccp_Input(struct ccp *ccp, struct bundle *bundle, struct mbuf *bp) +extern struct mbuf * +ccp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) { /* Got PROTO_CCP from link */ if (bundle_Phase(bundle) == PHASE_NETWORK) - fsm_Input(&ccp->fsm, bp); + fsm_Input(&l->ccp.fsm, bp); else { if (bundle_Phase(bundle) < PHASE_NETWORK) log_Printf(LogCCP, "%s: Error: Unexpected CCP in phase %s (ignored)\n", - ccp->fsm.link->name, bundle_PhaseName(bundle)); + l->ccp.fsm.link->name, bundle_PhaseName(bundle)); mbuf_Free(bp); } + return NULL; } static void @@ -571,42 +575,40 @@ CcpRecvResetAck(struct fsm *fp, u_char id) (*algorithm[ccp->in.algorithm]->i.Reset)(ccp->in.state); } -int -ccp_Compress(struct ccp *ccp, struct link *l, int pri, u_short proto, - struct mbuf *m) +static struct mbuf * +ccp_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp, + int pri, u_short *proto) { - /* - * Compress outgoing data. It's already deemed to be suitable Network - * Layer data. - */ - if (ccp->fsm.state == ST_OPENED && ccp->out.state != NULL) - return (*algorithm[ccp->out.algorithm]->o.Write) - (ccp->out.state, ccp, l, pri, proto, m); - return 0; + 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); + + return bp; } -struct mbuf * -ccp_Decompress(struct ccp *ccp, u_short *proto, struct mbuf *bp) +static struct mbuf * +ccp_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, u_short *proto) { /* * If proto isn't PROTO_[I]COMPD, we still want to pass it to the * decompression routines so that the dictionary's updated */ - if (ccp->fsm.state == ST_OPENED) { + if (l->ccp.fsm.state == ST_OPENED) { if (*proto == PROTO_COMPD || *proto == PROTO_ICOMPD) { /* Decompress incoming data */ - if (ccp->reset_sent != -1) + if (l->ccp.reset_sent != -1) /* Send another REQ and put the packet in the bit bucket */ - fsm_Output(&ccp->fsm, CODE_RESETREQ, ccp->reset_sent, NULL, 0); - else if (ccp->in.state != NULL) - return (*algorithm[ccp->in.algorithm]->i.Read) - (ccp->in.state, ccp, proto, bp); + 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); mbuf_Free(bp); bp = NULL; - } else if (PROTO_COMPRESSIBLE(*proto) && ccp->in.state != NULL) + } else if (PROTO_COMPRESSIBLE(*proto) && l->ccp.in.state != NULL) /* Add incoming Network Layer traffic to our dictionary */ - (*algorithm[ccp->in.algorithm]->i.DictSetup) - (ccp->in.state, ccp, *proto, bp); + (*algorithm[l->ccp.in.algorithm]->i.DictSetup) + (l->ccp.in.state, &l->ccp, *proto, bp); } return bp; @@ -638,3 +640,5 @@ ccp_SetOpenMode(struct ccp *ccp) return 0; /* No CCP at all */ } + +struct layer ccplayer = { LAYER_CCP, "ccp", ccp_LayerPush, ccp_LayerPull }; |