Lines Matching refs:ccp

30  * $FreeBSD: stable/11/usr.sbin/ppp/ccp.c 330449 2018-03-05 07:26:05Z eadler $
62 #include "ccp.h"
165 struct ccp *ccp;
169 ccp = &l->ccp;
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) {
175 protoname(ccp->my_proto), protoname(ccp->his_proto));
177 ccp->uncompout, ccp->compout,
178 ccp->compin, ccp->uncompin);
181 if (ccp->in.algorithm != -1)
183 (*algorithm[ccp->in.algorithm]->Disp)(&ccp->in.opt));
185 if (ccp->out.algorithm != -1) {
186 o = &ccp->out.opt;
187 for (f = 0; f < ccp->out.algorithm; f++)
188 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
191 (*algorithm[ccp->out.algorithm]->Disp)(&(*o)->val));
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");
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);
204 if (ccp->cfg.mppe.keybits)
205 prompt_Printf(arg->prompt, "%d bits, ", ccp->cfg.mppe.keybits);
208 switch (ccp->cfg.mppe.state) {
220 ccp->cfg.mppe.required ? ", required" : "");
224 command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE]));
226 command_ShowNegval(ccp->cfg.neg[CCP_NEG_PRED1]));
228 command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE24]));
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,
251 fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, LogCCP,
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;
269 ccp_Setup(ccp);
273 ccp_Setup(struct ccp *ccp)
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;
282 ccp->out.opt = NULL;
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
293 * It's not possible for the peer to reject a required ccp protocol
296 * If ccp is required but not open, the NCP layer should not push
300 ccp_Required(struct ccp *ccp)
305 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
306 (*algorithm[f]->Required)(&ccp->fsm))
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;
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;
349 struct ccp *ccp = fsm2ccp(fp);
356 o = &ccp->out.opt;
357 alloc = ccp->his_reject == 0 && ccp->out.opt == NULL;
358 ccp->my_proto = -1;
359 ccp->out.algorithm = -1;
361 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
362 !REJECTED(ccp, algorithm[f]->id) &&
366 for (o = &ccp->out.opt; *o != NULL; o = &(*o)->next)
380 (*algorithm[f]->o.OptInit)(fp->bundle, &(*o)->val, &ccp->cfg);
390 ccp->my_proto = (*o)->val.hdr.id;
391 ccp->out.algorithm = f;
404 struct ccp *ccp = fsm2ccp(fp);
406 ccp->reset_sent = fp->reqid;
407 ccp->last_reset = -1;
428 struct ccp *ccp = fsm2ccp(fp);
429 if (ccp->out.state == NULL)
431 return (*algorithm[ccp->out.algorithm]->o.Reset)(ccp->out.state);
438 struct ccp *ccp = fsm2ccp(fp);
441 fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3;
448 struct ccp *ccp = fsm2ccp(fp);
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;
466 free(ccp->out.opt);
467 ccp->out.opt = next;
469 ccp_Setup(ccp);
476 struct ccp *ccp = fsm2ccp(fp);
485 while (ccp->out.opt) {
486 next = ccp->out.opt->next;
487 free(ccp->out.opt);
488 ccp->out.opt = next;
491 if (ccp_Required(ccp)) {
503 struct ccp *ccp = fsm2ccp(fp);
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)) {
518 ccp->his_proto = ccp->my_proto = -1;
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) {
532 fp->link->name, protoname(ccp->his_proto));
533 ccp->his_proto = ccp->my_proto = -1;
539 o = &ccp->out.opt;
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)
549 if (ccp->out.state == NULL) {
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;
561 fp->link->name, protoname(ccp->my_proto), ccp->my_proto,
562 protoname(ccp->his_proto), ccp->his_proto);
572 struct ccp *ccp = fsm2ccp(fp);
578 ccp->in.algorithm = -1; /* In case we've received two REQs in a row */
598 ccp->my_reject |= (1 << opt->hdr.id);
606 if (IsAccepted(ccp->cfg.neg[algorithm[f]->Neg]) &&
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)
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);
641 ccp->my_proto = -1;
652 ccp->his_reject |= (1 << opt->hdr.id);
653 ccp->my_proto = -1;
667 if (ccp->in.state == NULL) {
668 ccp->his_proto = -1;
669 ccp->in.algorithm = -1;
681 fsm_Input(&l->ccp.fsm, bp);
685 l->ccp.fsm.link->name, bundle_PhaseName(bundle));
695 struct ccp *ccp = fsm2ccp(fp);
697 if (ccp->reset_sent != -1) {
698 if (id != ccp->reset_sent) {
700 " ignored\n", fp->link->name, id, ccp->reset_sent);
704 } else if (id == ccp->last_reset)
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);
724 if (l->ccp.fsm.state != ST_OPENED) {
725 if (ccp_Required(&l->ccp)) {
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);
757 if (l->ccp.fsm.state == ST_OPENED) {
760 if (l->ccp.reset_sent != -1)
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);
779 } else if (PROTO_COMPRESSIBLE(*proto) && l->ccp.in.state != NULL) {
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 ?
797 ccp_SetOpenMode(struct ccp *ccp)
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 ? */
810 if (IsAccepted(ccp->cfg.neg[f]))
828 struct layer ccplayer = { LAYER_CCP, "ccp", ccp_LayerPush, ccp_LayerPull };