PPtP right now works with a pure userland implementation though there is
perfectly working support for kernel-accelerated PPtP.
Having this as a seperate package is a bit ugly, I think it should be a patch
on top of the ppp package adding ppp-mod-pptp...?

Signed-off-by: Daniel Golle <dgo...@allnet.de>

---
 package/accel-pptp/Makefile           |   78 +++++++++++++++++++++++++++++++++
 package/accel-pptp/files/options.pptp |    8 ++++
 package/accel-pptp/files/pptp.sh      |   58 ++++++++++++++++++++++++
 3 files changed, 144 insertions(+)
 create mode 100644 package/accel-pptp/Makefile
 create mode 100644 package/accel-pptp/files/options.pptp
 create mode 100644 package/accel-pptp/files/pptp.sh

diff --git a/package/accel-pptp/Makefile b/package/accel-pptp/Makefile
new file mode 100644
index 0000000..4ccd52e
--- /dev/null
+++ b/package/accel-pptp/Makefile
@@ -0,0 +1,78 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=accel-pptp
+PKG_VERSION:=0.8.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@SF/accel-pptp
+PKG_MD5SUM:=061ca3991fb69e0e79cb872b0aaf1d89
+
+PKG_PPP_VERSION:=2.4.5
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/accel-pptp
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=PPTP client
+  MAINTAINER:=Jo-Philipp Wich <x...@subsignal.org>
+  URL:=http://pptpclient.sourceforge.net/
+  DEPENDS:=+ppp +kmod-gre +kmod-pptp +resolveip +ip
+endef
+
+define Package/accel-pptp/description
+ This package contains a PPTP (Point-to-Point Tunneling Protocol) client 
(kernel-accelerated version).
+endef
+
+define Package/accel-pptp/conffiles
+/etc/ppp/options.pptp
+endef
+
+CONFIGURE_ARGS+= \
+        --host=$(GNU_TARGET_NAME) \
+        --build=$(GNU_HOST_NAME) \
+        --prefix="/usr/share/$(PKG_NAME)" \
+        --bindir="/usr/bin" \
+        --libdir="/usr/lib" \
+        --srcdir="$(PKG_BUILD_DIR)/pppd_plugin" \
+        --sysconfdir="/etc/$(PKG_NAME)" \
+        --with-random="/dev/urandom" \
+
+
+MAKE_OPTS+= \
+        PPPD_SRCDIR="$(STAGING_DIR)/usr/include" \
+        PPPD_LIBDIR="$(STAGING_DIR)/usr/lib" \
+        PPPD_VERSION="$(PKG_PPP_VERSION)" \
+        DESTDIR="$(PKG_INSTALL_DIR)"
+
+
+define Build/Configure
+        (cd $(PKG_BUILD_DIR)/pppd_plugin ; \
+        $(TARGET_CONFIGURE_OPTS) KDIR=$(LINUX_DIR) ./configure 
$(CONFIGURE_ARGS) )
+endef
+
+define Build/Compile
+        (cd $(PKG_BUILD_DIR)/pppd_plugin ; \
+        $(MAKE) $(MAKE_OPTS) ; \
+        $(MAKE) $(MAKE_OPTS) install );
+endef
+
+define Package/accel-pptp/install
+       $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_PPP_VERSION)
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/pptp.so.0.0.0 
$(1)/usr/lib/pppd/$(PKG_PPP_VERSION)/pptp.so
+       $(INSTALL_DIR) $(1)/etc/ppp
+       $(INSTALL_DATA) ./files/options.pptp $(1)/etc/ppp/
+       $(INSTALL_DIR) $(1)/lib/network
+       $(INSTALL_BIN) ./files/pptp.sh $(1)/lib/network/
+endef
+
+$(eval $(call BuildPackage,accel-pptp))
diff --git a/package/accel-pptp/files/options.pptp 
b/package/accel-pptp/files/options.pptp
new file mode 100644
index 0000000..56e7d07
--- /dev/null
+++ b/package/accel-pptp/files/options.pptp
@@ -0,0 +1,8 @@
+lock 
+noauth 
+nobsdcomp 
+nodeflate
+idle 0
+defaultroute
+mppe required,no40,no56,stateless
+maxfail 0
diff --git a/package/accel-pptp/files/pptp.sh b/package/accel-pptp/files/pptp.sh
new file mode 100644
index 0000000..69dc159
--- /dev/null
+++ b/package/accel-pptp/files/pptp.sh
@@ -0,0 +1,58 @@
+find_route() {
+       ip route get $1 | sed -e 's/ /\n/g' | \
+            sed -ne '1p;/via/{N;p};/dev/{N;p};/src/{N;p};/mtu/{N;p}'
+}
+
+scan_pptp() {
+       config_set "$1" device "pptp-$1"
+}
+
+stop_interface_pptp() {
+       stop_interface_ppp "$1"
+       for ip in $(uci_get_state network "$1" serv_addrs); do
+               ip route del "$ip" 2>/dev/null
+       done
+}
+
+coldplug_interface_pptp() {
+       setup_interface_pptp "pptp-$1" "$1"
+}
+
+setup_interface_pptp() {
+       local config="$2"
+       local ifname
+
+       local device
+       config_get device "$config" device
+
+       local server
+       config_get server "$config" server
+
+       local buffering
+       config_get_bool buffering "$config" buffering 1
+       [ "$buffering" == 0 ] && buffering="--nobuffer" || buffering=
+
+       for module in slhc ppp_generic ppp_async gre pppox pptp ; do
+               /sbin/insmod $module 2>&- >&-
+       done
+       sleep 1
+
+       local serv_addrs=""
+       for ip in $(resolveip -t 3 "${server}"); do
+               append serv_addrs "$ip"
+               ip route replace $(find_route $ip)
+       done
+       uci_toggle_state network "$config" serv_addrs "$serv_addrs"
+}
+
+       # fix up the netmask
+       config_get netmask "$config" netmask
+       [ -z "$netmask" -o -z "$device" ] || ifconfig $device netmask $netmask
+
+       config_get mtu "$config" mtu
+       mtu=${mtu:-1452}
+       start_pppd "$config" \
+               plugin pptp.so pptp_server $server \
+               file /etc/ppp/options.pptp \
+               mtu $mtu mru $mtu
+}
-- 
1.7.10.1

Attachment: pgpFMLBn6s8pi.pgp
Description: PGP signature

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to