]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/lcp.c
PPPoE updates: don't exit if discovery fails, cope with both
[ppp.git] / pppd / lcp.c
index 442ae227a5143215a863130bc138bc22c4225f17..8d540715a0470775ea39516e83f199a28120ff94 100644 (file)
@@ -40,7 +40,7 @@
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#define RCSID  "$Id: lcp.c,v 1.64 2002/12/04 23:03:32 paulus Exp $"
+#define RCSID  "$Id: lcp.c,v 1.70 2003/07/28 12:25:41 carlsonj Exp $"
 
 /*
  * TODO:
@@ -53,7 +53,7 @@
 #include "pppd.h"
 #include "fsm.h"
 #include "lcp.h"
-#include "chap.h"
+#include "chap-new.h"
 #include "magic.h"
 
 static const char rcsid[] = RCSID;
@@ -414,7 +414,7 @@ lcp_close(unit, reason)
        lcp_finished(f);
 
     } else
-       fsm_close(&lcp_fsm[unit], reason);
+       fsm_close(f, reason);
 }
 
 
@@ -433,9 +433,10 @@ lcp_lowerup(unit)
      * but accept A/C and protocol compressed packets
      * if we are going to ask for A/C and protocol compression.
      */
-    ppp_send_config(unit, PPP_MRU, 0xffffffff, 0, 0);
-    ppp_recv_config(unit, PPP_MRU, (lax_recv? 0: 0xffffffff),
-                   wo->neg_pcompression, wo->neg_accompression);
+    if (ppp_send_config(unit, PPP_MRU, 0xffffffff, 0, 0) < 0
+       || ppp_recv_config(unit, PPP_MRU, (lax_recv? 0: 0xffffffff),
+                          wo->neg_pcompression, wo->neg_accompression) < 0)
+           return;
     peer_mru[unit] = PPP_MRU;
 
     if (listen_time != 0) {
@@ -1028,6 +1029,10 @@ lcp_nakci(f, p, len)
        try.neg = 0; \
     }
 
+    /*
+     * NOTE!  There must be no assignments to individual fields of *go in
+     * the code below.  Any such assignment is a BUG!
+     */
     /*
      * We don't care if they want to send us smaller packets than
      * we want.  Therefore, accept any MRU less than what we asked for,
@@ -1088,7 +1093,7 @@ lcp_nakci(f, p, len)
                try.neg_eap = 0;
                /* Try to set up to use their suggestion, if possible */
                if (CHAP_CANDIGEST(go->chap_mdtype, cichar))
-                   go->chap_mdtype = CHAP_MDTYPE_D(cichar);
+                   try.chap_mdtype = CHAP_MDTYPE_D(cichar);
            } else if (go->neg_chap) {
                /*
                 * We were asking for our preferred algorithm, they must
@@ -1097,7 +1102,7 @@ lcp_nakci(f, p, len)
                if (cichar != CHAP_DIGEST(go->chap_mdtype)) {
                    if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) {
                        /* Use their suggestion if we support it ... */
-                       go->chap_mdtype = CHAP_MDTYPE_D(cichar);
+                       try.chap_mdtype = CHAP_MDTYPE_D(cichar);
                    } else {
                        /* ... otherwise, try our next-preferred algorithm. */
                        try.chap_mdtype &= ~(CHAP_MDTYPE(try.chap_mdtype));
@@ -1215,7 +1220,7 @@ lcp_nakci(f, p, len)
      * An option we don't recognize represents the peer asking to
      * negotiate some option we don't support, so ignore it.
      */
-    while (len > CILEN_VOID) {
+    while (len >= CILEN_VOID) {
        GETCHAR(citype, p);
        GETCHAR(cilen, p);
        if (cilen < CILEN_VOID || (len -= cilen) < 0)
@@ -1602,11 +1607,11 @@ lcp_reqci(f, inp, lenp, reject_if_disagree)
                }
                if (!ao->neg_upap) {    /* we don't want to do PAP */
                    orc = CONFNAK;      /* NAK it and suggest CHAP or EAP */
+                   PUTCHAR(CI_AUTHTYPE, nakp);
                    if (ao->neg_eap) {
                        PUTCHAR(CILEN_SHORT, nakp);
                        PUTSHORT(PPP_EAP, nakp);
                    } else {
-                       PUTCHAR(CI_AUTHTYPE, nakp);
                        PUTCHAR(CILEN_CHAP, nakp);
                        PUTSHORT(PPP_CHAP, nakp);
                        PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakp);
@@ -2033,7 +2038,7 @@ lcp_printpkt(p, plen, printer, arg)
                        printer(arg, "chap");
                        if (p < optend) {
                            switch (*p) {
-                           case CHAP_DIGEST_MD5:
+                           case CHAP_MD5:
                                printer(arg, " MD5");
                                ++p;
                                break;