From: Paul Mackerras Date: Fri, 5 Aug 2022 04:10:40 +0000 (+1000) Subject: Merge pull request #354 from pali/register-with-name X-Git-Tag: ppp-2.5.0~33 X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=607d8eadccfd62c1fa84a36bd1440bd48b4e55ca;hp=4a54e34cf5629f9fed61f0b7d69ee3ba4d874bc6 Merge pull request #354 from pali/register-with-name pppd: Add support for registering ppp interface via Linux rtnetlink API --- diff --git a/.gitignore b/.gitignore index 133a3df..c80a008 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ autom4te.cache /pppd/config.h /pppd/config.h.in /pppd/pppdconf.h +/pppd/plugins/pppoe/config.h +/pppd/plugins/pppoe/stamp-h3 # https://www.gnu.org/software/libtool/ /libtool diff --git a/Makefile.am b/Makefile.am index 15b2d09..d7b376c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS="-Im4" SUBDIRS = chat contrib pppd pppstats pppdump -if WITH_PLUGINS +if PPP_WITH_PLUGINS SUBDIRS += pppd/plugins endif diff --git a/configure.ac b/configure.ac index dd22dc6..5a134fa 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AM_MAINTAINER_MODE([enable]) AC_LANG(C) AC_CONFIG_SRCDIR([pppd/main.c]) -AC_CONFIG_HEADERS([pppd/config.h pppd/pppdconf.h]) +AC_CONFIG_HEADERS([pppd/config.h pppd/pppdconf.h pppd/plugins/pppoe/config.h]) # Checks for programs. AC_PROG_CC @@ -38,8 +38,8 @@ case "${host_os}" in ;; esac -AM_CONDITIONAL([LINUX], [test "${build_linux}" = "yes" ]) -AM_CONDITIONAL([SUNOS], [test "${build_sunos}" = "yes" ]) +AM_CONDITIONAL([LINUX], [test "x${build_linux}" = "xyes" ]) +AM_CONDITIONAL([SUNOS], [test "x${build_sunos}" = "xyes" ]) AM_COND_IF([SUNOS], CFLAGS="$CFLAGS -DSOL2 -DSRV4") @@ -88,7 +88,7 @@ AC_CHECK_FUNCS([ \ # If libc doesn't provide logwtmp, check if libutil provides logwtmp(), and if so link to it. AS_IF([test "x${ac_cv_func_logwtmp}" != "xyes"], [ AC_CHECK_LIB([util], [logwtmp], [ - AC_DEFINE(HAVE_LOGWTMP, 1, ["System provides the logwtmp() function"]) + AC_DEFINE(HAVE_LOGWTMP, 1, [System provides the logwtmp() function]) AC_SUBST([UTIL_LIBS], ["-lutil"]) ]) ]) @@ -105,96 +105,91 @@ AC_ARG_ENABLE([systemd], AM_CONDITIONAL(WITH_SYSTEMD, test "x${enable_systemd}" = "xyes") AM_COND_IF([WITH_SYSTEMD], AC_DEFINE([SYSTEMD], 1, [Enable support for systemd notifications])) +AS_IF([test "x${enable_systemd}" = "xyes"], [ + PKG_CHECK_MODULES([systemd], [systemd])]) # # Enable Callback Protocol Support, disabled by default AC_ARG_ENABLE([cbcp], AS_HELP_STRING([--enable-cbcp], [Enable Callback Protocol])) -AM_CONDITIONAL(WITH_CBCP, test "x${enable_cbcp}" = "xyes") -AM_COND_IF([WITH_CBCP], - AC_DEFINE([CBCP_SUPPORT], 1, [Have Callback Protocol support])) - -# -# Disable support for limiting session duration by maximum octets -AC_ARG_ENABLE([maxoctets], - AS_HELP_STRING([--disable-maxoctets], [Disable support for limiting session by maximum octets])) -AS_IF([test "x$enable_maxoctets" != "xno"], - AC_DEFINE([MAXOCTETS], 1, ["Limit sessions by maximum number of octets"])) +AM_CONDITIONAL(PPP_WITH_CBCP, test "x${enable_cbcp}" = "xyes") +AM_COND_IF([PPP_WITH_CBCP], + AC_DEFINE([PPP_WITH_CBCP], 1, [Have Callback Protocol support])) # # Disable Microsoft extensions will remove CHAP and MPPE support AC_ARG_ENABLE([microsoft-extensions], AS_HELP_STRING([--disable-microsoft-extensions], [Disable Microsoft CHAP / MPPE extensions])) -AM_CONDITIONAL(WITH_CHAPMS, test "x${enable_microsoft_extensions}" != "xno") -AM_COND_IF([WITH_CHAPMS], - AC_DEFINE([CHAPMS], 1, ["Have Microsoft CHAP support"])) +AM_CONDITIONAL(PPP_WITH_CHAPMS, test "x${enable_microsoft_extensions}" != "xno") +AM_COND_IF([PPP_WITH_CHAPMS], + AC_DEFINE([PPP_WITH_CHAPMS], 1, [Have Microsoft CHAP support])) -AM_CONDITIONAL(WITH_MPPE, test "x${enable_microsoft_extensions}" != "xno") -AM_COND_IF([WITH_MPPE], - AC_DEFINE([MPPE], 1, ["Have Microsoft MPPE support"])) +AM_CONDITIONAL(PPP_WITH_MPPE, test "x${enable_microsoft_extensions}" != "xno") +AM_COND_IF([PPP_WITH_MPPE], + AC_DEFINE([PPP_WITH_MPPE], 1, [Have Microsoft MPPE support])) # # Enable Microsoft LAN Manager support, depends on Microsoft Extensions AC_ARG_ENABLE([mslanman], AS_HELP_STRING([--enable-mslanman], [Enable Microsoft LAN Manager support])) AS_IF([test "x${enable_mslanman}" = "xyes" && test "x${enable_microsoft_extensions}" != "xno"], - AC_DEFINE([MSLANMAN], 1, ["Have Microsoft LAN Manager support"])) + AC_DEFINE([PPP_WITH_MSLANMAN], 1, [Have Microsoft LAN Manager support])) # # Disable IPv6 support -AC_ARG_ENABLE([ipv6-support], - AS_HELP_STRING([--disable-ipv6-support], [Disable IPv6 support])) -AM_CONDITIONAL(WITH_INET6, test "x${enable_ipv6_support}" != "xno") -AM_COND_IF([WITH_INET6], - AC_DEFINE(INET6, 1, ["Have IPv6 support"])) +AC_ARG_ENABLE([ipv6cp], + AS_HELP_STRING([--disable-ipv6cp], [Disable IPv6 Control Protocol])) +AM_CONDITIONAL(PPP_WITH_IPV6CP, test "x${enable_ipv6cp}" != "xno") +AM_COND_IF([PPP_WITH_IPV6CP], + AC_DEFINE(PPP_WITH_IPV6CP, 1, [Have IPv6 Control Protocol])) # # Disable Multilink support AC_ARG_ENABLE([multilink], AS_HELP_STRING([--enable-multilink], [Enable multilink support])) -AM_CONDITIONAL(WITH_MULTILINK, test "x${enable_multilink}" = "xyes") -AM_COND_IF([WITH_MULTILINK], - AC_DEFINE([HAVE_MULTILINK], 1, ["Have multilink support"])) +AM_CONDITIONAL(PPP_WITH_MULTILINK, test "x${enable_multilink}" = "xyes") +AM_COND_IF([PPP_WITH_MULTILINK], + AC_DEFINE([PPP_WITH_MULTILINK], 1, [Have multilink support])) AS_IF([test "x${build_sunos}" = "xyes" && test "x${enable_multilink}" = "xyes"], [AC_MSG_ERROR([Multilink is not supported on SunOS])]) # # Multilink require Trivial Database Support -AM_CONDITIONAL(WITH_TDB, test "x${enable_multilink}" = "xyes") -AM_COND_IF([WITH_TDB], - AC_DEFINE([USE_TDB], 1, ["Include TDB support"])) +AM_CONDITIONAL(PPP_WITH_TDB, test "x${enable_multilink}" = "xyes") +AM_COND_IF([PPP_WITH_TDB], + AC_DEFINE([PPP_WITH_TDB], 1, [Include TDB support])) # # Enable support for loadable plugins AC_ARG_ENABLE([plugins], AS_HELP_STRING([--disable-plugins], [Disable support for loadable plugins])) AS_IF([test "x$enable_plugins" != "xno"], - AC_DEFINE([PLUGIN], 1, ["Have support for loadable plugins"])) -AM_CONDITIONAL(WITH_PLUGINS, test "${enable_plugins}" != "no") + AC_DEFINE([PPP_WITH_PLUGINS], 1, [Have support for loadable plugins])) +AM_CONDITIONAL(PPP_WITH_PLUGINS, test "x${enable_plugins}" != "xno") # # Disable EAP-TLS support AC_ARG_ENABLE([eaptls], AS_HELP_STRING([--disable-eaptls], [Disable EAP-TLS authentication support])) AS_IF([test "x$enable_eaptls" != "xno"], - AC_DEFINE([USE_EAPTLS], 1, ["Have EAP-TLS authentication support"])) -AM_CONDITIONAL(WITH_EAPTLS, test "x${enable_eaptls}" != "xno") + AC_DEFINE([PPP_WITH_EAPTLS], 1, [Have EAP-TLS authentication support])) +AM_CONDITIONAL(PPP_WITH_EAPTLS, test "x${enable_eaptls}" != "xno") # # Disable PEAP support AC_ARG_ENABLE([peap], AS_HELP_STRING([--disable-peap], [Disable PEAP authentication support])) AS_IF([test "x${enable_peap}" != "xno"], - AC_DEFINE([USE_PEAP], 1, ["Have PEAP authentication support"])) -AM_CONDITIONAL([WITH_PEAP], test "x${enable_peap}" != "xno") + AC_DEFINE([PPP_WITH_PEAP], 1, [Have PEAP authentication support])) +AM_CONDITIONAL([PPP_WITH_PEAP], test "x${enable_peap}" != "xno") # # Disable OpenSSL engine support AC_ARG_ENABLE([openssl-engine], AS_HELP_STRING([--disable-openssl-engine], [Disable OpenSSL engine support])) AS_IF([test "x$enable_openssl_engine" != "xno"], [], - AC_DEFINE([OPENSSL_NO_ENGINE], 1, ["OpenSSL engine support"])) + AC_DEFINE([OPENSSL_NO_ENGINE], 1, [OpenSSL engine support])) # # Specify runtime directory @@ -226,7 +221,7 @@ AC_SUBST(PPPD_LOGFILE_DIR) # # Check for OpenSSL AX_CHECK_OPENSSL -AM_CONDITIONAL(WITH_OPENSSL, test "${with_openssl}" != "no") +AM_CONDITIONAL(WITH_OPENSSL, test "x${with_openssl}" != "xno") # # Check if OpenSSL has compiled in support for various ciphers @@ -242,23 +237,23 @@ AS_IF([test "x${with_openssl}" != "xno" ], [ AM_CONDITIONAL([OPENSSL_HAVE_MD4], test "x${ac_cv_openssl_md4}" = "xyes") AM_COND_IF([OPENSSL_HAVE_MD4],, - AC_DEFINE([USE_MD4], 1, [Use included md4 included with pppd])) + AC_DEFINE([USE_MD4], 1, [Use MD4 included with pppd])) AM_CONDITIONAL([OPENSSL_HAVE_MD5], test "x${ac_cv_openssl_md5}" = "xyes") AM_COND_IF([OPENSSL_HAVE_MD5],, - AC_DEFINE([USE_MD5], 1, [Use included md5 included with pppd])) + AC_DEFINE([USE_MD5], 1, [Use MD5 included with pppd])) AM_CONDITIONAL([OPENSSL_HAVE_SHA], test "x${ac_cv_openssl_sha}" = "xyes") AM_COND_IF([OPENSSL_HAVE_SHA],, - AC_DEFINE([USE_SHA], 1, [Use included sha included with pppd])) + AC_DEFINE([USE_SHA], 1, [Use SHA included with pppd])) AM_CONDITIONAL([OPENSSL_HAVE_DES], test "x${ac_cv_openssl_des}" = "xyes") AM_COND_IF([OPENSSL_HAVE_DES],, - AC_DEFINE([USE_CRYPT], 1, [Use included des included with pppd])) + AC_DEFINE([USE_CRYPT], 1, [Use DES included with pppd])) # # If OpenSSL doesn't support DES, then use the one from libcrypt (glibc dropped support for this in 2.27). -AS_IF([test "${ac_cv_openssl_des}" = "no" ], [ +AS_IF([test "x${ac_cv_openssl_des}" = "xno" ], [ AC_CHECK_LIB([crypt], [encrypt], [LIBS="$LIBS -lcrypt"], [AC_MSG_ERROR([OpenSSL not found or does not support DES, and libcrypt also doesn't support encrypt])] @@ -267,7 +262,8 @@ AS_IF([test "${ac_cv_openssl_des}" = "no" ], [ # # With libsrp support -AX_CHECK_SRP +AX_CHECK_SRP([ + AC_DEFINE([PPP_WITH_SRP], 1, [Support for libsrp authentication module])]) # # With libatm support @@ -275,8 +271,8 @@ AX_CHECK_ATM # # With libpam support -AX_CHECK_PAM(AC_DEFINE([USE_PAM], 1, ["Support for Pluggable Authentication Modules"])) -AM_CONDITIONAL(WITH_PAM, test "x${with_pam}" = "xyes") +AX_CHECK_PAM(AC_DEFINE([PPP_WITH_PAM], 1, [Support for Pluggable Authentication Modules])) +AM_CONDITIONAL(PPP_WITH_PAM, test "x${with_pam}" = "xyes") # # With libpcap support, activate pppd on network activity @@ -284,9 +280,9 @@ AX_CHECK_PCAP # # SunOS provides a version of libpcap that would work, but SunOS has no support for activity filter -AM_CONDITIONAL([WITH_FILTER], [ test "x${with_pcap}" = "xyes" && test "x${build_sunos}" != "xyes" ]) -AM_COND_IF([WITH_FILTER], [ - AC_DEFINE([PPP_FILTER], 1, ["Have packet activity filter support"])], [ +AM_CONDITIONAL([PPP_WITH_FILTER], [ test "x${with_pcap}" = "xyes" && test "x${build_sunos}" != "xyes" ]) +AM_COND_IF([PPP_WITH_FILTER], [ + AC_DEFINE([PPP_WITH_FILTER], 1, [Have packet activity filter support])], [ AS_IF([test "x${build_sunos}" = "xyes"], [ AC_MSG_WARN([Packet activity filter not supported on SunOS]) with_pcap="no" @@ -302,6 +298,7 @@ if test "x${with_gtk}" = "xyes"; then fi AM_CONDITIONAL([WITH_GTK], test "x${with_gtk}" = "xyes") +AC_DEFINE_UNQUOTED(PPPD_VERSION, "$VERSION", [Version of pppd]) AC_CONFIG_FILES([ Makefile @@ -410,6 +407,8 @@ Features enabled Multilink............: ${enable_multilink:-no} Plugins..............: ${enable_plugins:-yes} CBCP.................: ${enable_cbcp:-no} + IPV6CP...............: ${enable_ipv6cp:-yes} EAP-TLS..............: ${enable_eaptls:-yes} PEAP.................: ${enable_peap:-yes} + systemd notifications: ${enable_systemd:-no} " diff --git a/include/net/if_ppp.h b/include/net/if_ppp.h index d08605e..1beb470 100644 --- a/include/net/if_ppp.h +++ b/include/net/if_ppp.h @@ -129,10 +129,10 @@ struct ifpppcstatsreq { #define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */ #define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */ #define PPPIOCGIDLE _IOR('t', 74, struct ppp_idle) /* get idle time */ -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER #define PPPIOCSPASS _IOW('t', 71, struct bpf_program) /* set pass filter */ #define PPPIOCSACTIVE _IOW('t', 70, struct bpf_program) /* set active filt */ -#endif /* PPP_FILTER */ +#endif /* PPP_WITH_FILTER */ /* PPPIOC[GS]MTU are alternatives to SIOC[GS]IFMTU, used under Ultrix */ #define PPPIOCGMTU _IOR('t', 73, int) /* get interface MTU */ diff --git a/m4/ax_check_atm.m4 b/m4/ax_check_atm.m4 index 004fe9f..ddd0f53 100644 --- a/m4/ax_check_atm.m4 +++ b/m4/ax_check_atm.m4 @@ -77,7 +77,7 @@ AC_DEFUN([AX_CHECK_ATM], [ $1 ], [ AC_MSG_RESULT([no]) - with_atm="" + with_atm="no" $2 ]) CPPFLAGS="$save_CPPFLAGS" @@ -88,6 +88,6 @@ AC_DEFUN([AX_CHECK_ATM], [ AC_SUBST([ATM_LIBS]) AC_SUBST([ATM_LDFLAGS]) fi - AM_CONDITIONAL(WITH_LIBATM, test -n "${with_atm}") + AM_CONDITIONAL(WITH_LIBATM, test "x${with_atm}" != "xno") ]) diff --git a/m4/ax_check_pam.m4 b/m4/ax_check_pam.m4 index edb30e3..b17a757 100644 --- a/m4/ax_check_pam.m4 +++ b/m4/ax_check_pam.m4 @@ -77,7 +77,7 @@ AC_DEFUN([AX_CHECK_PAM], [ $1 ], [ AC_MSG_RESULT([no]) - with_pam="" + with_pam="no" $2 ]) CPPFLAGS="$save_CPPFLAGS" @@ -88,6 +88,6 @@ AC_DEFUN([AX_CHECK_PAM], [ AC_SUBST([PAM_LIBS]) AC_SUBST([PAM_LDFLAGS]) fi - AM_CONDITIONAL(WITH_LIBPAM, test -n "${with_pam}") + AM_CONDITIONAL(WITH_LIBPAM, test "x${with_pam}" != "xno") ]) diff --git a/m4/ax_check_pcap.m4 b/m4/ax_check_pcap.m4 index 6d70ec1..379a113 100644 --- a/m4/ax_check_pcap.m4 +++ b/m4/ax_check_pcap.m4 @@ -76,7 +76,7 @@ AC_DEFUN([AX_CHECK_PCAP], [ $1 ], [ AC_MSG_RESULT([no]) - with_pcap="" + with_pcap="no" $2 ]) CPPFLAGS="$save_CPPFLAGS" @@ -88,6 +88,6 @@ AC_DEFUN([AX_CHECK_PCAP], [ AC_SUBST([PCAP_LDFLAGS]) fi - AM_CONDITIONAL(WITH_PCAP, test -n "${with_pcap}") + AM_CONDITIONAL(WITH_PCAP, test "x${with_pcap}" != "xno") ]) diff --git a/m4/ax_check_srp.m4 b/m4/ax_check_srp.m4 index 631341d..11e66f5 100644 --- a/m4/ax_check_srp.m4 +++ b/m4/ax_check_srp.m4 @@ -77,7 +77,7 @@ AC_DEFUN([AX_CHECK_SRP], [ $1 ], [ AC_MSG_RESULT([no]) - with_srp="" + with_srp="no" $2 ]) CPPFLAGS="$save_CPPFLAGS" @@ -89,6 +89,6 @@ AC_DEFUN([AX_CHECK_SRP], [ AC_SUBST([SRP_LDFLAGS]) fi - AM_CONDITIONAL(WITH_SRP, test -n "${with_srp}") + AM_CONDITIONAL(WITH_SRP, test "x${with_srp}" != "xno") ]) diff --git a/pppd/Makefile.am b/pppd/Makefile.am index 97edd3c..7dc6cdd 100644 --- a/pppd/Makefile.am +++ b/pppd/Makefile.am @@ -7,7 +7,7 @@ utest_chap_CPPFLAGS = -DUNIT_TEST utest_chap_LDFLAGS = utest_peap_SOURCES = peap.c utils.c mppe.c -utest_peap_CPPFLAGS = -DUNIT_TEST -I${top_srcdir}/include +utest_peap_CPPFLAGS = -DUNIT_TEST utest_peap_LDFLAGS = if WITH_SRP @@ -37,7 +37,6 @@ pppd_include_HEADERS = \ md4.h \ md5.h \ mppe.h \ - patchlevel.h \ pathnames.h \ peap.h \ pppcrypt.h \ @@ -69,7 +68,7 @@ pppd_SOURCES = \ upap.c \ utils.c -pppd_CPPFLAGS = -I${top_srcdir}/include -DPPPD_RUNTIME_DIR='"@PPPD_RUNTIME_DIR@"' -DPPPD_LOGFILE_DIR='"@PPPD_LOGFILE_DIR@"' +pppd_CPPFLAGS = -DPPPD_RUNTIME_DIR='"@PPPD_RUNTIME_DIR@"' -DPPPD_LOGFILE_DIR='"@PPPD_LOGFILE_DIR@"' pppd_LDFLAGS = pppd_LIBS = @@ -80,10 +79,11 @@ endif if SUNOS pppd_SOURCES += sys-solaris.c +pppd_CPPFLAGS += -I${top_srcdir}/include pppd_LIBS += -lsocket -lnsl endif -if WITH_CHAPMS +if PPP_WITH_CHAPMS pppd_SOURCES += chap_ms.c pppd_SOURCES += pppcrypt.c check_PROGRAMS += utest_chap @@ -93,21 +93,21 @@ pppd_SOURCES += pppcrypt.c endif endif -if WITH_CBCP +if PPP_WITH_CBCP pppd_SOURCES += cbcp.c endif -if WITH_MPPE +if PPP_WITH_MPPE pppd_SOURCES += mppe.c endif -if WITH_FILTER +if PPP_WITH_FILTER pppd_CPPFLAGS += $(PCAP_CFLAGS) pppd_LDFLAGS += $(PCAP_LDFLAGS) pppd_LIBS += $(PCAP_LIBS) endif -if WITH_PLUGINS +if PPP_WITH_PLUGINS pppd_CPPFLAGS += -DPPPD_PLUGIN_DIR='"@PPPD_PLUGIN_DIR@"' pppd_LIBS += -ldl if LINUX @@ -115,31 +115,33 @@ pppd_LDFLAGS += -Wl,-E endif endif -if WITH_MULTILINK +if PPP_WITH_MULTILINK pppd_SOURCES += multilink.c endif -if WITH_TDB +if PPP_WITH_TDB pppd_SOURCES += tdb.c spinlock.c endif -if WITH_INET6 +if PPP_WITH_IPV6CP pppd_SOURCES += ipv6cp.c eui64.c endif -if WITH_PAM -pppd_LIBS += -lpam -ldl +if PPP_WITH_PAM +pppd_CPPFLAGS += $(PAM_CFLAGS) +pppd_LIBS += $(PAM_LIBS) -ldl +pppd_LDFLAGS += $(PAM_LDFLAGS) endif -if WITH_EAPTLS +if PPP_WITH_EAPTLS pppd_SOURCES += eap-tls.c tls.c else -if WITH_PEAP +if PPP_WITH_PEAP pppd_SOURCES += tls.c endif endif -if WITH_PEAP +if PPP_WITH_PEAP pppd_SOURCES += peap.c check_PROGRAMS += utest_peap endif @@ -169,7 +171,8 @@ utest_chap_LDADD = libppp_crypt.la pppd_LIBS += libppp_crypt.la if WITH_SYSTEMD -pppd_LIBS += -lsystemd +pppd_CPPFLAGS += $(SYSTEMD_CFLAGS) +pppd_LIBS += $(SYSTEMD_LIBS) endif if WITH_SRP diff --git a/pppd/auth.c b/pppd/auth.c index fa32fea..fc28390 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -122,10 +122,10 @@ #include "upap.h" #include "chap-new.h" #include "eap.h" -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS #include "eap-tls.h" #endif -#ifdef CBCP_SUPPORT +#ifdef PPP_WITH_CBCP #include "cbcp.h" #endif #include "pathnames.h" @@ -198,7 +198,7 @@ int (*chap_check_hook)(void) = NULL; /* Hook for a plugin to get the CHAP password for authenticating us */ int (*chap_passwd_hook)(char *user, char *passwd) = NULL; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS /* Hook for a plugin to get the EAP-TLS password for authenticating us */ int (*eaptls_passwd_hook)(char *user, char *passwd) = NULL; #endif @@ -210,7 +210,7 @@ int (*null_auth_hook)(struct wordlist **paddrs, int (*allowed_address_hook)(u_int32_t addr) = NULL; -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK /* Hook for plugin to hear when an interface joins a multilink bundle */ void (*multilink_join_hook)(void) = NULL; #endif @@ -244,7 +244,7 @@ bool cryptpap = 0; /* Passwords in pap-secrets are encrypted */ bool refuse_pap = 0; /* Don't wanna auth. ourselves with PAP */ bool refuse_chap = 0; /* Don't wanna auth. ourselves with CHAP */ bool refuse_eap = 0; /* Don't wanna auth. ourselves with EAP */ -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS bool refuse_mschap = 0; /* Don't wanna auth. ourselves with MS-CHAP */ bool refuse_mschap_v2 = 0; /* Don't wanna auth. ourselves with MS-CHAPv2 */ #else @@ -259,7 +259,7 @@ bool explicit_user = 0; /* Set if "user" option supplied */ bool explicit_passwd = 0; /* Set if "password" option supplied */ char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ -#if defined(USE_EAPTLS) || defined(USE_PEAP) +#if defined(PPP_WITH_EAPTLS) || defined(PPP_WITH_PEAP) char *cacert_file = NULL; /* CA certificate file (pem format) */ char *ca_path = NULL; /* Directory with CA certificates */ char *crl_dir = NULL; /* Directory containing CRL files */ @@ -269,7 +269,7 @@ char *tls_verify_method = NULL; /* Verify certificate method */ bool tls_verify_key_usage = 0; /* Verify peer certificate key usage */ #endif -#if defined(USE_EAPTLS) +#if defined(PPP_WITH_EAPTLS) char *cert_file = NULL; /* Client certificate file (pem format) */ char *privkey_file = NULL; /* Client private key file (pem format) */ char *pkcs12_file = NULL; /* Client private key envelope file (pkcs12 format) */ @@ -290,7 +290,7 @@ static int have_chap_secret (char *, char *, int, int *); static int have_srp_secret(char *client, char *server, int need_ip, int *lacks_ipp); -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS static int have_eaptls_secret_server (char *client, char *server, int need_ip, int *lacks_ipp); static int have_eaptls_secret_client (char *client, char *server); @@ -317,10 +317,7 @@ static int set_noauth_addr (char **); static int set_permitted_number (char **); static void check_access (FILE *, char *); static int wordlist_count (struct wordlist *); - -#ifdef MAXOCTETS static void check_maxoctets (void *); -#endif /* * Authentication-related options. @@ -345,7 +342,7 @@ option_t auth_options[] = { "Require CHAP authentication from peer", OPT_ALIAS | OPT_PRIOSUB | OPT_A2OR | MDTYPE_MD5, &lcp_wantoptions[0].chap_mdtype }, -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS { "require-mschap", o_bool, &auth_required, "Require MS-CHAP authentication from peer", OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT, @@ -376,7 +373,7 @@ option_t auth_options[] = { "Don't allow CHAP authentication with peer", OPT_ALIAS | OPT_A2CLRB | MDTYPE_MD5, &lcp_allowoptions[0].chap_mdtype }, -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS { "refuse-mschap", o_bool, &refuse_mschap, "Don't agree to auth to peer with MS-CHAP", OPT_A2CLRB | MDTYPE_MICROSOFT, @@ -449,7 +446,7 @@ option_t auth_options[] = { "Set telephone number(s) which are allowed to connect", OPT_PRIV | OPT_A2LIST }, -#if defined(USE_EAPTLS) || defined(USE_PEAP) +#if defined(PPP_WITH_EAPTLS) || defined(PPP_WITH_PEAP) { "ca", o_string, &cacert_file, "CA certificate in PEM format" }, { "capath", o_string, &ca_path, "TLS CA certificate directory" }, { "crl-dir", o_string, &crl_dir, "Use CRLs in directory" }, @@ -462,13 +459,13 @@ option_t auth_options[] = { "Verify peer by method (none|subject|name|suffix)" }, #endif -#if defined(USE_EAPTLS) +#if defined(PPP_WITH_EAPTLS) { "cert", o_string, &cert_file, "client certificate in PEM format" }, { "key", o_string, &privkey_file, "client private key in PEM format" }, { "pkcs12", o_string, &pkcs12_file, "EAP-TLS client credentials in PKCS12 format" }, { "need-peer-eap", o_bool, &need_peer_eap, "Require the peer to authenticate us", 1 }, -#endif +#endif /* PPP_WITH_EAPTLS */ { NULL } }; @@ -793,7 +790,7 @@ link_established(int unit) lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *go = &lcp_gotoptions[unit]; lcp_options *ho = &lcp_hisoptions[unit]; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS lcp_options *ao = &lcp_allowoptions[unit]; #endif int i; @@ -830,7 +827,7 @@ link_established(int unit) } } -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS if (need_peer_eap && !ao->neg_eap) { warn("eap required to authenticate us but no suitable secrets"); lcp_close(unit, "couldn't negotiate eap"); @@ -906,7 +903,7 @@ network_phase(int unit) } } -#ifdef CBCP_SUPPORT +#ifdef PPP_WITH_CBCP /* * If we negotiated callback, do it now. */ @@ -937,7 +934,7 @@ start_networks(int unit) new_phase(PHASE_NETWORK); -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK if (multilink) { if (mp_join_bundle()) { if (multilink_join_hook) @@ -947,9 +944,9 @@ start_networks(int unit) return; } } -#endif /* HAVE_MULTILINK */ +#endif /* PPP_WITH_MULTILINK */ -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER if (!demand) set_filters(&pass_filter, &active_filter); #endif @@ -1019,7 +1016,7 @@ auth_peer_success(int unit, int protocol, int prot_flavor, case CHAP_MD5: bit |= CHAP_MD5_PEER; break; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case CHAP_MICROSOFT: bit |= CHAP_MS_PEER; break; @@ -1095,7 +1092,7 @@ auth_withpeer_success(int unit, int protocol, int prot_flavor) case CHAP_MD5: bit |= CHAP_MD5_WITHPEER; break; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case CHAP_MICROSOFT: bit |= CHAP_MS_WITHPEER; break; @@ -1164,10 +1161,8 @@ np_up(int unit, int proto) if (maxconnect > 0) TIMEOUT(connect_time_expired, 0, maxconnect); -#ifdef MAXOCTETS if (maxoctets > 0) TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); -#endif /* * Detach now, if the updetach option was given. @@ -1194,9 +1189,7 @@ np_down(int unit, int proto) if (--num_np_up == 0) { UNTIMEOUT(check_idle, NULL); UNTIMEOUT(connect_time_expired, NULL); -#ifdef MAXOCTETS UNTIMEOUT(check_maxoctets, NULL); -#endif new_phase(PHASE_NETWORK); } } @@ -1213,7 +1206,6 @@ np_finished(int unit, int proto) } } -#ifdef MAXOCTETS static void check_maxoctets(void *arg) { @@ -1246,7 +1238,6 @@ check_maxoctets(void *arg) TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); } } -#endif /* * check_idle - check whether the link has been idle for long @@ -1352,7 +1343,7 @@ auth_check_options(void) our_name, 1, &lacks_ip); } -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS if (!can_auth && wo->neg_eap) { can_auth = have_eaptls_secret_server((explicit_remote ? remote_name : @@ -1415,7 +1406,7 @@ auth_reset(int unit) (hadchap == 1 || (hadchap == -1 && have_chap_secret(user, (explicit_remote? remote_name: NULL), 0, NULL))) || have_srp_secret(user, (explicit_remote? remote_name: NULL), 0, NULL) -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS || have_eaptls_secret_client(user, (explicit_remote? remote_name: NULL)) #endif ); @@ -1434,7 +1425,7 @@ auth_reset(int unit) 1, NULL))) && !have_srp_secret((explicit_remote? remote_name: NULL), our_name, 1, NULL) -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS && !have_eaptls_secret_server((explicit_remote? remote_name: NULL), our_name, 1, NULL) #endif @@ -2414,7 +2405,7 @@ auth_script(char *script) } -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS static int have_eaptls_secret_server(char *client, char *server, int need_ip, int *lacks_ipp) diff --git a/pppd/ccp.c b/pppd/ccp.c index 644a9d1..088a163 100644 --- a/pppd/ccp.c +++ b/pppd/ccp.c @@ -36,11 +36,15 @@ #include #include +#if defined(SOL2) +#include +#else +#include +#endif #include "pppd.h" #include "fsm.h" #include "ccp.h" -#include #include "chap_ms.h" #include "mppe.h" @@ -67,7 +71,7 @@ static char deflate_value[8]; /* * Option variables. */ -#ifdef MPPE +#ifdef PPP_WITH_MPPE bool refuse_mppe_stateful = 1; /* Allow stateful mode? */ #endif @@ -110,7 +114,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", @@ -445,7 +449,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"); @@ -500,7 +504,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"); @@ -521,11 +525,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; @@ -556,7 +560,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 @@ -610,13 +614,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; @@ -627,7 +629,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; @@ -700,7 +702,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]; @@ -810,7 +812,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]; @@ -900,7 +902,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; @@ -922,7 +924,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) { @@ -991,7 +993,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"); @@ -1063,7 +1065,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 @@ -1087,7 +1089,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; @@ -1187,7 +1189,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 @@ -1329,7 +1331,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"); @@ -1349,7 +1351,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; @@ -1426,7 +1428,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 */ @@ -1444,7 +1446,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) { @@ -1507,7 +1509,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; @@ -1609,7 +1611,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. */ diff --git a/pppd/ccp.h b/pppd/ccp.h index 35961b9..a37695c 100644 --- a/pppd/ccp.h +++ b/pppd/ccp.h @@ -29,6 +29,9 @@ * * $Id: ccp.h,v 1.12 2004/11/04 10:02:26 paulus Exp $ */ +#ifndef PPP_CCP_H +#define PPP_CCP_H + #include "pppdconf.h" typedef struct ccp_options { @@ -51,3 +54,5 @@ extern ccp_options ccp_allowoptions[]; extern ccp_options ccp_hisoptions[]; extern struct protent ccp_protent; + +#endif diff --git a/pppd/chap-md5.h b/pppd/chap-md5.h index 4dbbfd1..55f9ba2 100644 --- a/pppd/chap-md5.h +++ b/pppd/chap-md5.h @@ -27,6 +27,12 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef PPP_CHAP_MD5_H +#define PPP_CHAP_MD5_H + #include "pppdconf.h" extern void chap_md5_init(void); + +#endif diff --git a/pppd/chap-new.c b/pppd/chap-new.c index ab4302b..565713f 100644 --- a/pppd/chap-new.c +++ b/pppd/chap-new.c @@ -41,7 +41,7 @@ #include "chap-new.h" #include "chap-md5.h" -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS #include "chap_ms.h" #define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5) #else @@ -155,7 +155,7 @@ chap_init(int unit) memset(&server, 0, sizeof(server)); chap_md5_init(); -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS chapms_init(); #endif } diff --git a/pppd/chap-new.h b/pppd/chap-new.h index b4b0ee2..9ebec54 100644 --- a/pppd/chap-new.h +++ b/pppd/chap-new.h @@ -28,6 +28,9 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef PPP_CHAP_NEW_H +#define PPP_CHAP_NEW_H + #include "pppdconf.h" /* @@ -133,3 +136,5 @@ extern void chap_auth_with_peer(int unit, char *our_name, int digest_code); /* Represents the CHAP protocol to the main pppd code */ extern struct protent chap_protent; + +#endif diff --git a/pppd/chap_ms.c b/pppd/chap_ms.c index c6e4b34..8e59280 100644 --- a/pppd/chap_ms.c +++ b/pppd/chap_ms.c @@ -80,8 +80,6 @@ #include "config.h" #endif -#ifdef CHAPMS - #include #include #include @@ -89,6 +87,11 @@ #include #include #include +#if defined(SOL2) +#include +#else +#include +#endif #include "pppd.h" #include "chap-new.h" @@ -100,7 +103,7 @@ #include "mppe.h" #ifdef UNIT_TEST -#undef MPPE +#undef PPP_WITH_MPPE #endif static void ascii2unicode (char[], int, u_char[]); @@ -112,16 +115,16 @@ static void ChapMS2_NT (u_char *, u_char[16], char *, char *, int, static void GenerateAuthenticatorResponsePlain (char*, int, u_char[24], u_char[16], u_char *, char *, u_char[41]); -#ifdef MSLANMAN +#ifdef PPP_WITH_MSLANMAN static void ChapMS_LANMan (u_char *, char *, int, u_char *); #endif -#ifdef MSLANMAN +#ifdef PPP_WITH_MSLANMAN bool ms_lanman = 0; /* Use LanMan password instead of NT */ /* Has meaning only with MS-CHAP challenges */ #endif -#ifdef MPPE +#ifdef PPP_WITH_MPPE #ifdef DEBUGMPPEKEY /* For MPPE debug */ /* Use "[]|}{?/><,`!2&&(" (sans quotes) for RFC 3079 MS-CHAPv2 test value */ @@ -132,14 +135,13 @@ static char *mschap2_peer_challenge = NULL; #include "fsm.h" /* Need to poke MPPE options */ #include "ccp.h" -#include #endif /* * Command-line options. */ static option_t chapms_option_list[] = { -#ifdef MSLANMAN +#ifdef PPP_WITH_MSLANMAN { "ms-lanman", o_bool, &ms_lanman, "Use LanMan passwd when using MS-CHAP", 1 }, #endif @@ -197,7 +199,7 @@ chapms_verify_response(int id, char *name, if (response_len != MS_CHAP_RESPONSE_LEN) goto bad; -#ifndef MSLANMAN +#ifndef PPP_WITH_MSLANMAN if (!response[MS_CHAP_USENT]) { /* Should really propagate this into the error packet. */ notice("Peer request for LANMAN auth not supported"); @@ -208,7 +210,7 @@ chapms_verify_response(int id, char *name, /* Generate the expected response. */ ChapMS(challenge, (char *)secret, secret_len, md); -#ifdef MSLANMAN +#ifdef PPP_WITH_MSLANMAN /* Determine which part of response to verify against */ if (!response[MS_CHAP_USENT]) diff = memcmp(&response[MS_CHAP_LANMANRESP], @@ -626,7 +628,7 @@ ChapMS2_NT(u_char *rchallenge, u_char PeerChallenge[16], char *username, ChallengeResponse(Challenge, PasswordHash, NTResponse); } -#ifdef MSLANMAN +#ifdef PPP_WITH_MSLANMAN static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ static void @@ -718,7 +720,7 @@ GenerateAuthenticatorResponsePlain } -#ifdef MPPE +#ifdef PPP_WITH_MPPE /* * Set mppe_xxxx_key from MS-CHAP credentials. (see RFC 3079) @@ -754,7 +756,7 @@ SetMasterKeys(char *secret, int secret_len, u_char NTResponse[24], int IsServer) mppe_set_chapv2(PasswordHashHash, NTResponse, IsServer); } -#endif /* MPPE */ +#endif /* PPP_WITH_MPPE */ void @@ -765,7 +767,7 @@ ChapMS(u_char *rchallenge, char *secret, int secret_len, ChapMS_NT(rchallenge, secret, secret_len, &response[MS_CHAP_NTRESP]); -#ifdef MSLANMAN +#ifdef PPP_WITH_MSLANMAN ChapMS_LANMan(rchallenge, secret, secret_len, &response[MS_CHAP_LANMANRESP]); @@ -775,7 +777,7 @@ ChapMS(u_char *rchallenge, char *secret, int secret_len, response[MS_CHAP_USENT] = 1; #endif -#ifdef MPPE +#ifdef PPP_WITH_MPPE Set_Start_Key(rchallenge, secret, secret_len); #endif } @@ -820,7 +822,7 @@ ChapMS2(u_char *rchallenge, u_char *PeerChallenge, &response[MS_CHAP2_PEER_CHALLENGE], rchallenge, user, authResponse); -#ifdef MPPE +#ifdef PPP_WITH_MPPE SetMasterKeys(secret, secret_len, &response[MS_CHAP2_NTRESP], authenticator); #endif @@ -944,5 +946,3 @@ int main(int argc, char *argv[]) { #endif /* UNIT_TEST */ - -#endif /* CHAPMS */ diff --git a/pppd/chap_ms.h b/pppd/chap_ms.h index c1c5ed8..7b08cff 100644 --- a/pppd/chap_ms.h +++ b/pppd/chap_ms.h @@ -30,9 +30,10 @@ * $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $ */ -#include "pppdconf.h" +#ifndef PPP_CHAPMS_H +#define PPP_CHAPMS_H -#ifndef __CHAPMS_INCLUDE__ +#include "pppdconf.h" #define MD4_SIGNATURE_SIZE 16 /* 16 bytes in a MD4 message digest */ #define MAX_NT_PASSWORD 256 /* Max (Unicode) chars in an NT pass */ @@ -87,5 +88,4 @@ void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE], void chapms_init(void); -#define __CHAPMS_INCLUDE__ -#endif /* __CHAPMS_INCLUDE__ */ +#endif /* PPP_CHAPMS_H */ diff --git a/pppd/demand.c b/pppd/demand.c index 0943e8a..d610d69 100644 --- a/pppd/demand.c +++ b/pppd/demand.c @@ -47,7 +47,7 @@ #include #include #include -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER #include #endif @@ -102,7 +102,7 @@ demand_conf(void) || ppp_recv_config(0, PPP_MRU, (u_int32_t) 0, 0, 0) < 0) fatal("Couldn't set up demand-dialled PPP interface: %m"); -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER set_filters(&pass_filter, &active_filter); #endif @@ -210,6 +210,7 @@ static u_short fcstab[256] = { 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 }; +#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) /* * loop_chars - process characters received from the loopback. @@ -336,7 +337,7 @@ active_packet(unsigned char *p, int len) if (len < PPP_HDRLEN) return 0; proto = PPP_PROTOCOL(p); -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER p[0] = 1; /* outbound packet indicator */ if ((pass_filter.bf_len != 0 && bpf_filter(pass_filter.bf_insns, p, len, len) == 0) diff --git a/pppd/eap-tls.c b/pppd/eap-tls.c index 40796d5..69e34a1 100644 --- a/pppd/eap-tls.c +++ b/pppd/eap-tls.c @@ -85,7 +85,7 @@ void ssl_msg_callback(int write_p, int version, int ct, const void *buf, size_t len, SSL * ssl, void *arg); int ssl_new_session_cb(SSL *s, SSL_SESSION *sess); -#ifdef MPPE +#ifdef PPP_WITH_MPPE #define EAPTLS_MPPE_KEY_LEN 32 /* @@ -137,7 +137,7 @@ void eaptls_gen_mppe_keys(struct eaptls_session *ets, int client) } } -#endif /* MPPE */ +#endif /* PPP_WITH_MPPE */ int password_callback (char *buf, int size, int rwflag, void *u) { diff --git a/pppd/eap-tls.h b/pppd/eap-tls.h index 9c56687..2777d81 100644 --- a/pppd/eap-tls.h +++ b/pppd/eap-tls.h @@ -30,11 +30,10 @@ * */ -#include "pppdconf.h" - -#ifndef __EAP_TLS_H__ -#define __EAP_TLS_H__ +#ifndef PPP_EAP_TLS_H +#define PPP_EAP_TLS_H +#include "pppdconf.h" #include "eap.h" #include @@ -88,7 +87,7 @@ int get_eaptls_secret(int unit, char *client, char *server, char *clicertfile, char *servcertfile, char *cacertfile, char *capath, char *pkfile, char *pkcs12, int am_server); -#ifdef MPPE +#ifdef PPP_WITH_MPPE void eaptls_gen_mppe_keys(struct eaptls_session *ets, int client); #endif diff --git a/pppd/eap.c b/pppd/eap.c index 6cb595f..4ad67a5 100644 --- a/pppd/eap.c +++ b/pppd/eap.c @@ -67,11 +67,11 @@ #include "pathnames.h" #include "md5.h" #include "eap.h" -#ifdef USE_PEAP +#ifdef PPP_WITH_PEAP #include "peap.h" -#endif /* USE_PEAP */ +#endif /* PPP_WITH_PEAP */ -#ifdef USE_SRP +#ifdef PPP_WITH_SRP #ifdef HAVE_TIME_H #include #endif @@ -79,25 +79,25 @@ #include #include #include "pppcrypt.h" -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ #ifndef SHA_DIGESTSIZE #define SHA_DIGESTSIZE 20 #endif -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS #include "eap-tls.h" -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS #include "chap_ms.h" #include "chap-new.h" extern int chapms_strip_domain; -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ eap_state eap_states[NUM_PPP]; /* EAP state; one for each unit */ -#ifdef USE_SRP +#ifdef PPP_WITH_SRP static char *pn_secret = NULL; /* Pseudonym generating secret */ #endif @@ -115,7 +115,7 @@ static option_t eap_option_list[] = { "Set max number of EAP Requests allows (client)" }, { "eap-interval", o_int, &eap_states[0].es_rechallenge, "Set interval for EAP rechallenge" }, -#ifdef USE_SRP +#ifdef PPP_WITH_SRP { "srp-interval", o_int, &eap_states[0].es_lwrechallenge, "Set interval for SRP lightweight rechallenge" }, { "srp-pn-secret", o_string, &pn_secret, @@ -157,7 +157,7 @@ struct protent eap_protent = { NULL /* say whether to bring up link for this pkt */ }; -#ifdef USE_SRP +#ifdef PPP_WITH_SRP /* * A well-known 2048 bit modulus. */ @@ -195,7 +195,7 @@ static const u_char wkmodulus[] = { 0x9B, 0x65, 0xE3, 0x72, 0xFC, 0xD6, 0x8E, 0xF2, 0x0F, 0xA7, 0x11, 0x1F, 0x9E, 0x4A, 0xFF, 0x73 }; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ /* Local forward declarations. */ static void eap_server_timeout (void *arg); @@ -227,10 +227,10 @@ eap_init(int unit) esp->es_server.ea_id = (u_char)(drand48() * 0x100); esp->es_client.ea_timeout = EAP_DEFREQTIME; esp->es_client.ea_maxrequests = EAP_DEFALLOWREQ; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS esp->es_client.ea_using_eaptls = 0; -#endif /* USE_EAPTLS */ -#ifdef CHAPMS +#endif /* PPP_WITH_EAPTLS */ +#ifdef PPP_WITH_CHAPMS esp->es_client.digest = chap_find_digest(CHAP_MICROSOFT_V2); esp->es_server.digest = chap_find_digest(CHAP_MICROSOFT_V2); #endif @@ -327,7 +327,7 @@ eap_send_success(eap_state *esp) esp->es_server.ea_peer, esp->es_server.ea_peerlen); } -#ifdef USE_SRP +#ifdef PPP_WITH_SRP /* * Set DES key according to pseudonym-generating secret and current * date. @@ -423,7 +423,7 @@ b64dec(struct b64state *bs, u_char *inp, int inlen, u_char *outp) } return (outlen); } -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ /* * Assume that current waiting server state is complete and figure @@ -434,7 +434,7 @@ b64dec(struct b64state *bs, u_char *inp, int inlen, u_char *outp) static void eap_figure_next_state(eap_state *esp, int status) { -#ifdef USE_SRP +#ifdef PPP_WITH_SRP unsigned char secbuf[MAXWORDLEN], clear[8], *sp, *dp; struct t_pw tpw; struct t_confent *tce, mytce; @@ -443,23 +443,23 @@ eap_figure_next_state(eap_state *esp, int status) int id, i, plen, toffs; u_char vals[2]; struct b64state bs; -#endif /* USE_SRP */ -#ifdef USE_EAPTLS +#endif /* PPP_WITH_SRP */ +#ifdef PPP_WITH_EAPTLS struct eaptls_session *ets; int secret_len; char secret[MAXWORDLEN]; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ esp->es_server.ea_timeout = esp->es_savedtime; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS esp->es_server.ea_prev_state = esp->es_server.ea_state; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ switch (esp->es_server.ea_state) { case eapBadAuth: return; case eapIdentify: -#ifdef USE_SRP +#ifdef PPP_WITH_SRP /* Discard any previous session. */ ts = (struct t_server *)esp->es_server.ea_session; if (ts != NULL) { @@ -467,12 +467,12 @@ eap_figure_next_state(eap_state *esp, int status) esp->es_server.ea_session = NULL; esp->es_server.ea_skey = NULL; } -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ if (status != 0) { esp->es_server.ea_state = eapBadAuth; break; } -#ifdef USE_SRP +#ifdef PPP_WITH_SRP /* If we've got a pseudonym, try to decode to real name. */ if (esp->es_server.ea_peerlen > SRP_PSEUDO_LEN && strncmp(esp->es_server.ea_peer, SRP_PSEUDO_ID, @@ -577,20 +577,20 @@ eap_figure_next_state(eap_state *esp, int status) t_servergenexp(ts); break; } -#endif /* USE_SRP */ -#ifdef USE_EAPTLS +#endif /* PPP_WITH_SRP */ +#ifdef PPP_WITH_EAPTLS if (!get_secret(esp->es_unit, esp->es_server.ea_peer, esp->es_server.ea_name, secret, &secret_len, 1)) { esp->es_server.ea_state = eapTlsStart; break; } -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ esp->es_server.ea_state = eapMD5Chall; break; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS case eapTlsStart: /* Initialize ssl session */ if(!eaptls_init_ssl_server(esp)) { @@ -651,17 +651,17 @@ eap_figure_next_state(eap_state *esp, int status) case eapTlsSendAlert: esp->es_server.ea_state = eapTlsRecvAlertAck; break; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ case eapSRP1: -#ifdef USE_SRP +#ifdef PPP_WITH_SRP ts = (struct t_server *)esp->es_server.ea_session; if (ts != NULL && status != 0) { t_serverclose(ts); esp->es_server.ea_session = NULL; esp->es_server.ea_skey = NULL; } -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ if (status == 1) { esp->es_server.ea_state = eapMD5Chall; } else if (status != 0 || esp->es_server.ea_session == NULL) { @@ -672,14 +672,14 @@ eap_figure_next_state(eap_state *esp, int status) break; case eapSRP2: -#ifdef USE_SRP +#ifdef PPP_WITH_SRP ts = (struct t_server *)esp->es_server.ea_session; if (ts != NULL && status != 0) { t_serverclose(ts); esp->es_server.ea_session = NULL; esp->es_server.ea_skey = NULL; } -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ if (status != 0 || esp->es_server.ea_session == NULL) { esp->es_server.ea_state = eapBadAuth; } else { @@ -689,14 +689,14 @@ eap_figure_next_state(eap_state *esp, int status) case eapSRP3: case eapSRP4: -#ifdef USE_SRP +#ifdef PPP_WITH_SRP ts = (struct t_server *)esp->es_server.ea_session; if (ts != NULL && status != 0) { t_serverclose(ts); esp->es_server.ea_session = NULL; esp->es_server.ea_skey = NULL; } -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ if (status != 0 || esp->es_server.ea_session == NULL) { esp->es_server.ea_state = eapBadAuth; } else { @@ -704,7 +704,7 @@ eap_figure_next_state(eap_state *esp, int status) } break; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case eapMSCHAPv2Chall: #endif case eapMD5Chall: @@ -722,12 +722,12 @@ eap_figure_next_state(eap_state *esp, int status) if (esp->es_server.ea_state == eapBadAuth) eap_send_failure(esp); -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS dbglog("EAP id=0x%2x '%s' -> '%s'", esp->es_server.ea_id, eap_state_name(esp->es_server.ea_prev_state), eap_state_name(esp->es_server.ea_state)); -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ } -#if CHAPMS +#if PPP_WITH_CHAPMS /* * eap_chap_verify_response - check whether the peer's response matches * what we think it should be. Returns 1 if it does (authentication @@ -795,7 +795,7 @@ eap_chapms2_send_request(eap_state *esp, u_char id, auth_peer_fail(esp->es_unit, PPP_EAP); } } -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ /* * Format an EAP Request message and send it to the peer. Message @@ -810,13 +810,13 @@ eap_send_request(eap_state *esp) int outlen; int challen; char *str; -#ifdef USE_SRP +#ifdef PPP_WITH_SRP struct t_server *ts; u_char clear[8], cipher[8], dig[SHA_DIGESTSIZE], *optr, *cp; int i, j; struct b64state b64; SHA1_CTX ctxt; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ /* Handle both initial auth and restart */ if (esp->es_server.ea_state < eapIdentify && @@ -882,7 +882,7 @@ eap_send_request(eap_state *esp) INCPTR(esp->es_server.ea_namelen, outp); break; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case eapMSCHAPv2Chall: esp->es_server.digest->generate_challenge(esp->es_challenge); challen = esp->es_challenge[0]; @@ -903,9 +903,9 @@ eap_send_request(eap_state *esp) esp->es_server.ea_namelen); INCPTR(esp->es_server.ea_namelen, outp); break; -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS case eapTlsStart: PUTCHAR(EAPT_TLS, outp); PUTCHAR(EAP_TLS_FLAGS_START, outp); @@ -927,9 +927,9 @@ eap_send_request(eap_state *esp) eaptls_send(esp->es_server.ea_session, &outp); eap_figure_next_state(esp, 0); break; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ -#ifdef USE_SRP +#ifdef PPP_WITH_SRP case eapSRP1: PUTCHAR(EAPT_SRP, outp); PUTCHAR(EAPSRP_CHALLENGE, outp); @@ -1058,7 +1058,7 @@ eap_send_request(eap_state *esp) BCOPY(esp->es_challenge, outp, esp->es_challen); INCPTR(esp->es_challen, outp); break; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ default: return; @@ -1112,18 +1112,18 @@ eap_authpeer(int unit, char *localname) static void eap_server_timeout(void *arg) { -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS u_char *outp; u_char *lenloc; int outlen; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ eap_state *esp = (eap_state *) arg; if (!eap_server_active(esp)) return; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS switch(esp->es_server.ea_prev_state) { /* @@ -1161,7 +1161,7 @@ eap_server_timeout(void *arg) default: break; } -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ /* EAP ID number must not change on timeout. */ eap_send_request(esp); @@ -1342,7 +1342,7 @@ eap_chap_response(eap_state *esp, u_char id, u_char *hash, output(esp->es_unit, outpacket_buf, PPP_HDRLEN + msglen); } -#ifdef USE_SRP +#ifdef PPP_WITH_SRP /* * Format and send a SRP EAP Response message. */ @@ -1397,9 +1397,9 @@ eap_srpval_response(eap_state *esp, u_char id, u_int32_t flags, u_char *str) output(esp->es_unit, outpacket_buf, PPP_HDRLEN + msglen); } -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS /* * Send an EAP-TLS response message with tls data */ @@ -1466,7 +1466,7 @@ eap_tls_sendack(eap_state *esp, u_char id) output(esp->es_unit, outpacket_buf, PPP_HDRLEN + outlen); } -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ static void eap_send_nak(eap_state *esp, u_char id, u_char type) @@ -1489,7 +1489,7 @@ eap_send_nak(eap_state *esp, u_char id, u_char type) output(esp->es_unit, outpacket_buf, PPP_HDRLEN + msglen); } -#ifdef USE_SRP +#ifdef PPP_WITH_SRP static char * name_of_pn_file(void) { @@ -1596,9 +1596,9 @@ write_pseudonym(eap_state *esp, u_char *inp, int len, int id) remove_pn_file(); } } -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ -#if CHAPMS +#if PPP_WITH_CHAPMS /* * Format and send an CHAPV2-Challenge EAP Response message. */ @@ -1644,19 +1644,19 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) char rhostname[256]; MD5_CTX mdContext; u_char hash[MD5_SIGNATURE_SIZE]; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS u_char flags; struct eaptls_session *ets = esp->es_client.ea_session; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ -#ifdef USE_SRP +#ifdef PPP_WITH_SRP struct t_client *tc; struct t_num sval, gval, Nval, *Ap, Bval; u_char vals[2]; SHA1_CTX ctxt; u_char dig[SHA_DIGESTSIZE]; int fd; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ /* * Ignore requests if we're not open @@ -1693,7 +1693,7 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) case EAPT_IDENTITY: if (len > 0) info("EAP: Identity prompt \"%.*q\"", len, inp); -#ifdef USE_SRP +#ifdef PPP_WITH_SRP if (esp->es_usepseudo && (esp->es_usedpseudo == 0 || (esp->es_usedpseudo == 1 && @@ -1719,7 +1719,7 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) remove_pn_file(); esp->es_usedpseudo = 2; } -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ eap_send_response(esp, id, typenum, (u_char *)esp->es_client.ea_name, esp->es_client.ea_namelen); break; @@ -1791,7 +1791,7 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) esp->es_client.ea_namelen); break; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS case EAPT_TLS: switch(esp->es_client.ea_state) { @@ -1859,7 +1859,7 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) /* Check if TLS handshake is finished */ if(eaptls_is_init_finished(ets)) { -#ifdef MPPE +#ifdef PPP_WITH_MPPE eaptls_gen_mppe_keys(ets, 1); #endif eaptls_free_session(ets); @@ -1879,9 +1879,9 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) } break; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ -#ifdef USE_SRP +#ifdef PPP_WITH_SRP case EAPT_SRP: if (len < 1) { error("EAP: received empty SRP Request"); @@ -2111,9 +2111,9 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) break; } break; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case EAPT_MSCHAPV2: if (len < 4) { error("EAP: received invalid MSCHAPv2 packet, too short"); @@ -2219,8 +2219,8 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) } break; -#endif /* CHAPMS */ -#ifdef USE_PEAP +#endif /* PPP_WITH_CHAPMS */ +#ifdef PPP_WITH_PEAP case EAPT_PEAP: /* Initialize the PEAP context (if not already initialized) */ @@ -2241,7 +2241,7 @@ eap_request(eap_state *esp, u_char *inp, int id, int len) } break; -#endif /* USE_PEAP */ +#endif // PPP_WITH_PEAP default: info("EAP: unknown authentication type %d; Naking", typenum); @@ -2262,10 +2262,10 @@ client_failure: UNTIMEOUT(eap_client_timeout, (void *)esp); } esp->es_client.ea_session = NULL; -#ifdef USE_SRP +#ifdef PPP_WITH_SRP t_clientclose(tc); auth_withpeer_fail(esp->es_unit, PPP_EAP); -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ } /* @@ -2281,23 +2281,23 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) char rhostname[256]; MD5_CTX mdContext; u_char hash[MD5_SIGNATURE_SIZE]; -#ifdef USE_SRP +#ifdef PPP_WITH_SRP struct t_server *ts; struct t_num A; SHA1_CTX ctxt; u_char dig[SHA_DIGESTSIZE]; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS struct eaptls_session *ets; u_char flags; -#endif /* USE_EAPTLS */ -#ifdef CHAPMS +#endif /* PPP_WITH_EAPTLS */ +#ifdef PPP_WITH_CHAPMS u_char opcode; int (*chap_verifier)(char *, char *, int, struct chap_digest_type *, unsigned char *, unsigned char *, char *, int); char response_message[256]; -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ /* * Ignore responses if we're not open @@ -2344,7 +2344,7 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) eap_figure_next_state(esp, 0); break; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS case EAPT_TLS: switch(esp->es_server.ea_state) { @@ -2374,7 +2374,7 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) GETCHAR(flags, inp); if(len == 1 && !flags) { /* Ack = ok */ -#ifdef MPPE +#ifdef PPP_WITH_MPPE eaptls_gen_mppe_keys( esp->es_server.ea_session, 0 ); #endif eap_send_success(esp); @@ -2400,7 +2400,7 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) break; } break; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ case EAPT_NOTIFICATION: dbglog("EAP unexpected Notification; response discarded"); @@ -2433,14 +2433,14 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) esp->es_server.ea_state = eapMD5Chall; break; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS /* Send EAP-TLS start packet */ case EAPT_TLS: esp->es_server.ea_state = eapTlsStart; break; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case EAPT_MSCHAPV2: info("EAP: peer proposes MSCHAPv2"); /* If MSCHAPv2 digest was not found, NAK the packet */ @@ -2451,7 +2451,7 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) } esp->es_server.ea_state = eapMSCHAPv2Chall; break; -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ default: dbglog("EAP: peer requesting unknown Type %d", vallen); @@ -2534,7 +2534,7 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) TIMEOUT(eap_rechallenge, esp, esp->es_rechallenge); break; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case EAPT_MSCHAPV2: if (len < 1) { error("EAP: received MSCHAPv2 with no data"); @@ -2637,9 +2637,9 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) } break; -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ -#ifdef USE_SRP +#ifdef PPP_WITH_SRP case EAPT_SRP: if (len < 1) { error("EAP: empty SRP Response"); @@ -2740,7 +2740,7 @@ eap_response(eap_state *esp, u_char *inp, int id, int len) break; } break; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ default: /* This can't happen. */ @@ -2766,9 +2766,9 @@ static void eap_success(eap_state *esp, u_char *inp, int id, int len) { if (esp->es_client.ea_state != eapOpen && !eap_client_active(esp) -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS && esp->es_client.ea_state != eapTlsRecvSuccess -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ ) { dbglog("EAP unexpected success message in state %s (%d)", eap_state_name(esp->es_client.ea_state), @@ -2776,7 +2776,7 @@ eap_success(eap_state *esp, u_char *inp, int id, int len) return; } -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS if(esp->es_client.ea_using_eaptls && esp->es_client.ea_state != eapTlsRecvSuccess) { dbglog("EAP-TLS unexpected success message in state %s (%d)", @@ -2784,7 +2784,7 @@ eap_success(eap_state *esp, u_char *inp, int id, int len) esp->es_client.ea_state); return; } -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ if (esp->es_client.ea_timeout > 0) { UNTIMEOUT(eap_client_timeout, (void *)esp); @@ -2795,7 +2795,7 @@ eap_success(eap_state *esp, u_char *inp, int id, int len) PRINTMSG(inp, len); } -#ifdef USE_PEAP +#ifdef PPP_WITH_PEAP peap_finish(&esp->ea_peap); #endif @@ -2834,7 +2834,7 @@ eap_failure(eap_state *esp, u_char *inp, int id, int len) error("EAP: peer reports authentication failure"); -#ifdef USE_PEAP +#ifdef PPP_WITH_PEAP peap_finish(&esp->ea_peap); #endif @@ -2918,12 +2918,12 @@ eap_printpkt(u_char *inp, int inlen, int code, id, len, rtype, vallen; u_char *pstart; u_int32_t uval; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS u_char flags; -#endif /* USE_EAPTLS */ -#ifdef CHAPMS +#endif /* PPP_WITH_EAPTLS */ +#ifdef PPP_WITH_CHAPMS u_char opcode; -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ if (inlen < EAP_HEADERLEN) return (0); @@ -2988,7 +2988,7 @@ eap_printpkt(u_char *inp, int inlen, } break; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case EAPT_MSCHAPV2: if (len <= 0) break; @@ -3041,9 +3041,9 @@ eap_printpkt(u_char *inp, int inlen, break; } break; -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS case EAPT_TLS: if (len < 1) break; @@ -3059,9 +3059,9 @@ eap_printpkt(u_char *inp, int inlen, printer(arg, flags & EAP_TLS_FLAGS_MF ? "M":"-"); printer(arg, flags & EAP_TLS_FLAGS_START ? "S":"- "); break; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ -#ifdef USE_SRP +#ifdef PPP_WITH_SRP case EAPT_SRP: if (len < 3) goto truncated; @@ -3149,7 +3149,7 @@ eap_printpkt(u_char *inp, int inlen, break; } break; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ } break; @@ -3174,7 +3174,7 @@ eap_printpkt(u_char *inp, int inlen, } break; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS case EAPT_TLS: if (len < 1) break; @@ -3191,7 +3191,7 @@ eap_printpkt(u_char *inp, int inlen, printer(arg, flags & EAP_TLS_FLAGS_START ? "S":"- "); break; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ case EAPT_NAK: if (len <= 0) { @@ -3230,7 +3230,7 @@ eap_printpkt(u_char *inp, int inlen, } break; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case EAPT_MSCHAPV2: if (len <= 0) break; @@ -3273,9 +3273,9 @@ eap_printpkt(u_char *inp, int inlen, break; } break; -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ -#ifdef USE_SRP +#ifdef PPP_WITH_SRP case EAPT_SRP: if (len < 1) goto truncated; @@ -3320,7 +3320,7 @@ eap_printpkt(u_char *inp, int inlen, break; } break; -#endif /* USE_SRP */ +#endif /* PPP_WITH_SRP */ } break; diff --git a/pppd/eap.h b/pppd/eap.h index 5d582bc..01697a8 100644 --- a/pppd/eap.h +++ b/pppd/eap.h @@ -20,15 +20,21 @@ * $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $ */ -#include "pppdconf.h" - #ifndef PPP_EAP_H #define PPP_EAP_H +#include "pppdconf.h" + #ifdef __cplusplus extern "C" { #endif + +#ifndef PPP_EAP +#define PPP_EAP 0xc227 +#endif + + /* * Packet header = Code, id, length. */ @@ -124,13 +130,13 @@ enum eap_state_code { "TlsSendAlert", "TlsRecvAlertAck" , "TlsRecvSuccess", "TlsRecvFailure", \ "SRP1", "SRP2", "SRP3", "MD5Chall", "MSCHAPv2Chall", "Open", "SRP4", "BadAuth" -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS #define eap_client_active(esp) ((esp)->es_client.ea_state != eapInitial &&\ (esp)->es_client.ea_state != eapPending &&\ (esp)->es_client.ea_state != eapClosed) #else #define eap_client_active(esp) ((esp)->es_client.ea_state == eapListen) -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ #define eap_server_active(esp) \ ((esp)->es_server.ea_state >= eapIdentify && \ @@ -146,10 +152,10 @@ struct eap_auth { u_short ea_namelen; /* Length of our name */ u_short ea_peerlen; /* Length of peer's name */ enum eap_state_code ea_state; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS enum eap_state_code ea_prev_state; #endif -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS struct chap_digest_type *digest; #endif u_char ea_id; /* Current id */ @@ -157,7 +163,7 @@ struct eap_auth { u_char ea_responses; /* Number of Responses */ u_char ea_type; /* One of EAPT_* */ u_int32_t ea_keyflags; /* SRP shared key usage flags */ -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS bool ea_using_eaptls; #endif }; @@ -169,7 +175,7 @@ typedef struct eap_state { int es_unit; /* Interface unit number */ struct eap_auth es_client; /* Client (authenticatee) data */ struct eap_auth es_server; /* Server (authenticator) data */ -#ifdef USE_PEAP +#ifdef PPP_WITH_PEAP struct peap_state *ea_peap; /* Client PEAP (authenticator) data */ #endif int es_savedtime; /* Saved timeout */ @@ -185,12 +191,12 @@ typedef struct eap_state { * Timeouts. */ #define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */ -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS #define EAP_DEFTRANSMITS 30 /* max # times to transmit */ /* certificates can be long ... */ #else #define EAP_DEFTRANSMITS 10 /* max # times to transmit */ -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ #define EAP_DEFREQTIME 20 /* Time to wait for peer request */ #define EAP_DEFALLOWREQ 20 /* max # times to accept requests */ diff --git a/pppd/ecp.h b/pppd/ecp.h index 162dace..5a0df4d 100644 --- a/pppd/ecp.h +++ b/pppd/ecp.h @@ -30,8 +30,16 @@ * * $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $ */ +#ifndef PPP_ECP_H +#define PPP_ECP_H + #include "pppdconf.h" +#ifndef PPP_ECP +#define PPP_ECP 0x8053 +#endif + + typedef struct ecp_options { bool required; /* Is ECP required? */ unsigned enctype; /* Encryption type */ @@ -44,3 +52,5 @@ extern ecp_options ecp_allowoptions[]; extern ecp_options ecp_hisoptions[]; extern struct protent ecp_protent; + +#endif diff --git a/pppd/eui64.h b/pppd/eui64.h index aa83e1a..f29200b 100644 --- a/pppd/eui64.h +++ b/pppd/eui64.h @@ -33,46 +33,14 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ +#ifndef PPP_EUI64_H +#define PPP_EUI64_H #include "pppdconf.h" -#ifndef __EUI64_H__ -#define __EUI64_H__ - -#if !defined(INET6) -#error "this file should only be included when INET6 is defined" -#endif /* not defined(INET6) */ - -#if defined(SOL2) -#include - -typedef union { - uint8_t e8[8]; /* lower 64-bit IPv6 address */ - uint32_t e32[2]; /* lower 64-bit IPv6 address */ -} eui64_t; - -/* - * Declare the two below, since in.h only defines them when _KERNEL - * is declared - which shouldn't be true when dealing with user-land programs - */ -#define s6_addr8 _S6_un._S6_u8 -#define s6_addr32 _S6_un._S6_u32 - -#else /* else if not defined(SOL2) */ - -/* - * TODO: - * - * Maybe this should be done by processing struct in6_addr directly... - */ -typedef union -{ - u_int8_t e8[8]; - u_int16_t e16[4]; - u_int32_t e32[2]; -} eui64_t; - -#endif /* defined(SOL2) */ +#if !defined(PPP_WITH_IPV6CP) +#error "this file should only be included when PPP_WITH_IPV6CP is defined" +#endif /* not defined(PPP_WITH_IPV6CP) */ #define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0) #define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \ @@ -111,5 +79,4 @@ typedef union char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ -#endif /* __EUI64_H__ */ - +#endif /* PPP_EUI64_H */ diff --git a/pppd/fsm.h b/pppd/fsm.h index d23725c..1cda6cf 100644 --- a/pppd/fsm.h +++ b/pppd/fsm.h @@ -41,6 +41,8 @@ * * $Id: fsm.h,v 1.10 2004/11/13 02:28:15 paulus Exp $ */ +#ifndef PPP_FSM_H +#define PPP_FSM_H #include "pppdconf.h" @@ -160,3 +162,5 @@ void fsm_sdata (fsm *, int, int, u_char *, int); * Variables */ extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */ + +#endif diff --git a/pppd/ipcp.h b/pppd/ipcp.h index 90336c4..0e44931 100644 --- a/pppd/ipcp.h +++ b/pppd/ipcp.h @@ -39,6 +39,9 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef PPP_IPCP_H +#define PPP_IPCP_H + #include "pppdconf.h" /* @@ -96,3 +99,5 @@ extern ipcp_options ipcp_hisoptions[]; char *ip_ntoa(u_int32_t); extern struct protent ipcp_protent; + +#endif /* PPP_IPCP_H */ diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c index 130819d..5a99841 100644 --- a/pppd/ipv6cp.c +++ b/pppd/ipv6cp.c @@ -164,6 +164,7 @@ #include "pppd.h" #include "fsm.h" +#include "eui64.h" #include "ipcp.h" #include "ipv6cp.h" #include "magic.h" diff --git a/pppd/ipv6cp.h b/pppd/ipv6cp.h index 3ce9df4..172b6eb 100644 --- a/pppd/ipv6cp.h +++ b/pppd/ipv6cp.h @@ -33,6 +33,10 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ + +#ifndef PPP_IPV6CP_H +#define PPP_IPV6CP_H + #include "pppdconf.h" /* Original version, based on RFC2023 : @@ -169,3 +173,5 @@ extern ipv6cp_options ipv6cp_allowoptions[]; extern ipv6cp_options ipv6cp_hisoptions[]; extern struct protent ipv6cp_protent; + +#endif diff --git a/pppd/lcp.c b/pppd/lcp.c index 8a18e95..9dc883e 100644 --- a/pppd/lcp.c +++ b/pppd/lcp.c @@ -51,6 +51,7 @@ #include "pppd.h" #include "fsm.h" #include "lcp.h" +#include "eap.h" #include "chap-new.h" #include "magic.h" @@ -76,10 +77,10 @@ bool noendpoint = 0; /* don't send/accept endpoint discriminator */ static int noopt(char **); -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK static int setendpoint(char **); static void printendpoint(option_t *, void (*)(void *, char *, ...), void *); -#endif /* HAVE_MULTILINK */ +#endif /* PPP_WITH_MULTILINK */ static option_t lcp_option_list[] = { /* LCP options */ @@ -162,7 +163,7 @@ static option_t lcp_option_list[] = { { "receive-all", o_bool, &lax_recv, "Accept all received control characters", 1 }, -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK { "mrru", o_int, &lcp_wantoptions[0].mrru, "Maximum received packet size for multilink bundle", OPT_PRIO, &lcp_wantoptions[0].neg_mrru }, @@ -177,7 +178,7 @@ static option_t lcp_option_list[] = { { "endpoint", o_special, (void *) setendpoint, "Endpoint discriminator for multilink", OPT_PRIO | OPT_A2PRINTER, (void *) printendpoint }, -#endif /* HAVE_MULTILINK */ +#endif /* PPP_WITH_MULTILINK */ { "noendpoint", o_bool, &noendpoint, "Don't send or accept multilink endpoint discriminator", 1 }, @@ -303,7 +304,7 @@ noopt(char **argv) return (1); } -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK static int setendpoint(char **argv) { @@ -320,7 +321,7 @@ printendpoint(option_t *opt, void (*printer)(void *, char *, ...), void *arg) { printer(arg, "%s", epdisc_to_str(&lcp_wantoptions[0].endpoint)); } -#endif /* HAVE_MULTILINK */ +#endif /* PPP_WITH_MULTILINK */ /* * lcp_init - Initialize LCP. @@ -1868,9 +1869,9 @@ lcp_up(fsm *f) */ mtu = ho->neg_mru? ho->mru: PPP_MRU; mru = go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU; -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK if (!(multilink && go->neg_mrru && ho->neg_mrru)) -#endif /* HAVE_MULTILINK */ +#endif /* PPP_WITH_MULTILINK */ netif_set_mtu(f->unit, MIN(MIN(mtu, mru), ao->mru)); ppp_send_config(f->unit, mtu, (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), @@ -2092,7 +2093,7 @@ lcp_printpkt(u_char *p, int plen, void (*printer)(void *, char *, ...), void *ar } break; case CI_EPDISC: -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK if (olen >= CILEN_CHAR) { struct epdisc epd; p += 2; diff --git a/pppd/lcp.h b/pppd/lcp.h index 768442d..c01313d 100644 --- a/pppd/lcp.h +++ b/pppd/lcp.h @@ -39,6 +39,9 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef PPP_LCP_H +#define PPP_LCP_H + #include "pppdconf.h" /* @@ -132,3 +135,5 @@ extern struct protent lcp_protent; /* Default number of times we receive our magic number from the peer before deciding the link is looped-back. */ #define DEFLOOPBACKFAIL 10 + +#endif diff --git a/pppd/magic.h b/pppd/magic.h index b864b7b..70e4ce5 100644 --- a/pppd/magic.h +++ b/pppd/magic.h @@ -39,6 +39,9 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef PPP_MAGIC_H +#define PPP_MAGIC_H + #include "pppdconf.h" void magic_init (void); /* Initialize the magic number generator */ @@ -46,3 +49,5 @@ u_int32_t magic (void); /* Returns the next magic number */ /* Fill buffer with random bytes */ void random_bytes (unsigned char *buf, int len); + +#endif diff --git a/pppd/main.c b/pppd/main.c index 2329437..49319e2 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -91,14 +91,16 @@ #include #include #include +#include #include +#include #include "pppd.h" #include "magic.h" #include "fsm.h" #include "lcp.h" #include "ipcp.h" -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP #include "ipv6cp.h" #endif #include "upap.h" @@ -108,11 +110,11 @@ #include "ecp.h" #include "pathnames.h" -#ifdef USE_TDB +#ifdef PPP_WITH_TDB #include "tdb.h" #endif -#ifdef CBCP_SUPPORT +#ifdef PPP_WITH_CBCP #include "cbcp.h" #endif @@ -151,7 +153,7 @@ int ppp_session_number; /* Session number, for channels with such a concept (eg PPPoE) */ int childwait_done; /* have timed out waiting for children */ -#ifdef USE_TDB +#ifdef PPP_WITH_TDB TDB_CONTEXT *pppdb; /* database for storing status etc. */ #endif @@ -245,7 +247,7 @@ static void forget_child(int pid, int status); static int reap_kids(void); static void childwait_end(void *); -#ifdef USE_TDB +#ifdef PPP_WITH_TDB static void update_db_entry(void); static void add_db_key(const char *); static void delete_db_key(const char *); @@ -267,11 +269,11 @@ struct protent *protocols[] = { &lcp_protent, &pap_protent, &chap_protent, -#ifdef CBCP_SUPPORT +#ifdef PPP_WITH_CBCP &cbcp_protent, #endif &ipcp_protent, -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP &ipv6cp_protent, #endif &ccp_protent, @@ -292,12 +294,12 @@ main(int argc, char *argv[]) struct protent *protp; char numbuf[16]; - strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup)); - strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown)); + strlcpy(path_ipup, _PATH_IPUP, MAXPATHLEN); + strlcpy(path_ipdown, _PATH_IPDOWN, MAXPATHLEN); -#ifdef INET6 - strlcpy(path_ipv6up, _PATH_IPV6UP, sizeof(path_ipv6up)); - strlcpy(path_ipv6down, _PATH_IPV6DOWN, sizeof(path_ipv6down)); +#ifdef PPP_WITH_IPV6CP + strlcpy(path_ipv6up, _PATH_IPV6UP, MAXPATHLEN); + strlcpy(path_ipv6down, _PATH_IPV6DOWN, MAXPATHLEN); #endif link_stats_valid = 0; new_phase(PHASE_INITIALIZE); @@ -383,7 +385,7 @@ main(int argc, char *argv[]) if (!sys_check_options()) exit(EXIT_OPTION_ERROR); auth_check_options(); -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK mp_check_options(); #endif for (i = 0; (protp = protocols[i]) != NULL; ++i) @@ -418,7 +420,7 @@ main(int argc, char *argv[]) */ sys_init(); -#ifdef USE_TDB +#ifdef PPP_WITH_TDB pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR|O_CREAT, 0644); if (pppdb != NULL) { slprintf(db_key, sizeof(db_key), "pppd%d", getpid()); @@ -1180,7 +1182,7 @@ cleanup(void) (*the_channel->cleanup)(); remove_pidfiles(); -#ifdef USE_TDB +#ifdef PPP_WITH_TDB if (pppdb != NULL) cleanup_db(); #endif @@ -1561,7 +1563,7 @@ safe_fork(int infd, int outfd, int errfd) /* Executing in the child */ sys_close(); -#ifdef USE_TDB +#ifdef PPP_WITH_TDB if (pppdb != NULL) tdb_close(pppdb); #endif @@ -2011,13 +2013,13 @@ script_setenv(char *var, char *value, int iskey) if (script_env != 0) { for (i = 0; (p = script_env[i]) != 0; ++i) { if (strncmp(p, var, varl) == 0 && p[varl] == '=') { -#ifdef USE_TDB +#ifdef PPP_WITH_TDB if (p[-1] && pppdb != NULL) delete_db_key(p); #endif free(p-1); script_env[i] = newstring; -#ifdef USE_TDB +#ifdef PPP_WITH_TDB if (pppdb != NULL) { if (iskey) add_db_key(newstring); @@ -2041,7 +2043,7 @@ script_setenv(char *var, char *value, int iskey) if (!add_script_env(i, newstring)) return; -#ifdef USE_TDB +#ifdef PPP_WITH_TDB if (pppdb != NULL) { if (iskey) add_db_key(newstring); @@ -2065,7 +2067,7 @@ script_unsetenv(char *var) return; for (i = 0; (p = script_env[i]) != 0; ++i) { if (strncmp(p, var, vl) == 0 && p[vl] == '=') { -#ifdef USE_TDB +#ifdef PPP_WITH_TDB if (p[-1] && pppdb != NULL) delete_db_key(p); #endif @@ -2073,7 +2075,7 @@ script_unsetenv(char *var) break; } } -#ifdef USE_TDB +#ifdef PPP_WITH_TDB if (pppdb != NULL) update_db_entry(); #endif @@ -2091,7 +2093,7 @@ script_unsetenv(char *var) */ void lock_db(void) { -#ifdef USE_TDB +#ifdef PPP_WITH_TDB TDB_DATA key; key.dptr = PPPD_LOCK_KEY; @@ -2105,7 +2107,7 @@ void lock_db(void) */ void unlock_db(void) { -#ifdef USE_TDB +#ifdef PPP_WITH_TDB TDB_DATA key; key.dptr = PPPD_LOCK_KEY; @@ -2114,7 +2116,7 @@ void unlock_db(void) #endif } -#ifdef USE_TDB +#ifdef PPP_WITH_TDB /* * update_db_entry - update our entry in the database. */ @@ -2195,4 +2197,4 @@ cleanup_db(void) if (p[-1]) delete_db_key(p); } -#endif /* USE_TDB */ +#endif /* PPP_WITH_TDB */ diff --git a/pppd/md4.h b/pppd/md4.h index d67daeb..546ea02 100644 --- a/pppd/md4.h +++ b/pppd/md4.h @@ -7,10 +7,11 @@ ** (C) 1990 RSA Data Security, Inc. ** ** ******************************************************************** */ +#ifndef PPP_MD4_H +#define PPP_MD4_H + #include "pppdconf.h" -#ifndef __MD4_INCLUDE__ -#define __MD4_INCLUDE__ #ifndef USE_MD4 #include #define MD4Init MD4_Init @@ -64,4 +65,4 @@ extern void MD4Final(unsigned char *, MD4_CTX *); ** End of md4.h ****************************(cut)***********************************/ #endif /* USE_MD4 */ -#endif /* __MD4_INCLUDE__ */ +#endif /* PPP_MD4_H */ diff --git a/pppd/md5.h b/pppd/md5.h index 662eb41..31f410d 100644 --- a/pppd/md5.h +++ b/pppd/md5.h @@ -36,10 +36,11 @@ ** documentation and/or software. ** *********************************************************************** */ +#ifndef PPP_MD5_H +#define PPP_MD5_H + #include "pppdconf.h" -#ifndef __MD5_INCLUDE__ -#define __MD5_INCLUDE__ #ifndef USE_MD5 #include #else @@ -67,4 +68,4 @@ void MD5_Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); void MD5_Final (unsigned char hash[], MD5_CTX *mdContext); #endif /* USE_MD5 */ -#endif /* __MD5_INCLUDE__ */ +#endif /* PPP_MD5_H */ diff --git a/pppd/mppe.h b/pppd/mppe.h index 2684a7f..ade208f 100644 --- a/pppd/mppe.h +++ b/pppd/mppe.h @@ -32,10 +32,10 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "pppdconf.h" +#ifndef PPP_MPPE_H +#define PPP_MPPE_H -#ifndef __MPPE_H__ -#define __MPPE_H__ +#include "pppdconf.h" #define MPPE_PAD 4 /* MPPE growth per frame */ #define MPPE_MAX_KEY_SIZE 32 /* Largest key length */ @@ -126,7 +126,7 @@ } while (/* CONSTCOND */ 0) -#if MPPE +#if PPP_WITH_MPPE /* * NOTE: @@ -187,5 +187,5 @@ void mppe_set_chapv1(u_char *rchallenge, u_char PasswordHashHash[MD4_SIGNATURE_S void mppe_set_chapv2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE], u_char NTResponse[MS_AUTH_NTRESP_LEN], int IsServer); -#endif // #ifdef MPPE -#endif // #ifdef __MPPE_H__ +#endif // #ifdef PPP_WITH_MPPE +#endif // #ifdef PPP_MPPE_H diff --git a/pppd/options.c b/pppd/options.c index d4906c9..1fbe46e 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -54,11 +54,13 @@ #include #include #include -#ifdef PLUGIN +#include +#include +#ifdef PPP_WITH_PLUGINS #include #endif -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER #include /* * There have been 3 or 4 different names for this in libpcap CVS, but @@ -73,7 +75,7 @@ #define DLT_PPP_PPPD DLT_PPP #endif #endif -#endif /* PPP_FILTER */ +#endif /* PPP_WITH_FILTER */ #include "pppd.h" #include "pathnames.h" @@ -131,22 +133,20 @@ int child_wait = 5; /* # seconds to wait for children at exit */ struct userenv *userenv_list; /* user environment variables */ int dfl_route_metric = -1; /* metric of the default route to set over the PPP link */ -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */ char path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */ #endif -#ifdef MAXOCTETS unsigned int maxoctets = 0; /* default - no limit */ int maxoctets_dir = 0; /* default - sum of traffic */ int maxoctets_timeout = 1; /* default 1 second */ -#endif extern option_t auth_options[]; extern struct stat devstat; -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER struct bpf_program pass_filter;/* Filter program for packets to pass */ struct bpf_program active_filter; /* Filter program for link-active pkts */ #endif @@ -173,18 +173,16 @@ static int showversion(char **); static int showhelp(char **); static void usage(void); static int setlogfile(char **); -#ifdef PLUGIN +#ifdef PPP_WITH_PLUGINS static int loadplugin(char **); #endif -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER static int setpassfilter(char **); static int setactivefilter(char **); #endif -#ifdef MAXOCTETS static int setmodir(char **); -#endif static int user_setenv(char **); static void user_setprint(option_t *, printer_func, void *); @@ -335,7 +333,7 @@ option_t general_options[] = { "Set pathname of ip-down script", OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN }, -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP { "ipv6-up-script", o_string, path_ipv6up, "Set pathname of ipv6-up script", OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN }, @@ -344,7 +342,7 @@ option_t general_options[] = { OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN }, #endif -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK { "multilink", o_bool, &multilink, "Enable multilink operation", OPT_PRIO | 1 }, { "mp", o_bool, &multilink, @@ -356,14 +354,14 @@ option_t general_options[] = { { "bundle", o_string, &bundle_name, "Bundle name for multilink", OPT_PRIO }, -#endif /* HAVE_MULTILINK */ +#endif /* PPP_WITH_MULTILINK */ -#ifdef PLUGIN +#ifdef PPP_WITH_PLUGINS { "plugin", o_special, (void *)loadplugin, "Load a plug-in module into pppd", OPT_PRIV | OPT_A2LIST }, #endif -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER { "pass-filter", o_special, setpassfilter, "set filter for packets to pass", OPT_PRIO }, @@ -371,7 +369,6 @@ option_t general_options[] = { "set filter for active pkts", OPT_PRIO }, #endif -#ifdef MAXOCTETS { "maxoctets", o_int, &maxoctets, "Set connection traffic limit", OPT_PRIO | OPT_LLIMIT | OPT_NOINCR | OPT_ZEROINF }, @@ -382,7 +379,6 @@ option_t general_options[] = { "Set direction for limit traffic (sum,in,out,max)" }, { "mo-timeout", o_int, &maxoctets_timeout, "Check for traffic limit every N seconds", OPT_PRIO | OPT_LLIMIT | 1 }, -#endif /* Dummy option, does nothing */ { "noipx", o_bool, &noipx_opt, NULL, OPT_NOPRINT | 1 }, @@ -1482,7 +1478,7 @@ callfile(char **argv) return ok; } -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER /* * setpassfilter - Set the pass filter for packets */ @@ -1572,7 +1568,6 @@ setlogfile(char **argv) return 1; } -#ifdef MAXOCTETS static int setmodir(char **argv) { @@ -1589,9 +1584,8 @@ setmodir(char **argv) } return 1; } -#endif -#ifdef PLUGIN +#ifdef PPP_WITH_PLUGINS static int loadplugin(char **argv) { @@ -1644,7 +1638,7 @@ loadplugin(char **argv) free(path); return 0; } -#endif /* PLUGIN */ +#endif /* PPP_WITH_PLUGINS */ /* * Set an environment variable specified by the user. diff --git a/pppd/patchlevel.h b/pppd/patchlevel.h deleted file mode 100644 index 1ecdb82..0000000 --- a/pppd/patchlevel.h +++ /dev/null @@ -1 +0,0 @@ -#define DATE "5 January 2021" diff --git a/pppd/pathnames.h b/pppd/pathnames.h index 915db67..57a130e 100644 --- a/pppd/pathnames.h +++ b/pppd/pathnames.h @@ -1,6 +1,9 @@ /* * define path names */ +#ifndef PPP_PATHNAMES_H +#define PPP_PATHNAMES_H + #include "pppdconf.h" #ifdef HAVE_PATHS_H @@ -39,11 +42,11 @@ #define _PATH_CHAPFILE _ROOT_PATH "/etc/ppp/chap-secrets" #define _PATH_SRPFILE _ROOT_PATH "/etc/ppp/srp-secrets" -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS #define _PATH_EAPTLSCLIFILE _ROOT_PATH "/etc/ppp/eaptls-client" #define _PATH_EAPTLSSERVFILE _ROOT_PATH "/etc/ppp/eaptls-server" #define _PATH_OPENSSLCONFFILE _ROOT_PATH "/etc/ppp/openssl.cnf" -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ #define _PATH_SYSOPTIONS _ROOT_PATH "/etc/ppp/options" #define _PATH_IPUP _ROOT_PATH "/etc/ppp/ip-up" @@ -59,7 +62,7 @@ #define _PATH_USEROPT ".ppprc" #define _PATH_PSEUDONYM ".ppp_pseudonym" -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP #define _PATH_IPV6UP _ROOT_PATH "/etc/ppp/ipv6-up" #define _PATH_IPV6DOWN _ROOT_PATH "/etc/ppp/ipv6-down" #endif @@ -70,3 +73,4 @@ #define _PATH_PPPDB _PPP_VARRUN "pppd2.tdb" #endif /* __STDC__ */ +#endif /* PPP_PATHNAMES_H */ diff --git a/pppd/peap.c b/pppd/peap.c index fb9af3e..d6e5fcf 100644 --- a/pppd/peap.c +++ b/pppd/peap.c @@ -56,7 +56,6 @@ #include #include #include -#include #include "pppd.h" #include "eap.h" @@ -85,7 +84,7 @@ struct peap_state { u_char tk[PEAP_TLV_TK_LEN]; u_char nonce[PEAP_TLV_NONCE_LEN]; struct tls_info *info; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS struct chap_digest_type *chap; #endif }; @@ -162,7 +161,7 @@ static void generate_cmk(u_char *ipmk, u_char *tempkey, u_char *nonce, u_char *t BCOPY(nonce, (data_tlv + PEAP_TLV_HEADERLEN), PEAP_TLV_NONCE_LEN); data_tlv[60] = EAPT_PEAP; -#ifdef MPPE +#ifdef PPP_WITH_MPPE mppe_get_send_key(isk, MPPE_MAX_KEY_LEN); mppe_get_recv_key(isk + MPPE_MAX_KEY_LEN, MPPE_MAX_KEY_LEN); #endif @@ -192,7 +191,7 @@ static void verify_compound_mac(struct peap_state *psm, u_char *in_buf) fatal("server's CMK does not match client's CMK, potential MiTM"); } -#ifdef MPPE +#ifdef PPP_WITH_MPPE #define PEAP_MPPE_KEY_LEN 32 static void generate_mppe_keys(u_char *ipmk, int client) @@ -310,7 +309,7 @@ void peap_do_inner_eap(u_char *in_buf, int in_len, eap_state *esp, int id, outp = outp + PEAP_TLV_RESULT_LEN; RAND_bytes(psm->nonce, PEAP_TLV_NONCE_LEN); generate_cmk(psm->ipmk, psm->tk, psm->nonce, outp, 1); -#ifdef MPPE +#ifdef PPP_WITH_MPPE /* set mppe keys */ generate_mppe_keys(psm->ipmk, 1); #endif @@ -337,7 +336,7 @@ void peap_do_inner_eap(u_char *in_buf, int in_len, eap_state *esp, int id, used += 2; break; -#if CHAPMS +#if PPP_WITH_CHAPMS case EAPT_MSCHAPV2: { // Must have at least 4 more bytes to process CHAP header diff --git a/pppd/peap.h b/pppd/peap.h index 49e28e8..f11312e 100644 --- a/pppd/peap.h +++ b/pppd/peap.h @@ -30,6 +30,8 @@ #ifndef PPP_PEAP_H #define PPP_PEAP_H +#include "pppdconf.h" + #define PEAP_PHASE_1 1 #define PEAP_PHASE_2 2 diff --git a/pppd/plugins/Makefile.am b/pppd/plugins/Makefile.am index cfc9164..2826148 100644 --- a/pppd/plugins/Makefile.am +++ b/pppd/plugins/Makefile.am @@ -1,7 +1,7 @@ pppd_plugin_LTLIBRARIES = minconn.la passprompt.la passwordfd.la winbind.la pppd_plugindir = $(PPPD_PLUGIN_DIR) -PLUGIN_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir}/pppd +PLUGIN_CPPFLAGS = -I${top_srcdir} PLUGIN_LDFLAGS = -module -avoid-version minconn_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) diff --git a/pppd/plugins/minconn.c b/pppd/plugins/minconn.c index 40855ee..82bef48 100644 --- a/pppd/plugins/minconn.c +++ b/pppd/plugins/minconn.c @@ -32,15 +32,12 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif #include #include -#include "pppd.h" +#include -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; static int minconnect = 0; diff --git a/pppd/plugins/passprompt.c b/pppd/plugins/passprompt.c index 743c087..14a199f 100644 --- a/pppd/plugins/passprompt.c +++ b/pppd/plugins/passprompt.c @@ -9,17 +9,15 @@ * 2 of the License, or (at your option) any later version. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include #include +#include +#include #include -#include "pppd.h" +#include -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; static char promptprog[PATH_MAX+1]; static int promptprog_refused = 0; @@ -124,7 +122,7 @@ void plugin_init(void) { add_options(options); pap_passwd_hook = promptpass; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS eaptls_passwd_hook = promptpass; #endif } diff --git a/pppd/plugins/passwordfd.c b/pppd/plugins/passwordfd.c index 84fd72e..6f8bc6f 100644 --- a/pppd/plugins/passwordfd.c +++ b/pppd/plugins/passwordfd.c @@ -7,18 +7,14 @@ * with pap- and chap-secrets files. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include #include #include -#include "pppd.h" +#include -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; static int passwdfd = -1; static char save_passwd[MAXSECRETLEN]; @@ -84,7 +80,7 @@ void plugin_init (void) chap_check_hook = pwfd_check; chap_passwd_hook = pwfd_passwd; -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS eaptls_passwd_hook = pwfd_passwd; #endif } diff --git a/pppd/plugins/pppoatm/Makefile.am b/pppd/plugins/pppoatm/Makefile.am index 66119c9..1bc77c1 100644 --- a/pppd/plugins/pppoatm/Makefile.am +++ b/pppd/plugins/pppoatm/Makefile.am @@ -6,7 +6,7 @@ noinst_HEADERS = \ atmres.h \ atmsap.h -pppoatm_la_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir}/pppd +pppoatm_la_CPPFLAGS = -I${top_srcdir} pppoatm_la_LDFLAGS = -module -avoid-version pppoatm_la_SOURCES = pppoatm.c diff --git a/pppd/plugins/pppoatm/pppoatm.c b/pppd/plugins/pppoatm/pppoatm.c index 09cd0b8..5ac03c8 100644 --- a/pppd/plugins/pppoatm/pppoatm.c +++ b/pppd/plugins/pppoatm/pppoatm.c @@ -13,25 +13,25 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ -#ifdef HAVE_CONFIG_H -#include -#endif #include #include #include -#include "pppd.h" -#include "pathnames.h" -#include "fsm.h" /* Needed for lcp.h to include cleanly */ -#include "lcp.h" #include #include #include #include #include #include +#include + +#include +#include +#include /* Needed for lcp.h to include cleanly */ +#include + -const char pppd_version[] = VERSION; +const char pppd_version[] = PPPD_VERSION; static struct sockaddr_atmpvc pvcaddr; static char *qosstr = NULL; @@ -89,7 +89,7 @@ static int setdevname_pppoatm(const char *cp, const char **argv, int doit) return 1; memcpy(&pvcaddr, &addr, sizeof pvcaddr); - strlcpy(devnam, cp, sizeof devnam); + strlcpy(devnam, cp, MAXPATHLEN); devstat.st_mode = S_IFSOCK; if (the_channel != &pppoa_channel) { the_channel = &pppoa_channel; @@ -163,7 +163,7 @@ static int connect_pppoatm(void) pppoatm_max_mtu = lcp_allowoptions[0].mru; pppoatm_max_mru = lcp_wantoptions[0].mru; set_line_discipline_pppoatm(fd); - strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); + strlcpy(ppp_devnam, devnam, MAXPATHLEN); pppoa_fd = fd; return fd; } diff --git a/pppd/plugins/pppoe/Makefile.am b/pppd/plugins/pppoe/Makefile.am index 0d70380..6cea70a 100644 --- a/pppd/plugins/pppoe/Makefile.am +++ b/pppd/plugins/pppoe/Makefile.am @@ -6,9 +6,9 @@ dist_man8_MANS = pppoe-discovery.8 noinst_HEADERS = \ pppoe.h -pppoe_la_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/include +pppoe_la_CPPFLAGS = -I${top_srcdir} pppoe_la_LDFLAGS = -module -avoid-version pppoe_la_SOURCES = plugin.c discovery.c if.c common.c -pppoe_discovery_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/include +pppoe_discovery_CPPFLAGS = -I${top_srcdir} pppoe_discovery_SOURCES = pppoe-discovery.c discovery.c if.c common.c diff --git a/pppd/plugins/pppoe/common.c b/pppd/plugins/pppoe/common.c index 9ddbcbd..31811f5 100644 --- a/pppd/plugins/pppoe/common.c +++ b/pppd/plugins/pppoe/common.c @@ -17,12 +17,12 @@ static char const RCSID[] = "$Id: common.c,v 1.3 2008/06/09 08:34:23 paulus Exp $"; #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #define _GNU_SOURCE 1 #include "pppoe.h" -#include "pppd/pppd.h" +#include #include #include diff --git a/pppd/plugins/pppoe/config.h.in b/pppd/plugins/pppoe/config.h.in new file mode 100644 index 0000000..0c4d9da --- /dev/null +++ b/pppd/plugins/pppoe/config.h.in @@ -0,0 +1,56 @@ +/* pppd/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_ASM_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_IF_ETHER_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_IF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_IF_PACKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_IF_ARP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_IF_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IF_ETHER_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETPACKET_PACKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_BPF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_IF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_DLPI_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* The size of `unsigned int', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_INT + +/* The size of `unsigned long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG + +/* The size of `unsigned short', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_SHORT + diff --git a/pppd/plugins/pppoe/discovery.c b/pppd/plugins/pppoe/discovery.c index b32b0c8..a5c2c62 100644 --- a/pppd/plugins/pppoe/discovery.c +++ b/pppd/plugins/pppoe/discovery.c @@ -12,14 +12,14 @@ static char const RCSID[] = "$Id: discovery.c,v 1.6 2008/06/15 04:35:50 paulus Exp $"; #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #define _GNU_SOURCE 1 #include "pppoe.h" -#include "pppd/pppd.h" -#include "pppd/fsm.h" -#include "pppd/lcp.h" +#include +#include +#include #include #include diff --git a/pppd/plugins/pppoe/if.c b/pppd/plugins/pppoe/if.c index 3dfea8c..a3c3848 100644 --- a/pppd/plugins/pppoe/if.c +++ b/pppd/plugins/pppoe/if.c @@ -17,12 +17,12 @@ static char const RCSID[] = "$Id: if.c,v 1.2 2008/06/09 08:34:23 paulus Exp $"; #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #define _GNU_SOURCE 1 #include "pppoe.h" -#include "pppd/pppd.h" +#include #ifdef HAVE_UNISTD_H #include diff --git a/pppd/plugins/pppoe/plugin.c b/pppd/plugins/pppoe/plugin.c index c534507..92d0493 100644 --- a/pppd/plugins/pppoe/plugin.c +++ b/pppd/plugins/pppoe/plugin.c @@ -26,24 +26,18 @@ static char const RCSID[] = "$Id: plugin.c,v 1.17 2008/06/15 04:35:50 paulus Exp $"; #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #define _GNU_SOURCE 1 #include "pppoe.h" -#include "pppd/pppd.h" -#include "pppd/fsm.h" -#include "pppd/lcp.h" -#include "pppd/ipcp.h" -#include "pppd/ccp.h" -/* #include "pppd/pathnames.h" */ - #include #include #include #include #include +#include #include #include #include @@ -54,13 +48,20 @@ static char const RCSID[] = #include #include +#include +#include +#include +#include +#include +/* #include ?, see below ... */ + #ifndef _ROOT_PATH #define _ROOT_PATH "" #endif #define _PATH_ETHOPT _ROOT_PATH "/etc/ppp/options." -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; /* From sys-linux.c in pppd -- MUST FIX THIS! */ extern int new_style_driver; @@ -200,7 +201,7 @@ PPPOEConnectDevice(void) conn->acName = acName; conn->serviceName = pppd_pppoe_service; - strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); + strlcpy(ppp_devnam, devnam, MAXPATHLEN); if (existingSession) { unsigned int mac[ETH_ALEN]; int i, ses; @@ -395,7 +396,7 @@ PPPoEDevnameHook(char *cmd, char **argv, int doit) /* Close socket */ close(fd); if (r && doit) { - strlcpy(devnam, cmd, sizeof(devnam)); + strlcpy(devnam, cmd, MAXPATHLEN); if (the_channel != &pppoe_channel) { the_channel = &pppoe_channel; @@ -427,7 +428,7 @@ plugin_init(void) add_options(Options); - info("PPPoE plugin from pppd %s", VERSION); + info("PPPoE plugin from pppd %s", PPPD_VERSION); } void pppoe_check_options(void) diff --git a/pppd/plugins/pppoe/pppoe-discovery.c b/pppd/plugins/pppoe/pppoe-discovery.c index 10f51dc..b698bca 100644 --- a/pppd/plugins/pppoe/pppoe-discovery.c +++ b/pppd/plugins/pppoe/pppoe-discovery.c @@ -10,7 +10,7 @@ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #include @@ -21,6 +21,7 @@ #include #include #include +#include #include "pppoe.h" @@ -207,7 +208,7 @@ int main(int argc, char *argv[]) optarg, strerror(errno)); exit(1); } - fprintf(debugFile, "pppoe-discovery from pppd %s\n", VERSION); + fprintf(debugFile, "pppoe-discovery from pppd %s\n", PPPD_VERSION); break; case 'I': conn->ifName = xstrdup(optarg); @@ -269,5 +270,5 @@ usage(void) " -U -- Use Host-Unique to allow multiple PPPoE sessions.\n" " -W hexvalue -- Set the Host-Unique to the supplied hex string.\n" " -h -- Print usage information.\n"); - fprintf(stderr, "\npppoe-discovery from pppd " VERSION "\n"); + fprintf(stderr, "\npppoe-discovery from pppd " PPPD_VERSION "\n"); } diff --git a/pppd/plugins/pppoe/pppoe.h b/pppd/plugins/pppoe/pppoe.h index 26e14f5..1517e34 100644 --- a/pppd/plugins/pppoe/pppoe.h +++ b/pppd/plugins/pppoe/pppoe.h @@ -18,7 +18,7 @@ #include #include -#include "pppd/pppd.h" /* For error */ +#include /* For error */ /* How do we access raw Ethernet devices? */ #undef USE_LINUX_PACKET diff --git a/pppd/plugins/pppol2tp/Makefile.am b/pppd/plugins/pppol2tp/Makefile.am index 999f35b..1018981 100644 --- a/pppd/plugins/pppol2tp/Makefile.am +++ b/pppd/plugins/pppol2tp/Makefile.am @@ -4,10 +4,10 @@ pppd_plugindir = $(PPPD_PLUGIN_DIR) noinst_HEADERS = \ l2tp_event.h -pppol2tp_la_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir}/pppd +pppol2tp_la_CPPFLAGS = -I${top_srcdir} pppol2tp_la_LDFLAGS = -module -avoid-version pppol2tp_la_SOURCES = pppol2tp.c -openl2tp_la_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir}/pppd +openl2tp_la_CPPFLAGS = -I${top_srcdir} openl2tp_la_LDFLAGS = -module -avoid-version openl2tp_la_SOURCES = openl2tp.c diff --git a/pppd/plugins/pppol2tp/openl2tp.c b/pppd/plugins/pppol2tp/openl2tp.c index 0f9db6d..2ba8707 100644 --- a/pppd/plugins/pppol2tp/openl2tp.c +++ b/pppd/plugins/pppol2tp/openl2tp.c @@ -19,20 +19,11 @@ /* pppd plugin for interfacing to openl2tpd */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include #include -#include "pppd.h" -#include "pathnames.h" -#include "fsm.h" -#include "lcp.h" -#include "ccp.h" -#include "ipcp.h" + #include #include #include @@ -43,6 +34,14 @@ #include #include +#include +#include +#include +#include +#include +#include + + #ifndef aligned_u64 /* should be defined in sys/types.h */ #define aligned_u64 unsigned long long __attribute__((aligned(8))) @@ -63,7 +62,7 @@ extern void (*pppol2tp_send_accm_hook)(int tunnel_id, int session_id, uint32_t send_accm, uint32_t recv_accm); extern void (*pppol2tp_ip_updown_hook)(int tunnel_id, int session_id, int up); -const char pppd_version[] = VERSION; +const char pppd_version[] = PPPD_VERSION; static int openl2tp_fd = -1; diff --git a/pppd/plugins/pppol2tp/pppol2tp.c b/pppd/plugins/pppol2tp/pppol2tp.c index c9902af..c1eaa9a 100644 --- a/pppd/plugins/pppol2tp/pppol2tp.c +++ b/pppd/plugins/pppol2tp/pppol2tp.c @@ -20,20 +20,10 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include #include -#include "pppd.h" -#include "pathnames.h" -#include "fsm.h" -#include "lcp.h" -#include "ccp.h" -#include "ipcp.h" #include #include #include @@ -42,10 +32,12 @@ #include #include #include + #ifndef aligned_u64 /* should be defined in sys/types.h */ #define aligned_u64 unsigned long long __attribute__((aligned(8))) #endif + #include #include #include @@ -53,12 +45,20 @@ #include #include +#include +#include +#include +#include +#include +#include + + /* should be added to system's socket.h... */ #ifndef SOL_PPPOL2TP #define SOL_PPPOL2TP 273 #endif -const char pppd_version[] = VERSION; +const char pppd_version[] = PPPD_VERSION; static int setdevname_pppol2tp(char **argv); diff --git a/pppd/plugins/radius/Makefile.am b/pppd/plugins/radius/Makefile.am index c3cff23..ec637ae 100644 --- a/pppd/plugins/radius/Makefile.am +++ b/pppd/plugins/radius/Makefile.am @@ -25,7 +25,7 @@ EXTRA_ETC = \ etc/realms \ etc/servers -RADIUS_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir}/pppd -DRC_LOG_FACILITY=LOG_DAEMON +RADIUS_CPPFLAGS = -I${top_srcdir} -DRC_LOG_FACILITY=LOG_DAEMON RADIUS_LDFLAGS = -module -avoid-version $(LDFLAGS) radius_la_CPPFLAGS = $(RADIUS_CPPFLAGS) diff --git a/pppd/plugins/radius/includes.h b/pppd/plugins/radius/includes.h index f48d9b7..1e6d87a 100644 --- a/pppd/plugins/radius/includes.h +++ b/pppd/plugins/radius/includes.h @@ -47,7 +47,7 @@ #include -#include "magic.h" +#include /* rlib/lock.c */ int do_lock_exclusive(int); diff --git a/pppd/plugins/radius/md5.c b/pppd/plugins/radius/md5.c index 8af03aa..8acfb38 100644 --- a/pppd/plugins/radius/md5.c +++ b/pppd/plugins/radius/md5.c @@ -1,7 +1,7 @@ /* * $Id: md5.c,v 1.1 2004/11/14 07:26:26 paulus Exp $ */ -#include "md5.h" +#include void rc_md5_calc (unsigned char *output, unsigned char *input, unsigned int inlen) { diff --git a/pppd/plugins/radius/radattr.c b/pppd/plugins/radius/radattr.c index f6a7874..16f7fba 100644 --- a/pppd/plugins/radius/radattr.c +++ b/pppd/plugins/radius/radattr.c @@ -17,21 +17,17 @@ static char const RCSID[] = "$Id: radattr.c,v 1.2 2004/10/28 00:24:40 paulus Exp $"; -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "pppd.h" -#include "radiusclient.h" #include -#include #include +#include + +#include "radiusclient.h" extern void (*radius_attributes_hook)(VALUE_PAIR *); static void print_attributes(VALUE_PAIR *); static void cleanup(void *opaque, int arg); -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; /********************************************************************** * %FUNCTION: plugin_init diff --git a/pppd/plugins/radius/radius.c b/pppd/plugins/radius/radius.c index 6a5b1b8..02875b4 100644 --- a/pppd/plugins/radius/radius.c +++ b/pppd/plugins/radius/radius.c @@ -26,29 +26,28 @@ static char const RCSID[] = "$Id: radius.c,v 1.32 2008/05/26 09:18:08 paulus Exp $"; -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "pppd.h" -#include "chap-new.h" -#ifdef CHAPMS -#include "chap_ms.h" -#ifdef MPPE -#include "mppe.h" -#include "md5.h" -#endif -#endif -#include "radiusclient.h" -#include "fsm.h" -#include "ipcp.h" #include #include #include +#include #include #include #include +#include +#include +#ifdef PPP_WITH_CHAPMS +#include +#ifdef PPP_WITH_MPPE +#include +#include +#endif +#endif +#include +#include + +#include "radiusclient.h" + #define BUF_LEN 1024 #define MD5_HASH_SIZE 16 @@ -97,7 +96,7 @@ static int radius_init(char *msg); static int get_client_port(char *ifname); static int radius_allowed_address(u_int32_t addr); static void radius_acct_interim(void *); -#ifdef MPPE +#ifdef PPP_WITH_MPPE static int radius_setmppekeys(VALUE_PAIR *vp, REQUEST_INFO *req_info, unsigned char *); static int radius_setmppekeys2(VALUE_PAIR *vp, REQUEST_INFO *req_info); @@ -140,7 +139,7 @@ void (*radius_pre_auth_hook)(char const *user, static struct radius_state rstate; -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; /********************************************************************** * %FUNCTION: plugin_init @@ -346,7 +345,7 @@ radius_chap_verify(char *user, char *ourname, int id, int result; int challenge_len, response_len; u_char cpassword[MAX_RESPONSE_LEN + 1]; -#ifdef MPPE +#ifdef PPP_WITH_MPPE /* Need the RADIUS secret and Request Authenticator to decode MPPE */ REQUEST_INFO request_info, *req_info = &request_info; #else @@ -365,7 +364,7 @@ radius_chap_verify(char *user, char *ourname, int id, /* return error for types we can't handle */ if ((digest->code != CHAP_MD5) -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS && (digest->code != CHAP_MICROSOFT) && (digest->code != CHAP_MICROSOFT_V2) #endif @@ -412,7 +411,7 @@ radius_chap_verify(char *user, char *ourname, int id, cpassword, MD5_HASH_SIZE + 1, VENDOR_NONE); break; -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS case CHAP_MICROSOFT: { /* MS-CHAP-Challenge and MS-CHAP-Response */ @@ -544,7 +543,7 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, { u_int32_t remote; int ms_chap2_success = 0; -#ifdef MPPE +#ifdef PPP_WITH_MPPE int mppe_enc_keys = 0; /* whether or not these were received */ int mppe_enc_policy = 0; int mppe_enc_types = 0; @@ -607,7 +606,6 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, /* idle parameter */ idle_time_limit = vp->lvalue; break; -#ifdef MAXOCTETS case PW_SESSION_OCTETS_LIMIT: /* Session traffic limit */ maxoctets = vp->lvalue; @@ -616,7 +614,6 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, /* Session traffic limit direction check */ maxoctets_dir = ( vp->lvalue > 4 ) ? 0 : vp->lvalue ; break; -#endif case PW_ACCT_INTERIM_INTERVAL: /* Send accounting updates every few seconds */ rstate.acct_interim_interval = vp->lvalue; @@ -662,7 +659,7 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, } else if (vp->vendorcode == VENDOR_MICROSOFT) { -#ifdef CHAPMS +#ifdef PPP_WITH_CHAPMS switch (vp->attribute) { case PW_MS_CHAP2_SUCCESS: if ((vp->lvalue != 43) || strncmp((char*) vp->strvalue + 1, "S=", 2)) { @@ -674,7 +671,7 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, ms_chap2_success = 1; break; -#ifdef MPPE +#ifdef PPP_WITH_MPPE case PW_MS_CHAP_MPPE_KEYS: if (radius_setmppekeys(vp, req_info, challenge) < 0) { slprintf(msg, BUF_LEN, @@ -704,7 +701,7 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, mppe_enc_types = vp->lvalue; /* save for later */ break; -#endif /* MPPE */ +#endif /* PPP_WITH_MPPE */ #ifdef MSDNS case PW_MS_PRIMARY_DNS_SERVER: ao->dnsaddr[0] = htonl(vp->lvalue); @@ -732,7 +729,7 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, break; #endif /* MSDNS */ } -#endif /* CHAPMS */ +#endif /* PPP_WITH_CHAPMS */ } vp = vp->next; } @@ -741,7 +738,7 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, if (digest && (digest->code == CHAP_MICROSOFT_V2) && !ms_chap2_success) return -1; -#ifdef MPPE +#ifdef PPP_WITH_MPPE /* * Require both policy and key attributes to indicate a valid key. * Note that if the policy value was '0' we don't set the key! @@ -758,7 +755,7 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info, return 0; } -#ifdef MPPE +#ifdef PPP_WITH_MPPE /********************************************************************** * %FUNCTION: radius_setmppekeys * %ARGUMENTS: @@ -880,7 +877,7 @@ radius_setmppekeys2(VALUE_PAIR *vp, REQUEST_INFO *req_info) return 0; } -#endif /* MPPE */ +#endif /* PPP_WITH_MPPE */ /********************************************************************** * %FUNCTION: radius_acct_start @@ -1090,11 +1087,9 @@ radius_acct_stop(void) av_type = PW_ACCT_SESSION_TIMEOUT; break; -#ifdef MAXOCTETS case EXIT_TRAFFIC_LIMIT: av_type = PW_NAS_REQUEST; break; -#endif default: av_type = PW_NAS_ERROR; diff --git a/pppd/plugins/radius/radiusclient.h b/pppd/plugins/radius/radiusclient.h index 87e6e0a..96449be 100644 --- a/pppd/plugins/radius/radiusclient.h +++ b/pppd/plugins/radius/radiusclient.h @@ -17,10 +17,10 @@ #ifndef RADIUSCLIENT_H #define RADIUSCLIENT_H -#include -#include -#include -#include "pppd.h" +#include +#include +#include +#include #ifndef _UINT4_T /* This works for all machines that Linux runs on... */ diff --git a/pppd/plugins/radius/radrealms.c b/pppd/plugins/radius/radrealms.c index a3b9a51..27955e0 100644 --- a/pppd/plugins/radius/radrealms.c +++ b/pppd/plugins/radius/radrealms.c @@ -17,17 +17,15 @@ static char const RCSID[] = "$Id: radrealms.c,v 1.2 2004/11/14 07:26:26 paulus Exp $"; -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "pppd.h" -#include "radiusclient.h" #include #include #include +#include +#include + +#include "radiusclient.h" -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; char radrealms_config[MAXPATHLEN] = "/etc/radiusclient/realms"; diff --git a/pppd/plugins/winbind.c b/pppd/plugins/winbind.c index 76db234..71c0d03 100644 --- a/pppd/plugins/winbind.c +++ b/pppd/plugins/winbind.c @@ -34,16 +34,6 @@ * ***********************************************************************/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "pppd.h" -#include "chap-new.h" -#include "chap_ms.h" -#include "fsm.h" -#include "ipcp.h" -#include "mppe.h" #include #include #include @@ -56,6 +46,13 @@ #include #include +#include +#include +#include +#include +#include +#include + #define BUF_LEN 1024 #define NOT_AUTHENTICATED 0 @@ -104,7 +101,7 @@ static int winbind_chap_verify(char *user, char *ourname, int id, char *message, int message_space); static int winbind_allowed_address(u_int32_t addr); -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; /********************************************************************** * %FUNCTION: plugin_init @@ -569,14 +566,14 @@ winbind_chap_verify(char *user, char *ourname, int id, nt_response = &response[MS_CHAP_NTRESP]; nt_response_size = MS_CHAP_NTRESP_LEN; } else { -#ifdef MSLANMAN +#ifdef PPP_WITH_MSLANMAN lm_response = &response[MS_CHAP_LANMANRESP]; lm_response_size = MS_CHAP_LANMANRESP_LEN; #else /* Should really propagate this into the error packet. */ notice("Peer request for LANMAN auth not supported"); return NOT_AUTHENTICATED; -#endif /* MSLANMAN */ +#endif /* PPP_WITH_MSLANMAN */ } /* ship off to winbind, and check */ @@ -590,7 +587,7 @@ winbind_chap_verify(char *user, char *ourname, int id, nt_response, nt_response_size, session_key, &error_string) == AUTHENTICATED) { -#ifdef MPPE +#ifdef PPP_WITH_MPPE mppe_set_chapv1(challenge, session_key); #endif slprintf(message, message_space, "Access granted"); @@ -637,7 +634,7 @@ winbind_chap_verify(char *user, char *ourname, int id, &response[MS_CHAP2_NTRESP], &response[MS_CHAP2_PEER_CHALLENGE], challenge, user, saresponse); -#ifdef MPPE +#ifdef PPP_WITH_MPPE mppe_set_chapv2(session_key, &response[MS_CHAP2_NTRESP], MS_CHAP2_AUTHENTICATOR); #endif diff --git a/pppd/pppcrypt.h b/pppd/pppcrypt.h index 79676ca..fff396c 100644 --- a/pppd/pppcrypt.h +++ b/pppd/pppcrypt.h @@ -29,10 +29,10 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "pppdconf.h" +#ifndef PPP_PPPCRYPT_H +#define PPP_PPPCRYPT_H -#ifndef PPPCRYPT_H -#define PPPCRYPT_H +#include "pppdconf.h" #ifdef HAVE_CRYPT_H #include @@ -46,4 +46,4 @@ extern bool DesSetkey(u_char *); extern bool DesEncrypt(u_char *, u_char *); extern bool DesDecrypt(u_char *, u_char *); -#endif /* PPPCRYPT_H */ +#endif /* PPP_PPPCRYPT_H */ diff --git a/pppd/pppd.h b/pppd/pppd.h index e54a526..bd9faf0 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -42,30 +42,54 @@ * $Id: pppd.h,v 1.96 2008/06/23 11:47:18 paulus Exp $ */ -#include "pppdconf.h" - -/* - * TODO: - */ +#ifndef PPP_PPPD_H +#define PPP_PPPD_H -#ifndef __PPPD_H__ -#define __PPPD_H__ +#include "pppdconf.h" #include /* for FILE */ #include /* for encrypt */ #include /* for setkey */ #include #include -#include /* for NGROUPS_MAX */ -#include /* for MAXPATHLEN and BSD4_4, if defined */ #include /* for u_int32_t, if defined */ -#include /* for struct timeval */ +#if defined(SOL2) #include -#include -#include "patchlevel.h" +#else +#include +#endif + +#ifdef PPP_WITH_IPV6CP +#if defined(SOL2) +#include -#ifdef INET6 -#include "eui64.h" +typedef union { + uint8_t e8[8]; /* lower 64-bit IPv6 address */ + uint32_t e32[2]; /* lower 64-bit IPv6 address */ +} eui64_t; + +/* + * Declare the two below, since in.h only defines them when _KERNEL + * is declared - which shouldn't be true when dealing with user-land programs + */ +#define s6_addr8 _S6_un._S6_u8 +#define s6_addr32 _S6_un._S6_u32 + +#else /* else if not defined(SOL2) */ + +/* + * TODO: + * + * Maybe this should be done by processing struct in6_addr directly... + */ +typedef union +{ + u_int8_t e8[8]; + u_int16_t e16[4]; + u_int32_t e32[2]; +} eui64_t; + +#endif /* defined(SOL2) */ #endif /* @@ -219,7 +243,7 @@ struct notifier { extern int got_sigterm; /* SIGINT or SIGTERM was received */ extern int hungup; /* Physical layer has disconnected */ extern int ifunit; /* Interface unit number */ -extern char ifname[]; /* Interface name */ +extern char ifname[]; /* Interface name (IFNAMSIZ) */ extern char hostname[]; /* Our hostname */ extern u_char outpacket_buf[]; /* Buffer for outgoing packets */ extern int devfd; /* fd of underlying device */ @@ -234,7 +258,7 @@ extern int privileged; /* We were run by real-uid root */ extern int need_holdoff; /* Need holdoff period after link terminates */ extern char **script_env; /* Environment variables for scripts */ extern int detached; /* Have detached from controlling tty */ -extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */ +extern GIDSET_TYPE groups[]; /* groups the user is in */ extern int ngroups; /* How many groups valid in groups */ extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */ extern int link_stats_valid; /* set if link_stats is valid */ @@ -249,7 +273,7 @@ extern int unsuccess; /* # unsuccessful connection attempts */ extern int do_callback; /* set if we want to do callback next */ extern int doing_callback; /* set if this is a callback */ extern int error_count; /* # of times error() has been called */ -extern char ppp_devnam[MAXPATHLEN]; +extern char ppp_devnam[]; /* name of PPP tty (maybe ttypx) */ extern char remote_number[MAXNAMELEN]; /* Remote telephone number, if avail. */ extern int ppp_session_number; /* Session number (eg PPPoE session) */ extern int fd_devnull; /* fd open to /dev/null */ @@ -283,7 +307,7 @@ extern struct notifier *fork_notifier; /* we are a new child process */ extern int debug; /* Debug flag */ extern int kdebugflag; /* Tell kernel to print debug messages */ extern int default_device; /* Using /dev/tty or equivalent */ -extern char devnam[MAXPATHLEN]; /* Device name */ +extern char devnam[]; /* Device name */ extern int crtscts; /* Use hardware flow control */ extern int stop_bits; /* Number of serial port stop bits */ extern bool modem; /* Use modem control lines */ @@ -322,14 +346,14 @@ extern char *pty_socket; /* Socket to connect to pty */ extern char *record_file; /* File to record chars sent/received */ extern bool sync_serial; /* Device is synchronous serial device */ extern int maxfail; /* Max # of unsuccessful connection attempts */ -extern char linkname[MAXPATHLEN]; /* logical name for link */ +extern char linkname[]; /* logical name for link */ extern bool tune_kernel; /* May alter kernel settings as necessary */ extern int connect_delay; /* Time to delay after connect script */ extern int max_data_rate; /* max bytes/sec through charshunt */ extern int req_unit; /* interface unit number to use */ -extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */ -extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */ -extern char req_ifname[IFNAMSIZ]; /* interface name to use */ +extern char path_ipup[]; /* pathname of ip-up script */ +extern char path_ipdown[]; /* pathname of ip-down script */ +extern char req_ifname[]; /* interface name to use (IFNAMSIZ) */ extern bool multilink; /* enable multilink operation */ extern bool noendpoint; /* don't send or accept endpt. discrim. */ extern char *bundle_name; /* bundle name for multilink */ @@ -337,13 +361,12 @@ extern bool dump_options; /* print out option values */ extern bool dryrun; /* check everything, print options, exit */ extern int child_wait; /* # seconds to wait for children at end */ -#ifdef INET6 -extern char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */ -extern char path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */ +#ifdef PPP_WITH_IPV6CP +extern char path_ipv6up[]; /* pathname of ipv6-up script */ +extern char path_ipv6down[]; /* pathname of ipv6-down script */ #endif -#if defined(USE_EAPTLS) || defined(USE_PEAP) - +#if defined(PPP_WITH_EAPTLS) || defined(PPP_WITH_PEAP) #define TLS_VERIFY_NONE "none" #define TLS_VERIFY_NAME "name" #define TLS_VERIFY_SUBJECT "subject" @@ -357,13 +380,12 @@ extern char *cacert_file; extern char *max_tls_version; extern bool tls_verify_key_usage; extern char *tls_verify_method; -#endif /* USE_EAPTLS || USE_PEAP */ +#endif /* PPP_WITH_EAPTLS || PPP_WITH_PEAP */ -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS extern char *pkcs12_file; -#endif /* USE_EAPTLS */ +#endif /* PPP_WITH_EAPTLS */ -#ifdef MAXOCTETS extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ extern int maxoctets_dir; /* Direction : 0 - in+out (default) @@ -377,14 +399,13 @@ extern int maxoctets_timeout; /* Timeout for check of octets limit */ #define PPP_OCTETS_DIRECTION_MAXOVERAL 3 /* same as previos, but little different on RADIUS side */ #define PPP_OCTETS_DIRECTION_MAXSESSION 4 -#endif -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER extern struct bpf_program pass_filter; /* Filter for pkts to pass */ extern struct bpf_program active_filter; /* Filter for link-active pkts */ #endif -#ifdef MSLANMAN +#ifdef PPP_WITH_MSLANMAN extern bool ms_lanman; /* Use LanMan password instead of NT */ /* Has meaning only with MS-CHAP challenges */ #endif @@ -625,7 +646,7 @@ int loop_chars(unsigned char *, int); /* process chars from loopback */ int loop_frame(unsigned char *, int); /* should we bring link up? */ /* Procedures exported from multilink.c */ -#ifdef HAVE_MULTILINK +#ifdef PPP_WITH_MULTILINK void mp_check_options(void); /* Check multilink-related options */ int mp_join_bundle(void); /* join our link to an appropriate bundle */ void mp_exit_bundle(void); /* have disconnected our link from bundle */ @@ -693,7 +714,7 @@ int sifaddr(int, u_int32_t, u_int32_t, u_int32_t); /* Configure IPv4 addresses for i/f */ int cifaddr(int, u_int32_t, u_int32_t); /* Reset i/f IP addresses */ -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP int sif6up(int); /* Configure i/f up for IPv6 */ int sif6down(int); /* Configure i/f down for IPv6 */ int sif6addr(int, eui64_t, eui64_t); @@ -705,7 +726,7 @@ int sifdefaultroute(int, u_int32_t, u_int32_t, bool replace_default_rt); /* Create default route through i/f */ int cifdefaultroute(int, u_int32_t, u_int32_t); /* Delete default route through i/f */ -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP int sif6defaultroute(int, eui64_t, eui64_t); /* Create default IPv6 route through i/f */ int cif6defaultroute(int, eui64_t, eui64_t); @@ -723,7 +744,7 @@ void logwtmp(const char *, const char *, const char *); /* Write entry to wtmp file */ int get_host_seed(void); /* Get host-dependent random number seed */ int have_route_to(u_int32_t); /* Check if route to addr exists */ -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER int set_filters(struct bpf_program *pass, struct bpf_program *active); /* Set filter programs in kernel */ #endif @@ -781,7 +802,7 @@ extern int (*chap_check_hook)(void); extern int (*chap_passwd_hook)(char *user, char *passwd); extern void (*multilink_join_hook)(void); -#ifdef USE_EAPTLS +#ifdef PPP_WITH_EAPTLS extern int (*eaptls_passwd_hook)(char *user, char *passwd); #endif @@ -872,9 +893,7 @@ extern void (*snoop_send_hook)(unsigned char *p, int len); #define EXIT_LOOPBACK 17 #define EXIT_INIT_FAILED 18 #define EXIT_AUTH_TOPEER_FAILED 19 -#ifdef MAXOCTETS #define EXIT_TRAFFIC_LIMIT 20 -#endif #define EXIT_CNID_AUTH_FAILED 21 /* @@ -968,4 +987,4 @@ extern void (*snoop_send_hook)(unsigned char *p, int len); #define offsetof(type, member) ((size_t) &((type *)0)->member) #endif -#endif /* __PPP_H__ */ +#endif /* PPP_PPPD_H */ diff --git a/pppd/pppdconf.h.in b/pppd/pppdconf.h.in index 9c0dacb..64c37f7 100644 --- a/pppd/pppdconf.h.in +++ b/pppd/pppdconf.h.in @@ -3,44 +3,47 @@ * in pppd when configured. */ -/* "Have Microsoft CHAP support" */ -#undef CHAPMS +#ifndef PPP_PPPDCONF_H +#define PPP_PPPDCONF_H -/* "Have Microsoft MPPE support" */ -#undef MPPE +/* Have Microsoft CHAP support */ +#undef PPP_WITH_CHAPMS -/* "Have multilink support" */ -#undef HAVE_MULTILINK +/* Have Microsoft LAN Manager support */ +#undef PPP_WITH_MSLANMAN -/* "Have packet activity filter support" */ -#undef PPP_FILTER +/* Have Microsoft MPPE support */ +#undef PPP_WITH_MPPE -/* "Have support for loadable plugins" */ -#undef PLUGIN +/* Have multilink support */ +#undef PPP_WITH_MULTILINK -/* "Limit sessions by maximum number of octets" */ -#undef MAXOCTETS +/* Have packet activity filter support */ +#undef PPP_WITH_FILTER -/* Have Microsoft Callback Protocol support */ -#undef CBCP_SUPPORT +/* Have support for loadable plugins */ +#undef PPP_WITH_PLUGINS -/* "Include Trivial Database support" */ -#undef USE_TDB +/* Have Callback Protocol support */ +#undef PPP_WITH_CBCP -/* "Have IPv6 support" */ -#undef INET6 +/* Include TDB support */ +#undef PPP_WITH_TDB -/* "Support for Pluggable Authentication Modules" */ -#undef USE_PAM +/* Have IPv6 Control Protocol */ +#undef PPP_WITH_IPV6CP -/* "Have EAP-SRP authentication support" */ -#undef USE_SRP +/* Support for Pluggable Authentication Modules */ +#undef PPP_WITH_PAM -/* "Have EAP-TLS authentication support" */ -#undef USE_EAPTLS +/* Have EAP-SRP authentication support */ +#undef PPP_WITH_SRP -/* "Have PEAP authentication support" */ -#undef USE_PEAP +/* Have EAP-TLS authentication support */ +#undef PPP_WITH_EAPTLS + +/* Have PEAP authentication support */ +#undef PPP_WITH_PEAP /* Use included des included with pppd */ #undef USE_CRYPT @@ -54,5 +57,7 @@ /* Use included sha included with pppd */ #undef USE_SHA -/* Version number of package */ -#undef VERSION +/* The pppd version */ +#undef PPPD_VERSION + +#endif diff --git a/pppd/session.c b/pppd/session.c index 3d1fb6d..8ab5b8b 100644 --- a/pppd/session.c +++ b/pppd/session.c @@ -92,9 +92,9 @@ #include "pppd.h" #include "session.h" -#ifdef USE_PAM +#ifdef PPP_WITH_PAM #include -#endif /* #ifdef USE_PAM */ +#endif /* #ifdef PPP_WITH_PAM */ #define SET_MSG(var, msg) if (var != NULL) { var[0] = msg; } #define COPY_STRING(s) ((s) ? strdup(s) : NULL) @@ -109,7 +109,7 @@ /* We have successfully started a session */ static bool logged_in = 0; -#ifdef USE_PAM +#ifdef PPP_WITH_PAM /* * Static variables used to communicate between the conversation function * and the server_login function @@ -167,17 +167,17 @@ static struct pam_conv pam_conv_data = { &conversation, NULL }; -#endif /* #ifdef USE_PAM */ +#endif /* #ifdef PPP_WITH_PAM */ int session_start(const int flags, const char *user, const char *passwd, const char *ttyName, char **msg) { -#ifdef USE_PAM +#ifdef PPP_WITH_PAM bool ok = 1; const char *usr; int pam_error; bool try_session = 0; -#else /* #ifdef USE_PAM */ +#else /* #ifdef PPP_WITH_PAM */ struct passwd *pw; char *cbuf; #ifdef HAVE_SHADOW_H @@ -185,7 +185,7 @@ session_start(const int flags, const char *user, const char *passwd, const char struct spwd *getspnam(); long now = 0; #endif /* #ifdef HAVE_SHADOW_H */ -#endif /* #ifdef USE_PAM */ +#endif /* #ifdef PPP_WITH_PAM */ SET_MSG(msg, SUCCESS_MSG); @@ -199,7 +199,7 @@ session_start(const int flags, const char *user, const char *passwd, const char return SESSION_FAILED; } -#ifdef USE_PAM +#ifdef PPP_WITH_PAM /* Find the '\\' in the username */ /* This needs to be fixed to support different username schemes */ if ((usr = strchr(user, '\\')) == NULL) @@ -295,7 +295,7 @@ session_start(const int flags, const char *user, const char *passwd, const char /* If our PAM checks have already failed, then we must return a failure */ if (!ok) return SESSION_FAILED; -#else /* #ifdef USE_PAM */ +#else /* #ifdef PPP_WITH_PAM */ /* * Use the non-PAM methods directly. 'pw' will remain NULL if the user @@ -359,7 +359,7 @@ session_start(const int flags, const char *user, const char *passwd, const char return SESSION_FAILED; } -#endif /* #ifdef USE_PAM */ +#endif /* #ifdef PPP_WITH_PAM */ /* * Write a wtmp entry for this user. @@ -371,7 +371,7 @@ session_start(const int flags, const char *user, const char *passwd, const char logwtmp(ttyName, user, ifname); /* Add wtmp login entry */ logged_in = 1; -#if defined(_PATH_LASTLOG) && !defined(USE_PAM) +#if defined(_PATH_LASTLOG) && !defined(PPP_WITH_PAM) /* * Enter the user in lastlog only if he has been authenticated using * local system services. If he has not, then we don't know what his @@ -393,7 +393,7 @@ session_start(const int flags, const char *user, const char *passwd, const char (void)close(fd); } } -#endif /* _PATH_LASTLOG and not USE_PAM */ +#endif /* _PATH_LASTLOG and not PPP_WITH_PAM */ info("user %s logged in on tty %s intf %s", user, ttyName, ifname); } @@ -406,7 +406,7 @@ session_start(const int flags, const char *user, const char *passwd, const char void session_end(const char* ttyName) { -#ifdef USE_PAM +#ifdef PPP_WITH_PAM int pam_error = PAM_SUCCESS; if (pamh != NULL) { diff --git a/pppd/session.h b/pppd/session.h index 0047db6..0b91a03 100644 --- a/pppd/session.h +++ b/pppd/session.h @@ -27,10 +27,10 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "pppdconf.h" +#ifndef PPP_SESSION_H +#define PPP_SESSION_H -#ifndef __SESSION_H -#define __SESSION_H +#include "pppdconf.h" #define SESS_AUTH 1 /* Check User Authentication */ #define SESS_ACCT 2 /* Check Account Validity */ @@ -89,4 +89,4 @@ session_start(const int flags, const char* user, const char* passwd, const char* void session_end(const char* tty); -#endif +#endif // PPP_SESSION_H diff --git a/pppd/sha1.c b/pppd/sha1.c index efb37be..4fc5345 100644 --- a/pppd/sha1.c +++ b/pppd/sha1.c @@ -23,7 +23,6 @@ #include #include #include /* htonl() */ -#include #include "sha1.h" static void diff --git a/pppd/sha1.h b/pppd/sha1.h index e7e5573..2325133 100644 --- a/pppd/sha1.h +++ b/pppd/sha1.h @@ -1,9 +1,9 @@ /* sha1.h */ -#include "pppdconf.h" +#ifndef PPP_SHA1_H +#define PPP_SHA1_H -#ifndef __SHA1_INCLUDE_ -#define __SHA1_INCLUDE_ +#include "pppdconf.h" #ifndef USE_SHA #include @@ -32,4 +32,4 @@ extern void SHA1_Update(SHA1_CTX *, const unsigned char *, unsigned int); extern void SHA1_Final(unsigned char[SHA1_SIGNATURE_SIZE], SHA1_CTX *); #endif /* USE_SHA */ -#endif /* __SHA1_INCLUDE_ */ +#endif /* PPP_SHA1_H */ diff --git a/pppd/spinlock.h b/pppd/spinlock.h index 38e7bcc..b36d2a8 100644 --- a/pppd/spinlock.h +++ b/pppd/spinlock.h @@ -1,7 +1,7 @@ -#include "pppdconf.h" +#ifndef PPP_SPINLOCK_H +#define PPP_SPINLOCK_H -#ifndef __SPINLOCK_H__ -#define __SPINLOCK_H__ +#include "pppdconf.h" #include "tdb.h" @@ -54,4 +54,4 @@ int tdb_clear_spinlocks(TDB_CONTEXT *tdb); #endif -#endif +#endif // PPP_SPINLOCK_H diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index 6eed86f..e7f851c 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -81,6 +81,7 @@ #include #include #include +#include #include #include @@ -125,17 +126,12 @@ #include #include -#include -#include +#include #include #include #include -#ifdef INET6 -#include -#endif - /* Attempt at retaining compile-support with older than 4.7 kernels, or kernels * where RTM_NEWSTATS isn't defined for whatever reason. */ @@ -145,6 +141,8 @@ #define IFLA_STATS_LINK_64 1 #endif +#include + /* glibc versions prior to 2.24 do not define SOL_NETLINK */ #ifndef SOL_NETLINK #define SOL_NETLINK 270 @@ -165,10 +163,14 @@ #include "fsm.h" #include "ipcp.h" -#ifdef PPP_FILTER +#ifdef PPP_WITH_IPV6CP +#include "eui64.h" +#endif /* PPP_WITH_IPV6CP */ + +#ifdef PPP_WITH_FILTER #include #include -#endif /* PPP_FILTER */ +#endif /* PPP_WITH_FILTER */ #ifdef LOCKLIB #include @@ -180,7 +182,7 @@ */ #include "termios_linux.h" -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP #ifndef _LINUX_IN6_H /* * This is in linux/include/net/ipv6.h. @@ -200,7 +202,7 @@ struct in6_ifreq { } while (0) static const eui64_t nulleui64; -#endif /* INET6 */ +#endif /* PPP_WITH_IPV6CP */ /* We can get an EIO error on an ioctl if the modem has hung up */ #define ok_error(num) ((num)==EIO) @@ -212,9 +214,9 @@ static int ppp_fd = -1; /* fd which is set to PPP discipline */ static int sock_fd = -1; /* socket for doing interface ioctls */ static int slave_fd = -1; /* pty for old-style demand mode, slave */ static int master_fd = -1; /* pty for old-style demand mode, master */ -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP static int sock6_fd = -1; -#endif /* INET6 */ +#endif /* PPP_WITH_IPV6CP */ /* * For the old-style kernel driver, this is the same as ppp_fd. @@ -357,7 +359,7 @@ void sys_init(void) if (sock_fd < 0) fatal("Couldn't create IP socket: %m(%d)", errno); -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP sock6_fd = socket(AF_INET6, SOCK_DGRAM, 0); if (sock6_fd < 0) sock6_fd = -errno; /* save errno for later */ @@ -383,15 +385,17 @@ void sys_cleanup(void) if_is_up = 0; sifdown(0); } +#ifdef PPP_WITH_IPV6CP if (if6_is_up) sif6down(0); +#endif /* * Delete any routes through the device. */ if (have_default_route) cifdefaultroute(0, 0, 0); -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP if (have_default_route6) cif6defaultroute(0, nulleui64, nulleui64); #endif @@ -411,7 +415,7 @@ sys_close(void) close(ppp_dev_fd); if (sock_fd >= 0) close(sock_fd); -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP if (sock6_fd >= 0) close(sock6_fd); #endif @@ -1612,7 +1616,7 @@ void ccp_flags_set (int unit, int isopen, int isup) modify_flags(ppp_dev_fd, SC_CCP_OPEN|SC_CCP_UP, x); } -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER /* * set_filters - set the active and pass filters in the kernel driver. */ @@ -1637,7 +1641,7 @@ int set_filters(struct bpf_program *pass, struct bpf_program *active) } return 1; } -#endif /* PPP_FILTER */ +#endif /* PPP_WITH_FILTER */ /******************************************************************** * @@ -1662,20 +1666,21 @@ get_ppp_stats_ioctl(int u, struct pppd_stats *stats) static u_int32_t iwraps = 0; static u_int32_t owraps = 0; - struct ifpppstatsreq req; + struct ifreq req; + struct ppp_stats data; memset (&req, 0, sizeof (req)); - req.stats_ptr = (caddr_t) &req.stats; - strlcpy(req.ifr__name, ifname, sizeof(req.ifr__name)); + req.ifr_data = (caddr_t) &data; + strlcpy(req.ifr_name, ifname, sizeof(req.ifr_name)); if (ioctl(sock_fd, SIOCGPPPSTATS, &req) < 0) { error("Couldn't get PPP statistics: %m"); return 0; } - stats->bytes_in = req.stats.p.ppp_ibytes; - stats->bytes_out = req.stats.p.ppp_obytes; - stats->pkts_in = req.stats.p.ppp_ipackets; - stats->pkts_out = req.stats.p.ppp_opackets; + stats->bytes_in = data.p.ppp_ibytes; + stats->bytes_out = data.p.ppp_obytes; + stats->pkts_in = data.p.ppp_ipackets; + stats->pkts_out = data.p.ppp_opackets; if (stats->bytes_in < previbytes) ++iwraps; @@ -2293,7 +2298,7 @@ int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) return 1; } -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP /* * /proc/net/ipv6_route parsing stuff. */ @@ -2483,7 +2488,7 @@ int cif6defaultroute (int unit, eui64_t ouraddr, eui64_t gateway) return 1; } -#endif /* INET6 */ +#endif /* PPP_WITH_IPV6CP */ /******************************************************************** * @@ -3109,15 +3114,15 @@ int sifdown (int u) if (if_is_up && --if_is_up > 0) return 1; -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP if (if6_is_up) return 1; -#endif /* INET6 */ +#endif /* PPP_WITH_IPV6CP */ return setifstate(u, 0); } -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP /******************************************************************** * * sif6up - Config the interface up for IPv6 @@ -3148,7 +3153,7 @@ int sif6down (int u) return setifstate(u, 0); } -#endif /* INET6 */ +#endif /* PPP_WITH_IPV6CP */ /******************************************************************** * @@ -3336,7 +3341,7 @@ int cifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr) return 1; } -#ifdef INET6 +#ifdef PPP_WITH_IPV6CP /******************************************************************** * * sif6addr_rtnetlink - Config the interface with both IPv6 link-local addresses via rtnetlink @@ -3597,7 +3602,7 @@ int cif6addr (int unit, eui64_t our_eui64, eui64_t his_eui64) } return 1; } -#endif /* INET6 */ +#endif /* PPP_WITH_IPV6CP */ /* * get_pty - get a pty master/slave pair and chown the slave side diff --git a/pppd/sys-solaris.c b/pppd/sys-solaris.c index 809b506..d903721 100644 --- a/pppd/sys-solaris.c +++ b/pppd/sys-solaris.c @@ -131,7 +131,7 @@ #include #endif -#ifdef PPP_FILTER +#ifdef PPP_WITH_FILTER #include #endif @@ -141,6 +141,10 @@ #include "ipcp.h" #include "ccp.h" +#ifdef PPP_WITH_IPV6CP +#include "eui64.h" +#endif + #if !defined(PPP_DRV_NAME) #define PPP_DRV_NAME "ppp" #endif /* !defined(PPP_DRV_NAME) */ @@ -190,7 +194,7 @@ static int fdmuxid = -1; static int ipfd; static int ipmuxid = -1; -#if defined(INET6) && defined(SOL2) +#if defined(PPP_WITH_IPV6CP) && defined(SOL2) static int ip6fd; /* IP file descriptor */ static int ip6muxid = -1; /* Multiplexer file descriptor */ static int if6_is_up = 0; /* IPv6 interface has been marked up */ @@ -224,11 +228,11 @@ static int if6_is_up = 0; /* IPv6 interface has been marked up */ #define IN6A_LLADDR_FROM_EUI64(s, eui64) \ _IN6A_LLX_FROM_EUI64(s, eui64, 0xfe800000) -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ -#if !defined(INET6) || !defined(SOL2) +#if !defined(PPP_WITH_IPV6CP) || !defined(SOL2) #define MAXIFS 256 /* Max # of interfaces */ -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ static int restore_term; static struct termios inittermios; @@ -297,7 +301,7 @@ sifppa(fd, ppa) } #endif /* SOL2 */ -#if defined(SOL2) && defined(INET6) +#if defined(SOL2) && defined(PPP_WITH_IPV6CP) /* * get_first_ether_hwaddr - get the hardware address for the first * ethernet-style interface on this system. @@ -477,7 +481,7 @@ get_first_ether_hwaddr(u_char *addr) else return -1; } -#endif /* defined(SOL2) && defined(INET6) */ +#endif /* defined(SOL2) && defined(PPP_WITH_IPV6CP) */ #if defined(SOL2) /* @@ -506,7 +510,7 @@ get_if_hwaddr(u_char *addr, char *if_name) } #endif /* SOL2 */ -#if defined(SOL2) && defined(INET6) +#if defined(SOL2) && defined(PPP_WITH_IPV6CP) /* * slifname - Sets interface ppa and flags * @@ -536,7 +540,7 @@ slifname_done: } -#endif /* defined(SOL2) && defined(INET6) */ +#endif /* defined(SOL2) && defined(PPP_WITH_IPV6CP) */ /* * sys_init - System-dependent initialization. @@ -546,10 +550,10 @@ sys_init(void) { int ifd, x; struct ifreq ifr; -#if defined(INET6) && defined(SOL2) +#if defined(PPP_WITH_IPV6CP) && defined(SOL2) int i6fd; struct lifreq lifr; -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ #if !defined(SOL2) struct { union DL_primitives prim; @@ -561,11 +565,11 @@ sys_init(void) if (ipfd < 0) fatal("Couldn't open IP device: %m"); -#if defined(INET6) && defined(SOL2) +#if defined(PPP_WITH_IPV6CP) && defined(SOL2) ip6fd = open(UDP6_DEV_NAME, O_RDWR, 0); if (ip6fd < 0) fatal("Couldn't open IP device (2): %m"); -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ if (default_device && !notty) tty_sid = getsid((pid_t)0); @@ -604,7 +608,7 @@ sys_init(void) strioctl(ifd, PPPIO_DEBUG, &x, sizeof(int), 0); } -#if defined(INET6) && defined(SOL2) +#if defined(PPP_WITH_IPV6CP) && defined(SOL2) i6fd = open(PPP_DEV_NAME, O_RDWR, 0); if (i6fd < 0) { close(ifd); @@ -614,14 +618,14 @@ sys_init(void) x = PPPDBG_LOG + PPPDBG_DRIVER; strioctl(i6fd, PPPIO_DEBUG, &x, sizeof(int), 0); } -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ #if defined(SOL2) if (ioctl(ifd, I_PUSH, IP_MOD_NAME) < 0) { close(ifd); -#if defined(INET6) +#if defined(PPP_WITH_IPV6CP) close(i6fd); -#endif /* defined(INET6) */ +#endif /* defined(PPP_WITH_IPV6CP) */ fatal("Can't push IP module: %m"); } @@ -631,13 +635,13 @@ sys_init(void) */ if (sifppa(ifd, ifunit) < 0) { close (ifd); -#if defined(INET6) +#if defined(PPP_WITH_IPV6CP) close(i6fd); -#endif /* defined(INET6) */ +#endif /* defined(PPP_WITH_IPV6CP) */ fatal("Can't set ppa for unit %d: %m", ifunit); } -#if defined(INET6) +#if defined(PPP_WITH_IPV6CP) /* * An IPv6 interface is created anyway, even when the user does not * explicitly enable it. Note that the interface will be marked @@ -659,14 +663,14 @@ sys_init(void) close(i6fd); fatal("Can't set ifname for unit %d: %m", ifunit); } -#endif /* defined(INET6) */ +#endif /* defined(PPP_WITH_IPV6CP) */ ipmuxid = ioctl(ipfd, I_PLINK, ifd); close(ifd); if (ipmuxid < 0) { -#if defined(INET6) +#if defined(PPP_WITH_IPV6CP) close(i6fd); -#endif /* defined(INET6) */ +#endif /* defined(PPP_WITH_IPV6CP) */ fatal("Can't I_PLINK PPP device to IP: %m"); } @@ -683,9 +687,9 @@ sys_init(void) */ if (ioctl(ipfd, SIOCSIFMUXID, &ifr) < 0) { ioctl(ipfd, I_PUNLINK, ipmuxid); -#if defined(INET6) +#if defined(PPP_WITH_IPV6CP) close(i6fd); -#endif /* defined(INET6) */ +#endif /* defined(PPP_WITH_IPV6CP) */ fatal("SIOCSIFMUXID: %m"); } @@ -703,7 +707,7 @@ sys_init(void) fatal("Can't link PPP device to IP: %m"); #endif /* defined(SOL2) */ -#if defined(INET6) && defined(SOL2) +#if defined(PPP_WITH_IPV6CP) && defined(SOL2) ip6muxid = ioctl(ip6fd, I_PLINK, i6fd); close(i6fd); if (ip6muxid < 0) { @@ -723,7 +727,7 @@ sys_init(void) ioctl(ip6fd, I_PUNLINK, ip6muxid); fatal("Can't link PPP device to IP (2): %m"); } -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ #if !defined(SOL2) /* Set the interface name for the link. */ @@ -746,15 +750,15 @@ sys_cleanup(void) { #if defined(SOL2) struct ifreq ifr; -#if defined(INET6) +#if defined(PPP_WITH_IPV6CP) struct lifreq lifr; -#endif /* defined(INET6) */ +#endif /* defined(PPP_WITH_IPV6CP) */ #endif /* defined(SOL2) */ -#if defined(SOL2) && defined(INET6) +#if defined(SOL2) && defined(PPP_WITH_IPV6CP) if (if6_is_up) sif6down(0); -#endif /* defined(SOL2) && defined(INET6) */ +#endif /* defined(SOL2) && defined(PPP_WITH_IPV6CP) */ if (if_is_up) sifdown(0); if (default_route_gateway) @@ -786,7 +790,7 @@ sys_cleanup(void) error("Can't I_PUNLINK PPP from IP: %m"); return; } -#if defined(INET6) +#if defined(PPP_WITH_IPV6CP) /* * Make sure we ask ip what the muxid, because 'ifconfig modlist' will * unlink and re-link the modules, causing the muxid to change. @@ -808,7 +812,7 @@ sys_cleanup(void) if (ioctl(ip6fd, I_PUNLINK, ip6muxid) < 0) { error("Can't I_PUNLINK PPP from IP (2): %m"); } -#endif /* defined(INET6) */ +#endif /* defined(PPP_WITH_IPV6CP) */ #endif /* defined(SOL2) */ } @@ -819,9 +823,9 @@ void sys_close(void) { close(ipfd); -#if defined(INET6) && defined(SOL2) +#if defined(PPP_WITH_IPV6CP) && defined(SOL2) close(ip6fd); -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ if (pppfd >= 0) close(pppfd); } @@ -1462,10 +1466,10 @@ void netif_set_mtu(int unit, int mtu) { struct ifreq ifr; -#if defined(INET6) && defined(SOL2) +#if defined(PPP_WITH_IPV6CP) && defined(SOL2) struct lifreq lifr; int fd; -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); @@ -1474,7 +1478,7 @@ netif_set_mtu(int unit, int mtu) error("Couldn't set IP MTU (%s): %m", ifr.ifr_name); } -#if defined(INET6) && defined(SOL2) +#if defined(PPP_WITH_IPV6CP) && defined(SOL2) fd = socket(AF_INET6, SOCK_DGRAM, 0); if (fd < 0) error("Couldn't open IPv6 socket: %m"); @@ -1487,7 +1491,7 @@ netif_set_mtu(int unit, int mtu) error("Couldn't set IPv6 MTU (%s): %m", ifr.ifr_name); } close(fd); -#endif /* defined(INET6) && defined(SOL2) */ +#endif /* defined(PPP_WITH_IPV6CP) && defined(SOL2) */ } @@ -1754,7 +1758,7 @@ sifnpmode(int u, int proto, enum NPmode mode) return 1; } -#if defined(SOL2) && defined(INET6) +#if defined(SOL2) && defined(PPP_WITH_IPV6CP) /* * sif6up - Config the IPv6 interface up and enable IPv6 packets to pass. */ @@ -1938,7 +1942,7 @@ cif6defaultroute(int u, eui64_t l, eui64_t g) return 1; } -#endif /* defined(SOL2) && defined(INET6) */ +#endif /* defined(SOL2) && defined(PPP_WITH_IPV6CP) */ #define INET_ADDR(x) (((struct sockaddr_in *) &(x))->sin_addr.s_addr) diff --git a/pppd/tdb.h b/pppd/tdb.h index 418bd8d..1d7d765 100644 --- a/pppd/tdb.h +++ b/pppd/tdb.h @@ -1,7 +1,7 @@ -#include "pppdconf.h" +#ifndef PPP_TDB_H +#define PPP_TDB_H -#ifndef __TDB_H__ -#define __TDB_H__ +#include "pppdconf.h" /* Unix SMB/CIFS implementation. @@ -163,4 +163,4 @@ extern TDB_DATA tdb_null; } #endif -#endif /* tdb.h */ +#endif /* PPP_TBD_H */ diff --git a/pppd/termios_linux.h b/pppd/termios_linux.h index 9c79d16..a234d30 100644 --- a/pppd/termios_linux.h +++ b/pppd/termios_linux.h @@ -6,8 +6,10 @@ * Copyright (c) 2021 Marek Behún */ -#ifndef _TERMIOS_LINUX_H_ -#define _TERMIOS_LINUX_H_ +#ifndef PPP_TERMIOS_LINUX_H +#define PPP_TERMIOS_LINUX_H + +#include "pppdconf.h" /* * We need to use raw TCGETS2/TCSETS2 or TCGETS/TCSETS ioctls with the BOTHER @@ -191,4 +193,4 @@ static void cfmakeraw(struct termios *t) t->c_cflag |= CS8; } -#endif /* _TERMIOS_LINUX_H_ */ +#endif /* PPP_TERMIOS_LINUX_H */ diff --git a/pppd/tls.h b/pppd/tls.h index 39fdef7..0796779 100644 --- a/pppd/tls.h +++ b/pppd/tls.h @@ -26,8 +26,10 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef TLS_H -#define TLS_H +#ifndef PPP_TLS_H +#define PPP_TLS_H + +#include "pppdconf.h" /** * Structure used in verifying the peer certificate @@ -85,4 +87,4 @@ int tls_set_ca(SSL_CTX *ctx, const char *ca_dir, const char *ca_file); */ void tls_log_sslerr( void ); -#endif /* TLS_H */ +#endif /* PPP_TLS_H */ diff --git a/pppd/tty.c b/pppd/tty.c index 7e208ba..ad74353 100644 --- a/pppd/tty.c +++ b/pppd/tty.c @@ -319,7 +319,7 @@ setdevname(char *cp, char **argv, int doit) } if (doit) { - strlcpy(devnam, cp, sizeof(devnam)); + strlcpy(devnam, cp, MAXPATHLEN); devstat = statbuf; default_device = 0; } @@ -414,7 +414,7 @@ void tty_process_extra_options(void) option_error("no device specified and stdin is not a tty"); exit(EXIT_OPTION_ERROR); } - strlcpy(devnam, p, sizeof(devnam)); + strlcpy(devnam, p, MAXPATHLEN); if (stat(devnam, &devstat) < 0) fatal("Couldn't stat default device %s: %m", devnam); } @@ -518,7 +518,7 @@ int connect_tty(void) * Get a pty master/slave pair if the pty, notty, socket, * or record options were specified. */ - strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); + strlcpy(ppp_devnam, devnam, MAXPATHLEN); pty_master = -1; pty_slave = -1; real_ttyfd = -1; diff --git a/pppd/upap.h b/pppd/upap.h index 709cd62..af09cd9 100644 --- a/pppd/upap.h +++ b/pppd/upap.h @@ -41,6 +41,10 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef PPP_UPAP_H +#define PPP_UPAP_H + +#include "pppdconf.h" /* * Packet header = Code, id, length. @@ -108,3 +112,5 @@ void upap_authwithpeer(int, char *, char *); void upap_authpeer(int); extern struct protent pap_protent; + +#endif // PPP_UPAP_H diff --git a/pppdump/Makefile.am b/pppdump/Makefile.am index 2df7e0e..186f34e 100644 --- a/pppdump/Makefile.am +++ b/pppdump/Makefile.am @@ -2,7 +2,6 @@ sbin_PROGRAMS = pppdump dist_man8_MANS = pppdump.8 pppdump_SOURCES = pppdump.c bsd-comp.c deflate.c zlib.c -pppdump_CFLAGS = -I${top_srcdir}/include/net noinst_HEADERS = \ ppp-comp.h \ diff --git a/pppdump/bsd-comp.c b/pppdump/bsd-comp.c index 9d45f0b..57f936c 100644 --- a/pppdump/bsd-comp.c +++ b/pppdump/bsd-comp.c @@ -46,7 +46,7 @@ #include #include #include -#include "ppp_defs.h" + #include "ppp-comp.h" #if DO_BSD_COMPRESS @@ -250,14 +250,15 @@ bsd_comp_stats(void *state, struct compstat *stats) stats->comp_packets = db->comp_count; stats->inc_bytes = db->incomp_bytes; stats->inc_packets = db->incomp_count; - stats->ratio = db->in_count; + + u_int ratio = db->in_count; out = db->bytes_out; - if (stats->ratio <= 0x7fffff) - stats->ratio <<= 8; + if (ratio <= 0x7fffff) + ratio <<= 8; else out >>= 8; if (out != 0) - stats->ratio /= out; + stats->ratio = ratio / out; } /* diff --git a/pppdump/deflate.c b/pppdump/deflate.c index 5668a4d..ebc1692 100644 --- a/pppdump/deflate.c +++ b/pppdump/deflate.c @@ -41,7 +41,7 @@ #include #include #include -#include "ppp_defs.h" + #include "ppp-comp.h" #include "zlib.h" @@ -115,12 +115,13 @@ z_comp_stats(void *arg, struct compstat *stats) *stats = state->stats; stats->ratio = stats->unc_bytes; out = stats->comp_bytes + stats->unc_bytes; - if (stats->ratio <= 0x7ffffff) - stats->ratio <<= 8; + u_int ratio = stats->ratio; + if (ratio <= 0x7ffffff) + ratio <<= 8; else out >>= 8; if (out != 0) - stats->ratio /= out; + stats->ratio = ratio / out; } /* diff --git a/pppdump/ppp-comp.h b/pppdump/ppp-comp.h index 4046a1f..0199b5f 100644 --- a/pppdump/ppp-comp.h +++ b/pppdump/ppp-comp.h @@ -51,6 +51,12 @@ #define DO_PREDICTOR_1 0 #define DO_PREDICTOR_2 0 +#if defined(SOL2) +#include +#else +#include +#endif + /* * Structure giving methods for compression/decompression. */ diff --git a/pppdump/pppdump.c b/pppdump/pppdump.c index 130300a..b85a862 100644 --- a/pppdump/pppdump.c +++ b/pppdump/pppdump.c @@ -38,7 +38,7 @@ #include #include #include -#include "ppp_defs.h" + #include "ppp-comp.h" int hexmode; @@ -233,6 +233,7 @@ static u_short fcstab[256] = { 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 }; +#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) struct pkt { int cnt; @@ -296,6 +297,10 @@ dumpppp(f) printf("%s aborted packet:\n ", dir); q = " "; } + if (pkt->cnt >= sizeof(pkt->buf)) { + printf("%s over-long packet truncated:\n ", dir); + q = " "; + } nb = pkt->cnt; p = pkt->buf; pkt->cnt = 0; @@ -399,7 +404,8 @@ dumpppp(f) c ^= 0x20; pkt->esc = 0; } - pkt->buf[pkt->cnt++] = c; + if (pkt->cnt < sizeof(pkt->buf)) + pkt->buf[pkt->cnt++] = c; break; } } diff --git a/pppstats/Makefile.am b/pppstats/Makefile.am index d7d74e0..4c8b83f 100644 --- a/pppstats/Makefile.am +++ b/pppstats/Makefile.am @@ -5,10 +5,6 @@ pppstats_SOURCES = pppstats.c pppstats_CFLAGS = pppstats_CPPFLAGS = -if LINUX -pppstats_CFLAGS += -I${top_srcdir}/include -endif - if SUNOS pppstats_CPPFLAGS += -DSTREAMS endif diff --git a/pppstats/pppstats.c b/pppstats/pppstats.c index cbea00b..44a254d 100644 --- a/pppstats/pppstats.c +++ b/pppstats/pppstats.c @@ -62,7 +62,6 @@ static const char rcsid[] = "$Id: pppstats.c,v 1.29 2002/10/27 12:56:26 fcusack #ifndef __linux__ #include #include -#include #else /* Linux */ #if __GLIBC__ >= 2 @@ -74,6 +73,7 @@ static const char rcsid[] = "$Id: pppstats.c,v 1.29 2002/10/27 12:56:26 fcusack #endif #include #include + #endif /* __linux__ */ #else /* STREAMS */ @@ -137,15 +137,11 @@ catchalarm(int arg) static void get_ppp_stats(struct ppp_stats *curp) { - struct ifpppstatsreq req; + struct ifreq req; memset (&req, 0, sizeof (req)); -#ifdef __linux__ - req.stats_ptr = (caddr_t) &req.stats; -#undef ifr_name -#define ifr_name ifr__name -#endif + req.ifr_data = (caddr_t) curp; strncpy(req.ifr_name, interface, IFNAMSIZ); req.ifr_name[IFNAMSIZ - 1] = 0; @@ -157,25 +153,21 @@ get_ppp_stats(struct ppp_stats *curp) perror("couldn't get PPP statistics"); exit(1); } - *curp = req.stats; } static void get_ppp_cstats(struct ppp_comp_stats *csp) { - struct ifpppcstatsreq creq; + struct ifreq req; + struct ppp_comp_stats stats; - memset (&creq, 0, sizeof (creq)); + memset (&req, 0, sizeof (req)); -#ifdef __linux__ - creq.stats_ptr = (caddr_t) &creq.stats; -#undef ifr_name -#define ifr_name ifr__name -#endif + req.ifr_data = (caddr_t) &stats; - strncpy(creq.ifr_name, interface, IFNAMSIZ); - creq.ifr_name[IFNAMSIZ - 1] = 0; - if (ioctl(s, SIOCGPPPCSTATS, &creq) < 0) { + strncpy(req.ifr_name, interface, IFNAMSIZ); + req.ifr_name[IFNAMSIZ - 1] = 0; + if (ioctl(s, SIOCGPPPCSTATS, &req) < 0) { fprintf(stderr, "%s: ", progname); if (errno == ENOTTY) { fprintf(stderr, "no kernel compression support\n"); @@ -189,28 +181,26 @@ get_ppp_cstats(struct ppp_comp_stats *csp) } #ifdef __linux__ - if (creq.stats.c.bytes_out == 0) { - creq.stats.c.bytes_out = creq.stats.c.comp_bytes + creq.stats.c.inc_bytes; - creq.stats.c.in_count = creq.stats.c.unc_bytes; + if (stats.c.bytes_out == 0) { + stats.c.bytes_out = stats.c.comp_bytes + stats.c.inc_bytes; + stats.c.in_count = stats.c.unc_bytes; } - if (creq.stats.c.bytes_out == 0) - creq.stats.c.ratio = 0.0; + if (stats.c.bytes_out == 0) + stats.c.ratio = 0.0; else - creq.stats.c.ratio = 256.0 * creq.stats.c.in_count / - creq.stats.c.bytes_out; + stats.c.ratio = 256.0 * stats.c.in_count / stats.c.bytes_out; - if (creq.stats.d.bytes_out == 0) { - creq.stats.d.bytes_out = creq.stats.d.comp_bytes + creq.stats.d.inc_bytes; - creq.stats.d.in_count = creq.stats.d.unc_bytes; + if (stats.d.bytes_out == 0) { + stats.d.bytes_out = stats.d.comp_bytes + stats.d.inc_bytes; + stats.d.in_count = stats.d.unc_bytes; } - if (creq.stats.d.bytes_out == 0) - creq.stats.d.ratio = 0.0; + if (stats.d.bytes_out == 0) + stats.d.ratio = 0.0; else - creq.stats.d.ratio = 256.0 * creq.stats.d.in_count / - creq.stats.d.bytes_out; + stats.d.ratio = 256.0 * stats.d.in_count / stats.d.bytes_out; #endif - *csp = creq.stats; + *csp = stats; } #else /* STREAMS */