2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
4 * Internet Initiative Japan, Inc (IIJ)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/param.h>
32 #include <netinet/in.h>
33 #include <netinet/in_systm.h>
34 #include <netinet/ip.h>
35 #include <sys/socket.h>
40 #include <string.h> /* memcpy() on some archs */
53 #include "throughput.h"
55 #include "slcompress.h"
63 #include "descriptor.h"
79 static void CcpSendConfigReq(struct fsm *);
80 static void CcpSentTerminateReq(struct fsm *);
81 static void CcpSendTerminateAck(struct fsm *, u_char);
82 static void CcpDecodeConfig(struct fsm *, u_char *, u_char *, int,
84 static void CcpLayerStart(struct fsm *);
85 static void CcpLayerFinish(struct fsm *);
86 static int CcpLayerUp(struct fsm *);
87 static void CcpLayerDown(struct fsm *);
88 static void CcpInitRestartCounter(struct fsm *, int);
89 static int CcpRecvResetReq(struct fsm *);
90 static void CcpRecvResetAck(struct fsm *, u_char);
92 static struct fsm_callbacks ccp_Callbacks = {
97 CcpInitRestartCounter,
106 static const char * const ccp_TimerNames[] =
107 {"CCP restart", "CCP openmode", "CCP stopped"};
112 static char const * const cftypes[] = {
113 /* Check out the latest ``Compression Control Protocol'' rfc (1962) */
115 "PRED1", /* 1: Predictor type 1 */
116 "PRED2", /* 2: Predictor type 2 */
117 "PUDDLE", /* 3: Puddle Jumber */
118 NULL, NULL, NULL, NULL, NULL, NULL,
119 NULL, NULL, NULL, NULL, NULL, NULL,
120 "HWPPC", /* 16: Hewlett-Packard PPC */
121 "STAC", /* 17: Stac Electronics LZS (rfc1974) */
122 "MPPE", /* 18: Microsoft PPC (rfc2118) and */
123 /* Microsoft PPE (draft-ietf-pppext-mppe) */
124 "GAND", /* 19: Gandalf FZA (rfc1993) */
125 "V42BIS", /* 20: ARG->DATA.42bis compression */
126 "BSD", /* 21: BSD LZW Compress */
128 "LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */
129 "MAGNALINK/DEFLATE",/* 24: Magnalink Variable Resource (rfc1975) */
130 /* 24: Deflate (according to pppd-2.3.*) */
131 "DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */
132 "DEFLATE", /* 26: Deflate (rfc1979) */
135 if (proto < 0 || proto > sizeof cftypes / sizeof *cftypes ||
136 cftypes[proto] == NULL) {
139 return HexStr(proto, NULL, 0);
142 return cftypes[proto];
145 /* We support these algorithms, and Req them in the given order */
146 static const struct ccp_algorithm * const algorithm[] = {
149 &PppdDeflateAlgorithm
155 #define NALGORITHMS (sizeof algorithm/sizeof algorithm[0])
158 ccp_ReportStatus(struct cmdargs const *arg)
165 l = command_ChooseLink(arg);
168 prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name,
169 State2Nam(ccp->fsm.state));
170 if (ccp->fsm.state == ST_OPENED) {
171 prompt_Printf(arg->prompt, " My protocol = %s, His protocol = %s\n",
172 protoname(ccp->my_proto), protoname(ccp->his_proto));
173 prompt_Printf(arg->prompt, " Output: %ld --> %ld, Input: %ld --> %ld\n",
174 ccp->uncompout, ccp->compout,
175 ccp->compin, ccp->uncompin);
178 if (ccp->in.algorithm != -1)
179 prompt_Printf(arg->prompt, "\n Input Options: %s\n",
180 (*algorithm[ccp->in.algorithm]->Disp)(&ccp->in.opt));
182 if (ccp->out.algorithm != -1) {
184 for (f = 0; f < ccp->out.algorithm; f++)
185 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
187 prompt_Printf(arg->prompt, " Output Options: %s\n",
188 (*algorithm[ccp->out.algorithm]->Disp)(&(*o)->val));
191 prompt_Printf(arg->prompt, "\n Defaults: ");
192 prompt_Printf(arg->prompt, "FSM retry = %us, max %u Config"
193 " REQ%s, %u Term REQ%s\n", ccp->cfg.fsm.timeout,
194 ccp->cfg.fsm.maxreq, ccp->cfg.fsm.maxreq == 1 ? "" : "s",
195 ccp->cfg.fsm.maxtrm, ccp->cfg.fsm.maxtrm == 1 ? "" : "s");
196 prompt_Printf(arg->prompt, " deflate windows: ");
197 prompt_Printf(arg->prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize);
198 prompt_Printf(arg->prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize);
200 prompt_Printf(arg->prompt, " MPPE: ");
201 if (ccp->cfg.mppe.keybits)
202 prompt_Printf(arg->prompt, "%d bits, ", ccp->cfg.mppe.keybits);
204 prompt_Printf(arg->prompt, "any bits, ");
205 switch (ccp->cfg.mppe.state) {
207 prompt_Printf(arg->prompt, "stateful");
210 prompt_Printf(arg->prompt, "stateless");
213 prompt_Printf(arg->prompt, "any state");
216 prompt_Printf(arg->prompt, "%s\n",
217 ccp->cfg.mppe.required ? ", required" : "");
220 prompt_Printf(arg->prompt, "\n DEFLATE: %s\n",
221 command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE]));
222 prompt_Printf(arg->prompt, " PREDICTOR1: %s\n",
223 command_ShowNegval(ccp->cfg.neg[CCP_NEG_PRED1]));
224 prompt_Printf(arg->prompt, " DEFLATE24: %s\n",
225 command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE24]));
227 prompt_Printf(arg->prompt, " MPPE: %s\n",
228 command_ShowNegval(ccp->cfg.neg[CCP_NEG_MPPE]));
234 ccp_SetupCallbacks(struct ccp *ccp)
236 ccp->fsm.fn = &ccp_Callbacks;
237 ccp->fsm.FsmTimer.name = ccp_TimerNames[0];
238 ccp->fsm.OpenTimer.name = ccp_TimerNames[1];
239 ccp->fsm.StoppedTimer.name = ccp_TimerNames[2];
243 ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l,
244 const struct fsm_parent *parent)
246 /* Initialise ourselves */
248 fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, LogCCP,
249 bundle, l, parent, &ccp_Callbacks, ccp_TimerNames);
251 ccp->cfg.deflate.in.winsize = 0;
252 ccp->cfg.deflate.out.winsize = 15;
253 ccp->cfg.fsm.timeout = DEF_FSMRETRY;
254 ccp->cfg.fsm.maxreq = DEF_FSMTRIES;
255 ccp->cfg.fsm.maxtrm = DEF_FSMTRIES;
256 ccp->cfg.neg[CCP_NEG_DEFLATE] = NEG_ENABLED|NEG_ACCEPTED;
257 ccp->cfg.neg[CCP_NEG_PRED1] = NEG_ENABLED|NEG_ACCEPTED;
258 ccp->cfg.neg[CCP_NEG_DEFLATE24] = 0;
260 ccp->cfg.mppe.keybits = 0;
261 ccp->cfg.mppe.state = MPPE_ANYSTATE;
262 ccp->cfg.mppe.required = 0;
263 ccp->cfg.neg[CCP_NEG_MPPE] = NEG_ENABLED|NEG_ACCEPTED;
270 ccp_Setup(struct ccp *ccp)
272 /* Set ourselves up for a startup */
273 ccp->fsm.open_mode = 0;
274 ccp->his_proto = ccp->my_proto = -1;
275 ccp->reset_sent = ccp->last_reset = -1;
276 ccp->in.algorithm = ccp->out.algorithm = -1;
277 ccp->in.state = ccp->out.state = NULL;
278 ccp->in.opt.hdr.id = -1;
280 ccp->his_reject = ccp->my_reject = 0;
281 ccp->uncompout = ccp->compout = 0;
282 ccp->uncompin = ccp->compin = 0;
286 * Is ccp *REQUIRED* ?
287 * We ask each of the configured ccp protocols if they're required and
288 * return TRUE if they are.
290 * It's not possible for the peer to reject a required ccp protocol
291 * without our state machine bringing the supporting lcp layer down.
293 * If ccp is required but not open, the NCP layer should not push
294 * any data into the link.
297 ccp_Required(struct ccp *ccp)
301 for (f = 0; f < NALGORITHMS; f++)
302 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
303 (*algorithm[f]->Required)(&ccp->fsm))
310 * Report whether it's possible to increase a packet's size after
311 * compression (and by how much).
314 ccp_MTUOverhead(struct ccp *ccp)
316 if (ccp->fsm.state == ST_OPENED && ccp->out.algorithm >= 0)
317 return algorithm[ccp->out.algorithm]->o.MTUOverhead;
323 CcpInitRestartCounter(struct fsm *fp, int what)
325 /* Set fsm timer load */
326 struct ccp *ccp = fsm2ccp(fp);
328 fp->FsmTimer.load = ccp->cfg.fsm.timeout * SECTICKS;
331 fp->restart = ccp->cfg.fsm.maxreq;
334 fp->restart = ccp->cfg.fsm.maxtrm;
343 CcpSendConfigReq(struct fsm *fp)
345 /* Send config REQ please */
346 struct ccp *ccp = fsm2ccp(fp);
348 u_char *cp, buff[100];
353 alloc = ccp->his_reject == 0 && ccp->out.opt == NULL;
355 ccp->out.algorithm = -1;
356 for (f = 0; f < NALGORITHMS; f++)
357 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
358 !REJECTED(ccp, algorithm[f]->id) &&
359 (*algorithm[f]->Usable)(fp)) {
362 for (o = &ccp->out.opt; *o != NULL; o = &(*o)->next)
363 if ((*o)->val.hdr.id == algorithm[f]->id && (*o)->algorithm == f)
366 if (alloc || *o == NULL) {
367 *o = (struct ccp_opt *)malloc(sizeof(struct ccp_opt));
368 (*o)->val.hdr.id = algorithm[f]->id;
369 (*o)->val.hdr.len = 2;
372 (*algorithm[f]->o.OptInit)(&(*o)->val, &ccp->cfg);
375 if (cp + (*o)->val.hdr.len > buff + sizeof buff) {
376 log_Printf(LogERROR, "%s: CCP REQ buffer overrun !\n", fp->link->name);
379 memcpy(cp, &(*o)->val, (*o)->val.hdr.len);
380 cp += (*o)->val.hdr.len;
382 ccp->my_proto = (*o)->val.hdr.id;
383 ccp->out.algorithm = f;
389 fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, cp - buff, MB_CCPOUT);
393 ccp_SendResetReq(struct fsm *fp)
395 /* We can't read our input - ask peer to reset */
396 struct ccp *ccp = fsm2ccp(fp);
398 ccp->reset_sent = fp->reqid;
399 ccp->last_reset = -1;
400 fsm_Output(fp, CODE_RESETREQ, fp->reqid, NULL, 0, MB_CCPOUT);
404 CcpSentTerminateReq(struct fsm *fp)
406 /* Term REQ just sent by FSM */
410 CcpSendTerminateAck(struct fsm *fp, u_char id)
412 /* Send Term ACK please */
413 fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_CCPOUT);
417 CcpRecvResetReq(struct fsm *fp)
419 /* Got a reset REQ, reset outgoing dictionary */
420 struct ccp *ccp = fsm2ccp(fp);
421 if (ccp->out.state == NULL)
423 return (*algorithm[ccp->out.algorithm]->o.Reset)(ccp->out.state);
427 CcpLayerStart(struct fsm *fp)
429 /* We're about to start up ! */
430 struct ccp *ccp = fsm2ccp(fp);
432 log_Printf(LogCCP, "%s: LayerStart.\n", fp->link->name);
433 fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3;
437 CcpLayerDown(struct fsm *fp)
439 /* About to come down */
440 struct ccp *ccp = fsm2ccp(fp);
441 struct ccp_opt *next;
443 log_Printf(LogCCP, "%s: LayerDown.\n", fp->link->name);
444 if (ccp->in.state != NULL) {
445 (*algorithm[ccp->in.algorithm]->i.Term)(ccp->in.state);
446 ccp->in.state = NULL;
447 ccp->in.algorithm = -1;
449 if (ccp->out.state != NULL) {
450 (*algorithm[ccp->out.algorithm]->o.Term)(ccp->out.state);
451 ccp->out.state = NULL;
452 ccp->out.algorithm = -1;
454 ccp->his_reject = ccp->my_reject = 0;
456 while (ccp->out.opt) {
457 next = ccp->out.opt->next;
465 CcpLayerFinish(struct fsm *fp)
468 struct ccp *ccp = fsm2ccp(fp);
469 struct ccp_opt *next;
471 log_Printf(LogCCP, "%s: LayerFinish.\n", fp->link->name);
474 * Nuke options that may be left over from sending a REQ but never
477 while (ccp->out.opt) {
478 next = ccp->out.opt->next;
483 if (ccp_Required(ccp)) {
484 if (fp->link->lcp.fsm.state == ST_OPENED)
485 log_Printf(LogLCP, "%s: Closing due to CCP completion\n", fp->link->name);
486 fsm_Close(&fp->link->lcp.fsm);
490 /* Called when CCP has reached the OPEN state */
492 CcpLayerUp(struct fsm *fp)
495 struct ccp *ccp = fsm2ccp(fp);
499 for (f = fail = 0; f < NALGORITHMS; f++)
500 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
501 (*algorithm[f]->Required)(&ccp->fsm) &&
502 (ccp->in.algorithm != f || ccp->out.algorithm != f)) {
503 /* Blow it all away - we haven't negotiated a required algorithm */
504 log_Printf(LogWARN, "%s: Failed to negotiate (required) %s\n",
505 fp->link->name, protoname(algorithm[f]->id));
510 ccp->his_proto = ccp->my_proto = -1;
512 fsm_Close(&fp->link->lcp.fsm);
516 log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name);
518 if (ccp->in.state == NULL && ccp->in.algorithm >= 0 &&
519 ccp->in.algorithm < NALGORITHMS) {
520 ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init)(&ccp->in.opt);
521 if (ccp->in.state == NULL) {
522 log_Printf(LogERROR, "%s: %s (in) initialisation failure\n",
523 fp->link->name, protoname(ccp->his_proto));
524 ccp->his_proto = ccp->my_proto = -1;
531 for (f = 0; f < ccp->out.algorithm; f++)
532 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
535 if (ccp->out.state == NULL && ccp->out.algorithm >= 0 &&
536 ccp->out.algorithm < NALGORITHMS) {
537 ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init)(&(*o)->val);
538 if (ccp->out.state == NULL) {
539 log_Printf(LogERROR, "%s: %s (out) initialisation failure\n",
540 fp->link->name, protoname(ccp->my_proto));
541 ccp->his_proto = ccp->my_proto = -1;
547 fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3;
549 log_Printf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n",
550 fp->link->name, protoname(ccp->my_proto), ccp->my_proto,
551 protoname(ccp->his_proto), ccp->his_proto);
557 CcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type,
558 struct fsm_decode *dec)
560 /* Deal with incoming data */
561 struct ccp *ccp = fsm2ccp(fp);
566 if (mode_type == MODE_REQ)
567 ccp->in.algorithm = -1; /* In case we've received two REQs in a row */
569 while (end - cp >= sizeof(opt->hdr)) {
570 if ((opt = fsm_readopt(&cp)) == NULL)
573 for (f = NALGORITHMS-1; f > -1; f--)
574 if (algorithm[f]->id == opt->hdr.id)
577 disp = f == -1 ? "" : (*algorithm[f]->Disp)(opt);
581 log_Printf(LogCCP, " %s[%d] %s\n", protoname(opt->hdr.id),
585 /* Don't understand that :-( */
586 if (mode_type == MODE_REQ) {
587 ccp->my_reject |= (1 << opt->hdr.id);
595 if (IsAccepted(ccp->cfg.neg[algorithm[f]->Neg]) &&
596 (*algorithm[f]->Usable)(fp) &&
597 ccp->in.algorithm == -1) {
598 memcpy(&ccp->in.opt, opt, opt->hdr.len);
599 switch ((*algorithm[f]->i.Set)(&ccp->in.opt, &ccp->cfg)) {
601 fsm_rej(dec, &ccp->in.opt);
604 fsm_nak(dec, &ccp->in.opt);
607 fsm_ack(dec, &ccp->in.opt);
608 ccp->his_proto = opt->hdr.id;
609 ccp->in.algorithm = f; /* This one'll do :-) */
617 for (o = ccp->out.opt; o != NULL; o = o->next)
618 if (o->val.hdr.id == opt->hdr.id)
621 log_Printf(LogCCP, "%s: Warning: Ignoring peer NAK of unsent"
622 " option\n", fp->link->name);
624 memcpy(&o->val, opt, opt->hdr.len);
625 if ((*algorithm[f]->o.Set)(&o->val, &ccp->cfg) == MODE_ACK)
626 ccp->my_proto = algorithm[f]->id;
628 ccp->his_reject |= (1 << opt->hdr.id);
630 if (algorithm[f]->Required(fp)) {
631 log_Printf(LogWARN, "%s: Cannot understand peers (required)"
632 " %s negotiation\n", fp->link->name,
633 protoname(algorithm[f]->id));
634 fsm_Close(&fp->link->lcp.fsm);
640 ccp->his_reject |= (1 << opt->hdr.id);
642 if (algorithm[f]->Required(fp)) {
643 log_Printf(LogWARN, "%s: Peer rejected (required) %s negotiation\n",
644 fp->link->name, protoname(algorithm[f]->id));
645 fsm_Close(&fp->link->lcp.fsm);
652 if (mode_type != MODE_NOP) {
653 fsm_opt_normalise(dec);
654 if (dec->rejend != dec->rej || dec->nakend != dec->nak) {
655 if (ccp->in.state == NULL) {
657 ccp->in.algorithm = -1;
664 ccp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
666 /* Got PROTO_CCP from link */
667 m_settype(bp, MB_CCPIN);
668 if (bundle_Phase(bundle) == PHASE_NETWORK)
669 fsm_Input(&l->ccp.fsm, bp);
671 if (bundle_Phase(bundle) < PHASE_NETWORK)
672 log_Printf(LogCCP, "%s: Error: Unexpected CCP in phase %s (ignored)\n",
673 l->ccp.fsm.link->name, bundle_PhaseName(bundle));
680 CcpRecvResetAck(struct fsm *fp, u_char id)
682 /* Got a reset ACK, reset incoming dictionary */
683 struct ccp *ccp = fsm2ccp(fp);
685 if (ccp->reset_sent != -1) {
686 if (id != ccp->reset_sent) {
687 log_Printf(LogCCP, "%s: Incorrect ResetAck (id %d, not %d)"
688 " ignored\n", fp->link->name, id, ccp->reset_sent);
691 /* Whaddaya know - a correct reset ack */
692 } else if (id == ccp->last_reset)
693 log_Printf(LogCCP, "%s: Duplicate ResetAck (resetting again)\n",
696 log_Printf(LogCCP, "%s: Unexpected ResetAck (id %d) ignored\n",
701 ccp->last_reset = ccp->reset_sent;
702 ccp->reset_sent = -1;
703 if (ccp->in.state != NULL)
704 (*algorithm[ccp->in.algorithm]->i.Reset)(ccp->in.state);
708 ccp_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp,
709 int pri, u_short *proto)
711 if (PROTO_COMPRESSIBLE(*proto)) {
712 if (l->ccp.fsm.state != ST_OPENED) {
713 if (ccp_Required(&l->ccp)) {
714 /* The NCP layer shouldn't have let this happen ! */
715 log_Printf(LogERROR, "%s: Unexpected attempt to use an unopened and"
716 " required CCP layer\n", l->name);
720 } else if (l->ccp.out.state != NULL) {
721 bp = (*algorithm[l->ccp.out.algorithm]->o.Write)
722 (l->ccp.out.state, &l->ccp, l, pri, proto, bp);
725 m_settype(bp, MB_ICOMPDOUT);
728 m_settype(bp, MB_COMPDOUT);
738 ccp_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, u_short *proto)
741 * If proto isn't PROTO_[I]COMPD, we still want to pass it to the
742 * decompression routines so that the dictionary's updated
744 if (l->ccp.fsm.state == ST_OPENED) {
745 if (*proto == PROTO_COMPD || *proto == PROTO_ICOMPD) {
746 log_Printf(LogDEBUG, "ccp_LayerPull: PROTO_%sCOMPDP -> PROTO_IP\n",
747 *proto == PROTO_ICOMPD ? "I" : "");
748 /* Decompress incoming data */
749 if (l->ccp.reset_sent != -1)
750 /* Send another REQ and put the packet in the bit bucket */
751 fsm_Output(&l->ccp.fsm, CODE_RESETREQ, l->ccp.reset_sent, NULL, 0,
753 else if (l->ccp.in.state != NULL) {
754 bp = (*algorithm[l->ccp.in.algorithm]->i.Read)
755 (l->ccp.in.state, &l->ccp, proto, bp);
758 m_settype(bp, MB_ICOMPDIN);
761 m_settype(bp, MB_COMPDIN);
768 } else if (PROTO_COMPRESSIBLE(*proto) && l->ccp.in.state != NULL) {
769 log_Printf(LogDEBUG, "ccp_LayerPull: Ignore packet (dict only)\n");
770 /* Add incoming Network Layer traffic to our dictionary */
771 (*algorithm[l->ccp.in.algorithm]->i.DictSetup)
772 (l->ccp.in.state, &l->ccp, *proto, bp);
774 log_Printf(LogDEBUG, "ccp_LayerPull: Ignore packet\n");
781 ccp_Proto(struct ccp *ccp)
783 return !link2physical(ccp->fsm.link) || !ccp->fsm.bundle->ncp.mp.active ?
784 PROTO_COMPD : PROTO_ICOMPD;
788 ccp_SetOpenMode(struct ccp *ccp)
792 for (f = 0; f < CCP_NEG_TOTAL; f++)
793 if (IsEnabled(ccp->cfg.neg[f])) {
794 ccp->fsm.open_mode = 0;
798 ccp->fsm.open_mode = OPEN_PASSIVE; /* Go straight to ST_STOPPED ? */
800 for (f = 0; f < CCP_NEG_TOTAL; f++)
801 if (IsAccepted(ccp->cfg.neg[f]))
804 return 0; /* No CCP at all */
808 ccp_DefaultUsable(struct fsm *fp)
814 ccp_DefaultRequired(struct fsm *fp)
819 struct layer ccplayer = { LAYER_CCP, "ccp", ccp_LayerPush, ccp_LayerPull };