]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/ccp.c
pppd.8: Document netmask option
[ppp.git] / pppd / ccp.c
index 6be16b85f11dc4558831a0230832e986e56b245b..3c286829157a25b7512661dbb3c69bdde925edcb 100644 (file)
  * 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.
- *
- * 3. The name(s) of the authors of this software must not be used to
+ * 2. The name(s) of the authors of this software must not be used to
  *    endorse or promote products derived from this software without
  *    prior written permission.
  *
- * 4. Redistributions of any form whatsoever must retain the following
+ * 3. Redistributions of any form whatsoever must retain the following
  *    acknowledgment:
  *    "This product includes software developed by Paul Mackerras
- *     <paulus@samba.org>".
+ *     <paulus@ozlabs.org>".
  *
  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#define RCSID  "$Id: ccp.c,v 1.45 2003/04/25 09:41:58 fcusack Exp $"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define RCSID  "$Id: ccp.c,v 1.50 2005/06/26 19:34:41 carlsonj Exp $"
 
 #include <stdlib.h>
 #include <string.h>
+#if defined(SOL2)
+#include <net/ppp-comp.h>
+#else
+#include <linux/ppp-comp.h>
+#endif
 
-#include "pppd.h"
+#include "pppd-private.h"
+#include "options.h"
 #include "fsm.h"
 #include "ccp.h"
-#include <net/ppp-comp.h>
 
-#ifdef MPPE
-#include "chap_ms.h"   /* mppe_xxxx_key, mppe_keys_set */
+#include "chap_ms.h"
+#include "mppe.h"
 #include "lcp.h"       /* lcp_close(), lcp_fsm */
-#endif
 
-static const char rcsid[] = RCSID;
 
 /*
  * Unfortunately there is a bug in zlib which means that using a
@@ -62,19 +64,19 @@ static const char rcsid[] = RCSID;
 /*
  * Command-line options.
  */
-static int setbsdcomp __P((char **));
-static int setdeflate __P((char **));
+static int setbsdcomp (char **);
+static int setdeflate (char **);
 static char bsd_value[8];
 static char deflate_value[8];
 
 /*
  * Option variables.
  */
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
 bool refuse_mppe_stateful = 1;         /* Allow stateful mode? */
 #endif
 
