This patch adds a new tool called he-update to the
packages repository. With it you can update the
dynamic IPv4 address of the endpoint of your 
Hurricane Electric IPv6 tunnel (tunnelbroker.net)
automatically.
It is designed to work even in really hard
environments like trough NAT and broken WLAN
connections.
After a change of the IPv4 address from your ISP
the IPv6 tunnel should work again in 1 to 2 minutes.

Signed-off-by: Alina Friedrichsen <[email protected]>

-- 
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss 
für nur 17,95 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02
Index: he-update/files/he_update.config
===================================================================
--- he-update/files/he_update.config	(Revision 0)
+++ he-update/files/he_update.config	(Revision 0)
@@ -0,0 +1,8 @@
+package 'he_update'
+
+config 'he-update'
+	option 'ifname' 'sixbone'
+	option 'tunnel_id' ''
+	option 'username' ''
+	option 'password' ''
+
Index: he-update/files/he-update.init
===================================================================
--- he-update/files/he-update.init	(Revision 0)
+++ he-update/files/he-update.init	(Revision 0)
@@ -0,0 +1,94 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2009  Alina Friedrichsen <[email protected]>
+START=47
+
+validate_varname() {
+	local varname="$1"
+	[ -z "$varname" ] && return 1
+	[ "$varname" != "${varname%%[!A-Za-z0-9_]*}" ] && return 1
+	[ "$varname" != "${varname#[!A-Za-z_]}" ] && return 1
+	return 0
+}
+
+validate_token() {
+	local token="$1"
+	[ -z "$token" ] && return 1
+	[ "$token" != "${token%%[!A-Za-z0-9_]*}" ] && return 1
+	return 0
+}
+
+start() {
+	package() {
+		UCI_PACKAGE="$1"
+		return 0
+	}
+
+	begin_config() {
+		INTERFACE=
+		IFNAME=
+		TUNNEL_ID=
+		USERNAME=
+		PASSWORD=
+		REMOTEIP6=
+
+		return 0
+	}
+
+	end_config() {
+		validate_token "$TUNNEL_ID" || return 0
+
+		if [ -z "$IFNAME" ]; then
+			if validate_varname "$INTERFACE"; then
+				IFNAME="$(uci -p /var/state/ -- get "network.$INTERFACE.ifname" 2> /dev/null)"
+			fi
+		fi
+		[ -z "$IFNAME" ] && return 0
+
+		start-stop-daemon -q -b -m -p "/var/run/he-watchdog_$TUNNEL_ID.pid" -x /bin/sh -S -- "$(which -- he-watchdog)" "$TUNNEL_ID" "$USERNAME" "$PASSWORD" "$IFNAME" "$REMOTEIP6"
+
+		return 0
+	}
+
+	config() {
+		[ -n "$UCI_TYPE" ] && end_config
+
+		UCI_TYPE="$1"
+		UCI_CONFIG="$2"
+
+		[ -n "$UCI_TYPE" ] && begin_config
+
+		return 0
+	}
+
+	option() {
+		UCI_OPTION="$1"
+		UCI_VALUE="$2"
+
+		if [ "$UCI_PACKAGE" = he_update -a "$UCI_TYPE" = he-update ]; then
+			case "$UCI_OPTION" in
+				interface) INTERFACE="$UCI_VALUE";;
+				ifname) IFNAME="$UCI_VALUE";;
+				tunnel_id) TUNNEL_ID="$UCI_VALUE";;
+				username) USERNAME="$UCI_VALUE";;
+				password) PASSWORD="$UCI_VALUE";;
+				ping6) REMOTEIP6="$UCI_VALUE";;
+			esac
+		fi
+
+		return 0
+	}
+
+	list() {
+		option "$@"
+	}
+
+	UCI_TYPE=
+	eval "$(uci -- export he_update)"
+	[ -n "$UCI_TYPE" ] && end_config
+}
+
+stop() {
+	for pidfile in /var/run/he-watchdog_*.pid; do
+		start-stop-daemon -q -p "$pidfile" -x /bin/sh -K
+	done
+}
Index: he-update/Makefile
===================================================================
--- he-update/Makefile	(Revision 0)
+++ he-update/Makefile	(Revision 0)
@@ -0,0 +1,50 @@
+#
+# Copyright (C) 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_NAME:=he-update
+PKG_VERSION:=0.9.1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://x-alina.freifunk-potsdam.de/downloads/he-update
+PKG_MD5SUM:=e4496fc805e44852fe05aa800e885218
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/he-update
+  SECTION:=ipv6
+  CATEGORY:=IPv6
+  DEPENDS:=+kmod-sit +ip 
+  TITLE:=HE tunnel endpoint update utility
+  URL:=http://x-alina.freifunk-potsdam.de/
+endef
+
+define Package/he-update/conffiles
+/etc/config/he_update
+endef
+
+HE_UPDATE_INSTALLOPTS = \
+	INSTALL_BIN='$(INSTALL_BIN)' \
+	INSTALL_DIR='$(INSTALL_DIR)' \
+	INSTALL_DATA='$(INSTALL_DATA)' \
+	INSTALL_CONF='$(INSTALL_CONF)'
+
+define Build/Compile
+endef
+
+define Package/he-update/install
+	$(MAKE) -C '$(PKG_BUILD_DIR)' $(WEBLOGIN_INSTALLOPTS) DESTDIR='$(1)' install
+	$(INSTALL_DIR) -- '$(1)/etc/config'
+	$(INSTALL_DATA) -- ./files/he_update.config '$(1)/etc/config/he_update'
+	$(INSTALL_DIR) -- '$(1)/etc/init.d'
+	$(INSTALL_BIN) -- ./files/he-update.init '$(1)/etc/init.d/he-update'
+endef
+
+$(eval $(call BuildPackage,he-update))
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to