diff options
author | brian <brian@FreeBSD.org> | 1999-02-26 21:28:14 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-02-26 21:28:14 +0000 |
commit | ee13d15d8f4dbbc16f743a3690a6e495279d5559 (patch) | |
tree | c5807a2099a7111ab5ef9d2ea6aee114863663ec /usr.sbin/ppp/ccp.c | |
parent | 7810a0ea5a45f6d62932ef2f65c9127f4683098e (diff) | |
download | FreeBSD-src-ee13d15d8f4dbbc16f743a3690a6e495279d5559.zip FreeBSD-src-ee13d15d8f4dbbc16f743a3690a6e495279d5559.tar.gz |
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.
Diffstat (limited to 'usr.sbin/ppp/ccp.c')
-rw-r--r-- | usr.sbin/ppp/ccp.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index eabcf76..97a36fb 100644 --- a/usr.sbin/ppp/ccp.c +++ b/usr.sbin/ppp/ccp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.c,v 1.41 1999/01/28 01:56:30 brian Exp $ + * $Id: ccp.c,v 1.42 1999/02/06 02:54:44 brian Exp $ * * TODO: * o Support other compression protocols @@ -70,7 +70,7 @@ static void CcpLayerStart(struct fsm *); static void CcpLayerFinish(struct fsm *); static int CcpLayerUp(struct fsm *); static void CcpLayerDown(struct fsm *); -static void CcpInitRestartCounter(struct fsm *); +static void CcpInitRestartCounter(struct fsm *, int); static void CcpRecvResetReq(struct fsm *); static void CcpRecvResetAck(struct fsm *, u_char); @@ -150,7 +150,10 @@ ccp_ReportStatus(struct cmdargs const *arg) ccp->compin, ccp->uncompin); prompt_Printf(arg->prompt, "\n Defaults: "); - prompt_Printf(arg->prompt, "FSM retry = %us\n", ccp->cfg.fsmretry); + prompt_Printf(arg->prompt, "FSM retry = %us, max %u Config" + " REQ%s, %u Term REQ%s\n", ccp->cfg.fsm.timeout, + ccp->cfg.fsm.maxreq, ccp->cfg.fsm.maxreq == 1 ? "" : "s", + ccp->cfg.fsm.maxtrm, ccp->cfg.fsm.maxtrm == 1 ? "" : "s"); prompt_Printf(arg->prompt, " deflate windows: "); prompt_Printf(arg->prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize); prompt_Printf(arg->prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize); @@ -178,12 +181,14 @@ ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l, { /* Initialise ourselves */ - fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, 10, LogCCP, + fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, LogCCP, bundle, l, parent, &ccp_Callbacks, ccp_TimerNames); ccp->cfg.deflate.in.winsize = 0; ccp->cfg.deflate.out.winsize = 15; - ccp->cfg.fsmretry = DEF_FSMRETRY; + ccp->cfg.fsm.timeout = DEF_FSMRETRY; + ccp->cfg.fsm.maxreq = DEF_FSMTRIES; + ccp->cfg.fsm.maxtrm = DEF_FSMTRIES; ccp->cfg.neg[CCP_NEG_DEFLATE] = NEG_ENABLED|NEG_ACCEPTED; ccp->cfg.neg[CCP_NEG_PRED1] = NEG_ENABLED|NEG_ACCEPTED; ccp->cfg.neg[CCP_NEG_DEFLATE24] = 0; @@ -196,7 +201,6 @@ ccp_Setup(struct ccp *ccp) { /* Set ourselves up for a startup */ ccp->fsm.open_mode = 0; - ccp->fsm.maxconfig = 10; ccp->his_proto = ccp->my_proto = -1; ccp->reset_sent = ccp->last_reset = -1; ccp->in.algorithm = ccp->out.algorithm = -1; @@ -209,13 +213,23 @@ ccp_Setup(struct ccp *ccp) } static void -CcpInitRestartCounter(struct fsm *fp) +CcpInitRestartCounter(struct fsm *fp, int what) { /* Set fsm timer load */ struct ccp *ccp = fsm2ccp(fp); - fp->FsmTimer.load = ccp->cfg.fsmretry * SECTICKS; - fp->restart = DEF_REQs; + fp->FsmTimer.load = ccp->cfg.fsm.timeout * SECTICKS; + switch (what) { + case FSM_REQ_TIMER: + fp->restart = ccp->cfg.fsm.maxreq; + break; + case FSM_TRM_TIMER: + fp->restart = ccp->cfg.fsm.maxtrm; + break; + default: + fp->restart = 1; + break; + } } static void @@ -304,7 +318,10 @@ static void CcpLayerStart(struct fsm *fp) { /* We're about to start up ! */ + struct ccp *ccp = fsm2ccp(fp); + log_Printf(LogCCP, "%s: LayerStart.\n", fp->link->name); + fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3; } static void @@ -350,7 +367,9 @@ CcpLayerUp(struct fsm *fp) { /* We're now up */ struct ccp *ccp = fsm2ccp(fp); + log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name); + if (ccp->in.state == NULL && ccp->in.algorithm >= 0 && ccp->in.algorithm < NALGORITHMS) { ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init)(&ccp->in.opt); @@ -359,6 +378,7 @@ CcpLayerUp(struct fsm *fp) fp->link->name, protoname(ccp->his_proto)); ccp->his_proto = ccp->my_proto = -1; fsm_Close(fp); + return 0; } } @@ -371,12 +391,16 @@ CcpLayerUp(struct fsm *fp) fp->link->name, protoname(ccp->my_proto)); ccp->his_proto = ccp->my_proto = -1; fsm_Close(fp); + return 0; } } + fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3; + log_Printf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n", fp->link->name, protoname(ccp->my_proto), ccp->my_proto, protoname(ccp->his_proto), ccp->his_proto); + return 1; } |