-static option_t ccp_option_list[] = {
+static struct option ccp_option_list[] = {
     { "noccp", o_bool, &ccp_protent.enabled_flag,
       "Disable CCP negotiation" },
     { "-ccp", o_bool, &ccp_protent.enabled_flag,
@@ -113,7 +115,7 @@ static option_t ccp_option_list[] = {
       "don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
       &ccp_allowoptions[0].predictor_1 },
 
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     /* MPPE options are symmetrical ... we only set wantoptions here */
     { "require-mppe", o_bool, &ccp_wantoptions[0].mppe,
       "require MPPE encryption",
@@ -169,17 +171,17 @@ static option_t ccp_option_list[] = {
 /*
  * Protocol entry points from main code.
  */
-static void ccp_init __P((int unit));
-static void ccp_open __P((int unit));
-static void ccp_close __P((int unit, char *));
-static void ccp_lowerup __P((int unit));
-static void ccp_lowerdown __P((int));
-static void ccp_input __P((int unit, u_char *pkt, int len));
-static void ccp_protrej __P((int unit));
-static int  ccp_printpkt __P((u_char *pkt, int len,
-                             void (*printer) __P((void *, char *, ...)),
-                             void *arg));
-static void ccp_datainput __P((int unit, u_char *pkt, int len));
+static void ccp_init (int unit);
+static void ccp_open (int unit);
+static void ccp_close (int unit, char *);
+static void ccp_lowerup (int unit);
+static void ccp_lowerdown (int);
+static void ccp_input (int unit, u_char *pkt, int len);
+static void ccp_protrej (int unit);
+static int  ccp_printpkt (u_char *pkt, int len,
+                         void (*printer)(void *, char *, ...),
+                         void *arg);
+static void ccp_datainput (int unit, u_char *pkt, int len);
 
 struct protent ccp_protent = {
     PPP_CCP,
@@ -210,18 +212,18 @@ ccp_options ccp_hisoptions[NUM_PPP];      /* what we agreed to do */
 /*
  * Callbacks for fsm code.
  */
-static void ccp_resetci __P((fsm *));
-static int  ccp_cilen __P((fsm *));
-static void ccp_addci __P((fsm *, u_char *, int *));
-static int  ccp_ackci __P((fsm *, u_char *, int));
-static int  ccp_nakci __P((fsm *, u_char *, int));
-static int  ccp_rejci __P((fsm *, u_char *, int));
-static int  ccp_reqci __P((fsm *, u_char *, int *, int));
-static void ccp_up __P((fsm *));
-static void ccp_down __P((fsm *));
-static int  ccp_extcode __P((fsm *, int, int, u_char *, int));
-static void ccp_rack_timeout __P((void *));
-static char *method_name __P((ccp_options *, ccp_options *));
+static void ccp_resetci (fsm *);
+static int  ccp_cilen (fsm *);
+static void ccp_addci (fsm *, u_char *, int *);
+static int  ccp_ackci (fsm *, u_char *, int);
+static int  ccp_nakci (fsm *, u_char *, int, int);
+static int  ccp_rejci (fsm *, u_char *, int);
+static int  ccp_reqci (fsm *, u_char *, int *, int);
+static void ccp_up (fsm *);
+static void ccp_down (fsm *);
+static int  ccp_extcode (fsm *, int, int, u_char *, int);
+static void ccp_rack_timeout (void *);
+static char *method_name (ccp_options *, ccp_options *);
 
 static fsm_callbacks ccp_callbacks = {
     ccp_resetci,
@@ -263,8 +265,7 @@ static int all_rejected[NUM_PPP];   /* we rejected all peer's options */
  * Option parsing.
  */
 static int
-setbsdcomp(argv)
-    char **argv;
+setbsdcomp(char **argv)
 {
     int rbits, abits;
     char *str, *endp;
@@ -276,12 +277,12 @@ setbsdcomp(argv)
        abits = strtol(str, &endp, 0);
     }
     if (*endp != 0 || endp == str) {
-       option_error("invalid parameter '%s' for bsdcomp option", *argv);
+       ppp_option_error("invalid parameter '%s' for bsdcomp option", *argv);
        return 0;
     }
     if ((rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS))
        || (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) {
-       option_error("bsdcomp option values must be 0 or %d .. %d",
+       ppp_option_error("bsdcomp option values must be 0 or %d .. %d",
                     BSD_MIN_BITS, BSD_MAX_BITS);
        return 0;
     }
@@ -302,8 +303,7 @@ setbsdcomp(argv)
 }
 
 static int
-setdeflate(argv)
-    char **argv;
+setdeflate(char **argv)
 {
     int rbits, abits;
     char *str, *endp;
@@ -315,13 +315,13 @@ setdeflate(argv)
        abits = strtol(str, &endp, 0);
     }
     if (*endp != 0 || endp == str) {
-       option_error("invalid parameter '%s' for deflate option", *argv);
+       ppp_option_error("invalid parameter '%s' for deflate option", *argv);
        return 0;
     }
     if ((rbits != 0 && (rbits < DEFLATE_MIN_SIZE || rbits > DEFLATE_MAX_SIZE))
        || (abits != 0 && (abits < DEFLATE_MIN_SIZE
                          || abits > DEFLATE_MAX_SIZE))) {
-       option_error("deflate option values must be 0 or %d .. %d",
+       ppp_option_error("deflate option values must be 0 or %d .. %d",
                     DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE);
        return 0;
     }
@@ -353,8 +353,7 @@ setdeflate(argv)
  * ccp_init - initialize CCP.
  */
 static void
-ccp_init(unit)
-    int unit;
+ccp_init(int unit)
 {
     fsm *f = &ccp_fsm[unit];
 
@@ -389,8 +388,7 @@ ccp_init(unit)
  * ccp_open - CCP is allowed to come up.
  */
 static void
-ccp_open(unit)
-    int unit;
+ccp_open(int unit)
 {
     fsm *f = &ccp_fsm[unit];
 
@@ -412,9 +410,7 @@ ccp_open(unit)
  * ccp_close - Terminate CCP.
  */
 static void
-ccp_close(unit, reason)
-    int unit;
-    char *reason;
+ccp_close(int unit, char *reason)
 {
     ccp_flags_set(unit, 0, 0);
     fsm_close(&ccp_fsm[unit], reason);
@@ -424,8 +420,7 @@ ccp_close(unit, reason)
  * ccp_lowerup - we may now transmit CCP packets.
  */
 static void
-ccp_lowerup(unit)
-    int unit;
+ccp_lowerup(int unit)
 {
     fsm_lowerup(&ccp_fsm[unit]);
 }
@@ -434,8 +429,7 @@ ccp_lowerup(unit)
  * ccp_lowerdown - we may not transmit CCP packets.
  */
 static void
-ccp_lowerdown(unit)
-    int unit;
+ccp_lowerdown(int unit)
 {
     fsm_lowerdown(&ccp_fsm[unit]);
 }
@@ -444,10 +438,7 @@ ccp_lowerdown(unit)
  * ccp_input - process a received CCP packet.
  */
 static void
-ccp_input(unit, p, len)
-    int unit;
-    u_char *p;
-    int len;
+ccp_input(int unit, u_char *p, int len)
 {
     fsm *f = &ccp_fsm[unit];
     int oldstate;
@@ -459,7 +450,7 @@ ccp_input(unit, p, len)
     fsm_input(f, p, len);
     if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) {
        notice("Compression disabled by peer.");
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
        if (ccp_gotoptions[unit].mppe) {
            error("MPPE disabled, closing LCP");
            lcp_close(unit, "MPPE disabled by peer");
@@ -480,11 +471,7 @@ ccp_input(unit, p, len)
  * Handle a CCP-specific code.
  */
 static int
-ccp_extcode(f, code, id, p, len)
-    fsm *f;
-    int code, id;
-    u_char *p;
-    int len;
+ccp_extcode(fsm *f, int code, int id, u_char *p, int len)
 {
     switch (code) {
     case CCP_RESETREQ:
@@ -513,13 +500,12 @@ ccp_extcode(f, code, id, p, len)
  * ccp_protrej - peer doesn't talk CCP.
  */
 static void
-ccp_protrej(unit)
-    int unit;
+ccp_protrej(int unit)
 {
     ccp_flags_set(unit, 0, 0);
     fsm_lowerdown(&ccp_fsm[unit]);
 
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (ccp_gotoptions[unit].mppe) {
        error("MPPE required but peer negotiation failed");
        lcp_close(unit, "MPPE required but peer negotiation failed");
@@ -532,8 +518,7 @@ ccp_protrej(unit)
  * ccp_resetci - initialize at start of negotiation.
  */
 static void
-ccp_resetci(f)
-    fsm *f;
+ccp_resetci(fsm *f)
 {
     ccp_options *go = &ccp_gotoptions[f->unit];
     u_char opt_buf[CCP_MAX_OPTION_LENGTH];
@@ -541,10 +526,13 @@ ccp_resetci(f)
     *go = ccp_wantoptions[f->unit];
     all_rejected[f->unit] = 0;
 
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (go->mppe) {
        ccp_options *ao = &ccp_allowoptions[f->unit];
        int auth_mschap_bits = auth_done[f->unit];
+#ifdef PPP_WITH_EAPTLS
+       int auth_eap_bits = auth_done[f->unit];
+#endif
        int numbits;
 
        /*
@@ -572,14 +560,29 @@ ccp_resetci(f)
            lcp_close(f->unit, "MPPE required but not available");
            return;
        }
+
+#ifdef PPP_WITH_EAPTLS
+    /*
+     * MPPE is also possible in combination with EAP-TLS.
+     * It is not possible to detect if we're doing EAP or EAP-TLS
+     * at this stage, hence we accept all forms of EAP. If TLS is
+     * not used then the MPPE keys will not be derived anyway.
+     */
+       /* Leave only the eap auth bits set */
+       auth_eap_bits &= (EAP_WITHPEER | EAP_PEER );
+
+       if ((numbits == 0) && (auth_eap_bits == 0)) {
+           error("MPPE required, but MS-CHAP[v2] nor EAP-TLS auth are performed.");
+#else
        if (!numbits) {
            error("MPPE required, but MS-CHAP[v2] auth not performed.");
+#endif
            lcp_close(f->unit, "MPPE required but not available");
            return;
        }
 
        /* A plugin (eg radius) may not have obtained key material. */
-       if (!mppe_keys_set) {
+       if (!mppe_keys_isset()) {
            error("MPPE required, but keys are not available.  "
                  "Possible plugin problem?");
            lcp_close(f->unit, "MPPE required but not available");
@@ -612,13 +615,11 @@ ccp_resetci(f)
        ao->predictor_2  = go->predictor_2  = 0;
        ao->deflate      = go->deflate      = 0;
     }
-#endif /* MPPE */
 
     /*
      * Check whether the kernel knows about the various
      * compression methods we might request.
      */
-#ifdef MPPE
     if (go->mppe) {
        opt_buf[0] = CI_MPPE;
        opt_buf[1] = CILEN_MPPE;
@@ -629,7 +630,7 @@ ccp_resetci(f)
            lcp_close(f->unit, "MPPE required but not available");
        }
     }
-#endif
+#endif /* PPP_WITH_MPPE */
     if (go->bsd_compress) {
        opt_buf[0] = CI_BSD_COMPRESS;
        opt_buf[1] = CILEN_BSD_COMPRESS;
@@ -675,13 +676,13 @@ ccp_resetci(f)
  * ccp_cilen - Return total length of our configuration info.
  */
 static int
-ccp_cilen(f)
-    fsm *f;
+  ccp_cilen(fsm *f)
 {
     ccp_options *go = &ccp_gotoptions[f->unit];
 
     return (go->bsd_compress? CILEN_BSD_COMPRESS: 0)
-       + (go->deflate? CILEN_DEFLATE: 0)
+       + (go->deflate && go->deflate_correct? CILEN_DEFLATE: 0)
+       + (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0)
        + (go->predictor_1? CILEN_PREDICTOR_1: 0)
        + (go->predictor_2? CILEN_PREDICTOR_2: 0)
        + (go->mppe? CILEN_MPPE: 0);
@@ -691,10 +692,7 @@ ccp_cilen(f)
  * ccp_addci - put our requests in a packet.
  */
 static void
-ccp_addci(f, p, lenp)
-    fsm *f;
-    u_char *p;
-    int *lenp;
+  ccp_addci(fsm *f, u_char *p, int *lenp)
 {
     int res;
     ccp_options *go = &ccp_gotoptions[f->unit];
@@ -705,7 +703,7 @@ ccp_addci(f, p, lenp)
      * preference order.  Get the kernel to allocate the first one
      * in case it gets Acked.
      */
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (go->mppe) {
        u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
 
@@ -713,7 +711,7 @@ ccp_addci(f, p, lenp)
        p[1] = opt_buf[1] = CILEN_MPPE;
        MPPE_OPTS_TO_CI(go->mppe, &p[2]);
        MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
-       BCOPY(mppe_recv_key, &opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
+       mppe_get_recv_key(&opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
        res = ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0);
        if (res > 0)
            p += CILEN_MPPE;
@@ -727,21 +725,25 @@ ccp_addci(f, p, lenp)
        p[1] = CILEN_DEFLATE;
        p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
        p[3] = DEFLATE_CHK_SEQUENCE;
-       for (;;) {
-           if (go->deflate_size < DEFLATE_MIN_WORKS) {
-               go->deflate = 0;
-               break;
-           }
-           res = ccp_test(f->unit, p, CILEN_DEFLATE, 0);
-           if (res > 0) {
-               p += CILEN_DEFLATE;
-               break;
-           } else if (res < 0) {
-               go->deflate = 0;
-               break;
+       if (p != p0) {
+           p += CILEN_DEFLATE;
+       } else {
+           for (;;) {
+               if (go->deflate_size < DEFLATE_MIN_WORKS) {
+                   go->deflate = 0;
+                   break;
+               }
+               res = ccp_test(f->unit, p, CILEN_DEFLATE, 0);
+               if (res > 0) {
+                   p += CILEN_DEFLATE;
+                   break;
+               } else if (res < 0) {
+                   go->deflate = 0;
+                   break;
+               }
+               --go->deflate_size;
+               p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
            }
-           --go->deflate_size;
-           p[2] = DEFLATE_MAKE_OPT(go->deflate_size);
        }
        if (p != p0 && go->deflate_correct && go->deflate_draft) {
            p[0] = CI_DEFLATE_DRAFT;
@@ -806,15 +808,12 @@ ccp_addci(f, p, lenp)
  * 1 iff the packet was OK.
  */
 static int
-ccp_ackci(f, p, len)
-    fsm *f;
-    u_char *p;
-    int len;
+  ccp_ackci(fsm *f, u_char *p, int len)
 {
     ccp_options *go = &ccp_gotoptions[f->unit];
     u_char *p0 = p;
 
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (go->mppe) {
        u_char opt_buf[CILEN_MPPE];
 
@@ -895,10 +894,7 @@ ccp_ackci(f, p, len)
  * Returns 1 iff the nak was OK.
  */
 static int
-ccp_nakci(f, p, len)
-    fsm *f;
-    u_char *p;
-    int len;
+  ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
 {
     ccp_options *go = &ccp_gotoptions[f->unit];
     ccp_options no;            /* options we've seen already */
@@ -907,7 +903,7 @@ ccp_nakci(f, p, len)
     memset(&no, 0, sizeof(no));
     try = *go;
 
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (go->mppe && len >= CILEN_MPPE
        && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
        no.mppe = 1;
@@ -929,7 +925,7 @@ ccp_nakci(f, p, len)
            lcp_close(f->unit, "MPPE required but peer negotiation failed");
        }
     }
-#endif /* MPPE */
+#endif /* PPP_WITH_MPPE */
     if (go->deflate && len >= CILEN_DEFLATE
        && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
        && p[1] == CILEN_DEFLATE) {
@@ -984,10 +980,7 @@ ccp_nakci(f, p, len)
  * ccp_rejci - reject some of our suggested compression methods.
  */
 static int
-ccp_rejci(f, p, len)
-    fsm *f;
-    u_char *p;
-    int len;
+ccp_rejci(fsm *f, u_char *p, int len)
 {
     ccp_options *go = &ccp_gotoptions[f->unit];
     ccp_options try;           /* options to request next time */
@@ -1001,7 +994,7 @@ ccp_rejci(f, p, len)
     if (len == 0 && all_rejected[f->unit])
        return -1;
 
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (go->mppe && len >= CILEN_MPPE
        && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
        error("MPPE required but peer refused");
@@ -1010,31 +1003,26 @@ ccp_rejci(f, p, len)
        len -= CILEN_MPPE;
     }
 #endif
-    if (go->deflate && len >= CILEN_DEFLATE
-       && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
-       && p[1] == CILEN_DEFLATE) {
+    if (go->deflate_correct && len >= CILEN_DEFLATE
+       && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
        if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
            || p[3] != DEFLATE_CHK_SEQUENCE)
            return 0;           /* Rej is bad */
-       if (go->deflate_correct)
-           try.deflate_correct = 0;
-       else
-           try.deflate_draft = 0;
+       try.deflate_correct = 0;
+       p += CILEN_DEFLATE;
+       len -= CILEN_DEFLATE;
+    }
+    if (go->deflate_draft && len >= CILEN_DEFLATE
+       && p[0] == CI_DEFLATE_DRAFT && p[1] == CILEN_DEFLATE) {
+       if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
+           || p[3] != DEFLATE_CHK_SEQUENCE)
+           return 0;           /* Rej is bad */
+       try.deflate_draft = 0;
        p += CILEN_DEFLATE;
        len -= CILEN_DEFLATE;
-       if (go->deflate_correct && go->deflate_draft
-           && len >= CILEN_DEFLATE && p[0] == CI_DEFLATE_DRAFT
-           && p[1] == CILEN_DEFLATE) {
-           if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
-               || p[3] != DEFLATE_CHK_SEQUENCE)
-               return 0;               /* Rej is bad */
-           try.deflate_draft = 0;
-           p += CILEN_DEFLATE;
-           len -= CILEN_DEFLATE;
-       }
-       if (!try.deflate_correct && !try.deflate_draft)
-           try.deflate = 0;
     }
+    if (!try.deflate_correct && !try.deflate_draft)
+       try.deflate = 0;
     if (go->bsd_compress && len >= CILEN_BSD_COMPRESS
        && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) {
        if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits))
@@ -1071,18 +1059,14 @@ ccp_rejci(f, p, len)
  * appropriately.
  */
 static int
-ccp_reqci(f, p, lenp, dont_nak)
-    fsm *f;
-    u_char *p;
-    int *lenp;
-    int dont_nak;
+ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak)
 {
     int ret, newret, res;
     u_char *p0, *retp;
     int len, clen, type, nb;
     ccp_options *ho = &ccp_hisoptions[f->unit];
     ccp_options *ao = &ccp_allowoptions[f->unit];
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     bool rej_for_ci_mppe = 1;  /* Are we rejecting based on a bad/missing */
                                /* CI_MPPE, or due to other options?       */
 #endif
@@ -1106,7 +1090,7 @@ ccp_reqci(f, p, lenp, dont_nak)
            clen = p[1];
 
            switch (type) {
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
            case CI_MPPE:
                if (!ao->mppe || clen != CILEN_MPPE) {
                    newret = CONFREJ;
@@ -1164,8 +1148,11 @@ ccp_reqci(f, p, lenp, dont_nak)
                    }
                } else {
                    /* Neither are set. */
-                   newret = CONFREJ;
-                   break;
+                   /* We cannot accept this.  */
+                   newret = CONFNAK;
+                   /* Give the peer our idea of what can be used,
+                      so it can choose and confirm */
+                   ho->mppe = ao->mppe;
                }
 
                /* rebuild the opts */
@@ -1175,8 +1162,7 @@ ccp_reqci(f, p, lenp, dont_nak)
                    int mtu;
 
                    BCOPY(p, opt_buf, CILEN_MPPE);
-                   BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
-                         MPPE_MAX_KEY_LEN);
+                   mppe_get_send_key(&opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
                    if (ccp_test(f->unit, opt_buf,
                                 CILEN_MPPE + MPPE_MAX_KEY_LEN, 1) <= 0) {
                        /* This shouldn't happen, we've already tested it! */
@@ -1190,9 +1176,9 @@ ccp_reqci(f, p, lenp, dont_nak)
                     * because MPPE frames **grow**.  The kernel [must]
                     * allocate MPPE_PAD extra bytes in xmit buffers.
                     */
-                   mtu = netif_get_mtu(f->unit);
+                   mtu = ppp_get_mtu(f->unit);
                    if (mtu)
-                       netif_set_mtu(f->unit, mtu - MPPE_PAD);
+                       ppp_set_mtu(f->unit, mtu - MPPE_PAD);
                    else
                        newret = CONFREJ;
                }
@@ -1204,7 +1190,7 @@ ccp_reqci(f, p, lenp, dont_nak)
                 */
                rej_for_ci_mppe = 0;
                break;
-#endif /* MPPE */
+#endif /* PPP_WITH_MPPE */
            case CI_DEFLATE:
            case CI_DEFLATE_DRAFT:
                if (!ao->deflate || clen != CILEN_DEFLATE
@@ -1346,7 +1332,7 @@ ccp_reqci(f, p, lenp, dont_nak)
        else
            *lenp = retp - p0;
     }
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) {
        error("MPPE required but peer negotiation failed");
        lcp_close(f->unit, "MPPE required but peer negotiation failed");
@@ -1359,15 +1345,14 @@ ccp_reqci(f, p, lenp, dont_nak)
  * Make a string name for a compression method (or 2).
  */
 static char *
-method_name(opt, opt2)
-    ccp_options *opt, *opt2;
+method_name(ccp_options *opt, ccp_options *opt2)
 {
     static char result[64];
 
     if (!ANY_COMPRESS(*opt))
        return "(none)";
     switch (opt->method) {
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     case CI_MPPE:
     {
        char *p = result;
@@ -1424,8 +1409,7 @@ method_name(opt, opt2)
  * CCP has come up - inform the kernel driver and log a message.
  */
 static void
-ccp_up(f)
-    fsm *f;
+ccp_up(fsm *f)
 {
     ccp_options *go = &ccp_gotoptions[f->unit];
     ccp_options *ho = &ccp_hisoptions[f->unit];
@@ -1445,10 +1429,9 @@ ccp_up(f)
            notice("%s receive compression enabled", method_name(go, NULL));
     } else if (ANY_COMPRESS(*ho))
        notice("%s transmit compression enabled", method_name(ho, NULL));
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (go->mppe) {
-       BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN);
-       BZERO(mppe_send_key, MPPE_MAX_KEY_LEN);
+       mppe_clear_keys();
        continue_networks(f->unit);             /* Bring up IP et al */
     }
 #endif
@@ -1458,14 +1441,13 @@ ccp_up(f)
  * CCP has gone down - inform the kernel driver.
  */
 static void
-ccp_down(f)
-    fsm *f;
+ccp_down(fsm *f)
 {
     if (ccp_localstate[f->unit] & RACK_PENDING)
        UNTIMEOUT(ccp_rack_timeout, f);
     ccp_localstate[f->unit] = 0;
     ccp_flags_set(f->unit, 1, 0);
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
     if (ccp_gotoptions[f->unit].mppe) {
        ccp_gotoptions[f->unit].mppe = 0;
        if (lcp_fsm[f->unit].state == OPENED) {
@@ -1488,11 +1470,8 @@ static char *ccp_codenames[] = {
 };
 
 static int
-ccp_printpkt(p, plen, printer, arg)
-    u_char *p;
-    int plen;
-    void (*printer) __P((void *, char *, ...));
-    void *arg;
+ccp_printpkt(u_char *p, int plen,
+            void (*printer) (void *, char *, ...), void *arg)
 {
     u_char *p0, *optend;
     int code, id, len;
@@ -1531,7 +1510,7 @@ ccp_printpkt(p, plen, printer, arg)
            len -= optlen;
            optend = p + optlen;
            switch (code) {
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
            case CI_MPPE:
                if (optlen >= CILEN_MPPE) {
                    u_char mppe_opts;
@@ -1621,10 +1600,7 @@ ccp_printpkt(p, plen, printer, arg)
  * compression :-(, otherwise we issue the reset-request.
  */
 static void
-ccp_datainput(unit, pkt, len)
-    int unit;
-    u_char *pkt;
-    int len;
+ccp_datainput(int unit, u_char *pkt, int len)
 {
     fsm *f;
 
@@ -1636,7 +1612,7 @@ ccp_datainput(unit, pkt, len)
             */
            error("Lost compression sync: disabling compression");
            ccp_close(unit, "Lost compression sync");
-#ifdef MPPE
+#ifdef PPP_WITH_MPPE
            /*
             * If we were doing MPPE, we must also take the link down.
             */
@@ -1665,8 +1641,7 @@ ccp_datainput(unit, pkt, len)
  * Timeout waiting for reset-ack.
  */
 static void
-ccp_rack_timeout(arg)
-    void *arg;
+ccp_rack_timeout(void *arg)
 {
     fsm *f = arg;