X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Flcp.c;h=8ed2778bfb672084181a0b27834dfcfdbb875abb;hp=e70dcec525507b9ddcfba06542941f8bcca24619;hb=c9d9dbfb8459b528ab56bd1cf0c41460801bbfdf;hpb=f9f667ee187be5d34ac94f11bf366dd218191122 diff --git a/pppd/lcp.c b/pppd/lcp.c index e70dcec..8ed2778 100644 --- a/pppd/lcp.c +++ b/pppd/lcp.c @@ -40,7 +40,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: lcp.c,v 1.75 2004/11/14 22:53:42 carlsonj Exp $" +#define RCSID "$Id: lcp.c,v 1.76 2006/05/22 00:04:07 paulus Exp $" /* * TODO: @@ -397,21 +397,29 @@ lcp_close(unit, reason) char *reason; { fsm *f = &lcp_fsm[unit]; + int oldstate; if (phase != PHASE_DEAD && phase != PHASE_MASTER) new_phase(PHASE_TERMINATE); - if (f->state == STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) { + + if (f->flags & DELAYED_UP) { + untimeout(lcp_delayed_up, f); + f->state = STOPPED; + } + oldstate = f->state; + + fsm_close(f, reason); + if (oldstate == STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT|DELAYED_UP)) { /* * This action is not strictly according to the FSM in RFC1548, * but it does mean that the program terminates if you do a - * lcp_close() in passive/silent mode when a connection hasn't - * been established. + * lcp_close() when a connection hasn't been established + * because we are in passive/silent mode or because we have + * delayed the fsm_lowerup() call and it hasn't happened yet. */ - f->state = CLOSED; + f->flags &= ~DELAYED_UP; lcp_finished(f); - - } else - fsm_close(f, reason); + } } @@ -453,9 +461,10 @@ lcp_lowerdown(unit) { fsm *f = &lcp_fsm[unit]; - if (f->flags & DELAYED_UP) + if (f->flags & DELAYED_UP) { f->flags &= ~DELAYED_UP; - else + untimeout(lcp_delayed_up, f); + } else fsm_lowerdown(&lcp_fsm[unit]); } @@ -489,6 +498,7 @@ lcp_input(unit, p, len) if (f->flags & DELAYED_UP) { f->flags &= ~DELAYED_UP; + untimeout(lcp_delayed_up, f); fsm_lowerup(f); } fsm_input(f, p, len); @@ -1305,8 +1315,8 @@ lcp_nakci(f, p, len, treat_as_reject) if (looped_back) { if (++try.numloops >= lcp_loopbackfail) { notice("Serial line is looped back."); - lcp_close(f->unit, "Loopback detected"); status = EXIT_LOOPBACK; + lcp_close(f->unit, "Loopback detected"); } } else try.numloops = 0; @@ -2056,7 +2066,6 @@ lcp_printpkt(p, plen, printer, arg) printer(arg, " MD5"); ++p; break; -#ifdef CHAPMS case CHAP_MICROSOFT: printer(arg, " MS"); ++p; @@ -2066,7 +2075,6 @@ lcp_printpkt(p, plen, printer, arg) printer(arg, " MS-v2"); ++p; break; -#endif } } break; @@ -2233,8 +2241,8 @@ void LcpLinkFailure (f) if (f->state == OPENED) { info("No response to %d echo-requests", lcp_echos_pending); notice("Serial link appears to be disconnected."); - lcp_close(f->unit, "Peer not responding"); status = EXIT_PEER_DEAD; + lcp_close(f->unit, "Peer not responding"); } }