add n2n
authorTravis Kemen <thepeople@openwrt.org>
Thu, 10 Jul 2008 02:34:06 +0000 (02:34 +0000)
committerTravis Kemen <thepeople@openwrt.org>
Thu, 10 Jul 2008 02:34:06 +0000 (02:34 +0000)
SVN-Revision: 11760

net/n2n/Makefile [new file with mode: 0644]
net/n2n/files/n2n.config [new file with mode: 0644]
net/n2n/files/n2n.init [new file with mode: 0644]

diff --git a/net/n2n/Makefile b/net/n2n/Makefile
new file mode 100644 (file)
index 0000000..a1172b9
--- /dev/null
@@ -0,0 +1,53 @@
+#
+## Copyright (C) 2007-2008 OpenWrt.org
+#
+## This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+
+include $(TOPDIR)/rules.mk
+
+PKG_BRANCH:=trunk
+PKG_SOURCE_URL:=https://svn.ntop.org/svn/ntop/trunk/n2n
+PKG_REV:=3561
+
+PKG_NAME:=n2n
+PKG_VERSION:=$(PKG_REV)
+PKG_RELEASE:=1
+
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+PKG_SOURCE_PROTO:=svn
+PKG_SOURCE_VERSION:=$(PKG_REV)
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/n2n
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=VPN tunneling daemon
+  URL:=http://www.ntop.org/n2n/
+  SUBMENU:=VPN
+  DEPENDS:=+libpthread +kmod-tun
+endef
+
+define Build/Compile
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+       $(TARGET_CONFIGURE_OPTS) \
+       CFLAGS="$(TARGET_CFLAGS)"
+endef
+
+define Package/n2n/install
+       $(INSTALL_DIR) $(1)/sbin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/edge $(1)/sbin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/supernode $(1)/sbin/
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/n2n.config $(1)/etc/config/n2n
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/n2n.init $(1)/etc/init.d/n2n
+endef
+
+$(eval $(call BuildPackage,n2n))
diff --git a/net/n2n/files/n2n.config b/net/n2n/files/n2n.config
new file mode 100644 (file)
index 0000000..bf4acfe
--- /dev/null
@@ -0,0 +1,7 @@
+config edge
+       option ipaddr           ''
+       option supernode        ''
+       option port             ''
+       option community        ''
+       option key              ''
+       option route            ''
diff --git a/net/n2n/files/n2n.init b/net/n2n/files/n2n.init
new file mode 100644 (file)
index 0000000..4730112
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org
+START=90
+
+config_cb() {
+       local cfg="$CONFIG_SECTION"
+       config_get configname "$cfg" TYPE
+
+       case "$configname" in
+               edge)
+                       config_get ipaddr "$cfg" ipaddr
+                       config_get supernode "$cfg" supernode
+                       config_get port "$cfg" port
+                       config_get community "$cfg" community
+                       config_get key "$cfg" key
+                       config_get_bool route "$cfg" route 0
+                       [ "$route" = "1" ] && args='-r'
+                       if [ "$ipaddr" != "" ]; then
+                               edge -f $args -a $ipaddr -c $community -k $key -l ${supernode}:${port}
+                       fi
+               ;;
+               supernode)
+                       config_get port "$cfg" port
+                       if [ "$port" != "" ]; then
+                               supernode -l $port &
+                       fi
+               ;;
+       esac
+}
+
+start() {
+       config_load n2n
+}
+stop() {
+       killall edge
+       killall supernode
+}