X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fccp.c;h=0828658a253ee1d48281b1f699d4068063d62116;hb=ee107019bdd7d91a34d8bebb5d1de43e78e8580f;hp=387b571d3db8cf4deec012a8888d51eab80891b9;hpb=d706c95906d996534f13632a747af5dc617f306e;p=ppp.git diff --git a/pppd/ccp.c b/pppd/ccp.c index 387b571..0828658 100644 --- a/pppd/ccp.c +++ b/pppd/ccp.c @@ -28,15 +28,24 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#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 #include +#if defined(SOL2) +#include +#else +#include +#endif -#include "pppd.h" +#include "pppd-private.h" +#include "options.h" #include "fsm.h" #include "ccp.h" -#include #include "chap_ms.h" #include "mppe.h" @@ -63,11 +72,11 @@ 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, @@ -106,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", @@ -268,12 +277,12 @@ setbsdcomp(char **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; } @@ -306,13 +315,13 @@ setdeflate(char **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; } @@ -441,7 +450,7 @@ ccp_input(int unit, u_char *p, int 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"); @@ -496,7 +505,7 @@ 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"); @@ -517,11 +526,11 @@ ccp_resetci(fsm *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 USE_EAPTLS +#ifdef PPP_WITH_EAPTLS int auth_eap_bits = auth_done[f->unit]; #endif int numbits; @@ -552,7 +561,7 @@ ccp_resetci(fsm *f) return; } -#ifdef USE_EAPTLS +#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 @@ -606,13 +615,11 @@ ccp_resetci(fsm *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; @@ -623,7 +630,7 @@ ccp_resetci(fsm *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; @@ -696,7 +703,7 @@ static void * 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]; @@ -806,7 +813,7 @@ static int 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]; @@ -896,7 +903,7 @@ static int 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; @@ -918,7 +925,7 @@ static int 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) { @@ -987,7 +994,7 @@ ccp_rejci(fsm *f, u_char *p, int 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"); @@ -1059,7 +1066,7 @@ ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) 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 @@ -1083,7 +1090,7 @@ ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) clen = p[1]; switch (type) { -#ifdef MPPE +#ifdef PPP_WITH_MPPE case CI_MPPE: if (!ao->mppe || clen != CILEN_MPPE) { newret = CONFREJ; @@ -1169,9 +1176,9 @@ ccp_reqci(fsm *f, u_char *p, int *lenp, int 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; } @@ -1183,7 +1190,7 @@ ccp_reqci(fsm *f, u_char *p, int *lenp, int 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 @@ -1325,7 +1332,7 @@ ccp_reqci(fsm *f, u_char *p, int *lenp, int 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"); @@ -1345,7 +1352,7 @@ method_name(ccp_options *opt, ccp_options *opt2) if (!ANY_COMPRESS(*opt)) return "(none)"; switch (opt->method) { -#ifdef MPPE +#ifdef PPP_WITH_MPPE case CI_MPPE: { char *p = result; @@ -1422,7 +1429,7 @@ ccp_up(fsm *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) { mppe_clear_keys(); continue_networks(f->unit); /* Bring up IP et al */ @@ -1440,7 +1447,7 @@ ccp_down(fsm *f) 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) { @@ -1503,7 +1510,7 @@ ccp_printpkt(u_char *p, int plen, len -= optlen; optend = p + optlen; switch (code) { -#ifdef MPPE +#ifdef PPP_WITH_MPPE case CI_MPPE: if (optlen >= CILEN_MPPE) { u_char mppe_opts; @@ -1605,7 +1612,7 @@ ccp_datainput(int unit, u_char *pkt, int 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. */