1995-01-31 06:29:58 +00:00
|
|
|
/*
|
|
|
|
* PPP Link Control Protocol (LCP) Module
|
|
|
|
*
|
|
|
|
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that the above copyright notice and this paragraph are
|
|
|
|
* duplicated in all such forms and that any documentation,
|
|
|
|
* advertising materials, and other materials related to such
|
|
|
|
* distribution and use acknowledge that the software was developed
|
|
|
|
* by the Internet Initiative Japan, Inc. The name of the
|
|
|
|
* IIJ may not be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1997-12-03 10:23:54 +00:00
|
|
|
* $Id: lcp.c,v 1.48 1997/11/22 03:37:35 brian Exp $
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1995-01-31 06:29:58 +00:00
|
|
|
* TODO:
|
|
|
|
* o Validate magic number received from peer.
|
|
|
|
* o Limit data field length by MRU
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <sys/param.h>
|
1997-11-16 22:15:11 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/socket.h>
|
1997-09-03 00:40:51 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
1997-11-16 22:15:11 +00:00
|
|
|
#include <net/if.h>
|
1997-11-22 03:37:54 +00:00
|
|
|
#ifdef __FreeBSD__
|
1997-11-16 22:15:11 +00:00
|
|
|
#include <net/if_var.h>
|
1997-11-22 03:37:54 +00:00
|
|
|
#endif
|
1997-11-16 22:15:11 +00:00
|
|
|
#include <net/if_tun.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
1997-09-22 02:51:24 +00:00
|
|
|
#include <signal.h>
|
1997-12-03 10:23:54 +00:00
|
|
|
#include <stdarg.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
#include "command.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "mbuf.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "defs.h"
|
|
|
|
#include "timer.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "fsm.h"
|
|
|
|
#include "lcp.h"
|
|
|
|
#include "ipcp.h"
|
|
|
|
#include "lcpproto.h"
|
|
|
|
#include "os.h"
|
|
|
|
#include "hdlc.h"
|
1996-01-11 17:48:59 +00:00
|
|
|
#include "ccp.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "lqr.h"
|
|
|
|
#include "phase.h"
|
1997-05-26 00:44:10 +00:00
|
|
|
#include "loadalias.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "vars.h"
|
1995-02-26 12:18:08 +00:00
|
|
|
#include "auth.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "pap.h"
|
|
|
|
#include "chap.h"
|
|
|
|
#include "async.h"
|
|
|
|
#include "main.h"
|
1997-10-26 12:42:13 +00:00
|
|
|
#include "ip.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "modem.h"
|
1997-11-16 22:15:11 +00:00
|
|
|
#include "tun.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-12-03 10:23:54 +00:00
|
|
|
/* for received LQRs */
|
|
|
|
struct lqrreq {
|
|
|
|
u_char type;
|
|
|
|
u_char length;
|
|
|
|
u_short proto; /* Quality protocol */
|
|
|
|
u_long period; /* Reporting interval */
|
|
|
|
};
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
struct lcpstate LcpInfo;
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
static void LcpSendConfigReq(struct fsm *);
|
1997-10-26 01:04:02 +00:00
|
|
|
static void LcpSendTerminateReq(struct fsm *);
|
|
|
|
static void LcpSendTerminateAck(struct fsm *);
|
|
|
|
static void LcpDecodeConfig(u_char *, int, int);
|
1997-06-09 03:27:43 +00:00
|
|
|
static void LcpInitRestartCounter(struct fsm *);
|
|
|
|
static void LcpLayerUp(struct fsm *);
|
|
|
|
static void LcpLayerDown(struct fsm *);
|
|
|
|
static void LcpLayerStart(struct fsm *);
|
|
|
|
static void LcpLayerFinish(struct fsm *);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-22 03:37:54 +00:00
|
|
|
static const char *cftypes[] = {
|
1997-11-14 15:39:15 +00:00
|
|
|
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
|
|
|
|
"???",
|
|
|
|
"MRU", /* 1: Maximum-Receive-Unit */
|
|
|
|
"ACCMAP", /* 2: Async-Control-Character-Map */
|
|
|
|
"AUTHPROTO", /* 3: Authentication-Protocol */
|
|
|
|
"QUALPROTO", /* 4: Quality-Protocol */
|
|
|
|
"MAGICNUM", /* 5: Magic-Number */
|
|
|
|
"RESERVED", /* 6: RESERVED */
|
|
|
|
"PROTOCOMP", /* 7: Protocol-Field-Compression */
|
|
|
|
"ACFCOMP", /* 8: Address-and-Control-Field-Compression */
|
|
|
|
"FCSALT", /* 9: FCS-Alternatives */
|
|
|
|
"SDP", /* 10: Self-Describing-Pad */
|
|
|
|
"NUMMODE", /* 11: Numbered-Mode */
|
|
|
|
"MULTIPROC", /* 12: Multi-Link-Procedure */
|
|
|
|
"CALLBACK", /* 13: Callback */
|
|
|
|
"CONTIME", /* 14: Connect-Time */
|
|
|
|
"COMPFRAME", /* 15: Compound-Frames */
|
|
|
|
"NDE", /* 16: Nominal-Data-Encapsulation */
|
|
|
|
"MULTIMRRU", /* 17: Multilink-MRRU */
|
|
|
|
"MULTISSNH", /* 18: Multilink-Short-Sequence-Number-Header */
|
|
|
|
"MULTIED", /* 19: Multilink-Endpoint-Descriminator */
|
|
|
|
"PROPRIETRY", /* 20: Proprietary */
|
|
|
|
"DCEID", /* 21: DCE-Identifier */
|
|
|
|
"MULTIPP", /* 22: Multi-Link-Plus-Procedure */
|
|
|
|
"LDBACP", /* 23: Link Discriminator for BACP */
|
1995-01-31 06:29:58 +00:00
|
|
|
};
|
|
|
|
|
1997-11-14 15:39:15 +00:00
|
|
|
#define NCFTYPES (sizeof(cftypes)/sizeof(char *))
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
struct fsm LcpFsm = {
|
|
|
|
"LCP", /* Name of protocol */
|
|
|
|
PROTO_LCP, /* Protocol Number */
|
|
|
|
LCP_MAXCODE,
|
|
|
|
OPEN_ACTIVE,
|
|
|
|
ST_INITIAL, /* State of machine */
|
|
|
|
0, 0, 0,
|
|
|
|
0,
|
1997-08-25 00:29:32 +00:00
|
|
|
{0, 0, 0, NULL, NULL, NULL},
|
|
|
|
{0, 0, 0, NULL, NULL, NULL},
|
1997-08-20 23:47:53 +00:00
|
|
|
LogLCP,
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
LcpLayerUp,
|
|
|
|
LcpLayerDown,
|
|
|
|
LcpLayerStart,
|
|
|
|
LcpLayerFinish,
|
|
|
|
LcpInitRestartCounter,
|
|
|
|
LcpSendConfigReq,
|
|
|
|
LcpSendTerminateReq,
|
|
|
|
LcpSendTerminateAck,
|
|
|
|
LcpDecodeConfig,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct pppTimer LcpReportTimer;
|
1997-09-22 02:51:24 +00:00
|
|
|
static int LcpFailedMagic;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
static void
|
1997-11-22 03:37:54 +00:00
|
|
|
LcpReportTime(void *data)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
if (LogIsKept(LogDEBUG)) {
|
|
|
|
time_t t;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
time(&t);
|
1997-08-31 22:59:49 +00:00
|
|
|
LogPrintf(LogDEBUG, "LcpReportTime: %s\n", ctime(&t));
|
1997-06-09 03:27:43 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
StopTimer(&LcpReportTimer);
|
|
|
|
LcpReportTimer.state = TIMER_STOPPED;
|
|
|
|
StartTimer(&LcpReportTimer);
|
|
|
|
HdlcErrorCheck();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1997-11-22 03:37:54 +00:00
|
|
|
ReportLcpStatus(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
struct lcpstate *lcp = &LcpInfo;
|
|
|
|
struct fsm *fp = &LcpFsm;
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
if (!VarTerm)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
fprintf(VarTerm, "%s [%s]\n", fp->name, StateNames[fp->state]);
|
1997-08-25 00:29:32 +00:00
|
|
|
fprintf(VarTerm,
|
|
|
|
" his side: MRU %ld, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d, MAGIC %08lx,\n"
|
|
|
|
" REJECT %04lx\n",
|
|
|
|
lcp->his_mru, lcp->his_accmap, lcp->his_protocomp, lcp->his_acfcomp,
|
|
|
|
lcp->his_magic, lcp->his_reject);
|
|
|
|
fprintf(VarTerm,
|
|
|
|
" my side: MRU %ld, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d, MAGIC %08lx,\n"
|
|
|
|
" REJECT %04lx\n",
|
1997-05-11 00:41:30 +00:00
|
|
|
lcp->want_mru, lcp->want_accmap, lcp->want_protocomp, lcp->want_acfcomp,
|
1997-08-25 00:29:32 +00:00
|
|
|
lcp->want_magic, lcp->my_reject);
|
1997-06-09 03:27:43 +00:00
|
|
|
fprintf(VarTerm, "\nDefaults: MRU = %ld, ACCMAP = %08x\t", VarMRU, VarAccmap);
|
1997-08-25 00:29:32 +00:00
|
|
|
fprintf(VarTerm, "Open Mode: %s\n", (VarOpenMode == OPEN_ACTIVE) ? "active" : "passive");
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generate random number which will be used as magic number.
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
static u_long
|
1997-11-22 03:37:54 +00:00
|
|
|
GenerateMagic(void)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-10-26 01:04:02 +00:00
|
|
|
randinit();
|
1997-05-11 00:16:00 +00:00
|
|
|
return (random());
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LcpInit()
|
|
|
|
{
|
|
|
|
struct lcpstate *lcp = &LcpInfo;
|
|
|
|
|
|
|
|
FsmInit(&LcpFsm);
|
|
|
|
HdlcInit();
|
|
|
|
|
1997-10-26 01:04:02 +00:00
|
|
|
memset(lcp, '\0', sizeof(struct lcpstate));
|
1995-01-31 06:29:58 +00:00
|
|
|
lcp->want_mru = VarMRU;
|
|
|
|
lcp->his_mru = DEF_MRU;
|
|
|
|
lcp->his_accmap = 0xffffffff;
|
|
|
|
lcp->want_accmap = VarAccmap;
|
|
|
|
lcp->want_magic = GenerateMagic();
|
|
|
|
lcp->want_auth = lcp->his_auth = 0;
|
|
|
|
if (Enabled(ConfChap))
|
|
|
|
lcp->want_auth = PROTO_CHAP;
|
|
|
|
else if (Enabled(ConfPap))
|
|
|
|
lcp->want_auth = PROTO_PAP;
|
1997-08-25 00:29:32 +00:00
|
|
|
if (Enabled(ConfLqr))
|
|
|
|
lcp->want_lqrperiod = VarLqrTimeout * 100;
|
|
|
|
if (Enabled(ConfAcfcomp))
|
|
|
|
lcp->want_acfcomp = 1;
|
|
|
|
if (Enabled(ConfProtocomp))
|
|
|
|
lcp->want_protocomp = 1;
|
1995-01-31 06:29:58 +00:00
|
|
|
LcpFsm.maxconfig = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpInitRestartCounter(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1995-02-26 12:18:08 +00:00
|
|
|
fp->FsmTimer.load = VarRetryTimeout * SECTICKS;
|
1995-01-31 06:29:58 +00:00
|
|
|
fp->restart = 5;
|
|
|
|
}
|
|
|
|
|
1997-12-03 10:23:54 +00:00
|
|
|
int
|
|
|
|
LcpPutConf(int log, u_char *tgt, const struct lcp_opt *o, const char *nm,
|
|
|
|
const char *arg, ...)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-12-03 10:23:54 +00:00
|
|
|
va_list ap;
|
|
|
|
char buf[30];
|
|
|
|
|
|
|
|
va_start(ap, arg);
|
|
|
|
memcpy(tgt, o, o->len);
|
|
|
|
if (arg == NULL || *arg == '\0')
|
|
|
|
LogPrintf(log, " %s[%d]\n", nm, o->len);
|
|
|
|
else {
|
|
|
|
vsnprintf(buf, sizeof buf, arg, ap);
|
|
|
|
LogPrintf(log, " %s[%d] %s\n", nm, o->len, buf);
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
return o->len;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1997-12-03 10:23:54 +00:00
|
|
|
#define PUTN(ty) \
|
|
|
|
do { \
|
|
|
|
o.id = ty; \
|
|
|
|
o.len = 2; \
|
|
|
|
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], NULL); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define PUTHEXL(ty, arg) \
|
|
|
|
do { \
|
|
|
|
o.id = ty; \
|
|
|
|
o.len = 6; \
|
|
|
|
*(u_long *)o.data = htonl(arg); \
|
|
|
|
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "0x%08x", (u_int)arg);\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define PUTACCMAP(arg) PUTHEXL(TY_ACCMAP, arg)
|
|
|
|
#define PUTMAGIC(arg) PUTHEXL(TY_MAGICNUM, arg)
|
|
|
|
|
|
|
|
#define PUTMRU(arg) \
|
|
|
|
do { \
|
|
|
|
o.id = TY_MRU; \
|
|
|
|
o.len = 4; \
|
|
|
|
*(u_short *)o.data = htons(arg); \
|
|
|
|
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "%lu", arg); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define PUTLQR(period) \
|
|
|
|
do { \
|
|
|
|
o.id = TY_QUALPROTO; \
|
|
|
|
o.len = 8; \
|
|
|
|
*(u_short *)o.data = htons(PROTO_LQR); \
|
|
|
|
*(u_long *)(o.data+2) = period; \
|
|
|
|
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "period %ld", period);\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define PUTPAP() \
|
|
|
|
do { \
|
|
|
|
o.id = TY_AUTHPROTO; \
|
|
|
|
o.len = 4; \
|
|
|
|
*(u_short *)o.data = PROTO_PAP; \
|
|
|
|
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "PAP REQ"); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define PUTCHAP(val) \
|
|
|
|
do { \
|
|
|
|
o.id = TY_AUTHPROTO; \
|
|
|
|
o.len = 5; \
|
|
|
|
*(u_short *)o.data = PROTO_CHAP; \
|
|
|
|
o.data[4] = val; \
|
|
|
|
cp += LcpPutConf(LogLCP, cp, &o, cftypes[o.id], "CHAP REQ (0x%02x)", val);\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define PUTMD5CHAP() PUTCHAP(0x05)
|
|
|
|
#define PUTMSCHAP() PUTCHAP(0x80)
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpSendConfigReq(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
u_char *cp;
|
|
|
|
struct lcpstate *lcp = &LcpInfo;
|
1997-12-03 10:23:54 +00:00
|
|
|
struct lcp_opt o;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogLCP, "LcpSendConfigReq\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
cp = ReqBuff;
|
1995-02-26 12:18:08 +00:00
|
|
|
if (!DEV_IS_SYNC) {
|
1997-12-03 10:23:54 +00:00
|
|
|
if (lcp->want_acfcomp && !REJECTED(lcp, TY_ACFCOMP))
|
|
|
|
PUTN(TY_ACFCOMP);
|
|
|
|
|
|
|
|
if (lcp->want_protocomp && !REJECTED(lcp, TY_PROTOCOMP))
|
|
|
|
PUTN(TY_PROTOCOMP);
|
|
|
|
|
1995-02-26 12:18:08 +00:00
|
|
|
if (!REJECTED(lcp, TY_ACCMAP))
|
1997-12-03 10:23:54 +00:00
|
|
|
PUTACCMAP(lcp->want_accmap);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
if (!REJECTED(lcp, TY_MRU))
|
1997-12-03 10:23:54 +00:00
|
|
|
PUTMRU(lcp->want_mru);
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
if (lcp->want_magic && !REJECTED(lcp, TY_MAGICNUM))
|
1997-12-03 10:23:54 +00:00
|
|
|
PUTMAGIC(lcp->want_magic);
|
|
|
|
|
|
|
|
if (lcp->want_lqrperiod && !REJECTED(lcp, TY_QUALPROTO))
|
|
|
|
PUTLQR(lcp->want_lqrperiod);
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
switch (lcp->want_auth) {
|
|
|
|
case PROTO_PAP:
|
1997-12-03 10:23:54 +00:00
|
|
|
PUTPAP();
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case PROTO_CHAP:
|
1997-09-25 00:52:37 +00:00
|
|
|
#ifdef HAVE_DES
|
1997-12-03 10:23:54 +00:00
|
|
|
if (VarMSChap)
|
|
|
|
PUTMSCHAP(); /* Use MSChap */
|
|
|
|
else
|
1997-09-25 00:52:37 +00:00
|
|
|
#else
|
1997-12-03 10:23:54 +00:00
|
|
|
PUTMD5CHAP(); /* Use MD5 */
|
1997-09-25 00:52:37 +00:00
|
|
|
#endif
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
FsmOutput(fp, CODE_CONFIGREQ, fp->reqid++, ReqBuff, cp - ReqBuff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpSendProtoRej(u_char * option, int count)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
struct fsm *fp = &LcpFsm;
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogLCP, "LcpSendProtoRej\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmOutput(fp, CODE_PROTOREJ, fp->reqid, option, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpSendTerminateReq(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-08-25 00:29:32 +00:00
|
|
|
/* Most thins are done in fsm layer. Nothing to to. */
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpSendTerminateAck(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogLCP, "LcpSendTerminateAck.\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmOutput(fp, CODE_TERMACK, fp->reqid++, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpLayerStart(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogLCP, "LcpLayerStart\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
NewPhase(PHASE_ESTABLISH);
|
|
|
|
}
|
|
|
|
|
1995-02-26 12:18:08 +00:00
|
|
|
static void
|
1997-11-22 03:37:54 +00:00
|
|
|
StopAllTimers(void)
|
1995-02-26 12:18:08 +00:00
|
|
|
{
|
|
|
|
StopTimer(&LcpReportTimer);
|
|
|
|
StopIdleTimer();
|
|
|
|
StopTimer(&AuthPapInfo.authtimer);
|
|
|
|
StopTimer(&AuthChapInfo.authtimer);
|
1996-01-30 11:08:50 +00:00
|
|
|
StopLqrTimer();
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpLayerFinish(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogLCP, "LcpLayerFinish\n");
|
1997-10-29 01:19:51 +00:00
|
|
|
HangupModem(0);
|
1995-02-26 12:18:08 +00:00
|
|
|
StopAllTimers();
|
1997-10-05 15:00:10 +00:00
|
|
|
/* We're down at last. Lets tell background and direct mode to get out */
|
1997-10-29 01:19:51 +00:00
|
|
|
NewPhase(PHASE_DEAD);
|
1997-10-15 01:01:17 +00:00
|
|
|
LcpInit();
|
|
|
|
IpcpInit();
|
|
|
|
CcpInit();
|
1997-06-09 03:27:43 +00:00
|
|
|
Prompt();
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpLayerUp(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogLCP, "LcpLayerUp\n");
|
1997-11-16 22:15:11 +00:00
|
|
|
tun_configure(LcpInfo.his_mru, ModemSpeed());
|
1995-01-31 06:29:58 +00:00
|
|
|
SetLinkParams(&LcpInfo);
|
|
|
|
|
|
|
|
NewPhase(PHASE_AUTHENTICATE);
|
|
|
|
|
|
|
|
StartLqm();
|
|
|
|
StopTimer(&LcpReportTimer);
|
|
|
|
LcpReportTimer.state = TIMER_STOPPED;
|
|
|
|
LcpReportTimer.load = 60 * SECTICKS;
|
|
|
|
LcpReportTimer.func = LcpReportTime;
|
|
|
|
StartTimer(&LcpReportTimer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpLayerDown(struct fsm * fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1995-02-26 12:18:08 +00:00
|
|
|
StopAllTimers();
|
1995-01-31 06:29:58 +00:00
|
|
|
OsLinkdown();
|
1997-09-03 02:08:20 +00:00
|
|
|
LogPrintf(LogLCP, "LcpLayerDown\n");
|
1997-10-05 15:00:10 +00:00
|
|
|
/*
|
|
|
|
* OsLinkdown() brings CCP & IPCP down, then waits 'till we go from
|
|
|
|
* STOPPING to STOPPED. At this point, the FSM gives us a LayerFinish
|
|
|
|
*/
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LcpUp()
|
|
|
|
{
|
|
|
|
FsmUp(&LcpFsm);
|
1997-09-22 02:51:24 +00:00
|
|
|
LcpFailedMagic = 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpDown()
|
|
|
|
{ /* Sudden death */
|
1997-09-22 02:51:24 +00:00
|
|
|
LcpFailedMagic = 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmDown(&LcpFsm);
|
1997-10-29 01:19:51 +00:00
|
|
|
/* FsmDown() results in a LcpLayerDown() if we're currently open. */
|
|
|
|
LcpLayerFinish(&LcpFsm);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-11-08 00:28:11 +00:00
|
|
|
LcpOpen(int open_mode)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-11-08 00:28:11 +00:00
|
|
|
LcpFsm.open_mode = open_mode;
|
1997-09-22 02:51:24 +00:00
|
|
|
LcpFailedMagic = 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmOpen(&LcpFsm);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LcpClose()
|
|
|
|
{
|
1997-10-29 01:19:51 +00:00
|
|
|
NewPhase(PHASE_TERMINATE);
|
|
|
|
OsInterfaceDown(0);
|
1995-01-31 06:29:58 +00:00
|
|
|
FsmClose(&LcpFsm);
|
1997-09-22 02:51:24 +00:00
|
|
|
LcpFailedMagic = 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: Should validate option length
|
|
|
|
*/
|
|
|
|
static void
|
1997-12-03 10:23:54 +00:00
|
|
|
LcpDecodeConfig(u_char *cp, int plen, int mode_type)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1997-12-03 10:23:54 +00:00
|
|
|
int type, length, mru, mtu, sz, pos;
|
1995-01-31 06:29:58 +00:00
|
|
|
u_long *lp, magic, accmap;
|
|
|
|
u_short *sp, proto;
|
|
|
|
struct lqrreq *req;
|
1997-12-03 10:23:54 +00:00
|
|
|
char request[20], desc[22];
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
ackp = AckBuff;
|
|
|
|
nakp = NakBuff;
|
|
|
|
rejp = RejBuff;
|
|
|
|
|
|
|
|
while (plen >= sizeof(struct fsmconfig)) {
|
|
|
|
type = *cp;
|
|
|
|
length = cp[1];
|
1997-12-03 10:23:54 +00:00
|
|
|
|
|
|
|
if (type < 0 || type >= NCFTYPES)
|
|
|
|
snprintf(request, sizeof request, " <%d>[%d]", type, length);
|
1995-01-31 06:29:58 +00:00
|
|
|
else
|
1997-12-03 10:23:54 +00:00
|
|
|
snprintf(request, sizeof request, " %s[%d]", cftypes[type], length);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case TY_MRU:
|
1997-08-25 00:29:32 +00:00
|
|
|
sp = (u_short *) (cp + 2);
|
1995-01-31 06:29:58 +00:00
|
|
|
mru = htons(*sp);
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, "%s %d\n", request, mru);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
1997-09-29 19:40:16 +00:00
|
|
|
mtu = VarPrefMTU;
|
|
|
|
if (mtu == 0)
|
|
|
|
mtu = MAX_MTU;
|
|
|
|
if (mru > mtu) {
|
|
|
|
*sp = htons(mtu);
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(nakp, cp, 4);
|
1997-08-25 00:29:32 +00:00
|
|
|
nakp += 4;
|
1995-01-31 06:29:58 +00:00
|
|
|
} else if (mru < MIN_MRU) {
|
|
|
|
*sp = htons(MIN_MRU);
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(nakp, cp, 4);
|
1997-08-25 00:29:32 +00:00
|
|
|
nakp += 4;
|
1995-01-31 06:29:58 +00:00
|
|
|
} else {
|
|
|
|
LcpInfo.his_mru = mru;
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(ackp, cp, 4);
|
1997-08-25 00:29:32 +00:00
|
|
|
ackp += 4;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
|
|
|
if (mru >= MIN_MRU || mru <= MAX_MRU)
|
|
|
|
LcpInfo.want_mru = mru;
|
|
|
|
break;
|
|
|
|
case MODE_REJ:
|
|
|
|
LcpInfo.his_reject |= (1 << type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case TY_ACCMAP:
|
1997-08-25 00:29:32 +00:00
|
|
|
lp = (u_long *) (cp + 2);
|
1995-01-31 06:29:58 +00:00
|
|
|
accmap = htonl(*lp);
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, "%s 0x%08x\n", request, accmap);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
|
|
|
LcpInfo.his_accmap = accmap;
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(ackp, cp, 6);
|
1997-08-25 00:29:32 +00:00
|
|
|
ackp += 6;
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
|
|
|
LcpInfo.want_accmap = accmap;
|
|
|
|
break;
|
|
|
|
case MODE_REJ:
|
|
|
|
LcpInfo.his_reject |= (1 << type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case TY_AUTHPROTO:
|
1997-08-25 00:29:32 +00:00
|
|
|
sp = (u_short *) (cp + 2);
|
1995-01-31 06:29:58 +00:00
|
|
|
proto = ntohs(*sp);
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, "%s 0x%04x\n", request, proto);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
|
|
|
switch (proto) {
|
|
|
|
case PROTO_PAP:
|
|
|
|
if (length != 4) {
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, " Bad length!\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
goto reqreject;
|
|
|
|
}
|
|
|
|
if (Acceptable(ConfPap)) {
|
|
|
|
LcpInfo.his_auth = proto;
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(ackp, cp, length);
|
1997-08-25 00:29:32 +00:00
|
|
|
ackp += length;
|
1995-01-31 06:29:58 +00:00
|
|
|
} else if (Acceptable(ConfChap)) {
|
1997-08-25 00:29:32 +00:00
|
|
|
*nakp++ = *cp;
|
|
|
|
*nakp++ = 5;
|
|
|
|
*nakp++ = (unsigned char) (PROTO_CHAP >> 8);
|
|
|
|
*nakp++ = (unsigned char) PROTO_CHAP;
|
1995-01-31 06:29:58 +00:00
|
|
|
*nakp++ = 5;
|
|
|
|
} else
|
|
|
|
goto reqreject;
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case PROTO_CHAP:
|
|
|
|
if (length < 5) {
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, " Bad length!\n");
|
1995-01-31 06:29:58 +00:00
|
|
|
goto reqreject;
|
|
|
|
}
|
1997-09-25 00:52:37 +00:00
|
|
|
#ifdef HAVE_DES
|
|
|
|
if (Acceptable(ConfChap) && (cp[4] == 5 || cp[4] == 0x80))
|
|
|
|
#else
|
|
|
|
if (Acceptable(ConfChap) && cp[4] == 5)
|
|
|
|
#endif
|
|
|
|
{
|
1995-01-31 06:29:58 +00:00
|
|
|
LcpInfo.his_auth = proto;
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(ackp, cp, length);
|
1997-08-25 00:29:32 +00:00
|
|
|
ackp += length;
|
1997-09-25 00:52:37 +00:00
|
|
|
#ifdef HAVE_DES
|
1997-11-11 13:08:12 +00:00
|
|
|
VarMSChap = cp[4] == 0x80;
|
1997-09-25 00:52:37 +00:00
|
|
|
#endif
|
1995-01-31 06:29:58 +00:00
|
|
|
} else if (Acceptable(ConfPap)) {
|
1997-08-25 00:29:32 +00:00
|
|
|
*nakp++ = *cp;
|
|
|
|
*nakp++ = 4;
|
|
|
|
*nakp++ = (unsigned char) (PROTO_PAP >> 8);
|
|
|
|
*nakp++ = (unsigned char) PROTO_PAP;
|
1995-01-31 06:29:58 +00:00
|
|
|
} else
|
|
|
|
goto reqreject;
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
default:
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, " proto %d not implemented, NAK.\n", proto);
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(nakp, cp, length);
|
1997-08-25 00:29:32 +00:00
|
|
|
nakp += length;
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
|
|
|
break;
|
|
|
|
case MODE_REJ:
|
|
|
|
LcpInfo.his_reject |= (1 << type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case TY_QUALPROTO:
|
1997-08-25 00:29:32 +00:00
|
|
|
req = (struct lqrreq *) cp;
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, "%s proto %x, interval %dms\n",
|
|
|
|
request, ntohs(req->proto), ntohl(req->period) * 10);
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
|
|
|
if (ntohs(req->proto) != PROTO_LQR || !Acceptable(ConfLqr))
|
|
|
|
goto reqreject;
|
|
|
|
else {
|
|
|
|
LcpInfo.his_lqrperiod = ntohl(req->period);
|
|
|
|
if (LcpInfo.his_lqrperiod < 500)
|
|
|
|
LcpInfo.his_lqrperiod = 500;
|
|
|
|
req->period = htonl(LcpInfo.his_lqrperiod);
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(ackp, cp, length);
|
1997-08-25 00:29:32 +00:00
|
|
|
ackp += length;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
|
|
|
break;
|
|
|
|
case MODE_REJ:
|
|
|
|
LcpInfo.his_reject |= (1 << type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case TY_MAGICNUM:
|
1997-08-25 00:29:32 +00:00
|
|
|
lp = (u_long *) (cp + 2);
|
1995-01-31 06:29:58 +00:00
|
|
|
magic = ntohl(*lp);
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, "%s 0x%08x\n", request, magic);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
|
|
|
if (LcpInfo.want_magic) {
|
1997-06-01 03:43:26 +00:00
|
|
|
/* Validate magic number */
|
|
|
|
if (magic == LcpInfo.want_magic) {
|
1997-09-22 02:51:24 +00:00
|
|
|
LogPrintf(LogLCP, "Magic is same (%08x) - %d times\n",
|
|
|
|
magic, ++LcpFailedMagic);
|
1997-06-01 03:43:26 +00:00
|
|
|
LcpInfo.want_magic = GenerateMagic();
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(nakp, cp, 6);
|
1997-08-25 00:29:32 +00:00
|
|
|
nakp += 6;
|
1997-09-22 02:51:24 +00:00
|
|
|
ualarm(TICKUNIT * (4 + 4 * LcpFailedMagic), 0);
|
|
|
|
sigpause(0);
|
1997-08-25 00:29:32 +00:00
|
|
|
} else {
|
1997-06-01 03:43:26 +00:00
|
|
|
LcpInfo.his_magic = magic;
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(ackp, cp, length);
|
1997-08-25 00:29:32 +00:00
|
|
|
ackp += length;
|
1997-09-22 02:51:24 +00:00
|
|
|
LcpFailedMagic = 0;
|
1997-08-25 00:29:32 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
} else {
|
|
|
|
LcpInfo.my_reject |= (1 << type);
|
|
|
|
goto reqreject;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, " Magic 0x%08x is NAKed!\n", magic);
|
1995-01-31 06:29:58 +00:00
|
|
|
LcpInfo.want_magic = GenerateMagic();
|
|
|
|
break;
|
|
|
|
case MODE_REJ:
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, " Magic 0x%80x is REJected!\n", magic);
|
1995-01-31 06:29:58 +00:00
|
|
|
LcpInfo.want_magic = 0;
|
|
|
|
LcpInfo.his_reject |= (1 << type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case TY_PROTOCOMP:
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, "%s\n", request);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
1997-08-25 00:29:32 +00:00
|
|
|
if (Acceptable(ConfProtocomp)) {
|
1995-01-31 06:29:58 +00:00
|
|
|
LcpInfo.his_protocomp = 1;
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(ackp, cp, 2);
|
1997-08-25 00:29:32 +00:00
|
|
|
ackp += 2;
|
|
|
|
} else {
|
1995-01-31 06:29:58 +00:00
|
|
|
#ifdef OLDMST
|
|
|
|
/*
|
|
|
|
* MorningStar before v1.3 needs NAK
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(nakp, cp, 2);
|
1997-08-25 00:29:32 +00:00
|
|
|
nakp += 2;
|
1995-01-31 06:29:58 +00:00
|
|
|
#else
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(rejp, cp, 2);
|
1997-08-25 00:29:32 +00:00
|
|
|
rejp += 2;
|
1995-01-31 06:29:58 +00:00
|
|
|
LcpInfo.my_reject |= (1 << type);
|
|
|
|
#endif
|
1997-08-25 00:29:32 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
|
|
|
case MODE_REJ:
|
|
|
|
LcpInfo.want_protocomp = 0;
|
|
|
|
LcpInfo.his_reject |= (1 << type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case TY_ACFCOMP:
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, "%s\n", request);
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
1997-08-25 00:29:32 +00:00
|
|
|
if (Acceptable(ConfAcfcomp)) {
|
1995-01-31 06:29:58 +00:00
|
|
|
LcpInfo.his_acfcomp = 1;
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(ackp, cp, 2);
|
1995-01-31 06:29:58 +00:00
|
|
|
ackp += 2;
|
1997-08-25 00:29:32 +00:00
|
|
|
} else {
|
1995-01-31 06:29:58 +00:00
|
|
|
#ifdef OLDMST
|
|
|
|
/*
|
|
|
|
* MorningStar before v1.3 needs NAK
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(nakp, cp, 2);
|
1995-01-31 06:29:58 +00:00
|
|
|
nakp += 2;
|
|
|
|
#else
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(rejp, cp, 2);
|
1995-01-31 06:29:58 +00:00
|
|
|
rejp += 2;
|
|
|
|
LcpInfo.my_reject |= (1 << type);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
|
|
|
case MODE_REJ:
|
|
|
|
LcpInfo.want_acfcomp = 0;
|
|
|
|
LcpInfo.his_reject |= (1 << type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case TY_SDP:
|
1997-12-03 10:23:54 +00:00
|
|
|
LogPrintf(LogLCP, "%s\n", request);
|
1997-11-08 00:28:11 +00:00
|
|
|
switch (mode_type) {
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REQ:
|
|
|
|
case MODE_NAK:
|
|
|
|
case MODE_REJ:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
default:
|
1997-12-03 10:23:54 +00:00
|
|
|
sz = (sizeof(desc)-2)/2;
|
|
|
|
if (sz > length - 2)
|
|
|
|
sz = length - 2;
|
|
|
|
pos = 0;
|
|
|
|
desc[0] = sz ? ' ' : '\0';
|
|
|
|
for (pos = 0; sz--; pos++)
|
|
|
|
sprintf(desc+(pos<<1)+1, "%02x", cp[pos+2]);
|
|
|
|
|
|
|
|
LogPrintf(LogLCP, "%s%s\n", request, desc);
|
|
|
|
|
1997-11-08 00:28:11 +00:00
|
|
|
if (mode_type == MODE_REQ) {
|
1997-12-03 10:23:54 +00:00
|
|
|
reqreject:
|
|
|
|
if (length > sizeof(RejBuff) - (rejp - RejBuff)) {
|
|
|
|
length = sizeof(RejBuff) - (rejp - RejBuff);
|
|
|
|
LogPrintf(LogLCP, "Can't REJ length %d - trunating to %d\n",
|
|
|
|
cp[1], length);
|
|
|
|
}
|
1997-10-26 01:04:02 +00:00
|
|
|
memcpy(rejp, cp, length);
|
1997-08-25 00:29:32 +00:00
|
|
|
rejp += length;
|
|
|
|
LcpInfo.my_reject |= (1 << type);
|
1997-12-03 10:23:54 +00:00
|
|
|
if (length != cp[1])
|
|
|
|
return;
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
1996-10-12 16:20:34 +00:00
|
|
|
/* to avoid inf. loop */
|
|
|
|
if (length == 0) {
|
1997-06-09 03:27:43 +00:00
|
|
|
LogPrintf(LogLCP, "LCP size zero\n");
|
1996-10-12 16:20:34 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
plen -= length;
|
|
|
|
cp += length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-08-25 00:29:32 +00:00
|
|
|
LcpInput(struct mbuf * bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
FsmInput(&LcpFsm, bp);
|
|
|
|
}
|