2001-06-13 21:52:19 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
|
|
|
|
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
|
|
|
|
* Internet Initiative Japan, Inc (IIJ)
|
|
|
|
* All rights reserved.
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-01-31 06:29:58 +00:00
|
|
|
*/
|
1998-05-21 21:49:08 +00:00
|
|
|
|
1999-01-28 01:56:34 +00:00
|
|
|
#include <sys/param.h>
|
1998-01-21 02:15:33 +00:00
|
|
|
#include <netinet/in.h>
|
1998-05-21 21:49:08 +00:00
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
2001-08-14 16:05:52 +00:00
|
|
|
#include <sys/socket.h>
|
1998-05-21 21:49:08 +00:00
|
|
|
#include <sys/un.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
1997-09-22 02:51:24 +00:00
|
|
|
#include <signal.h>
|
2002-08-27 20:11:58 +00:00
|
|
|
#include <stdarg.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
1998-06-27 23:48:54 +00:00
|
|
|
#include <string.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <termios.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "layer.h"
|
1998-09-04 18:26:00 +00:00
|
|
|
#include "ua.h"
|
1998-06-15 19:06:25 +00:00
|
|
|
#include "defs.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 "timer.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "fsm.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "iplist.h"
|
|
|
|
#include "throughput.h"
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "proto.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "descriptor.h"
|
|
|
|
#include "lqr.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "hdlc.h"
|
2000-07-19 02:10:35 +00:00
|
|
|
#include "lcp.h"
|
1996-01-11 17:48:59 +00:00
|
|
|
#include "ccp.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "async.h"
|
|
|
|
#include "link.h"
|
|
|
|
#include "physical.h"
|
|
|
|
#include "prompt.h"
|
|
|
|
#include "slcompress.h"
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ncpaddr.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "ipcp.h"
|
|
|
|
#include "filter.h"
|
|
|
|
#include "mp.h"
|
|
|
|
#include "chat.h"
|
1995-02-26 12:18:08 +00:00
|
|
|
#include "auth.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "chap.h"
|
1998-08-07 18:42:51 +00:00
|
|
|
#include "cbcp.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "datalink.h"
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
#include "radius.h"
|
|
|
|
#endif
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ipv6cp.h"
|
|
|
|
#include "ncp.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "bundle.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-12-03 10:23:54 +00:00
|
|
|
/* for received LQRs */
|
|
|
|
struct lqrreq {
|
2002-04-16 23:57:09 +00:00
|
|
|
struct fsm_opt_hdr hdr;
|
1997-12-03 10:23:54 +00:00
|
|
|
u_short proto; /* Quality protocol */
|
1998-06-27 23:48:54 +00:00
|
|
|
u_int32_t period; /* Reporting interval */
|
1997-12-03 10:23:54 +00:00
|
|
|
};
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static int LcpLayerUp(struct fsm *);
|
1997-06-09 03:27:43 +00:00
|
|
|
static void LcpLayerDown(struct fsm *);
|
|
|
|
static void LcpLayerStart(struct fsm *);
|
|
|
|
static void LcpLayerFinish(struct fsm *);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
static void LcpInitRestartCounter(struct fsm *, int);
|
1998-05-21 21:49:08 +00:00
|
|
|
static void LcpSendConfigReq(struct fsm *);
|
|
|
|
static void LcpSentTerminateReq(struct fsm *);
|
|
|
|
static void LcpSendTerminateAck(struct fsm *, u_char);
|
2002-04-16 23:57:09 +00:00
|
|
|
static void LcpDecodeConfig(struct fsm *, u_char *, u_char *, int,
|
1998-05-21 21:49:08 +00:00
|
|
|
struct fsm_decode *);
|
|
|
|
|
|
|
|
static struct fsm_callbacks lcp_Callbacks = {
|
|
|
|
LcpLayerUp,
|
|
|
|
LcpLayerDown,
|
|
|
|
LcpLayerStart,
|
|
|
|
LcpLayerFinish,
|
|
|
|
LcpInitRestartCounter,
|
|
|
|
LcpSendConfigReq,
|
|
|
|
LcpSentTerminateReq,
|
|
|
|
LcpSendTerminateAck,
|
|
|
|
LcpDecodeConfig,
|
|
|
|
fsm_NullRecvResetReq,
|
|
|
|
fsm_NullRecvResetAck
|
|
|
|
};
|
|
|
|
|
1999-12-27 11:54:57 +00:00
|
|
|
static const char * const lcp_TimerNames[] =
|
1998-05-21 21:49:08 +00:00
|
|
|
{"LCP restart", "LCP openmode", "LCP stopped"};
|
1995-01-31 06:29:58 +00:00
|
|
|
|
2000-03-14 01:46:54 +00:00
|
|
|
static const char *
|
|
|
|
protoname(int proto)
|
|
|
|
{
|
|
|
|
static const char * const cftypes[] = {
|
|
|
|
/* Check out the latest ``Assigned numbers'' rfc (1700) */
|
|
|
|
NULL,
|
|
|
|
"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 */
|
|
|
|
"MRRU", /* 17: Multilink-MRRU */
|
|
|
|
"SHORTSEQ", /* 18: Multilink-Short-Sequence-Number-Header */
|
|
|
|
"ENDDISC", /* 19: Multilink-Endpoint-Discriminator */
|
|
|
|
"PROPRIETRY", /* 20: Proprietary */
|
|
|
|
"DCEID", /* 21: DCE-Identifier */
|
|
|
|
"MULTIPP", /* 22: Multi-Link-Plus-Procedure */
|
|
|
|
"LDBACP", /* 23: Link Discriminator for BACP */
|
|
|
|
};
|
|
|
|
|
|
|
|
if (proto < 0 || proto > sizeof cftypes / sizeof *cftypes ||
|
|
|
|
cftypes[proto] == NULL)
|
|
|
|
return HexStr(proto, NULL, 0);
|
|
|
|
|
|
|
|
return cftypes[proto];
|
|
|
|
}
|
1997-11-14 15:39:15 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
int
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp_ReportStatus(struct cmdargs const *arg)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
struct link *l;
|
|
|
|
struct lcp *lcp;
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
l = command_ChooseLink(arg);
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp = &l->lcp;
|
|
|
|
|
|
|
|
prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, lcp->fsm.name,
|
|
|
|
State2Nam(lcp->fsm.state));
|
|
|
|
prompt_Printf(arg->prompt,
|
2002-04-16 23:57:09 +00:00
|
|
|
" his side: MRU %d, ACCMAP %08lx, PROTOCOMP %s, ACFCOMP %s,\n"
|
|
|
|
" MAGIC %08lx, MRRU %u, SHORTSEQ %s, REJECT %04x\n",
|
|
|
|
lcp->his_mru, (u_long)lcp->his_accmap,
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->his_protocomp ? "on" : "off",
|
|
|
|
lcp->his_acfcomp ? "on" : "off",
|
|
|
|
(u_long)lcp->his_magic, lcp->his_mrru,
|
|
|
|
lcp->his_shortseq ? "on" : "off", lcp->his_reject);
|
|
|
|
prompt_Printf(arg->prompt,
|
2002-04-16 23:57:09 +00:00
|
|
|
" my side: MRU %d, ACCMAP %08lx, PROTOCOMP %s, ACFCOMP %s,\n"
|
1998-05-21 21:49:08 +00:00
|
|
|
" MAGIC %08lx, MRRU %u, SHORTSEQ %s, REJECT %04x\n",
|
|
|
|
lcp->want_mru, (u_long)lcp->want_accmap,
|
|
|
|
lcp->want_protocomp ? "on" : "off",
|
|
|
|
lcp->want_acfcomp ? "on" : "off",
|
|
|
|
(u_long)lcp->want_magic, lcp->want_mrru,
|
|
|
|
lcp->want_shortseq ? "on" : "off", lcp->my_reject);
|
|
|
|
|
2001-07-26 11:33:53 +00:00
|
|
|
if (lcp->cfg.mru)
|
|
|
|
prompt_Printf(arg->prompt, "\n Defaults: MRU = %d (max %d), ",
|
|
|
|
lcp->cfg.mru, lcp->cfg.max_mru);
|
|
|
|
else
|
|
|
|
prompt_Printf(arg->prompt, "\n Defaults: MRU = any (max %d), ",
|
|
|
|
lcp->cfg.max_mru);
|
2001-06-18 14:59:36 +00:00
|
|
|
if (lcp->cfg.mtu)
|
|
|
|
prompt_Printf(arg->prompt, "MTU = %d (max %d), ",
|
|
|
|
lcp->cfg.mtu, lcp->cfg.max_mtu);
|
|
|
|
else
|
|
|
|
prompt_Printf(arg->prompt, "MTU = any (max %d), ", lcp->cfg.max_mtu);
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "ACCMAP = %08lx\n", (u_long)lcp->cfg.accmap);
|
|
|
|
prompt_Printf(arg->prompt, " LQR period = %us, ",
|
|
|
|
lcp->cfg.lqrperiod);
|
|
|
|
prompt_Printf(arg->prompt, "Open Mode = %s",
|
|
|
|
lcp->cfg.openmode == OPEN_PASSIVE ? "passive" : "active");
|
|
|
|
if (lcp->cfg.openmode > 0)
|
|
|
|
prompt_Printf(arg->prompt, " (delay %ds)", lcp->cfg.openmode);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
prompt_Printf(arg->prompt, "\n FSM retry = %us, max %u Config"
|
|
|
|
" REQ%s, %u Term REQ%s\n", lcp->cfg.fsm.timeout,
|
|
|
|
lcp->cfg.fsm.maxreq, lcp->cfg.fsm.maxreq == 1 ? "" : "s",
|
|
|
|
lcp->cfg.fsm.maxtrm, lcp->cfg.fsm.maxtrm == 1 ? "" : "s");
|
2000-07-19 02:10:35 +00:00
|
|
|
prompt_Printf(arg->prompt, " Ident: %s\n", lcp->cfg.ident);
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, "\n Negotiation:\n");
|
|
|
|
prompt_Printf(arg->prompt, " ACFCOMP = %s\n",
|
|
|
|
command_ShowNegval(lcp->cfg.acfcomp));
|
|
|
|
prompt_Printf(arg->prompt, " CHAP = %s\n",
|
1999-02-18 00:52:15 +00:00
|
|
|
command_ShowNegval(lcp->cfg.chap05));
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2000-11-29 15:47:35 +00:00
|
|
|
prompt_Printf(arg->prompt, " CHAP80 = %s\n",
|
1999-02-18 00:52:15 +00:00
|
|
|
command_ShowNegval(lcp->cfg.chap80nt));
|
|
|
|
prompt_Printf(arg->prompt, " LANMan = %s\n",
|
|
|
|
command_ShowNegval(lcp->cfg.chap80lm));
|
2000-10-30 00:15:04 +00:00
|
|
|
prompt_Printf(arg->prompt, " CHAP81 = %s\n",
|
|
|
|
command_ShowNegval(lcp->cfg.chap81));
|
1999-02-18 00:52:15 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
prompt_Printf(arg->prompt, " LQR = %s\n",
|
|
|
|
command_ShowNegval(lcp->cfg.lqr));
|
|
|
|
prompt_Printf(arg->prompt, " PAP = %s\n",
|
|
|
|
command_ShowNegval(lcp->cfg.pap));
|
|
|
|
prompt_Printf(arg->prompt, " PROTOCOMP = %s\n",
|
|
|
|
command_ShowNegval(lcp->cfg.protocomp));
|
|
|
|
|
1997-06-09 03:27:43 +00:00
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-01-11 17:50:49 +00:00
|
|
|
static u_int32_t
|
1997-11-22 03:37:54 +00:00
|
|
|
GenerateMagic(void)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Generate random number which will be used as magic number */
|
1997-10-26 01:04:02 +00:00
|
|
|
randinit();
|
1998-05-21 21:49:08 +00:00
|
|
|
return random();
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp_SetupCallbacks(struct lcp *lcp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->fsm.fn = &lcp_Callbacks;
|
|
|
|
lcp->fsm.FsmTimer.name = lcp_TimerNames[0];
|
|
|
|
lcp->fsm.OpenTimer.name = lcp_TimerNames[1];
|
|
|
|
lcp->fsm.StoppedTimer.name = lcp_TimerNames[2];
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
void
|
|
|
|
lcp_Init(struct lcp *lcp, struct bundle *bundle, struct link *l,
|
|
|
|
const struct fsm_parent *parent)
|
|
|
|
{
|
|
|
|
/* Initialise ourselves */
|
|
|
|
int mincode = parent ? 1 : LCP_MINMPCODE;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
fsm_Init(&lcp->fsm, "LCP", PROTO_LCP, mincode, LCP_MAXCODE, LogLCP,
|
1998-05-21 21:49:08 +00:00
|
|
|
bundle, l, parent, &lcp_Callbacks, lcp_TimerNames);
|
|
|
|
|
2001-07-26 11:33:53 +00:00
|
|
|
lcp->cfg.mru = 0;
|
2001-06-18 14:59:36 +00:00
|
|
|
lcp->cfg.max_mru = MAX_MRU;
|
|
|
|
lcp->cfg.mtu = 0;
|
|
|
|
lcp->cfg.max_mtu = MAX_MTU;
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->cfg.accmap = 0;
|
|
|
|
lcp->cfg.openmode = 1;
|
|
|
|
lcp->cfg.lqrperiod = DEF_LQRPERIOD;
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
lcp->cfg.fsm.timeout = DEF_FSMRETRY;
|
|
|
|
lcp->cfg.fsm.maxreq = DEF_FSMTRIES;
|
|
|
|
lcp->cfg.fsm.maxtrm = DEF_FSMTRIES;
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
lcp->cfg.acfcomp = NEG_ENABLED|NEG_ACCEPTED;
|
1999-02-18 00:52:15 +00:00
|
|
|
lcp->cfg.chap05 = NEG_ACCEPTED;
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
1999-02-18 00:52:15 +00:00
|
|
|
lcp->cfg.chap80nt = NEG_ACCEPTED;
|
2001-07-03 22:20:11 +00:00
|
|
|
lcp->cfg.chap80lm = 0;
|
2000-11-19 16:53:50 +00:00
|
|
|
lcp->cfg.chap81 = NEG_ACCEPTED;
|
1999-02-18 00:52:15 +00:00
|
|
|
#endif
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->cfg.lqr = NEG_ACCEPTED;
|
|
|
|
lcp->cfg.pap = NEG_ACCEPTED;
|
|
|
|
lcp->cfg.protocomp = NEG_ENABLED|NEG_ACCEPTED;
|
2000-07-19 02:10:35 +00:00
|
|
|
*lcp->cfg.ident = '\0';
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
lcp_Setup(lcp, lcp->cfg.openmode);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
void
|
|
|
|
lcp_Setup(struct lcp *lcp, int openmode)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
2001-06-18 14:59:36 +00:00
|
|
|
struct physical *p = link2physical(lcp->fsm.link);
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->fsm.open_mode = openmode;
|
|
|
|
|
2001-06-18 14:59:36 +00:00
|
|
|
lcp->his_mru = DEF_MRU;
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->his_mrru = 0;
|
|
|
|
lcp->his_magic = 0;
|
|
|
|
lcp->his_lqrperiod = 0;
|
|
|
|
lcp->his_acfcomp = 0;
|
|
|
|
lcp->his_auth = 0;
|
1999-02-18 00:52:15 +00:00
|
|
|
lcp->his_authtype = 0;
|
1998-08-07 18:42:51 +00:00
|
|
|
lcp->his_callback.opmask = 0;
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->his_shortseq = 0;
|
2001-10-18 08:47:56 +00:00
|
|
|
lcp->mru_req = 0;
|
1998-05-21 21:49:08 +00:00
|
|
|
|
2001-07-26 11:33:53 +00:00
|
|
|
if ((lcp->want_mru = lcp->cfg.mru) == 0)
|
|
|
|
lcp->want_mru = DEF_MRU;
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->want_mrru = lcp->fsm.bundle->ncp.mp.cfg.mrru;
|
|
|
|
lcp->want_shortseq = IsEnabled(lcp->fsm.bundle->ncp.mp.cfg.shortseq) ? 1 : 0;
|
|
|
|
lcp->want_acfcomp = IsEnabled(lcp->cfg.acfcomp) ? 1 : 0;
|
|
|
|
|
|
|
|
if (lcp->fsm.parent) {
|
|
|
|
lcp->his_accmap = 0xffffffff;
|
|
|
|
lcp->want_accmap = lcp->cfg.accmap;
|
|
|
|
lcp->his_protocomp = 0;
|
|
|
|
lcp->want_protocomp = IsEnabled(lcp->cfg.protocomp) ? 1 : 0;
|
|
|
|
lcp->want_magic = GenerateMagic();
|
1999-02-18 00:52:15 +00:00
|
|
|
|
|
|
|
if (IsEnabled(lcp->cfg.chap05)) {
|
|
|
|
lcp->want_auth = PROTO_CHAP;
|
|
|
|
lcp->want_authtype = 0x05;
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
1999-02-18 00:52:15 +00:00
|
|
|
} else if (IsEnabled(lcp->cfg.chap80nt) ||
|
|
|
|
IsEnabled(lcp->cfg.chap80lm)) {
|
|
|
|
lcp->want_auth = PROTO_CHAP;
|
|
|
|
lcp->want_authtype = 0x80;
|
2000-10-30 00:15:04 +00:00
|
|
|
} else if (IsEnabled(lcp->cfg.chap81)) {
|
|
|
|
lcp->want_auth = PROTO_CHAP;
|
|
|
|
lcp->want_authtype = 0x81;
|
1999-02-18 00:52:15 +00:00
|
|
|
#endif
|
|
|
|
} else if (IsEnabled(lcp->cfg.pap)) {
|
|
|
|
lcp->want_auth = PROTO_PAP;
|
|
|
|
lcp->want_authtype = 0;
|
|
|
|
} else {
|
|
|
|
lcp->want_auth = 0;
|
|
|
|
lcp->want_authtype = 0;
|
|
|
|
}
|
|
|
|
|
1998-08-07 18:42:51 +00:00
|
|
|
if (p->type != PHYS_DIRECT)
|
2000-10-30 00:15:29 +00:00
|
|
|
memcpy(&lcp->want_callback, &p->dl->cfg.callback,
|
|
|
|
sizeof(struct callback));
|
1998-08-07 18:42:51 +00:00
|
|
|
else
|
|
|
|
lcp->want_callback.opmask = 0;
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->want_lqrperiod = IsEnabled(lcp->cfg.lqr) ?
|
|
|
|
lcp->cfg.lqrperiod * 100 : 0;
|
|
|
|
} else {
|
|
|
|
lcp->his_accmap = lcp->want_accmap = 0;
|
|
|
|
lcp->his_protocomp = lcp->want_protocomp = 1;
|
|
|
|
lcp->want_magic = 0;
|
|
|
|
lcp->want_auth = 0;
|
1999-02-18 00:52:15 +00:00
|
|
|
lcp->want_authtype = 0;
|
1998-08-07 18:42:51 +00:00
|
|
|
lcp->want_callback.opmask = 0;
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->want_lqrperiod = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
lcp->his_reject = lcp->my_reject = 0;
|
|
|
|
lcp->auth_iwait = lcp->auth_ineed = 0;
|
|
|
|
lcp->LcpFailedMagic = 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static void
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
LcpInitRestartCounter(struct fsm *fp, int what)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Set fsm timer load */
|
|
|
|
struct lcp *lcp = fsm2lcp(fp);
|
1997-12-03 10:23:54 +00:00
|
|
|
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
fp->FsmTimer.load = lcp->cfg.fsm.timeout * SECTICKS;
|
|
|
|
switch (what) {
|
|
|
|
case FSM_REQ_TIMER:
|
|
|
|
fp->restart = lcp->cfg.fsm.maxreq;
|
|
|
|
break;
|
|
|
|
case FSM_TRM_TIMER:
|
|
|
|
fp->restart = lcp->cfg.fsm.maxtrm;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fp->restart = 1;
|
|
|
|
break;
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-05-21 21:49:08 +00:00
|
|
|
LcpSendConfigReq(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Send config REQ please */
|
|
|
|
struct physical *p = link2physical(fp->link);
|
|
|
|
struct lcp *lcp = fsm2lcp(fp);
|
|
|
|
u_char buff[200];
|
2002-04-16 23:57:09 +00:00
|
|
|
struct fsm_opt *o;
|
1998-05-21 21:49:08 +00:00
|
|
|
struct mp *mp;
|
1998-09-04 18:26:00 +00:00
|
|
|
u_int16_t proto;
|
2001-07-17 01:06:13 +00:00
|
|
|
u_short maxmru;
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
if (!p) {
|
|
|
|
log_Printf(LogERROR, "%s: LcpSendConfigReq: Not a physical link !\n",
|
|
|
|
fp->link->name);
|
|
|
|
return;
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
o = (struct fsm_opt *)buff;
|
1998-05-21 21:49:08 +00:00
|
|
|
if (!physical_IsSync(p)) {
|
1997-12-03 10:23:54 +00:00
|
|
|
if (lcp->want_acfcomp && !REJECTED(lcp, TY_ACFCOMP))
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_ACFCOMP, 2, o);
|
1997-12-03 10:23:54 +00:00
|
|
|
|
|
|
|
if (lcp->want_protocomp && !REJECTED(lcp, TY_PROTOCOMP))
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_PROTOCOMP, 2, o);
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (!REJECTED(lcp, TY_ACCMAP)) {
|
1998-09-04 18:26:00 +00:00
|
|
|
ua_htonl(&lcp->want_accmap, o->data);
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_ACCMAP, 6, o);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
|
2001-07-17 01:06:13 +00:00
|
|
|
maxmru = p ? physical_DeviceMTU(p) : 0;
|
|
|
|
if (lcp->cfg.max_mru && (!maxmru || maxmru > lcp->cfg.max_mru))
|
|
|
|
maxmru = lcp->cfg.max_mru;
|
|
|
|
if (maxmru && lcp->want_mru > maxmru) {
|
|
|
|
log_Printf(LogWARN, "%s: Reducing configured MRU from %u to %u\n",
|
|
|
|
fp->link->name, lcp->want_mru, maxmru);
|
|
|
|
lcp->want_mru = maxmru;
|
|
|
|
}
|
2001-07-30 17:04:39 +00:00
|
|
|
if (!REJECTED(lcp, TY_MRU)) {
|
1998-09-04 18:26:00 +00:00
|
|
|
ua_htons(&lcp->want_mru, o->data);
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_MRU, 4, o);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (lcp->want_magic && !REJECTED(lcp, TY_MAGICNUM)) {
|
1998-09-04 18:26:00 +00:00
|
|
|
ua_htonl(&lcp->want_magic, o->data);
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_MAGICNUM, 6, o);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (lcp->want_lqrperiod && !REJECTED(lcp, TY_QUALPROTO)) {
|
1998-09-04 18:26:00 +00:00
|
|
|
proto = PROTO_LQR;
|
|
|
|
ua_htons(&proto, o->data);
|
|
|
|
ua_htonl(&lcp->want_lqrperiod, o->data + 2);
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_QUALPROTO, 8, o);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
switch (lcp->want_auth) {
|
|
|
|
case PROTO_PAP:
|
1998-09-04 18:26:00 +00:00
|
|
|
proto = PROTO_PAP;
|
|
|
|
ua_htons(&proto, o->data);
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_AUTHPROTO, 4, o);
|
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:
|
1998-09-04 18:26:00 +00:00
|
|
|
proto = PROTO_CHAP;
|
|
|
|
ua_htons(&proto, o->data);
|
1999-02-18 00:52:15 +00:00
|
|
|
o->data[2] = lcp->want_authtype;
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_AUTHPROTO, 5, o);
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-08-07 18:42:51 +00:00
|
|
|
if (!REJECTED(lcp, TY_CALLBACK)) {
|
|
|
|
if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) {
|
|
|
|
*o->data = CALLBACK_AUTH;
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_CALLBACK, 3, o);
|
1998-08-07 18:42:51 +00:00
|
|
|
} else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_CBCP)) {
|
|
|
|
*o->data = CALLBACK_CBCP;
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_CALLBACK, 3, o);
|
1998-08-07 18:42:51 +00:00
|
|
|
} else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_E164)) {
|
|
|
|
int sz = strlen(lcp->want_callback.msg);
|
|
|
|
|
|
|
|
if (sz > sizeof o->data - 1) {
|
|
|
|
sz = sizeof o->data - 1;
|
|
|
|
log_Printf(LogWARN, "Truncating E164 data to %d octets (oops!)\n", sz);
|
|
|
|
}
|
|
|
|
*o->data = CALLBACK_E164;
|
|
|
|
memcpy(o->data + 1, lcp->want_callback.msg, sz);
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_CALLBACK, sz + 3, o);
|
1998-08-07 18:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (lcp->want_mrru && !REJECTED(lcp, TY_MRRU)) {
|
1998-09-04 18:26:00 +00:00
|
|
|
ua_htons(&lcp->want_mrru, o->data);
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_MRRU, 4, o);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (lcp->want_shortseq && !REJECTED(lcp, TY_SHORTSEQ))
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_SHORTSEQ, 2, o);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
mp = &lcp->fsm.bundle->ncp.mp;
|
1999-06-09 16:54:04 +00:00
|
|
|
if (mp->cfg.enddisc.class != 0 && IsEnabled(mp->cfg.negenddisc) &&
|
|
|
|
!REJECTED(lcp, TY_ENDDISC)) {
|
1998-05-21 21:49:08 +00:00
|
|
|
*o->data = mp->cfg.enddisc.class;
|
|
|
|
memcpy(o->data+1, mp->cfg.enddisc.address, mp->cfg.enddisc.len);
|
2002-04-16 23:57:09 +00:00
|
|
|
INC_FSM_OPT(TY_ENDDISC, mp->cfg.enddisc.len + 3, o);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff,
|
|
|
|
MB_LCPOUT);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
void
|
|
|
|
lcp_SendProtoRej(struct lcp *lcp, u_char *option, int count)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Don't understand `option' */
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(&lcp->fsm, CODE_PROTOREJ, lcp->fsm.reqid, option, count,
|
|
|
|
MB_LCPOUT);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
2000-07-19 02:10:35 +00:00
|
|
|
int
|
|
|
|
lcp_SendIdentification(struct lcp *lcp)
|
|
|
|
{
|
|
|
|
static u_char id; /* Use a private id */
|
|
|
|
u_char msg[DEF_MRU - 3];
|
|
|
|
const char *argv[2];
|
|
|
|
char *exp[2];
|
|
|
|
|
|
|
|
if (*lcp->cfg.ident == '\0')
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
argv[0] = lcp->cfg.ident;
|
|
|
|
argv[1] = NULL;
|
|
|
|
|
|
|
|
command_Expand(exp, 1, argv, lcp->fsm.bundle, 1, getpid());
|
|
|
|
|
|
|
|
ua_htonl(&lcp->want_magic, msg);
|
|
|
|
strncpy(msg + 4, exp[0], sizeof msg - 5);
|
|
|
|
msg[sizeof msg - 1] = '\0';
|
|
|
|
|
|
|
|
fsm_Output(&lcp->fsm, CODE_IDENT, id++, msg, 4 + strlen(msg + 4), MB_LCPOUT);
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, " MAGICNUM %08x\n", lcp->want_magic);
|
|
|
|
log_Printf(LogLCP, " TEXT %s\n", msg + 4);
|
2000-07-19 02:10:35 +00:00
|
|
|
|
2001-11-03 21:45:32 +00:00
|
|
|
command_Free(1, exp);
|
2000-07-19 02:10:35 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lcp_RecvIdentification(struct lcp *lcp, char *data)
|
|
|
|
{
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, " MAGICNUM %08x\n", lcp->his_magic);
|
|
|
|
log_Printf(LogLCP, " TEXT %s\n", data);
|
2000-07-19 02:10:35 +00:00
|
|
|
}
|
|
|
|
|
1995-02-26 12:18:08 +00:00
|
|
|
static void
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
LcpSentTerminateReq(struct fsm *fp)
|
1995-02-26 12:18:08 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Term REQ just sent by FSM */
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
static void
|
1998-05-21 21:49:08 +00:00
|
|
|
LcpSendTerminateAck(struct fsm *fp, u_char id)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Send Term ACK please */
|
1998-08-07 18:42:51 +00:00
|
|
|
struct physical *p = link2physical(fp->link);
|
|
|
|
|
|
|
|
if (p && p->dl->state == DATALINK_CBCP)
|
|
|
|
cbcp_ReceiveTerminateReq(p);
|
|
|
|
|
1999-06-02 15:59:09 +00:00
|
|
|
fsm_Output(fp, CODE_TERMACK, id, NULL, 0, MB_LCPOUT);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-05-21 21:49:08 +00:00
|
|
|
LcpLayerStart(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* We're about to start up ! */
|
|
|
|
struct lcp *lcp = fsm2lcp(fp);
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogLCP, "%s: LayerStart\n", fp->link->name);
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->LcpFailedMagic = 0;
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
fp->more.reqs = fp->more.naks = fp->more.rejs = lcp->cfg.fsm.maxreq * 3;
|
2001-10-18 08:47:56 +00:00
|
|
|
lcp->mru_req = 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-05-21 21:49:08 +00:00
|
|
|
LcpLayerFinish(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* We're now down */
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogLCP, "%s: LayerFinish\n", fp->link->name);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static int
|
|
|
|
LcpLayerUp(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* We're now up */
|
|
|
|
struct physical *p = link2physical(fp->link);
|
|
|
|
struct lcp *lcp = fsm2lcp(fp);
|
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogLCP, "%s: LayerUp\n", fp->link->name);
|
2002-03-30 12:30:09 +00:00
|
|
|
physical_SetAsyncParams(p, lcp->want_accmap, lcp->his_accmap);
|
1998-05-21 21:49:08 +00:00
|
|
|
lqr_Start(lcp);
|
|
|
|
hdlc_StartTimer(&p->hdlc);
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
fp->more.reqs = fp->more.naks = fp->more.rejs = lcp->cfg.fsm.maxreq * 3;
|
|
|
|
|
2000-07-19 02:10:35 +00:00
|
|
|
lcp_SendIdentification(lcp);
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
return 1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
static void
|
|
|
|
LcpLayerDown(struct fsm *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* About to come down */
|
|
|
|
struct physical *p = link2physical(fp->link);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogLCP, "%s: LayerDown\n", fp->link->name);
|
1998-05-21 21:49:08 +00:00
|
|
|
hdlc_StopTimer(&p->hdlc);
|
|
|
|
lqr_StopTimer(p);
|
1998-06-25 22:33:31 +00:00
|
|
|
lcp_Setup(fsm2lcp(fp), 0);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-08-07 18:42:51 +00:00
|
|
|
static int
|
|
|
|
E164ok(struct callback *cb, char *req, int sz)
|
|
|
|
{
|
|
|
|
char list[sizeof cb->msg], *next;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!strcmp(cb->msg, "*"))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
strncpy(list, cb->msg, sizeof list - 1);
|
|
|
|
list[sizeof list - 1] = '\0';
|
|
|
|
for (next = strtok(list, ","); next; next = strtok(NULL, ",")) {
|
|
|
|
len = strlen(next);
|
|
|
|
if (sz == len && !memcmp(list, req, sz))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
static int
|
|
|
|
lcp_auth_nak(struct lcp *lcp, struct fsm_decode *dec)
|
|
|
|
{
|
|
|
|
struct fsm_opt nak;
|
|
|
|
|
|
|
|
nak.hdr.id = TY_AUTHPROTO;
|
|
|
|
|
|
|
|
if (IsAccepted(lcp->cfg.pap)) {
|
|
|
|
nak.hdr.len = 4;
|
|
|
|
nak.data[0] = (unsigned char)(PROTO_PAP >> 8);
|
|
|
|
nak.data[1] = (unsigned char)PROTO_PAP;
|
|
|
|
fsm_nak(dec, &nak);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nak.hdr.len = 5;
|
|
|
|
nak.data[0] = (unsigned char)(PROTO_CHAP >> 8);
|
|
|
|
nak.data[1] = (unsigned char)PROTO_CHAP;
|
|
|
|
|
|
|
|
if (IsAccepted(lcp->cfg.chap05)) {
|
|
|
|
nak.data[2] = 0x05;
|
|
|
|
fsm_nak(dec, &nak);
|
|
|
|
#ifndef NODES
|
|
|
|
} else if (IsAccepted(lcp->cfg.chap80nt) ||
|
|
|
|
IsAccepted(lcp->cfg.chap80lm)) {
|
|
|
|
nak.data[2] = 0x80;
|
|
|
|
fsm_nak(dec, &nak);
|
|
|
|
} else if (IsAccepted(lcp->cfg.chap81)) {
|
|
|
|
nak.data[2] = 0x81;
|
|
|
|
fsm_nak(dec, &nak);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
static void
|
2002-04-16 23:57:09 +00:00
|
|
|
LcpDecodeConfig(struct fsm *fp, u_char *cp, u_char *end, int mode_type,
|
1998-05-21 21:49:08 +00:00
|
|
|
struct fsm_decode *dec)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Deal with incoming PROTO_LCP */
|
|
|
|
struct lcp *lcp = fsm2lcp(fp);
|
2002-04-16 23:57:09 +00:00
|
|
|
int sz, pos, op, callback_req, chap_type;
|
1998-05-21 21:49:08 +00:00
|
|
|
u_int32_t magic, accmap;
|
2001-07-17 01:06:13 +00:00
|
|
|
u_short mru, phmtu, maxmtu, maxmru, wantmtu, wantmru, proto;
|
1995-01-31 06:29:58 +00:00
|
|
|
struct lqrreq *req;
|
1997-12-03 10:23:54 +00:00
|
|
|
char request[20], desc[22];
|
1998-05-21 21:49:08 +00:00
|
|
|
struct mp *mp;
|
|
|
|
struct physical *p = link2physical(fp->link);
|
2002-04-16 23:57:09 +00:00
|
|
|
struct fsm_opt *opt, nak;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
2001-10-18 08:47:56 +00:00
|
|
|
sz = op = callback_req = 0;
|
1998-08-07 18:42:51 +00:00
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
while (end - cp >= sizeof(opt->hdr)) {
|
|
|
|
if ((opt = fsm_readopt(&cp)) == NULL)
|
1998-08-07 18:42:51 +00:00
|
|
|
break;
|
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
snprintf(request, sizeof request, " %s[%d]", protoname(opt->hdr.id),
|
|
|
|
opt->hdr.len);
|
|
|
|
|
|
|
|
switch (opt->hdr.id) {
|
1998-05-21 21:49:08 +00:00
|
|
|
case TY_MRRU:
|
|
|
|
mp = &lcp->fsm.bundle->ncp.mp;
|
2002-04-16 23:57:09 +00:00
|
|
|
ua_ntohs(opt->data, &mru);
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogLCP, "%s %u\n", request, mru);
|
|
|
|
|
|
|
|
switch (mode_type) {
|
|
|
|
case MODE_REQ:
|
|
|
|
if (mp->cfg.mrru) {
|
|
|
|
if (REJECTED(lcp, TY_MRRU))
|
|
|
|
/* Ignore his previous reject so that we REQ next time */
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject &= ~(1 << opt->hdr.id);
|
1998-05-21 21:49:08 +00:00
|
|
|
|
2001-06-18 14:59:36 +00:00
|
|
|
if (mru > MAX_MRU) {
|
|
|
|
/* Push him down to MAX_MRU */
|
|
|
|
lcp->his_mrru = MAX_MRU;
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.hdr.id = TY_MRRU;
|
|
|
|
nak.hdr.len = 4;
|
|
|
|
ua_htons(&lcp->his_mrru, nak.data);
|
|
|
|
fsm_nak(dec, &nak);
|
2001-06-18 14:59:36 +00:00
|
|
|
} else if (mru < MIN_MRU) {
|
2000-06-24 23:37:14 +00:00
|
|
|
/* Push him up to MIN_MRU */
|
|
|
|
lcp->his_mrru = MIN_MRU;
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.hdr.id = TY_MRRU;
|
|
|
|
nak.hdr.len = 4;
|
|
|
|
ua_htons(&lcp->his_mrru, nak.data);
|
|
|
|
fsm_nak(dec, &nak);
|
|
|
|
} else {
|
2000-06-24 23:37:14 +00:00
|
|
|
lcp->his_mrru = mru;
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_ack(dec, opt);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
|
|
|
if (mp->cfg.mrru) {
|
|
|
|
if (REJECTED(lcp, TY_MRRU))
|
|
|
|
/* Must have changed his mind ! */
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject &= ~(1 << opt->hdr.id);
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
if (mru > MAX_MRU)
|
|
|
|
lcp->want_mrru = MAX_MRU;
|
|
|
|
else if (mru < MIN_MRU)
|
|
|
|
lcp->want_mrru = MIN_MRU;
|
|
|
|
else
|
|
|
|
lcp->want_mrru = mru;
|
|
|
|
}
|
|
|
|
/* else we honour our config and don't send the suggested REQ */
|
|
|
|
break;
|
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->want_mrru = 0; /* Ah well, no multilink :-( */
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case TY_MRU:
|
2001-10-18 08:47:56 +00:00
|
|
|
lcp->mru_req = 1;
|
2002-04-16 23:57:09 +00:00
|
|
|
ua_ntohs(opt->data, &mru);
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(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:
|
2001-07-17 01:06:13 +00:00
|
|
|
maxmtu = p ? physical_DeviceMTU(p) : 0;
|
|
|
|
if (lcp->cfg.max_mtu && (!maxmtu || maxmtu > lcp->cfg.max_mtu))
|
|
|
|
maxmtu = lcp->cfg.max_mtu;
|
2001-07-26 11:33:53 +00:00
|
|
|
wantmtu = lcp->cfg.mtu;
|
2001-07-17 01:06:13 +00:00
|
|
|
if (maxmtu && wantmtu > maxmtu) {
|
|
|
|
log_Printf(LogWARN, "%s: Reducing configured MTU from %u to %u\n",
|
|
|
|
fp->link->name, wantmtu, maxmtu);
|
|
|
|
wantmtu = maxmtu;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxmtu && mru > maxmtu) {
|
|
|
|
lcp->his_mru = maxmtu;
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.hdr.id = TY_MRU;
|
|
|
|
nak.hdr.len = 4;
|
|
|
|
ua_htons(&lcp->his_mru, nak.data);
|
|
|
|
fsm_nak(dec, &nak);
|
2001-07-26 11:33:53 +00:00
|
|
|
} else if (wantmtu && mru < wantmtu) {
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Push him up to MTU or MIN_MRU */
|
2001-07-17 01:06:13 +00:00
|
|
|
lcp->his_mru = wantmtu;
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.hdr.id = TY_MRU;
|
|
|
|
nak.hdr.len = 4;
|
|
|
|
ua_htons(&lcp->his_mru, nak.data);
|
|
|
|
fsm_nak(dec, &nak);
|
1998-05-21 21:49:08 +00:00
|
|
|
} else {
|
2001-07-26 11:33:53 +00:00
|
|
|
lcp->his_mru = mru;
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_ack(dec, opt);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
2001-07-17 01:06:13 +00:00
|
|
|
maxmru = p ? physical_DeviceMTU(p) : 0;
|
|
|
|
if (lcp->cfg.max_mru && (!maxmru || maxmru > lcp->cfg.max_mru))
|
|
|
|
maxmru = lcp->cfg.max_mru;
|
|
|
|
wantmru = lcp->cfg.mru > maxmru ? maxmru : lcp->cfg.mru;
|
|
|
|
|
2001-07-26 11:33:53 +00:00
|
|
|
if (wantmru && mru > wantmru)
|
2001-07-17 01:06:13 +00:00
|
|
|
lcp->want_mru = wantmru;
|
2001-07-26 11:33:53 +00:00
|
|
|
else if (mru > maxmru)
|
|
|
|
lcp->want_mru = maxmru;
|
2001-07-17 01:06:13 +00:00
|
|
|
else if (mru < MIN_MRU)
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->want_mru = MIN_MRU;
|
|
|
|
else
|
|
|
|
lcp->want_mru = mru;
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
break;
|
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 TY_ACCMAP:
|
2002-04-16 23:57:09 +00:00
|
|
|
ua_ntohl(opt->data, &accmap);
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogLCP, "%s 0x%08lx\n", request, (u_long)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:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_accmap = accmap;
|
|
|
|
fsm_ack(dec, opt);
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->want_accmap = accmap;
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
break;
|
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 TY_AUTHPROTO:
|
2002-04-16 23:57:09 +00:00
|
|
|
ua_ntohs(opt->data, &proto);
|
|
|
|
chap_type = opt->hdr.len == 5 ? opt->data[2] : 0;
|
|
|
|
|
1999-02-18 00:52:15 +00:00
|
|
|
log_Printf(LogLCP, "%s 0x%04x (%s)\n", request, proto,
|
2002-04-16 23:57:09 +00:00
|
|
|
Auth2Nam(proto, chap_type));
|
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:
|
2002-04-16 23:57:09 +00:00
|
|
|
switch (proto) {
|
|
|
|
case PROTO_PAP:
|
|
|
|
if (opt->hdr.len == 4 && IsAccepted(lcp->cfg.pap)) {
|
|
|
|
lcp->his_auth = proto;
|
|
|
|
lcp->his_authtype = 0;
|
|
|
|
fsm_ack(dec, opt);
|
|
|
|
} else if (!lcp_auth_nak(lcp, dec)) {
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROTO_CHAP:
|
|
|
|
if ((chap_type == 0x05 && IsAccepted(lcp->cfg.chap05))
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2002-04-16 23:57:09 +00:00
|
|
|
|| (chap_type == 0x80 && (IsAccepted(lcp->cfg.chap80nt) ||
|
1999-02-18 00:52:15 +00:00
|
|
|
(IsAccepted(lcp->cfg.chap80lm))))
|
2002-04-16 23:57:09 +00:00
|
|
|
|| (chap_type == 0x81 && IsAccepted(lcp->cfg.chap81))
|
1997-09-25 00:52:37 +00:00
|
|
|
#endif
|
1999-02-18 00:52:15 +00:00
|
|
|
) {
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_auth = proto;
|
|
|
|
lcp->his_authtype = chap_type;
|
|
|
|
fsm_ack(dec, opt);
|
|
|
|
} else {
|
|
|
|
#ifdef NODES
|
|
|
|
if (chap_type == 0x80) {
|
1999-02-18 00:52:15 +00:00
|
|
|
log_Printf(LogWARN, "CHAP 0x80 not available without DES\n");
|
2002-04-16 23:57:09 +00:00
|
|
|
} else if (chap_type == 0x81) {
|
2000-10-30 00:15:04 +00:00
|
|
|
log_Printf(LogWARN, "CHAP 0x81 not available without DES\n");
|
|
|
|
} else
|
1998-10-17 12:28:02 +00:00
|
|
|
#endif
|
2002-04-16 23:57:09 +00:00
|
|
|
if (chap_type != 0x05)
|
1999-02-18 00:52:15 +00:00
|
|
|
log_Printf(LogWARN, "%s not supported\n",
|
2002-04-16 23:57:09 +00:00
|
|
|
Auth2Nam(PROTO_CHAP, chap_type));
|
|
|
|
|
|
|
|
if (!lcp_auth_nak(lcp, dec)) {
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
}
|
1998-10-17 12:28:02 +00:00
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
default:
|
|
|
|
log_Printf(LogLCP, "%s 0x%04x - not recognised\n",
|
1997-12-07 23:55:29 +00:00
|
|
|
request, proto);
|
2002-04-16 23:57:09 +00:00
|
|
|
if (!lcp_auth_nak(lcp, dec)) {
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
2002-04-16 23:57:09 +00:00
|
|
|
switch (proto) {
|
|
|
|
case PROTO_PAP:
|
1999-02-18 00:52:15 +00:00
|
|
|
if (IsEnabled(lcp->cfg.pap)) {
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->want_auth = PROTO_PAP;
|
1999-02-18 00:52:15 +00:00
|
|
|
lcp->want_authtype = 0;
|
|
|
|
} else {
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogLCP, "Peer will only send PAP (not enabled)\n");
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
1997-12-07 23:55:29 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-04-16 23:57:09 +00:00
|
|
|
case PROTO_CHAP:
|
|
|
|
if (chap_type == 0x05 && IsEnabled(lcp->cfg.chap05)) {
|
1999-02-18 00:52:15 +00:00
|
|
|
lcp->want_auth = PROTO_CHAP;
|
|
|
|
lcp->want_authtype = 0x05;
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2002-04-16 23:57:09 +00:00
|
|
|
} else if (chap_type == 0x80 && (IsEnabled(lcp->cfg.chap80nt) ||
|
|
|
|
IsEnabled(lcp->cfg.chap80lm))) {
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->want_auth = PROTO_CHAP;
|
1999-02-18 00:52:15 +00:00
|
|
|
lcp->want_authtype = 0x80;
|
2002-04-16 23:57:09 +00:00
|
|
|
} else if (chap_type == 0x81 && IsEnabled(lcp->cfg.chap81)) {
|
2000-10-30 00:15:04 +00:00
|
|
|
lcp->want_auth = PROTO_CHAP;
|
|
|
|
lcp->want_authtype = 0x81;
|
1999-02-18 00:52:15 +00:00
|
|
|
#endif
|
|
|
|
} else {
|
2002-04-16 23:57:09 +00:00
|
|
|
#ifdef NODES
|
|
|
|
if (chap_type == 0x80) {
|
1999-02-18 00:52:15 +00:00
|
|
|
log_Printf(LogLCP, "Peer will only send MSCHAP (not available"
|
|
|
|
" without DES)\n");
|
2002-04-16 23:57:09 +00:00
|
|
|
} else if (chap_type == 0x81) {
|
2000-10-30 00:15:04 +00:00
|
|
|
log_Printf(LogLCP, "Peer will only send MSCHAPV2 (not available"
|
|
|
|
" without DES)\n");
|
|
|
|
} else
|
1999-02-18 00:52:15 +00:00
|
|
|
#endif
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
log_Printf(LogLCP, "Peer will only send %s (not %s)\n",
|
2002-04-16 23:57:09 +00:00
|
|
|
Auth2Nam(PROTO_CHAP, chap_type),
|
2002-03-30 12:30:09 +00:00
|
|
|
#ifndef NODES
|
2002-04-16 23:57:09 +00:00
|
|
|
(chap_type == 0x80 || chap_type == 0x81) ? "configured" :
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
#endif
|
|
|
|
"supported");
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
1997-12-07 23:55:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* We've been NAK'd with something we don't understand :-( */
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
1997-12-07 23:55:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
break;
|
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 TY_QUALPROTO:
|
2002-04-16 23:57:09 +00:00
|
|
|
req = (struct lqrreq *)opt;
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogLCP, "%s proto %x, interval %lums\n",
|
|
|
|
request, ntohs(req->proto), (u_long)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:
|
2002-04-16 23:57:09 +00:00
|
|
|
if (ntohs(req->proto) != PROTO_LQR || !IsAccepted(lcp->cfg.lqr)) {
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
} else {
|
|
|
|
lcp->his_lqrperiod = ntohl(req->period);
|
|
|
|
if (lcp->his_lqrperiod < MIN_LQRPERIOD * 100)
|
|
|
|
lcp->his_lqrperiod = MIN_LQRPERIOD * 100;
|
|
|
|
req->period = htonl(lcp->his_lqrperiod);
|
|
|
|
fsm_ack(dec, opt);
|
|
|
|
}
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
2002-05-01 07:49:07 +00:00
|
|
|
lcp->want_lqrperiod = ntohl(req->period);
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
break;
|
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 TY_MAGICNUM:
|
2002-04-16 23:57:09 +00:00
|
|
|
ua_ntohl(opt->data, &magic);
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogLCP, "%s 0x%08lx\n", request, (u_long)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:
|
2002-04-16 23:57:09 +00:00
|
|
|
if (lcp->want_magic) {
|
|
|
|
/* Validate magic number */
|
|
|
|
if (magic == lcp->want_magic) {
|
|
|
|
sigset_t emptyset;
|
2001-09-13 10:03:30 +00:00
|
|
|
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, "Magic is same (%08lx) - %d times\n",
|
1998-05-21 21:49:08 +00:00
|
|
|
(u_long)magic, ++lcp->LcpFailedMagic);
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->want_magic = GenerateMagic();
|
|
|
|
fsm_nak(dec, opt);
|
1998-05-21 21:49:08 +00:00
|
|
|
ualarm(TICKUNIT * (4 + 4 * lcp->LcpFailedMagic), 0);
|
2002-04-16 23:57:09 +00:00
|
|
|
sigemptyset(&emptyset);
|
|
|
|
sigsuspend(&emptyset);
|
|
|
|
} else {
|
|
|
|
lcp->his_magic = magic;
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->LcpFailedMagic = 0;
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_ack(dec, opt);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
}
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, " Magic 0x%08lx is NAKed!\n", (u_long)magic);
|
|
|
|
lcp->want_magic = GenerateMagic();
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, " Magic 0x%08x is REJected!\n", magic);
|
|
|
|
lcp->want_magic = 0;
|
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
break;
|
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 TY_PROTOCOMP:
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(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:
|
2002-04-16 23:57:09 +00:00
|
|
|
if (IsAccepted(lcp->cfg.protocomp)) {
|
|
|
|
lcp->his_protocomp = 1;
|
|
|
|
fsm_ack(dec, opt);
|
|
|
|
} else {
|
1995-01-31 06:29:58 +00:00
|
|
|
#ifdef OLDMST
|
2002-04-16 23:57:09 +00:00
|
|
|
/* MorningStar before v1.3 needs NAK */
|
|
|
|
fsm_nak(dec, opt);
|
1995-01-31 06:29:58 +00:00
|
|
|
#else
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
1995-01-31 06:29:58 +00:00
|
|
|
#endif
|
2002-04-16 23:57:09 +00:00
|
|
|
}
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->want_protocomp = 0;
|
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
break;
|
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 TY_ACFCOMP:
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(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:
|
2002-04-16 23:57:09 +00:00
|
|
|
if (IsAccepted(lcp->cfg.acfcomp)) {
|
|
|
|
lcp->his_acfcomp = 1;
|
|
|
|
fsm_ack(dec, opt);
|
|
|
|
} else {
|
1995-01-31 06:29:58 +00:00
|
|
|
#ifdef OLDMST
|
2002-04-16 23:57:09 +00:00
|
|
|
/* MorningStar before v1.3 needs NAK */
|
|
|
|
fsm_nak(dec, opt);
|
1995-01-31 06:29:58 +00:00
|
|
|
#else
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
1995-01-31 06:29:58 +00:00
|
|
|
#endif
|
2002-04-16 23:57:09 +00:00
|
|
|
}
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->want_acfcomp = 0;
|
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
break;
|
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 TY_SDP:
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogLCP, "%s\n", request);
|
|
|
|
switch (mode_type) {
|
|
|
|
case MODE_REQ:
|
|
|
|
case MODE_NAK:
|
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-08-07 18:42:51 +00:00
|
|
|
case TY_CALLBACK:
|
2002-04-16 23:57:09 +00:00
|
|
|
if (opt->hdr.len == 2)
|
1998-08-07 18:42:51 +00:00
|
|
|
op = CALLBACK_NONE;
|
|
|
|
else
|
2002-04-16 23:57:09 +00:00
|
|
|
op = (int)opt->data[0];
|
|
|
|
sz = opt->hdr.len - 3;
|
1998-08-07 18:42:51 +00:00
|
|
|
switch (op) {
|
|
|
|
case CALLBACK_AUTH:
|
|
|
|
log_Printf(LogLCP, "%s Auth\n", request);
|
|
|
|
break;
|
|
|
|
case CALLBACK_DIALSTRING:
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, "%s Dialstring %.*s\n", request, sz,
|
|
|
|
opt->data + 1);
|
1998-08-07 18:42:51 +00:00
|
|
|
break;
|
|
|
|
case CALLBACK_LOCATION:
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, "%s Location %.*s\n", request, sz, opt->data + 1);
|
1998-08-07 18:42:51 +00:00
|
|
|
break;
|
|
|
|
case CALLBACK_E164:
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, "%s E.164 (%.*s)\n", request, sz, opt->data + 1);
|
1998-08-07 18:42:51 +00:00
|
|
|
break;
|
|
|
|
case CALLBACK_NAME:
|
2002-04-16 23:57:09 +00:00
|
|
|
log_Printf(LogLCP, "%s Name %.*s\n", request, sz, opt->data + 1);
|
1998-08-07 18:42:51 +00:00
|
|
|
break;
|
|
|
|
case CALLBACK_CBCP:
|
|
|
|
log_Printf(LogLCP, "%s CBCP\n", request);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
log_Printf(LogLCP, "%s ???\n", request);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode_type) {
|
|
|
|
case MODE_REQ:
|
|
|
|
callback_req = 1;
|
2002-04-16 23:57:09 +00:00
|
|
|
if (p->type != PHYS_DIRECT) {
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
}
|
|
|
|
nak.hdr.id = opt->hdr.id;
|
|
|
|
nak.hdr.len = 3;
|
1998-08-07 18:42:51 +00:00
|
|
|
if ((p->dl->cfg.callback.opmask & CALLBACK_BIT(op)) &&
|
2001-10-18 08:48:04 +00:00
|
|
|
(op != CALLBACK_AUTH || p->link.lcp.want_auth) &&
|
1998-08-07 18:42:51 +00:00
|
|
|
(op != CALLBACK_E164 ||
|
2002-04-16 23:57:09 +00:00
|
|
|
E164ok(&p->dl->cfg.callback, opt->data + 1, sz))) {
|
|
|
|
lcp->his_callback.opmask = CALLBACK_BIT(op);
|
1998-08-07 18:42:51 +00:00
|
|
|
if (sz > sizeof lcp->his_callback.msg - 1) {
|
|
|
|
sz = sizeof lcp->his_callback.msg - 1;
|
|
|
|
log_Printf(LogWARN, "Truncating option arg to %d octets\n", sz);
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
memcpy(lcp->his_callback.msg, opt->data + 1, sz);
|
|
|
|
lcp->his_callback.msg[sz] = '\0';
|
|
|
|
fsm_ack(dec, opt);
|
1998-08-07 18:42:51 +00:00
|
|
|
} else if ((p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) &&
|
|
|
|
p->link.lcp.auth_ineed) {
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.data[0] = CALLBACK_AUTH;
|
|
|
|
fsm_nak(dec, &nak);
|
1998-08-07 18:42:51 +00:00
|
|
|
} else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_CBCP)) {
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.data[0] = CALLBACK_CBCP;
|
|
|
|
fsm_nak(dec, &nak);
|
1998-08-07 18:42:51 +00:00
|
|
|
} else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_E164)) {
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.data[0] = CALLBACK_E164;
|
|
|
|
fsm_nak(dec, &nak);
|
1998-08-07 18:42:51 +00:00
|
|
|
} else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) {
|
|
|
|
log_Printf(LogWARN, "Cannot insist on auth callback without"
|
|
|
|
" PAP or CHAP enabled !\n");
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.data[0] = 2;
|
|
|
|
fsm_nak(dec, &nak);
|
|
|
|
} else {
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
}
|
1998-08-07 18:42:51 +00:00
|
|
|
break;
|
|
|
|
case MODE_NAK:
|
1999-01-12 21:50:20 +00:00
|
|
|
/* We don't do what he NAKs with, we do things in our preferred order */
|
1998-08-07 18:42:51 +00:00
|
|
|
if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_AUTH))
|
|
|
|
lcp->want_callback.opmask &= ~CALLBACK_BIT(CALLBACK_AUTH);
|
|
|
|
else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_CBCP))
|
|
|
|
lcp->want_callback.opmask &= ~CALLBACK_BIT(CALLBACK_CBCP);
|
|
|
|
else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_E164))
|
|
|
|
lcp->want_callback.opmask &= ~CALLBACK_BIT(CALLBACK_E164);
|
|
|
|
if (lcp->want_callback.opmask == CALLBACK_BIT(CALLBACK_NONE)) {
|
|
|
|
log_Printf(LogPHASE, "Peer NAKd all callbacks, trying none\n");
|
|
|
|
lcp->want_callback.opmask = 0;
|
|
|
|
} else if (!lcp->want_callback.opmask) {
|
|
|
|
log_Printf(LogPHASE, "Peer NAKd last configured callback\n");
|
|
|
|
fsm_Close(&lcp->fsm);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MODE_REJ:
|
|
|
|
if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_NONE)) {
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
1998-08-07 18:42:51 +00:00
|
|
|
lcp->want_callback.opmask = 0;
|
|
|
|
} else {
|
|
|
|
log_Printf(LogPHASE, "Peer rejected *required* callback\n");
|
|
|
|
fsm_Close(&lcp->fsm);
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1998-08-07 18:42:51 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case TY_SHORTSEQ:
|
|
|
|
mp = &lcp->fsm.bundle->ncp.mp;
|
|
|
|
log_Printf(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:
|
1998-05-21 21:49:08 +00:00
|
|
|
if (lcp->want_mrru && IsAccepted(mp->cfg.shortseq)) {
|
|
|
|
lcp->his_shortseq = 1;
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_ack(dec, opt);
|
|
|
|
} else {
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_NAK:
|
1998-05-21 21:49:08 +00:00
|
|
|
/*
|
|
|
|
* He's trying to get us to ask for short sequence numbers.
|
|
|
|
* We ignore the NAK and honour our configuration file instead.
|
|
|
|
*/
|
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
1998-05-21 21:49:08 +00:00
|
|
|
lcp->want_shortseq = 0; /* For when we hit MP */
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
break;
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
case TY_ENDDISC:
|
1999-06-09 20:27:26 +00:00
|
|
|
mp = &lcp->fsm.bundle->ncp.mp;
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogLCP, "%s %s\n", request,
|
2002-04-16 23:57:09 +00:00
|
|
|
mp_Enddisc(opt->data[0], opt->data + 1, opt->hdr.len - 3));
|
1998-05-21 21:49:08 +00:00
|
|
|
switch (mode_type) {
|
|
|
|
case MODE_REQ:
|
|
|
|
if (!p) {
|
|
|
|
log_Printf(LogLCP, " ENDDISC rejected - not a physical link\n");
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
} else if (!IsAccepted(mp->cfg.negenddisc)) {
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
|
|
|
fsm_rej(dec, opt);
|
|
|
|
} else if (opt->hdr.len - 3 < sizeof p->dl->peer.enddisc.address &&
|
|
|
|
opt->data[0] <= MAX_ENDDISC_CLASS) {
|
|
|
|
p->dl->peer.enddisc.class = opt->data[0];
|
|
|
|
p->dl->peer.enddisc.len = opt->hdr.len - 3;
|
|
|
|
memcpy(p->dl->peer.enddisc.address, opt->data + 1, opt->hdr.len - 3);
|
|
|
|
p->dl->peer.enddisc.address[opt->hdr.len - 3] = '\0';
|
1998-05-21 21:49:08 +00:00
|
|
|
/* XXX: If mp->active, compare and NAK with mp->peer ? */
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_ack(dec, opt);
|
1998-05-21 21:49:08 +00:00
|
|
|
} else {
|
2002-04-16 23:57:09 +00:00
|
|
|
if (opt->data[0] > MAX_ENDDISC_CLASS)
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogLCP, " ENDDISC rejected - unrecognised class %d\n",
|
2002-04-16 23:57:09 +00:00
|
|
|
opt->data[0]);
|
1998-05-21 21:49:08 +00:00
|
|
|
else
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogLCP, " ENDDISC rejected - local max length is %ld\n",
|
|
|
|
(long)(sizeof p->dl->peer.enddisc.address - 1));
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
break;
|
1998-05-21 21:49:08 +00:00
|
|
|
|
1999-06-09 16:54:04 +00:00
|
|
|
case MODE_NAK: /* Treat this as a REJ, we don't vary our disc (yet) */
|
1998-05-21 21:49:08 +00:00
|
|
|
case MODE_REJ:
|
2002-04-16 23:57:09 +00:00
|
|
|
lcp->his_reject |= (1 << opt->hdr.id);
|
|
|
|
break;
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-06-15 08:03:30 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
default:
|
1997-12-24 09:29:17 +00:00
|
|
|
sz = (sizeof desc - 2) / 2;
|
2002-04-16 23:57:09 +00:00
|
|
|
if (sz > opt->hdr.len - 2)
|
|
|
|
sz = opt->hdr.len - 2;
|
1997-12-03 10:23:54 +00:00
|
|
|
pos = 0;
|
|
|
|
desc[0] = sz ? ' ' : '\0';
|
|
|
|
for (pos = 0; sz--; pos++)
|
2002-04-16 23:57:09 +00:00
|
|
|
sprintf(desc+(pos<<1)+1, "%02x", opt->data[pos]);
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
log_Printf(LogLCP, "%s%s\n", request, desc);
|
1997-12-03 10:23:54 +00:00
|
|
|
|
1997-11-08 00:28:11 +00:00
|
|
|
if (mode_type == MODE_REQ) {
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_rej(dec, opt);
|
|
|
|
lcp->my_reject |= (1 << opt->hdr.id);
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
if (mode_type != MODE_NOP) {
|
1998-08-07 18:42:51 +00:00
|
|
|
if (mode_type == MODE_REQ && p && p->type == PHYS_DIRECT &&
|
|
|
|
p->dl->cfg.callback.opmask && !callback_req &&
|
|
|
|
!(p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_NONE))) {
|
|
|
|
/* We *REQUIRE* that the peer requests callback */
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.hdr.id = TY_CALLBACK;
|
|
|
|
nak.hdr.len = 3;
|
1998-08-07 18:42:51 +00:00
|
|
|
if ((p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) &&
|
2001-10-18 08:48:04 +00:00
|
|
|
p->link.lcp.want_auth)
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.data[0] = CALLBACK_AUTH;
|
1998-08-07 18:42:51 +00:00
|
|
|
else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_CBCP))
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.data[0] = CALLBACK_CBCP;
|
1998-08-07 18:42:51 +00:00
|
|
|
else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_E164))
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.data[0] = CALLBACK_E164;
|
1998-08-07 18:42:51 +00:00
|
|
|
else {
|
|
|
|
log_Printf(LogWARN, "Cannot insist on auth callback without"
|
|
|
|
" PAP or CHAP enabled !\n");
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.hdr.len = 2; /* XXX: Silly ! */
|
1998-08-07 18:42:51 +00:00
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_nak(dec, &nak);
|
1998-08-07 18:42:51 +00:00
|
|
|
}
|
2001-10-18 08:47:56 +00:00
|
|
|
if (mode_type == MODE_REQ && !lcp->mru_req) {
|
2001-06-18 14:59:36 +00:00
|
|
|
mru = DEF_MRU;
|
|
|
|
phmtu = p ? physical_DeviceMTU(p) : 0;
|
|
|
|
if (phmtu && mru > phmtu)
|
|
|
|
mru = phmtu;
|
|
|
|
if (mru > lcp->cfg.max_mtu)
|
|
|
|
mru = lcp->cfg.max_mtu;
|
|
|
|
if (mru < DEF_MRU) {
|
|
|
|
/* Don't let the peer use the default MRU */
|
|
|
|
lcp->his_mru = lcp->cfg.mtu && lcp->cfg.mtu < mru ? lcp->cfg.mtu : mru;
|
2002-04-16 23:57:09 +00:00
|
|
|
nak.hdr.id = TY_MRU;
|
|
|
|
nak.hdr.len = 4;
|
|
|
|
ua_htons(&lcp->his_mru, nak.data);
|
|
|
|
fsm_nak(dec, &nak);
|
2001-10-18 08:47:56 +00:00
|
|
|
lcp->mru_req = 1; /* Don't keep NAK'ing this */
|
2001-06-18 14:59:36 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-16 23:57:09 +00:00
|
|
|
fsm_opt_normalise(dec);
|
1998-05-21 21:49:08 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
extern struct mbuf *
|
|
|
|
lcp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Got PROTO_LCP from link */
|
1999-12-20 20:29:47 +00:00
|
|
|
m_settype(bp, MB_LCPIN);
|
1999-05-08 11:07:56 +00:00
|
|
|
fsm_Input(&l->lcp.fsm, bp);
|
|
|
|
return NULL;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|