summaryrefslogtreecommitdiff
path: root/pppd
diff options
context:
space:
mode:
authorEivind Næss <eivnaes@yahoo.com>2022-05-29 22:14:08 -0700
committerEivind Næss <eivnaes@yahoo.com>2022-07-15 15:25:39 -0700
commit199e97bae9c03f5cec5202a511b5c436aff05af9 (patch)
treeaae67baaaf1116f72c7139201589bcde3f72af1a /pppd
parent1d3327b87170d5d8db4a5ad06b465925cff4488a (diff)
downloadppp-199e97bae9c03f5cec5202a511b5c436aff05af9.tar.gz
For Linux, use the Linux / Glibc based defines instead of included headers
This is to ensure compatibility with the OS you are compiling against and that headers are maintained in upstream projects. - Moved PPP_EAP and PPP_ECP into respective header files in lieu of not currently existing in the linux/ppp_defs.h - Unchained the top-level ${topsrc_dir}/include, this folder is included for prosterity and may continue to exist on github, but in the future eliminated from distribution - Bogus upstream file in glibc for <net/if_ppp.h>, its content should be replaced with a simple include to <linux/ppp-ioctl.h>. The lack of an appropriate ifreq structure with ppp_stats or ppp_comp_stats, implementet that inline (and tested). - Updated instances where PPP_FCS() macro would expand the fcstab, while PPP_GOODFCS and PPP_INITFCS is provided in <linux/ppp_defs.h>, the latter is tied to a lookup table. It's used in two places, so add the PPP_FCS macro where applicable. Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
Diffstat (limited to 'pppd')
-rw-r--r--pppd/Makefile.am4
-rw-r--r--pppd/demand.c1
-rw-r--r--pppd/eap.h6
-rw-r--r--pppd/ecp.h10
-rw-r--r--pppd/lcp.c1
-rw-r--r--pppd/plugins/Makefile.am2
-rw-r--r--pppd/plugins/pppoatm/Makefile.am2
-rw-r--r--pppd/plugins/pppoe/Makefile.am4
-rw-r--r--pppd/plugins/pppol2tp/Makefile.am4
-rw-r--r--pppd/plugins/radius/Makefile.am2
-rw-r--r--pppd/sys-linux.c19
11 files changed, 37 insertions, 18 deletions
diff --git a/pppd/Makefile.am b/pppd/Makefile.am
index c316ea4..405671a 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
@@ -68,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 =
diff --git a/pppd/demand.c b/pppd/demand.c
index 3e32079..d610d69 100644
--- a/pppd/demand.c
+++ b/pppd/demand.c
@@ -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.
diff --git a/pppd/eap.h b/pppd/eap.h
index fbc7201..96c5f69 100644
--- a/pppd/eap.h
+++ b/pppd/eap.h
@@ -29,6 +29,12 @@
extern "C" {
#endif
+
+#ifndef PPP_EAP
+#define PPP_EAP 0xc227
+#endif
+
+
/*
* Packet header = Code, id, length.
*/
diff --git a/pppd/ecp.h b/pppd/ecp.h
index 162dace..807a100 100644
--- a/pppd/ecp.h
+++ b/pppd/ecp.h
@@ -32,6 +32,14 @@
*/
#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 */
@@ -44,3 +52,5 @@ extern ecp_options ecp_allowoptions[];
extern ecp_options ecp_hisoptions[];
extern struct protent ecp_protent;
+
+#endif
diff --git a/pppd/lcp.c b/pppd/lcp.c
index 91e73e7..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"
diff --git a/pppd/plugins/Makefile.am b/pppd/plugins/Makefile.am
index 292daf2..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}
+PLUGIN_CPPFLAGS = -I${top_srcdir}
PLUGIN_LDFLAGS = -module -avoid-version
minconn_la_CPPFLAGS = $(PLUGIN_CPPFLAGS)
diff --git a/pppd/plugins/pppoatm/Makefile.am b/pppd/plugins/pppoatm/Makefile.am
index 478aa96..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}
+pppoatm_la_CPPFLAGS = -I${top_srcdir}
pppoatm_la_LDFLAGS = -module -avoid-version
pppoatm_la_SOURCES = pppoatm.c
diff --git a/pppd/plugins/pppoe/Makefile.am b/pppd/plugins/pppoe/Makefile.am
index ce25cd6..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}/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
diff --git a/pppd/plugins/pppol2tp/Makefile.am b/pppd/plugins/pppol2tp/Makefile.am
index c109d22..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}
+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
diff --git a/pppd/plugins/radius/Makefile.am b/pppd/plugins/radius/Makefile.am
index b9f9e14..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} -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/sys-linux.c b/pppd/sys-linux.c
index b68babd..d16f9bf 100644
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -126,8 +126,8 @@
#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>
@@ -1476,20 +1476,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;