Deleted Added
full compact
ccp.c (67914) ccp.c (68423)
1/*
2 * PPP Compression Control Protocol (CCP) Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * PPP Compression Control Protocol (CCP) Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $FreeBSD: head/usr.sbin/ppp/ccp.c 67914 2000-10-30 00:15:33Z brian $
20 * $FreeBSD: head/usr.sbin/ppp/ccp.c 68423 2000-11-07 04:29:33Z brian $
21 *
22 * TODO:
23 * o Support other compression protocols
24 */
25#include <sys/param.h>
26#include <netinet/in.h>
27#include <netinet/in_systm.h>
28#include <netinet/ip.h>

--- 342 unchanged lines hidden (view full) ---

371 }
372 ccp_Setup(ccp);
373}
374
375static void
376CcpLayerFinish(struct fsm *fp)
377{
378 /* We're now down */
21 *
22 * TODO:
23 * o Support other compression protocols
24 */
25#include <sys/param.h>
26#include <netinet/in.h>
27#include <netinet/in_systm.h>
28#include <netinet/ip.h>

--- 342 unchanged lines hidden (view full) ---

371 }
372 ccp_Setup(ccp);
373}
374
375static void
376CcpLayerFinish(struct fsm *fp)
377{
378 /* We're now down */
379 struct ccp *ccp = fsm2ccp(fp);
380 struct ccp_opt *next;
381
379 log_Printf(LogCCP, "%s: LayerFinish.\n", fp->link->name);
382 log_Printf(LogCCP, "%s: LayerFinish.\n", fp->link->name);
383
384 /*
385 * Nuke options that may be left over from sending a REQ but never
386 * coming up.
387 */
388 while (ccp->out.opt) {
389 next = ccp->out.opt->next;
390 free(ccp->out.opt);
391 ccp->out.opt = next;
392 }
380}
381
382/* Called when CCP has reached the OPEN state */
383static int
384CcpLayerUp(struct fsm *fp)
385{
386 /* We're now up */
387 struct ccp *ccp = fsm2ccp(fp);
393}
394
395/* Called when CCP has reached the OPEN state */
396static int
397CcpLayerUp(struct fsm *fp)
398{
399 /* We're now up */
400 struct ccp *ccp = fsm2ccp(fp);
401 struct ccp_opt **o;
402 int f;
388
389 log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name);
390
391 if (ccp->in.state == NULL && ccp->in.algorithm >= 0 &&
392 ccp->in.algorithm < NALGORITHMS) {
393 ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init)(&ccp->in.opt);
394 if (ccp->in.state == NULL) {
395 log_Printf(LogERROR, "%s: %s (in) initialisation failure\n",
396 fp->link->name, protoname(ccp->his_proto));
397 ccp->his_proto = ccp->my_proto = -1;
398 fsm_Close(fp);
399 return 0;
400 }
401 }
402
403
404 log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name);
405
406 if (ccp->in.state == NULL && ccp->in.algorithm >= 0 &&
407 ccp->in.algorithm < NALGORITHMS) {
408 ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init)(&ccp->in.opt);
409 if (ccp->in.state == NULL) {
410 log_Printf(LogERROR, "%s: %s (in) initialisation failure\n",
411 fp->link->name, protoname(ccp->his_proto));
412 ccp->his_proto = ccp->my_proto = -1;
413 fsm_Close(fp);
414 return 0;
415 }
416 }
417
418 o = &ccp->out.opt;
419 for (f = 0; f < ccp->out.algorithm; f++)
420 if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]))
421 o = &(*o)->next;
422
403 if (ccp->out.state == NULL && ccp->out.algorithm >= 0 &&
404 ccp->out.algorithm < NALGORITHMS) {
423 if (ccp->out.state == NULL && ccp->out.algorithm >= 0 &&
424 ccp->out.algorithm < NALGORITHMS) {
405 ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init)
406 (&ccp->out.opt->val);
425 ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init)(&(*o)->val);
407 if (ccp->out.state == NULL) {
408 log_Printf(LogERROR, "%s: %s (out) initialisation failure\n",
409 fp->link->name, protoname(ccp->my_proto));
410 ccp->his_proto = ccp->my_proto = -1;
411 fsm_Close(fp);
412 return 0;
413 }
414 }

--- 267 unchanged lines hidden ---
426 if (ccp->out.state == NULL) {
427 log_Printf(LogERROR, "%s: %s (out) initialisation failure\n",
428 fp->link->name, protoname(ccp->my_proto));
429 ccp->his_proto = ccp->my_proto = -1;
430 fsm_Close(fp);
431 return 0;
432 }
433 }

--- 267 unchanged lines hidden ---