1 From 084ef529c5fb816927ca54866f66b340265aa9f6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Eivind=20N=C3=A6ss?= <eivnaes@yahoo.com>
3 Date: Sat, 4 Mar 2023 21:20:43 +0000
4 Subject: [PATCH] Adding support for compiling against pppd-2.5.0 (or master
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
13 configure.ac | 37 +++++++-
14 src/nm-fortisslvpn-pppd-compat.h | 93 +++++++++++++++++++
15 src/nm-fortisslvpn-pppd-plugin.c | 24 ++---
16 ...-status.h => nm-fortisslvpn-pppd-status.h} | 0
17 src/nm-fortisslvpn-service.c | 2 +-
18 6 files changed, 145 insertions(+), 16 deletions(-)
19 create mode 100644 src/nm-fortisslvpn-pppd-compat.h
20 rename src/{nm-ppp-status.h => nm-fortisslvpn-pppd-status.h} (100%)
22 diff --git a/Makefile.am b/Makefile.am
23 index b2e5533..e1e5ec9 100644
26 @@ -81,7 +81,7 @@ libexec_PROGRAMS += src/nm-fortisslvpn-service
27 src_nm_fortisslvpn_service_SOURCES = \
28 shared/nm-utils/nm-shared-utils.c \
29 shared/nm-utils/nm-shared-utils.h \
30 - src/nm-ppp-status.h \
31 + src/nm-fortisslvpn-pppd-status.h \
32 src/nm-fortisslvpn-service.h \
33 src/nm-fortisslvpn-service.c \
34 shared/nm-fortissl-properties.c \
35 @@ -106,7 +106,8 @@ src_nm_fortisslvpn_pppd_plugin_la_SOURCES = \
36 shared/nm-utils/nm-shared-utils.c \
37 shared/nm-utils/nm-shared-utils.h \
38 src/nm-fortisslvpn-pppd-plugin.c \
40 + src/nm-fortisslvpn-pppd-compat.h \
41 + src/nm-fortisslvpn-pppd-status.h
42 nodist_src_nm_fortisslvpn_pppd_plugin_la_SOURCES = \
43 src/nm-fortisslvpn-pppd-service-dbus.h
44 src_nm_fortisslvpn_pppd_plugin_la_CPPFLAGS = $(src_cppflags)
45 diff --git a/configure.ac b/configure.ac
46 index a998707..877493e 100644
49 @@ -19,7 +19,10 @@ AC_PROG_CC
55 AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
56 +PKG_PROG_PKG_CONFIG()
60 @@ -37,20 +40,50 @@ dnl
64 -AC_CHECK_HEADERS(fcntl.h paths.h sys/ioctl.h sys/time.h syslog.h unistd.h)
65 +AC_CHECK_HEADERS(fcntl.h paths.h stdarg.h stdbool.h sys/ioctl.h sys/time.h syslog.h unistd.h)
67 AC_CHECK_HEADERS(pppd/pppd.h,,
68 AC_MSG_ERROR(couldn't find pppd.h. pppd development headers are required.))
71 +dnl Check the presense of other pppd/*.h files
79 +dnl Versions >= 2.5.0 will have pkg-config support
80 +PKG_CHECK_EXISTS([pppd],
81 + [AS_VAR_SET([pppd_pkgconfig_support],[yes])])
84 +dnl Get the version of pppd using pkg-config, assume 2.4.9 if not present
86 +if test x"$pppd_pkgconfig_support" = xyes; then
87 + PPPD_VERSION=`$PKG_CONFIG --modversion pppd`
91 AC_ARG_WITH([pppd-plugin-dir], AS_HELP_STRING([--with-pppd-plugin-dir=DIR], [path to the pppd plugins directory]))
93 if test -n "$with_pppd_plugin_dir" ; then
94 PPPD_PLUGIN_DIR="$with_pppd_plugin_dir"
96 - PPPD_PLUGIN_DIR="${libdir}/pppd/2.4.5"
97 + PPPD_PLUGIN_DIR="${libdir}/pppd/$PPPD_VERSION"
99 AC_SUBST(PPPD_PLUGIN_DIR)
101 +dnl The version of pppd dictates what code can be included, i.e. enable use of
102 +dnl #if WITH_PPP_VERSION >= PPP_VERSION(2,5,0) in the code
103 +AC_DEFINE_UNQUOTED([PPP_VERSION(x,y,z)],
104 + [((x & 0xFF) << 16 | (y & 0xFF) << 8 | (z & 0xFF) << 0)],
105 + [Macro to help determine the particular version of pppd])
106 +PPP_VERSION=$(echo $PPPD_VERSION | sed -e "s/\./\,/g")
107 +AC_DEFINE_UNQUOTED(WITH_PPP_VERSION, PPP_VERSION($PPP_VERSION),
108 + [The real version of pppd represented as an int])
111 dnl Checks for typedefs, structures, and compiler characteristics.
113 diff --git a/src/nm-fortisslvpn-pppd-compat.h b/src/nm-fortisslvpn-pppd-compat.h
115 index 0000000..9a02908
117 +++ b/src/nm-fortisslvpn-pppd-compat.h
119 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
120 +/* nm-sstp-service - sstp (and other pppd) integration with NetworkManager
122 + * Copyright (C) Eivind Næss, eivnaes@yahoo.com
124 + * This program is free software; you can redistribute it and/or modify
125 + * it under the terms of the GNU General Public License as published by
126 + * the Free Software Foundation; either version 2 of the License, or
127 + * (at your option) any later version.
129 + * This program is distributed in the hope that it will be useful,
130 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
131 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132 + * GNU General Public License for more details.
134 + * You should have received a copy of the GNU General Public License along
135 + * with this program; if not, write to the Free Software Foundation, Inc.,
136 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
140 +#ifndef __NM_FORTISSLVPN_PPPD_COMPAT_H__
141 +#define __NM_FORTISSLVPN_PPPD_COMPAT_H__
145 +// PPP < 2.5.0 defines and exports VERSION which overlaps with current package VERSION define.
146 +// this silly macro magic is to work around that.
149 +#include <pppd/pppd.h>
151 +#ifndef PPPD_VERSION
152 +#define PPPD_VERSION VERSION
155 +#include <pppd/fsm.h>
156 +#include <pppd/ccp.h>
157 +#include <pppd/eui64.h>
158 +#include <pppd/ipcp.h>
159 +#include <pppd/ipv6cp.h>
160 +#include <pppd/eap.h>
161 +#include <pppd/upap.h>
163 +#ifdef HAVE_PPPD_CHAP_H
164 + #include <pppd/chap.h>
167 +#ifdef HAVE_PPPD_CHAP_NEW_H
168 + #include <pppd/chap-new.h>
171 +#ifdef HAVE_PPPD_CHAP_MS_H
172 + #include <pppd/chap_ms.h>
175 +#ifndef PPP_PROTO_CHAP
176 +#define PPP_PROTO_CHAP 0xc223
179 +#ifndef PPP_PROTO_EAP
180 +#define PPP_PROTO_EAP 0xc227
183 +#if WITH_PPP_VERSION < PPP_VERSION(2,5,0)
185 +static inline bool debug_on(void)
190 +static inline const char *ppp_ipparam(void)
195 +static inline int ppp_ifunit(void)
200 +static inline const char *ppp_ifname(void)
205 +static inline int ppp_get_mtu(int idx)
207 + return netif_get_mtu(idx);
210 +#endif // #if WITH_PPP_VERSION < PPP_VERSION(2,5,0)
211 +#endif // #ifdef __NM_FORTISSLVPN_PPPD_COMPAT_H__
212 diff --git a/src/nm-fortisslvpn-pppd-plugin.c b/src/nm-fortisslvpn-pppd-plugin.c
213 index f2ad262..c2efb9a 100644
214 --- a/src/nm-fortisslvpn-pppd-plugin.c
215 +++ b/src/nm-fortisslvpn-pppd-plugin.c
217 #define ___CONFIG_H__
220 -#include <pppd/pppd.h>
221 -#include <pppd/fsm.h>
222 -#include <pppd/ipcp.h>
224 -#include "nm-default.h"
226 #include <sys/types.h>
228 #include <sys/socket.h>
231 #include <glib/gstdio.h>
233 +#include "nm-fortisslvpn-pppd-status.h"
234 +#include "nm-fortisslvpn-pppd-compat.h"
235 #include "nm-fortisslvpn-pppd-service-dbus.h"
236 -#include "nm-fortisslvpn-service.h"
237 -#include "nm-ppp-status.h"
239 +#include "nm-default.h"
240 +#include "nm-fortisslvpn-service.h"
241 #include "nm-utils/nm-shared-utils.h"
242 #include "nm-utils/nm-vpn-plugin-macros.h"
244 @@ -80,7 +76,7 @@ static struct {
246 int plugin_init (void);
248 -char pppd_version[] = VERSION;
249 +char pppd_version[] = PPPD_VERSION;
252 chroot_sandbox (void)
253 @@ -296,7 +292,7 @@ get_ip4_routes (in_addr_t ouraddr)
255 nm_ip_up (void *data, int arg)
257 - guint32 pppd_made_up_address = htonl (0x0a404040 + ifunit);
258 + guint32 pppd_made_up_address = htonl (0x0a404040 + ppp_ifunit());
259 ipcp_options opts = ipcp_gotoptions[0];
260 ipcp_options peer_opts = ipcp_hisoptions[0];
261 GVariantBuilder builder;
262 @@ -317,7 +313,7 @@ nm_ip_up (void *data, int arg)
264 g_variant_builder_add (&builder, "{sv}",
265 NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV,
266 - g_variant_new_string (ifname));
267 + g_variant_new_string (ppp_ifname()));
269 str = g_getenv ("VPN_GATEWAY");
271 @@ -442,8 +438,14 @@ plugin_init (void)
275 +#if WITH_PPP_VERSION < PPP_VERSION(2,5,0)
276 add_notifier (&phasechange, nm_phasechange, NULL);
277 add_notifier (&ip_up_notifier, nm_ip_up, NULL);
278 add_notifier (&exitnotify, nm_exit_notify, NULL);
280 + ppp_add_notify (NF_PHASE_CHANGE, nm_phasechange, NULL);
281 + ppp_add_notify (NF_IP_UP, nm_ip_up, NULL);
282 + ppp_add_notify (NF_EXIT, nm_exit_notify, NULL);
286 diff --git a/src/nm-ppp-status.h b/src/nm-fortisslvpn-pppd-status.h
287 similarity index 100%
288 rename from src/nm-ppp-status.h
289 rename to src/nm-fortisslvpn-pppd-status.h
290 diff --git a/src/nm-fortisslvpn-service.c b/src/nm-fortisslvpn-service.c
291 index 6c340d0..a8483c2 100644
292 --- a/src/nm-fortisslvpn-service.c
293 +++ b/src/nm-fortisslvpn-service.c
295 #include <glib/gstdio.h>
297 #include "nm-fortissl-properties.h"
298 -#include "nm-ppp-status.h"
299 +#include "nm-fortisslvpn-pppd-status.h"
300 #include "nm-fortisslvpn-pppd-service-dbus.h"
301 #include "nm-utils/nm-shared-utils.h"
302 #include "nm-utils/nm-vpn-plugin-macros.h"
308 From 8773f772d39f8eee6edc1fd2e5437c754ed41e1e Mon Sep 17 00:00:00 2001
309 From: =?UTF-8?q?Eivind=20N=C3=A6ss?= <eivnaes@yahoo.com>
310 Date: Sat, 4 Mar 2023 21:29:54 +0000
311 Subject: [PATCH] Fixing configure.ac from previous change
313 Content-Type: text/plain; charset=UTF-8
314 Content-Transfer-Encoding: 8bit
316 Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
318 configure.ac | 6 +-----
319 1 file changed, 1 insertion(+), 5 deletions(-)
321 diff --git a/configure.ac b/configure.ac
322 index 877493e..a5b4abb 100644
325 @@ -47,11 +47,7 @@ AC_CHECK_HEADERS(pppd/pppd.h,,
328 dnl Check the presense of other pppd/*.h files
334 +AC_CHECK_HEADERS(pppd/chap.h pppd/chap-new.h pppd/chap_ms.h)
337 dnl Versions >= 2.5.0 will have pkg-config support