1From af55a6a414d32c12f9ef3cab778385a361e1ad6d Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?Eivind=20N=C3=A6ss?= <eivnaes@yahoo.com> 3Date: Sat, 25 Mar 2023 20:51:52 +0000 4Subject: [PATCH] vpn: Adding support for latest pppd 2.5.0 release 5 6The API has gone through a significant overhaul, and this change fixes any compile issues. 71) Fixes to configure.ac itself 82) Cleanup in pppd plugin itself 9 10Adding a libppp-compat.h file to mask for any differences in the version. 11 12Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=a48864a2e5d2a725dfc6eef567108bc13b43857f] 13Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> 14 15--- 16 scripts/libppp-compat.h | 127 ++++++++++++++++++++++++++++++++++++++++ 17 1 file changed, 127 insertions(+) 18 create mode 100644 scripts/libppp-compat.h 19 20diff --git a/scripts/libppp-compat.h b/scripts/libppp-compat.h 21new file mode 100644 22index 0000000..eee1d09 23--- /dev/null 24+++ b/scripts/libppp-compat.h 25@@ -0,0 +1,127 @@ 26+/* Copyright (C) Eivind Naess, eivnaes@yahoo.com */ 27+/* SPDX-License-Identifier: GPL-2.0-or-later */ 28+ 29+#ifndef __LIBPPP_COMPAT_H__ 30+#define __LIBPPP_COMPAT_H__ 31+ 32+/* Define USE_EAPTLS compile with EAP TLS support against older pppd headers, 33+ * pppd >= 2.5.0 use PPP_WITH_EAPTLS and is defined in pppdconf.h */ 34+#define USE_EAPTLS 1 35+ 36+/* Define INET6 to compile with IPv6 support against older pppd headers, 37+ * pppd >= 2.5.0 use PPP_WITH_IPV6CP and is defined in pppdconf.h */ 38+#define INET6 1 39+ 40+/* PPP < 2.5.0 defines and exports VERSION which overlaps with current package VERSION define. 41+ * this silly macro magic is to work around that. */ 42+#undef VERSION 43+#include <pppd/pppd.h> 44+ 45+#ifndef PPPD_VERSION 46+#define PPPD_VERSION VERSION 47+#endif 48+ 49+#include <pppd/fsm.h> 50+#include <pppd/ccp.h> 51+#include <pppd/eui64.h> 52+#include <pppd/ipcp.h> 53+#include <pppd/ipv6cp.h> 54+#include <pppd/eap.h> 55+#include <pppd/upap.h> 56+ 57+#ifdef HAVE_PPPD_CHAP_H 58+#include <pppd/chap.h> 59+#endif 60+ 61+#ifdef HAVE_PPPD_CHAP_NEW_H 62+#include <pppd/chap-new.h> 63+#endif 64+ 65+#ifdef HAVE_PPPD_CHAP_MS_H 66+#include <pppd/chap_ms.h> 67+#endif 68+ 69+#ifndef PPP_PROTO_CHAP 70+#define PPP_PROTO_CHAP 0xc223 71+#endif 72+ 73+#ifndef PPP_PROTO_EAP 74+#define PPP_PROTO_EAP 0xc227 75+#endif 76+ 77+ 78+#if WITH_PPP_VERSION < PPP_VERSION(2,5,0) 79+ 80+static inline bool 81+debug_on (void) 82+{ 83+ return debug; 84+} 85+ 86+static inline const char 87+*ppp_ipparam (void) 88+{ 89+ return ipparam; 90+} 91+ 92+static inline int 93+ppp_ifunit (void) 94+{ 95+ return ifunit; 96+} 97+ 98+static inline const char * 99+ppp_ifname (void) 100+{ 101+ return ifname; 102+} 103+ 104+static inline int 105+ppp_get_mtu (int idx) 106+{ 107+ return netif_get_mtu(idx); 108+} 109+ 110+typedef enum ppp_notify 111+{ 112+ NF_PID_CHANGE, 113+ NF_PHASE_CHANGE, 114+ NF_EXIT, 115+ NF_SIGNALED, 116+ NF_IP_UP, 117+ NF_IP_DOWN, 118+ NF_IPV6_UP, 119+ NF_IPV6_DOWN, 120+ NF_AUTH_UP, 121+ NF_LINK_DOWN, 122+ NF_FORK, 123+ NF_MAX_NOTIFY 124+} ppp_notify_t; 125+ 126+typedef void (ppp_notify_fn) (void *ctx, int arg); 127+ 128+static inline void 129+ppp_add_notify (ppp_notify_t type, ppp_notify_fn *func, void *ctx) 130+{ 131+ struct notifier **list[NF_MAX_NOTIFY] = { 132+ [NF_PID_CHANGE ] = &pidchange, 133+ [NF_PHASE_CHANGE] = &phasechange, 134+ [NF_EXIT ] = &exitnotify, 135+ [NF_SIGNALED ] = &sigreceived, 136+ [NF_IP_UP ] = &ip_up_notifier, 137+ [NF_IP_DOWN ] = &ip_down_notifier, 138+ [NF_IPV6_UP ] = &ipv6_up_notifier, 139+ [NF_IPV6_DOWN ] = &ipv6_down_notifier, 140+ [NF_AUTH_UP ] = &auth_up_notifier, 141+ [NF_LINK_DOWN ] = &link_down_notifier, 142+ [NF_FORK ] = &fork_notifier, 143+ }; 144+ 145+ struct notifier **notify = list[type]; 146+ if (notify) { 147+ add_notifier(notify, func, ctx); 148+ } 149+} 150+ 151+#endif /* #if WITH_PPP_VERSION < PPP_VERSION(2,5,0) */ 152+#endif /* #if__LIBPPP_COMPAT_H__ */ 153