2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
5 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
6 * Internet Initiative Japan, Inc (IIJ)
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/param.h>
34 #include <netinet/in.h>
35 #include <netinet/in_systm.h>
36 #include <netinet/ip.h>
37 #include <sys/socket.h>
43 #include <string.h> /* memcpy() on some archs */
56 #include "throughput.h"
58 #include "slcompress.h"
66 #include "descriptor.h"
82 static void CcpSendConfigReq(struct fsm *);
83 static void CcpSentTerminateReq(struct fsm *);
84 static void CcpSendTerminateAck(struct fsm *, u_char);
85 static void CcpDecodeConfig(struct fsm *, u_char *, u_char *, int,
87 static void CcpLayerStart(struct fsm *);
88 static void CcpLayerFinish(struct fsm *);
89 static int CcpLayerUp(struct fsm *);
90 static void CcpLayerDown(struct fsm *);
91 static void CcpInitRestartCounter(struct fsm *, int);
92 static int CcpRecvResetReq(struct fsm *);
93 static void CcpRecvResetAck(struct fsm *, u_char);
95 static struct fsm_callbacks ccp_Callbacks = {
100 CcpInitRestartCounter,
109 static const char * const ccp_TimerNames[] =
110 {"CCP restart", "CCP openmode", "CCP stopped"};
115 static char const * const cftypes[] = {
116 /* Check out the latest ``Compression Control Protocol'' rfc (1962) */
118 "PRED1", /* 1: Predictor type 1 */
119 "PRED2", /* 2: Predictor type 2 */
120 "PUDDLE", /* 3: Puddle Jumber */
121 NULL, NULL, NULL, NULL, NULL, NULL,
122 NULL, NULL, NULL, NULL, NULL, NULL,
123 "HWPPC", /* 16: Hewlett-Packard PPC */
124 "STAC", /* 17: Stac Electronics LZS (rfc1974) */
125 "MPPE", /* 18: Microsoft PPC (rfc2118) and */
126 /* Microsoft PPE (draft-ietf-pppext-mppe) */
127 "GAND", /* 19: Gandalf FZA (rfc1993) */
128 "V42BIS", /* 20: ARG->DATA.42bis compression */
129 "BSD", /* 21: BSD LZW Compress */
131 "LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */
132 "MAGNALINK/DEFLATE",/* 24: Magnalink Variable Resource (rfc1975) */
133 /* 24: Deflate (according to pppd-2.3.*) */
134 "DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */
135 "DEFLATE", /* 26: Deflate (rfc1979) */
138 if (proto < 0 || (unsigned)proto > sizeof cftypes / sizeof *cftypes ||
139 cftypes[proto] == NULL) {
142 return HexStr(proto, NULL, 0);
145 return cftypes[proto];
148 /* We support these algorithms, and Req them in the given order */
149 static const struct ccp_algorithm * const algorithm[] = {
152 &PppdDeflateAlgorithm
158 #define NALGORITHMS (sizeof algorithm/sizeof algorithm[0])
161 ccp_ReportStatus(struct cmdargs const *arg)
168 l = command_ChooseLink(arg);
171 prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name,
172 State2Nam(ccp->fsm.state));
173 if (ccp->fsm.state == ST_OPENED) {
174 prompt_Printf(arg->prompt, " My protocol = %s, His protocol = %s\n",
175 protoname(ccp->my_proto), protoname(ccp->his_proto));
176 prompt_Printf(arg->prompt, " Output: %ld --> %ld, Input: %ld --> %ld\n",
177 ccp->uncompout, ccp->compout,
178 ccp->compin, ccp->uncompin);
181 if (ccp->in.algorithm != -1)
182 prompt_Printf(arg->prompt, "\n Input Options: %s\n",
183 (*algorithm[ccp->in.algorithm]->Disp)(&ccp->in.opt));
185 if (ccp->out.algorithm != -1) {
187 for (f = 0; f < ccp->out.algorithm; f++)
188 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
190 prompt_Printf(arg->prompt, " Output Options: %s\n",
191 (*algorithm[ccp->out.algorithm]->Disp)(&(*o)->val));
194 prompt_Printf(arg->prompt, "\n Defaults: ");
195 prompt_Printf(arg->prompt, "FSM retry = %us, max %u Config"
196 " REQ%s, %u Term REQ%s\n", ccp->cfg.fsm.timeout,
197 ccp->cfg.fsm.maxreq, ccp->cfg.fsm.maxreq == 1 ? "" : "s",
198 ccp->cfg.fsm.maxtrm, ccp->cfg.fsm.maxtrm == 1 ? "" : "s");
199 prompt_Printf(arg->prompt, " deflate windows: ");
200 prompt_Printf(arg->prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize);
201 prompt_Printf(arg->prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize);
203 prompt_Printf(arg->prompt, " MPPE: ");
204 if (ccp->cfg.mppe.keybits)
205 prompt_Printf(arg->prompt, "%d bits, ", ccp->cfg.mppe.keybits);
207 prompt_Printf(arg->prompt, "any bits, ");
208 switch (ccp->cfg.mppe.state) {
210 prompt_Printf(arg->prompt, "stateful");
213 prompt_Printf(arg->prompt, "stateless");
216 prompt_Printf(arg->prompt, "any state");
219 prompt_Printf(arg->prompt, "%s\n",
220 ccp->cfg.mppe.required ? ", required" : "");
223 prompt_Printf(arg->prompt, "\n DEFLATE: %s\n",
224 command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE]));
225 prompt_Printf(arg->prompt, " PREDICTOR1: %s\n",
226 command_ShowNegval(ccp->cfg.neg[CCP_NEG_PRED1]));
227 prompt_Printf(arg->prompt, " DEFLATE24: %s\n",
228 command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE24]));
230 prompt_Printf(arg->prompt, " MPPE: %s\n",
231 command_ShowNegval(ccp->cfg.neg[CCP_NEG_MPPE]));
237 ccp_SetupCallbacks(struct ccp *ccp)
239 ccp->fsm.fn = &ccp_Callbacks;
240 ccp->fsm.FsmTimer.name = ccp_TimerNames[0];
241 ccp->fsm.OpenTimer.name = ccp_TimerNames[1];
242 ccp->fsm.StoppedTimer.name = ccp_TimerNames[2];
246 ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l,
247 const struct fsm_parent *parent)
249 /* Initialise ourselves */
251 fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, LogCCP,
252 bundle, l, parent, &ccp_Callbacks, ccp_TimerNames);
254 ccp->cfg.deflate.in.winsize = 0;
255 ccp->cfg.deflate.out.winsize = 15;
256 ccp->cfg.fsm.timeout = DEF_FSMRETRY;
257 ccp->cfg.fsm.maxreq = DEF_FSMTRIES;
258 ccp->cfg.fsm.maxtrm = DEF_FSMTRIES;
259 ccp->cfg.neg[CCP_NEG_DEFLATE] = NEG_ENABLED|NEG_ACCEPTED;
260 ccp->cfg.neg[CCP_NEG_PRED1] = NEG_ENABLED|NEG_ACCEPTED;
261 ccp->cfg.neg[CCP_NEG_DEFLATE24] = 0;
263 ccp->cfg.mppe.keybits = 0;
264 ccp->cfg.mppe.state = MPPE_ANYSTATE;
265 ccp->cfg.mppe.required = 0;
266 ccp->cfg.neg[CCP_NEG_MPPE] = NEG_ENABLED|NEG_ACCEPTED;
273 ccp_Setup(struct ccp *ccp)
275 /* Set ourselves up for a startup */
276 ccp->fsm.open_mode = 0;
277 ccp->his_proto = ccp->my_proto = -1;
278 ccp->reset_sent = ccp->last_reset = -1;
279 ccp->in.algorithm = ccp->out.algorithm = -1;
280 ccp->in.state = ccp->out.state = NULL;
281 ccp->in.opt.hdr.id = -1;
283 ccp->his_reject = ccp->my_reject = 0;
284 ccp->uncompout = ccp->compout = 0;
285 ccp->uncompin = ccp->compin = 0;
289 * Is ccp *REQUIRED* ?
290 * We ask each of the configured ccp protocols if they're required and
291 * return TRUE if they are.
293 * It's not possible for the peer to reject a required ccp protocol
294 * without our state machine bringing the supporting lcp layer down.
296 * If ccp is required but not open, the NCP layer should not push
297 * any data into the link.
300 ccp_Required(struct ccp *ccp)
304 for (f = 0; f < NALGORITHMS; f++)
305 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
306 (*algorithm[f]->Required)(&ccp->fsm))
313 * Report whether it's possible to increase a packet's size after
314 * compression (and by how much).
317 ccp_MTUOverhead(struct ccp *ccp)
319 if (ccp->fsm.state == ST_OPENED && ccp->out.algorithm >= 0)
320 return algorithm[ccp->out.algorithm]->o.MTUOverhead;
326 CcpInitRestartCounter(struct fsm *fp, int what)
328 /* Set fsm timer load */
329 struct ccp *ccp = fsm2ccp(fp);
331 fp->FsmTimer.load = ccp->cfg.fsm.timeout * SECTICKS;
334 fp->restart = ccp->cfg.fsm.maxreq;
337 fp->restart = ccp->cfg.fsm.maxtrm;
346 CcpSendConfigReq(struct fsm *fp)
348 /* Send config REQ please */
349 struct ccp *ccp = fsm2ccp(fp);
351 u_char *cp, buff[100];
357 alloc = ccp->his_reject == 0 && ccp->out.opt == NULL;
359 ccp->out.algorithm = -1;
360 for (f = 0; f < NALGORITHMS; f++)
361 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
362 !REJECTED(ccp, algorithm[f]->id) &&
363 (*algorithm[f]->Usable)(fp)) {
366 for (o = &ccp->out.opt; *o != NULL; o = &(*o)->next)
367 if ((*o)->val.hdr.id == algorithm[f]->id && (*o)->algorithm == (int)f)
370 if (alloc || *o == NULL) {
371 if ((*o = (struct ccp_opt *)malloc(sizeof(struct ccp_opt))) == NULL) {
372 log_Printf(LogERROR, "%s: Not enough memory for CCP REQ !\n",
376 (*o)->val.hdr.id = algorithm[f]->id;
377 (*o)->val.hdr.len = 2;
380 (*algorithm[f]->o.OptInit)(fp->bundle, &(*o)->val, &ccp->cfg);
383 if (cp + (*o)->val.hdr.len > buff + sizeof buff) {
384 log_Printf(LogERROR, "%s: CCP REQ buffer overrun !\n", fp->link->name);
387 memcpy(cp, &(*o)->val, (*o)->val.hdr.len);
388 cp += (*o)->val.hdr.len;
390 ccp->my_proto = (*o)->val.hdr.id;
391 ccp->out.algorithm = f;
397 fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, cp - buff, MB_CCPOUT);
401 ccp_SendResetReq(struct fsm *fp)
403 /* We can't read our input - ask peer to reset */
404 struct ccp *ccp = fsm2ccp(fp);
406 ccp->reset_sent = fp->reqid;
407 ccp->last_reset = -1;
408 fsm_Output(fp, CODE_RESETREQ, fp->reqid, NULL, 0, MB_CCPOUT);
412 CcpSentTerminateReq(struct fsm *fp __unused)
414 /* Term REQ just sent by FSM */
418 CcpSendTerminateAck(struct fsm *fp, u_char id)
420 /* Send Term ACK please */
421 fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_CCPOUT);
425 CcpRecvResetReq(struct fsm *fp)
427 /* Got a reset REQ, reset outgoing dictionary */
428 struct ccp *ccp = fsm2ccp(fp);
429 if (ccp->out.state == NULL)
431 return (*algorithm[ccp->out.algorithm]->o.Reset)(ccp->out.state);
435 CcpLayerStart(struct fsm *fp)
437 /* We're about to start up ! */
438 struct ccp *ccp = fsm2ccp(fp);
440 log_Printf(LogCCP, "%s: LayerStart.\n", fp->link->name);
441 fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3;
445 CcpLayerDown(struct fsm *fp)
447 /* About to come down */
448 struct ccp *ccp = fsm2ccp(fp);
449 struct ccp_opt *next;
451 log_Printf(LogCCP, "%s: LayerDown.\n", fp->link->name);
452 if (ccp->in.state != NULL) {
453 (*algorithm[ccp->in.algorithm]->i.Term)(ccp->in.state);
454 ccp->in.state = NULL;
455 ccp->in.algorithm = -1;
457 if (ccp->out.state != NULL) {
458 (*algorithm[ccp->out.algorithm]->o.Term)(ccp->out.state);
459 ccp->out.state = NULL;
460 ccp->out.algorithm = -1;
462 ccp->his_reject = ccp->my_reject = 0;
464 while (ccp->out.opt) {
465 next = ccp->out.opt->next;
473 CcpLayerFinish(struct fsm *fp)
476 struct ccp *ccp = fsm2ccp(fp);
477 struct ccp_opt *next;
479 log_Printf(LogCCP, "%s: LayerFinish.\n", fp->link->name);
482 * Nuke options that may be left over from sending a REQ but never
485 while (ccp->out.opt) {
486 next = ccp->out.opt->next;
491 if (ccp_Required(ccp)) {
492 if (fp->link->lcp.fsm.state == ST_OPENED)
493 log_Printf(LogLCP, "%s: Closing due to CCP completion\n", fp->link->name);
494 fsm_Close(&fp->link->lcp.fsm);
498 /* Called when CCP has reached the OPEN state */
500 CcpLayerUp(struct fsm *fp)
503 struct ccp *ccp = fsm2ccp(fp);
507 for (f = fail = 0; f < NALGORITHMS; f++)
508 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
509 (*algorithm[f]->Required)(&ccp->fsm) &&
510 (ccp->in.algorithm != (int)f || ccp->out.algorithm != (int)f)) {
511 /* Blow it all away - we haven't negotiated a required algorithm */
512 log_Printf(LogWARN, "%s: Failed to negotiate (required) %s\n",
513 fp->link->name, protoname(algorithm[f]->id));
518 ccp->his_proto = ccp->my_proto = -1;
520 fsm_Close(&fp->link->lcp.fsm);
524 log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name);
526 if (ccp->in.state == NULL && ccp->in.algorithm >= 0 &&
527 ccp->in.algorithm < (int)NALGORITHMS) {
528 ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init)
529 (fp->bundle, &ccp->in.opt);
530 if (ccp->in.state == NULL) {
531 log_Printf(LogERROR, "%s: %s (in) initialisation failure\n",
532 fp->link->name, protoname(ccp->his_proto));
533 ccp->his_proto = ccp->my_proto = -1;
540 if (ccp->out.algorithm > 0)
541 for (f = 0; f < (unsigned)ccp->out.algorithm; f++)
542 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
545 if (ccp->out.state == NULL && ccp->out.algorithm >= 0 &&
546 ccp->out.algorithm < (int)NALGORITHMS) {
547 ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init)
548 (fp->bundle, &(*o)->val);
549 if (ccp->out.state == NULL) {
550 log_Printf(LogERROR, "%s: %s (out) initialisation failure\n",
551 fp->link->name, protoname(ccp->my_proto));
552 ccp->his_proto = ccp->my_proto = -1;
558 fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3;
560 log_Printf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n",
561 fp->link->name, protoname(ccp->my_proto), ccp->my_proto,
562 protoname(ccp->his_proto), ccp->his_proto);
568 CcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type,
569 struct fsm_decode *dec)
571 /* Deal with incoming data */
572 struct ccp *ccp = fsm2ccp(fp);
577 if (mode_type == MODE_REQ)
578 ccp->in.algorithm = -1; /* In case we've received two REQs in a row */
580 while (end >= cp + sizeof(opt->hdr)) {
581 if ((opt = fsm_readopt(&cp)) == NULL)
584 for (f = NALGORITHMS-1; f > -1; f--)
585 if (algorithm[f]->id == opt->hdr.id)
588 disp = f == -1 ? "" : (*algorithm[f]->Disp)(opt);
592 log_Printf(LogCCP, " %s[%d] %s\n", protoname(opt->hdr.id),
596 /* Don't understand that :-( */
597 if (mode_type == MODE_REQ) {
598 ccp->my_reject |= (1 << opt->hdr.id);
606 if (IsAccepted(ccp->cfg.neg[algorithm[f]->Neg]) &&
607 (*algorithm[f]->Usable)(fp) &&
608 ccp->in.algorithm == -1) {
609 memcpy(&ccp->in.opt, opt, opt->hdr.len);
610 switch ((*algorithm[f]->i.Set)(fp->bundle, &ccp->in.opt, &ccp->cfg)) {
612 fsm_rej(dec, &ccp->in.opt);
615 fsm_nak(dec, &ccp->in.opt);
618 fsm_ack(dec, &ccp->in.opt);
619 ccp->his_proto = opt->hdr.id;
620 ccp->in.algorithm = (int)f; /* This one'll do :-) */
628 for (o = ccp->out.opt; o != NULL; o = o->next)
629 if (o->val.hdr.id == opt->hdr.id)
632 log_Printf(LogCCP, "%s: Warning: Ignoring peer NAK of unsent"
633 " option\n", fp->link->name);
635 memcpy(&o->val, opt, opt->hdr.len);
636 if ((*algorithm[f]->o.Set)(fp->bundle, &o->val, &ccp->cfg) ==
638 ccp->my_proto = algorithm[f]->id;
640 ccp->his_reject |= (1 << opt->hdr.id);
642 if (algorithm[f]->Required(fp)) {
643 log_Printf(LogWARN, "%s: Cannot understand peers (required)"
644 " %s negotiation\n", fp->link->name,
645 protoname(algorithm[f]->id));
646 fsm_Close(&fp->link->lcp.fsm);
652 ccp->his_reject |= (1 << opt->hdr.id);
654 if (algorithm[f]->Required(fp)) {
655 log_Printf(LogWARN, "%s: Peer rejected (required) %s negotiation\n",
656 fp->link->name, protoname(algorithm[f]->id));
657 fsm_Close(&fp->link->lcp.fsm);
664 if (mode_type != MODE_NOP) {
665 fsm_opt_normalise(dec);
666 if (dec->rejend != dec->rej || dec->nakend != dec->nak) {
667 if (ccp->in.state == NULL) {
669 ccp->in.algorithm = -1;
676 ccp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
678 /* Got PROTO_CCP from link */
679 m_settype(bp, MB_CCPIN);
680 if (bundle_Phase(bundle) == PHASE_NETWORK)
681 fsm_Input(&l->ccp.fsm, bp);
683 if (bundle_Phase(bundle) < PHASE_NETWORK)
684 log_Printf(LogCCP, "%s: Error: Unexpected CCP in phase %s (ignored)\n",
685 l->ccp.fsm.link->name, bundle_PhaseName(bundle));
692 CcpRecvResetAck(struct fsm *fp, u_char id)
694 /* Got a reset ACK, reset incoming dictionary */
695 struct ccp *ccp = fsm2ccp(fp);
697 if (ccp->reset_sent != -1) {
698 if (id != ccp->reset_sent) {
699 log_Printf(LogCCP, "%s: Incorrect ResetAck (id %d, not %d)"
700 " ignored\n", fp->link->name, id, ccp->reset_sent);
703 /* Whaddaya know - a correct reset ack */
704 } else if (id == ccp->last_reset)
705 log_Printf(LogCCP, "%s: Duplicate ResetAck (resetting again)\n",
708 log_Printf(LogCCP, "%s: Unexpected ResetAck (id %d) ignored\n",
713 ccp->last_reset = ccp->reset_sent;
714 ccp->reset_sent = -1;
715 if (ccp->in.state != NULL)
716 (*algorithm[ccp->in.algorithm]->i.Reset)(ccp->in.state);
720 ccp_LayerPush(struct bundle *b __unused, struct link *l, struct mbuf *bp,
721 int pri, u_short *proto)
723 if (PROTO_COMPRESSIBLE(*proto)) {
724 if (l->ccp.fsm.state != ST_OPENED) {
725 if (ccp_Required(&l->ccp)) {
726 /* The NCP layer shouldn't have let this happen ! */
727 log_Printf(LogERROR, "%s: Unexpected attempt to use an unopened and"
728 " required CCP layer\n", l->name);
732 } else if (l->ccp.out.state != NULL) {
733 bp = (*algorithm[l->ccp.out.algorithm]->o.Write)
734 (l->ccp.out.state, &l->ccp, l, pri, proto, bp);
737 m_settype(bp, MB_ICOMPDOUT);
740 m_settype(bp, MB_COMPDOUT);
750 ccp_LayerPull(struct bundle *b __unused, struct link *l, struct mbuf *bp,
754 * If proto isn't PROTO_[I]COMPD, we still want to pass it to the
755 * decompression routines so that the dictionary's updated
757 if (l->ccp.fsm.state == ST_OPENED) {
758 if (*proto == PROTO_COMPD || *proto == PROTO_ICOMPD) {
759 /* Decompress incoming data */
760 if (l->ccp.reset_sent != -1)
761 /* Send another REQ and put the packet in the bit bucket */
762 fsm_Output(&l->ccp.fsm, CODE_RESETREQ, l->ccp.reset_sent, NULL, 0,
764 else if (l->ccp.in.state != NULL) {
765 bp = (*algorithm[l->ccp.in.algorithm]->i.Read)
766 (l->ccp.in.state, &l->ccp, proto, bp);
769 m_settype(bp, MB_ICOMPDIN);
772 m_settype(bp, MB_COMPDIN);
779 } else if (PROTO_COMPRESSIBLE(*proto) && l->ccp.in.state != NULL) {
780 /* Add incoming Network Layer traffic to our dictionary */
781 (*algorithm[l->ccp.in.algorithm]->i.DictSetup)
782 (l->ccp.in.state, &l->ccp, *proto, bp);
790 ccp_Proto(struct ccp *ccp)
792 return !link2physical(ccp->fsm.link) || !ccp->fsm.bundle->ncp.mp.active ?
793 PROTO_COMPD : PROTO_ICOMPD;
797 ccp_SetOpenMode(struct ccp *ccp)
801 for (f = 0; f < CCP_NEG_TOTAL; f++)
802 if (IsEnabled(ccp->cfg.neg[f])) {
803 ccp->fsm.open_mode = 0;
807 ccp->fsm.open_mode = OPEN_PASSIVE; /* Go straight to ST_STOPPED ? */
809 for (f = 0; f < CCP_NEG_TOTAL; f++)
810 if (IsAccepted(ccp->cfg.neg[f]))
813 return 0; /* No CCP at all */
817 ccp_DefaultUsable(struct fsm *fp __unused)
823 ccp_DefaultRequired(struct fsm *fp __unused)
828 struct layer ccplayer = { LAYER_CCP, "ccp", ccp_LayerPush, ccp_LayerPull };