From 97697c332fd4a67878b0aa8af8a03d1b1ef7c298 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juhosg@openwrt.org>
Date: Thu, 3 May 2012 09:38:58 +0000
Subject: [PATCH] Add ppp-mod-pppol2tp subpackage to ppp

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

SVN-Revision: 31564
---
 package/ppp/Makefile                          | 19 ++++++++++++++++++-
 package/ppp/files.old/etc/ppp/ip-down         |  2 +-
 package/ppp/files.old/etc/ppp/ip-up           |  2 +-
 .../patches/400-simplify_kernel_checks.patch  | 16 ++++++++++++++++
 4 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/package/ppp/Makefile b/package/ppp/Makefile
index ed86a8ae45..b60ae7cb68 100644
--- a/package/ppp/Makefile
+++ b/package/ppp/Makefile
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=ppp
 PKG_VERSION:=2.4.5
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=ftp://ftp.samba.org/pub/ppp/
@@ -95,6 +95,16 @@ define Package/ppp-mod-radius/conffiles
 /etc/ppp/radius/
 endef
 
+define Package/ppp-mod-pppol2tp
+$(call Package/ppp/Default)
+  DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) +kmod-pppol2tp
+  TITLE:=PPPoL2TP plugin
+endef
+
+define Package/ppp-mod-pppol2tp/description
+This package contains a PPPoL2TP (PPP over L2TP) plugin for ppp.
+endef
+
 define Package/chat
 $(call Package/ppp/Default)
   DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink)
@@ -220,6 +230,12 @@ define Package/ppp-mod-radius/install
 		$(1)/etc/ppp/radius/
 endef
 
+define Package/ppp-mod-pppol2tp/install
+	$(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION)
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/pppol2tp.so \
+		$(1)/usr/lib/pppd/$(PKG_VERSION)/
+endef
+
 define Package/chat/install
 	$(INSTALL_DIR) $(1)/usr/sbin
 	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/chat $(1)/usr/sbin/
@@ -240,6 +256,7 @@ $(eval $(call BuildPackage,ppp-multilink))
 $(eval $(call BuildPackage,ppp-mod-pppoa))
 $(eval $(call BuildPackage,ppp-mod-pppoe))
 $(eval $(call BuildPackage,ppp-mod-radius))
+$(eval $(call BuildPackage,ppp-mod-pppol2tp))
 $(eval $(call BuildPackage,chat))
 $(eval $(call BuildPackage,pppdump))
 $(eval $(call BuildPackage,pppstats))
diff --git a/package/ppp/files.old/etc/ppp/ip-down b/package/ppp/files.old/etc/ppp/ip-down
index 487ff6b46b..994b15a976 100755
--- a/package/ppp/files.old/etc/ppp/ip-down
+++ b/package/ppp/files.old/etc/ppp/ip-down
@@ -10,7 +10,7 @@ export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
 [ -z "$PPP_IPPARAM" ] || {
 	case "$PPP_IFACE" in
 		# only handle uci managed interfaces here, others are done by generic hotplug
-		3g-*|ppp-*|pppoa-*|pppoe-*|pptp-*)
+		3g-*|ppp-*|pppoa-*|pppoe-*|pptp-*|l2tp-*)
 			env -i ACTION="ifdown" INTERFACE="$PPP_IPPARAM" DEVICE="$PPP_IFACE" PROTO=ppp /sbin/hotplug-call "iface"
 			uci_revert_state network "$PPP_IPPARAM"
 		;;
diff --git a/package/ppp/files.old/etc/ppp/ip-up b/package/ppp/files.old/etc/ppp/ip-up
index 353f667895..44f660bef1 100755
--- a/package/ppp/files.old/etc/ppp/ip-up
+++ b/package/ppp/files.old/etc/ppp/ip-up
@@ -23,7 +23,7 @@ export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
 [ -z "$PPP_IPPARAM" ] || {
 	case "$PPP_IFACE" in
 		# only handle uci managed interfaces here, others are done by generic hotplug
-		3g-*|ppp-*|pppoa-*|pppoe-*|pptp-*)
+		3g-*|ppp-*|pppoa-*|pppoe-*|pptp-*|l2tp-*)
 			env -i ACTION="ifup" INTERFACE="$PPP_IPPARAM" DEVICE="$PPP_IFACE" PROTO=ppp /sbin/hotplug-call "iface"
 		;;
 	esac
diff --git a/package/ppp/patches/400-simplify_kernel_checks.patch b/package/ppp/patches/400-simplify_kernel_checks.patch
index c48141311e..6ddf86a1ba 100644
--- a/package/ppp/patches/400-simplify_kernel_checks.patch
+++ b/package/ppp/patches/400-simplify_kernel_checks.patch
@@ -126,3 +126,19 @@
      add_options(Options);
  
      info("RP-PPPoE plugin version %s compiled against pppd %s",
+--- a/pppd/plugins/pppol2tp/pppol2tp.c	2010-11-15 12:12:43.000000000 +0000
++++ b/pppd/plugins/pppol2tp/pppol2tp.c	2012-04-24 15:53:58.806260309 +0100
+@@ -488,12 +488,7 @@ static void pppol2tp_check_options(void)
+ 
+ void plugin_init(void)
+ {
+-#if defined(__linux__)
+-	extern int new_style_driver;	/* From sys-linux.c */
+-	if (!ppp_available() && !new_style_driver)
+-		fatal("Kernel doesn't support ppp_generic - "
+-		    "needed for PPPoL2TP");
+-#else
++#if !defined(__linux__)
+ 	fatal("No PPPoL2TP support on this OS");
+ #endif
+ 	add_options(pppol2tp_options);
-- 
GitLab