Deleted Added
full compact
1/*
2 * PPP Finite State Machine for LCP/IPCP
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, 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 * $Id:$
21 *
22 * TODO:
23 * o Refer loglevel for log output
24 * o Better option log display
25 */
26#include "fsm.h"
27#include "hdlc.h"
28#include "lqr.h"
29#include "lcpproto.h"

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

224static void
225FsmSendConfigAck(fp, lhp, option, count)
226struct fsm *fp;
227struct fsmheader *lhp;
228u_char *option;
229int count;
230{
231 LogPrintf(LOG_LCP, "%s: SendConfigAck(%s)\n", fp->name, StateNames[fp->state]);
232 FsmOutput(fp, CODE_CONFIGACK, lhp->id, option, count);
233}
234
235static void
236FsmSendConfigRej(fp, lhp, option, count)
237struct fsm *fp;
238struct fsmheader *lhp;
239u_char *option;
240int count;
241{
242 LogPrintf(LOG_LCP, "%s: SendConfigRej(%s)\n", fp->name, StateNames[fp->state]);
243 FsmOutput(fp, CODE_CONFIGREJ, lhp->id, option, count);
244}
245
246static void
247FsmSendConfigNak(fp, lhp, option, count)
248struct fsm *fp;
249struct fsmheader *lhp;
250u_char *option;
251int count;
252{
253 LogPrintf(LOG_LCP, "%s: SendConfigNak(%s)\n",
254 fp->name, StateNames[fp->state]);
255 FsmOutput(fp, CODE_CONFIGNAK, lhp->id, option, count);
256}
257
258/*
259 * Timeout actions
260 */
261void
262FsmTimeout(fp)

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

313 * Actions when receive packets
314 */
315void
316FsmRecvConfigReq(fp, lhp, bp) /* RCR */
317struct fsm *fp;
318struct fsmheader *lhp;
319struct mbuf *bp;
320{
321 int plen;
322 int ackaction = 0;
323
324 plen = plength(bp);
325 if (plen < sizeof(struct fsmconfig)) {
326logprintf("** plen = %d\n", plen);
327 pfree(bp);
328 return;
329 }
330
331 /*
332 * Check and process easy case
333 */
334 switch (fp->state) {
335 case ST_INITIAL:
336 case ST_STARTING:
337 LogPrintf(LOG_LCP, "%s: Oops, RCR in %s.\n",
338 fp->name, StateNames[fp->state]);

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

344 return;
345 case ST_CLOSING:
346 case ST_STOPPING:
347logprintf("## state = %d\n", fp->state);
348 pfree(bp);
349 return;
350 }
351
352 (fp->DecodeConfig)(bp, MODE_REQ);
353
354 if (nakp == NakBuff && rejp == RejBuff)
355 ackaction = 1;
356
357 switch (fp->state) {
358 case ST_OPENED:
359 (fp->LayerDown)(fp);
360 FsmSendConfigReq(fp);

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

435}
436
437void
438FsmRecvConfigNak(fp, lhp, bp) /* RCN */
439struct fsm *fp;
440struct fsmheader *lhp;
441struct mbuf *bp;
442{
443 int plen;
444
445 plen = plength(bp);
446 if (plen < sizeof(struct fsmconfig)) {
447 pfree(bp);
448 return;
449 }
450
451 /*
452 * Check and process easy case
453 */
454 switch (fp->state) {

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

464 pfree(bp);
465 return;
466 case ST_CLOSING:
467 case ST_STOPPING:
468 pfree(bp);
469 return;
470 }
471
472 (fp->DecodeConfig)(bp, MODE_NAK);
473
474 switch (fp->state) {
475 case ST_REQSENT:
476 case ST_ACKSENT:
477 FsmInitRestartCounter(fp);
478 FsmSendConfigReq(fp);
479 break;
480 case ST_OPENED:

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

551}
552
553void
554FsmRecvConfigRej(fp, lhp, bp) /* RCJ */
555struct fsm *fp;
556struct fsmheader *lhp;
557struct mbuf *bp;
558{
559 int plen;
560
561 plen = plength(bp);
562 if (plen < sizeof(struct fsmconfig)) {
563 pfree(bp);
564 return;
565 }
566 LogPrintf(LOG_LCP, "%s: RecvConfigRej.\n", fp->name);
567
568 /*
569 * Check and process easy case
570 */

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

581 pfree(bp);
582 return;
583 case ST_CLOSING:
584 case ST_STOPPING:
585 pfree(bp);
586 return;
587 }
588
589 (fp->DecodeConfig)(bp, MODE_REJ);
590
591 switch (fp->state) {
592 case ST_REQSENT:
593 case ST_ACKSENT:
594 FsmInitRestartCounter(fp);
595 FsmSendConfigReq(fp);
596 break;
597 case ST_OPENED:

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

786 return;
787 }
788
789 bp->offset += sizeof(struct fsmheader);
790 bp->cnt -= sizeof(struct fsmheader);
791
792 codep = FsmCodes + lhp->code - 1;
793 LogPrintf(LOG_LCP, "%s: Received %s (%d) state = %s (%d)\n",
794 fp->name, codep->name, lhp->code, StateNames[fp->state], fp->state);
795#ifdef DEBUG
796 LogMemory();
797#endif
798 (codep->action)(fp, lhp, bp);
799#ifdef DEBUG
800 LogMemory();
801#endif
802}