$NetBSD: patch-bm,v 1.2 1999/12/08 13:57:43 rh Exp $ --- pppd/lcp.c.orig Fri Aug 13 08:46:14 1999 +++ pppd/lcp.c Wed Dec 8 14:54:55 1999 @@ -35,6 +35,8 @@ static const char rcsid[] = RCSID; +extern bool refuse_chap; + /* * LCP-related command-line options. */ @@ -277,19 +279,47 @@ wo->asyncmap = 0; wo->neg_chap = 0; /* Set to 1 on server */ wo->neg_upap = 0; /* Set to 1 on server */ + wo->use_digest = 1; +#ifdef CHAPMS + if(wo->use_chapms_v2) + wo->chap_mdtype = CHAP_MICROSOFT_V2; + else if(wo->use_chapms) + wo->chap_mdtype = CHAP_MICROSOFT; + else +#endif + if(wo->use_digest) wo->chap_mdtype = CHAP_DIGEST_MD5; + else + refuse_chap = 1; wo->neg_magicnumber = 1; wo->neg_pcompression = 1; wo->neg_accompression = 1; wo->neg_lqr = 0; /* no LQR implementation yet */ +#ifdef CBCP_SUPPORT + wo->neg_cbcp = 1; +#else wo->neg_cbcp = 0; +#endif ao->neg_mru = 1; ao->mru = MAXMRU; ao->neg_asyncmap = 1; ao->asyncmap = 0; ao->neg_chap = 1; + ao->use_digest = 1; +#ifdef CHAPMS + ao->use_chapms_v2 = ao->use_chapms = 1; + if(ao->use_chapms_v2) + ao->chap_mdtype = CHAP_MICROSOFT_V2; + else if(ao->use_chapms) + ao->chap_mdtype = CHAP_MICROSOFT; + else +#else + if(ao->use_digest) ao->chap_mdtype = CHAP_DIGEST_MD5; + else + refuse_chap = 1; +#endif ao->neg_upap = 1; ao->neg_magicnumber = 1; ao->neg_pcompression = 1; @@ -557,6 +587,18 @@ * NB: we only ask for one of CHAP and UPAP, even if we will * accept either. */ +#ifdef CHAPMS + if(go->use_chapms_v2) + go->chap_mdtype = CHAP_MICROSOFT_V2; + else if(go->use_chapms) + go->chap_mdtype = CHAP_MICROSOFT; + else +#endif + if(go->use_digest) + go->chap_mdtype = CHAP_DIGEST_MD5; + else + go->neg_chap = 0; + return (LENCISHORT(go->neg_mru && go->mru != DEFMRU) + LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) + LENCICHAP(go->neg_chap) + @@ -922,7 +964,34 @@ * algorithm. If they can't do MD5, we'll have to stop * asking for CHAP. */ - if (cichar != go->chap_mdtype) + if (go->chap_mdtype == CHAP_MICROSOFT_V2) + { + try.use_chapms_v2 = 0; + if(try.use_chapms) + try.chap_mdtype = CHAP_MICROSOFT; + else if(try.use_digest) + try.chap_mdtype = CHAP_DIGEST_MD5; + else + try.neg_chap = 0; + } + else if(go->chap_mdtype == CHAP_MICROSOFT) + { + try.use_chapms = 0; + if(try.use_digest) + try.chap_mdtype = CHAP_DIGEST_MD5; + else + try.neg_chap = 0; + } + else if(go->chap_mdtype == CHAP_DIGEST_MD5) + { + try.use_digest = 0; + try.neg_chap = 0; + } + else + try.neg_chap = 0; + if ((cichar != CHAP_MICROSOFT_V2) && + (cichar != CHAP_MICROSOFT) && + (cichar != CHAP_DIGEST_MD5)) try.neg_chap = 0; } else { /* @@ -1133,8 +1202,22 @@ /* Check rejected value. */ \ if (cishort != val || cichar != digest) \ goto bad; \ + switch(digest) \ + { \ + case CHAP_MICROSOFT_V2: \ + try.use_chapms_v2 = 0; \ + break; \ + case CHAP_MICROSOFT: \ + try.use_chapms = 0; \ + break; \ + case CHAP_DIGEST_MD5: \ + try.use_digest = 0; \ + } \ + if(!try.use_chapms_v2 && !try.use_chapms && !try.use_digest) \ + { \ try.neg = 0; \ try.neg_upap = 0; \ + } \ } #define REJCILONG(opt, neg, val) \ if (go->neg && \ @@ -1370,9 +1453,10 @@ if (cichar != CHAP_DIGEST_MD5 #ifdef CHAPMS && cichar != CHAP_MICROSOFT + && cichar != CHAP_MICROSOFT_V2 #endif ) { - orc = CONFNAK; + orc = CONFREJ; /* !!! CONFNAK !!! */ PUTCHAR(CI_AUTHTYPE, nakp); PUTCHAR(CILEN_CHAP, nakp); PUTSHORT(PPP_CHAP, nakp); @@ -1449,6 +1533,23 @@ ho->magicnumber = cilong; break; +#ifdef CBCP_SUPPORT + case CI_CALLBACK: + LCPDEBUG((LOG_INFO, "lcp_reqci: rcvd CBCP")); + if (!ao->neg_cbcp || + cilen != CILEN_CHAR) { + orc = CONFREJ; + break; + } + GETCHAR(cichar, p); + if(cichar != CBCP_OPT) + { + orc = CONFREJ; + break; + } + ho->neg_cbcp = 1; + break; +#endif case CI_PCOMPRESSION: if (!ao->neg_pcompression || @@ -1721,20 +1822,23 @@ } } break; +#ifdef CBCP_SUPPORT case CI_CALLBACK: - if (olen >= CILEN_CHAR) { + if (olen == CILEN_CHAR) { + u_char cichar; p += 2; printer(arg, "callback "); - GETCHAR(cishort, p); - switch (cishort) { + GETCHAR(cichar, p); + switch (cichar) { case CBCP_OPT: printer(arg, "CBCP"); break; default: - printer(arg, "0x%x", cishort); + printer(arg, "0x%x", cichar); } } break; +#endif case CI_MAGICNUMBER: if (olen == CILEN_LONG) { p += 2;