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
     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 =
 
 
        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.
 
 extern "C" {
 #endif
 
+
+#ifndef PPP_EAP
+#define PPP_EAP 0xc227
+#endif
+
+
 /*
  * Packet header = Code, id, length.
  */
 
  */
 #include "pppdconf.h"
 
+#ifndef PPP_ECP_H
+#define PPP_ECP_H
+
+#ifndef PPP_ECP
+#define PPP_ECP 0x8053
+#endif
+
+
 typedef struct ecp_options {
     bool required;             /* Is ECP required? */
     unsigned enctype;          /* Encryption type */
 extern ecp_options ecp_hisoptions[];
 
 extern struct protent ecp_protent;
+
+#endif
 
 #include "pppd.h"
 #include "fsm.h"
 #include "lcp.h"
+#include "eap.h"
 #include "chap-new.h"
 #include "magic.h"
 
 
 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}
+PLUGIN_CPPFLAGS = -I${top_srcdir}
 PLUGIN_LDFLAGS = -module -avoid-version
 
 minconn_la_CPPFLAGS = $(PLUGIN_CPPFLAGS)
 
     atmres.h \
     atmsap.h
 
-pppoatm_la_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir}
+pppoatm_la_CPPFLAGS = -I${top_srcdir}
 pppoatm_la_LDFLAGS = -module -avoid-version
 pppoatm_la_SOURCES = pppoatm.c
 
 
 noinst_HEADERS = \
     pppoe.h
 
-pppoe_la_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir}
+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
 
 noinst_HEADERS = \
     l2tp_event.h
 
-pppol2tp_la_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir}
+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}
+openl2tp_la_CPPFLAGS = -I${top_srcdir}
 openl2tp_la_LDFLAGS = -module -avoid-version
 openl2tp_la_SOURCES = openl2tp.c
 
     etc/realms \
     etc/servers
 
-RADIUS_CPPFLAGS = -I${top_srcdir}/include -I${top_srcdir} -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)
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#include <linux/ppp_defs.h>
-#include <linux/if_ppp.h>
+#include <linux/ppp-ioctl.h>
+
 
 #ifdef PPP_WITH_IPV6CP
 #include <linux/netlink.h>
     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;
 
 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 \
 
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
-#include "ppp_defs.h"
+#include <net/ppp_defs.h>
+
 #include "ppp-comp.h"
 
 #if DO_BSD_COMPRESS
     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;
 }
 
 /*
 
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
-#include "ppp_defs.h"
+#include <net/ppp_defs.h>
+
 #include "ppp-comp.h"
 #include "zlib.h"
 
     *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;
 }
 
 /*
 
 #include <stdlib.h>
 #include <time.h>
 #include <sys/types.h>
-#include "ppp_defs.h"
+#include <net/ppp_defs.h>
 #include "ppp-comp.h"
 
 int hexmode;
        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;
 
 pppstats_CFLAGS =
 pppstats_CPPFLAGS =
 
-if LINUX
-pppstats_CFLAGS += -I${top_srcdir}/include
-endif
-
 if SUNOS
 pppstats_CPPFLAGS += -DSTREAMS
 endif
 
 #ifndef __linux__
 #include <net/if.h>
 #include <net/ppp_defs.h>
-#include <net/if_ppp.h>
 #else
 /* Linux */
 #if __GLIBC__ >= 2
 #endif
 #include <linux/ppp_defs.h>
 #include <linux/if_ppp.h>
+
 #endif /* __linux__ */
 
 #else  /* STREAMS */
 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;
            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");
     }
 
 #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 */