X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Flcp.c;h=f215a76d822d4771154d58a5b990f3656f9585fe;hp=cd0f6f85eb52c61b0c20c15d6af3b052b8ecd44e;hb=1b9f7635dd45d643b2fb7cf496f67789892897c5;hpb=4b3147e69bffe5b8b7aa2af95e2abfcec36b4880;ds=sidebyside diff --git a/pppd/lcp.c b/pppd/lcp.c index cd0f6f8..f215a76 100644 --- a/pppd/lcp.c +++ b/pppd/lcp.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: lcp.c,v 1.5 1994/05/24 11:23:13 paulus Exp $"; +static char rcsid[] = "$Id: lcp.c,v 1.13 1994/09/16 02:15:37 paulus Exp $"; #endif /* @@ -26,19 +26,15 @@ static char rcsid[] = "$Id: lcp.c,v 1.5 1994/05/24 11:23:13 paulus Exp $"; */ #include +#include #include #include #include #include #include #include - -#include -#include #include -#include - #include "pppd.h" #include "ppp.h" #include "fsm.h" @@ -48,20 +44,21 @@ static char rcsid[] = "$Id: lcp.c,v 1.5 1994/05/24 11:23:13 paulus Exp $"; #include "upap.h" #include "ipcp.h" +#ifdef _linux_ /* Needs ppp ioctls */ +#include +#endif + /* global vars */ fsm lcp_fsm[NPPP]; /* LCP fsm structure (global)*/ lcp_options lcp_wantoptions[NPPP]; /* Options that we want to request */ lcp_options lcp_gotoptions[NPPP]; /* Options that peer ack'd */ lcp_options lcp_allowoptions[NPPP]; /* Options we allow peer to request */ lcp_options lcp_hisoptions[NPPP]; /* Options that we ack'd */ -u_long xmit_accm[NPPP][8]; /* extended transmit ACCM */ - -static u_long lcp_echos_pending = 0; /* Number of outstanding echo msgs */ -static u_long lcp_echo_number = 0; /* ID number of next echo frame */ -static u_long lcp_echo_timer_running = 0; /* TRUE if a timer is running */ +uint32 xmit_accm[NPPP][8]; /* extended transmit ACCM */ -u_long lcp_echo_interval = 0; -u_long lcp_echo_fails = 0; +static uint32 lcp_echos_pending = 0; /* Number of outstanding echo msgs */ +static uint32 lcp_echo_number = 0; /* ID number of next echo frame */ +static uint32 lcp_echo_timer_running = 0; /* TRUE if a timer is running */ /* * Callbacks for fsm code. (CI = Configuration Information) @@ -255,7 +252,23 @@ lcp_input(unit, p, len) u_char *p; int len; { - fsm_input(&lcp_fsm[unit], p, len); + int oldstate; + fsm *f = &lcp_fsm[unit]; + lcp_options *go = &lcp_gotoptions[f->unit]; + + oldstate = f->state; + fsm_input(f, p, len); + if (oldstate == REQSENT && f->state == ACKSENT) { + /* + * The peer will probably send us an ack soon and then + * immediately start sending packets with the negotiated + * options. So as to be ready when that happens, we set + * our receive side to accept packets as negotiated now. + */ + ppp_recv_config(f->unit, MTU, + go->neg_asyncmap? go->asyncmap: 0x00000000, + go->neg_pcompression, go->neg_accompression); + } } @@ -282,8 +295,6 @@ lcp_extcode(f, code, id, inp, len) LCPDEBUG((LOG_INFO, "lcp: Echo-Request, Rcvd id %d", id)); magp = inp; PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp); - if (len < CILEN_LONG) - len = CILEN_LONG; fsm_sdata(f, ECHOREP, id, inp, len); break; @@ -500,7 +511,7 @@ lcp_ackci(f, p, len) lcp_options *go = &lcp_gotoptions[f->unit]; u_char cilen, citype, cichar; u_short cishort; - u_long cilong; + uint32 cilong; /* * CIs must be in exactly the same order that we sent. @@ -616,7 +627,7 @@ lcp_nakci(f, p, len) lcp_options *wo = &lcp_wantoptions[f->unit]; u_char cilen, citype, cichar, *next; u_short cishort; - u_long cilong; + uint32 cilong; lcp_options no; /* options we've seen Naks for */ lcp_options try; /* options to request next time */ int looped_back = 0; @@ -816,7 +827,7 @@ lcp_nakci(f, p, len) if (f->state != OPENED) { *go = try; if (looped_back && try.numloops % lcp_warnloops == 0) - LCPDEBUG((LOG_INFO, "The line appears to be looped back.")); + syslog(LOG_WARNING, "Serial line appears to be looped back."); } return 1; @@ -845,7 +856,7 @@ lcp_rejci(f, p, len) lcp_options *go = &lcp_gotoptions[f->unit]; u_char cichar; u_short cishort; - u_long cilong; + uint32 cilong; u_char *start = p; int plen = len; lcp_options try; /* options to request next time */ @@ -977,7 +988,7 @@ lcp_reqci(f, inp, lenp, reject_if_disagree) u_char *cip, *next; /* Pointer to current and next CIs */ u_char cilen, citype, cichar;/* Parsed len, type, char value */ u_short cishort; /* Parsed short value */ - u_long cilong; /* Parse long value */ + uint32 cilong; /* Parse long value */ int rc = CONFACK; /* Final packet return code */ int orc; /* Individual option return code */ u_char *p; /* Pointer to next char to parse */ @@ -1271,8 +1282,13 @@ lcp_up(f) ppp_send_config(f->unit, MIN(ao->mru, (ho->neg_mru? ho->mru: MTU)), (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), ho->neg_pcompression, ho->neg_accompression); + /* + * If the asyncmap hasn't been negotiated, we really should + * set the receive asyncmap to ffffffff, but we set it to 0 + * for backwards contemptibility. + */ ppp_recv_config(f->unit, (go->neg_mru? MAX(wo->mru, go->mru): MTU), - (go->neg_asyncmap? go->asyncmap: 0xffffffff), + (go->neg_asyncmap? go->asyncmap: 0x00000000), go->neg_pcompression, go->neg_accompression); if (ho->neg_mru) @@ -1281,6 +1297,7 @@ lcp_up(f) ChapLowerUp(f->unit); /* Enable CHAP */ upap_lowerup(f->unit); /* Enable UPAP */ ipcp_lowerup(f->unit); /* Enable IPCP */ + ccp_lowerup(f->unit); /* Enable CCP */ lcp_echo_lowerup(f->unit); /* Enable echo messages */ link_established(f->unit); @@ -1297,6 +1314,7 @@ lcp_down(f) fsm *f; { lcp_echo_lowerdown(f->unit); + ccp_lowerdown(f->unit); ipcp_lowerdown(f->unit); ChapLowerDown(f->unit); upap_lowerdown(f->unit); @@ -1351,7 +1369,7 @@ lcp_printpkt(p, plen, printer, arg) int code, id, len, olen; u_char *pstart, *optend; u_short cishort; - u_long cilong; + uint32 cilong; if (plen < HEADERLEN) return 0; @@ -1478,7 +1496,7 @@ void LcpLinkFailure (f) { if (f->state == OPENED) { syslog (LOG_NOTICE, "Excessive lack of response to LCP echo frames."); - lcp_lowerdown(f->unit); /* Reset connection */ + lcp_close(f->unit); /* Reset connection */ } } @@ -1490,10 +1508,10 @@ static void LcpEchoCheck (f) fsm *f; { - u_long delta; + uint32 delta; #ifdef __linux__ struct ppp_ddinfo ddinfo; - u_long latest; + uint32 latest; /* * Read the time since the last packet was received. */ @@ -1553,15 +1571,19 @@ lcp_received_echo_reply (f, id, inp, len) fsm *f; int id; u_char *inp; int len; { - u_long magic; + uint32 magic; /* Check the magic number - don't count replies from ourselves. */ - if (len < CILEN_LONG) + if (len < 4) { + syslog(LOG_DEBUG, "lcp: received short Echo-Reply, length %d", len); return; + } GETLONG(magic, inp); if (lcp_gotoptions[f->unit].neg_magicnumber - && magic == lcp_gotoptions[f->unit].magicnumber) + && magic == lcp_gotoptions[f->unit].magicnumber) { + syslog(LOG_WARNING, "appear to have received our own echo-reply!"); return; + } /* Reset the number of outstanding echo frames */ lcp_echos_pending = 0; @@ -1575,7 +1597,7 @@ static void LcpSendEchoRequest (f) fsm *f; { - u_long lcp_magic; + uint32 lcp_magic; u_char pkt[4], *pktp; /*