#
-# Copyright (C) 2006-2011 OpenWrt.org
+# Copyright (C) 2006-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
PKG_NAME:=aiccu
PKG_VERSION:=20070115
-PKG_RELEASE:=9
+PKG_RELEASE:=10
PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.sixxs.net/archive/sixxs/aiccu/unix
define Package/aiccu
SECTION:=ipv6
CATEGORY:=IPv6
- DEPENDS:=+libpthread +ip +kmod-sit +kmod-tun
+ DEPENDS:=+libpthread
TITLE:=SixXS Automatic IPv6 Connectivity Client Utility
URL:=http://www.sixxs.net/tools/aiccu/
endef
define Package/aiccu/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/unix-console/$(PKG_NAME) $(1)/usr/sbin/
- $(INSTALL_DIR) $(1)/etc/config
- $(INSTALL_CONF) ./files/aiccu.config $(1)/etc/config/aiccu
- $(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_BIN) ./files/aiccu.init $(1)/etc/init.d/aiccu
endef
$(eval $(call BuildPackage,aiccu))
+++ /dev/null
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006-2011 OpenWrt.org
-START=51
-
-add_config_bool() {
- local section="$1"
- local option="$2"
- local value="$3"
- local default="$4"
- local _val
-
- config_get_bool _val "$section" "$option" "$default"
- [ "$_val" -gt 0 ] && _val="true" || _val="false"
- append args "$3 $_val" "\n"
-}
-
-add_config() {
- local section="$1"
- local option="$2"
- local value="$3"
- local _val
-
- config_get _val "$section" "$option"
- [ -n "$_val" ] && append args "$3 $_val" "\n"
-}
-
-start_instance() {
- local cfg="$1"
- CFGFILE="/var/etc/aiccu-${cfg}.conf"
- PIDFILE="/var/run/aiccu-${cfg}.pid"
- args=""
-
- add_config "$cfg" username username
- add_config "$cfg" password password
- add_config "$cfg" server server
- add_config "$cfg" protocol protocol
- add_config "$cfg" interface ipv6_interface
- add_config "$cfg" tunnel_id tunnel_id
- add_config_bool "$cfg" requiretls requiretls 0
- add_config_bool "$cfg" defaultroute defaultroute 1
- add_config_bool "$cfg" nat behindnat 1
- add_config_bool "$cfg" heartbeat makebeats 1
- append args "daemonize true" "\n"
- append args "pidfile $PIDFILE" "\n"
-
- mkdir -p /var/run /var/etc
- echo -e "$args" > "$CFGFILE"
-
- config_get_bool enabled "$cfg" enabled '1'
- [ "$enabled" -gt 0 ] && aiccu start "$CFGFILE" &
-}
-
-stop_instance() {
- local cfg="$1"
- aiccu stop "/var/etc/aiccu-${cfg}.conf"
-}
-
-restart_instance() {
- local cfg="$1"
- config_get_bool restart "$cfg" restart 0
- [ "$restart" -eq 1 ] && stop_instance "$cfg"
- start_instance "$cfg"
-}
-
-start() {
- config_load aiccu
- config_foreach start_instance aiccu
-}
-
-stop() {
- config_load aiccu
- config_foreach stop_instance aiccu
-}
-
-restart() {
- config_load aiccu
- config_foreach restart_instance aiccu
-}
+++ /dev/null
---- a/common/tic.c
-+++ b/common/tic.c
-@@ -60,7 +60,7 @@ int tic_checktime(time_t epochtime)
- return 0;
- }
-
--bool tic_Login(struct TIC_conf *tic, const char *username, const char *password, const char *server)
-+bool tic_Login(struct TIC_conf *tic, const char *username, const char *password, const char *server, bool *fatal)
- {
- char buf[1024], sSignature[33], sChallenge[1024];
- int i;
-@@ -74,6 +74,7 @@ bool tic_Login(struct TIC_conf *tic, con
- #endif
-
- D(dolog(LOG_DEBUG, "Trying to connect to TIC server %s\n", server));
-+ *fatal = false;
-
- /* Connect to the TIC server */
- tic->sock = connect_client(server, TIC_PORT, AF_INET, SOCK_STREAM);
-@@ -166,6 +167,7 @@ bool tic_Login(struct TIC_conf *tic, con
- if (buf[0] != '2')
- {
- dolog(LOG_ERR, "Time not available? %s\n", &buf[4]);
-+ *fatal = true;
- return false;
- }
-
-@@ -199,6 +201,7 @@ bool tic_Login(struct TIC_conf *tic, con
- if (g_aiccu->requiretls)
- {
- dolog(LOG_ERR, "TIC Server does not support TLS and TLS is required\n");
-+ *fatal = true;
- return false;
- }
- if (g_aiccu->verbose) dolog(LOG_WARNING, "TIC Server does not support TLS but TLS is not required, continuing\n");
-@@ -217,6 +220,7 @@ bool tic_Login(struct TIC_conf *tic, con
- if (buf[0] != '2')
- {
- dolog(LOG_ERR, "Username not accepted: %s.\n", &buf[4]);
-+ *fatal = true;
- return false;
- }
-
-@@ -231,6 +235,7 @@ bool tic_Login(struct TIC_conf *tic, con
- if (buf[0] != '2')
- {
- dolog(LOG_ERR, "Challenge not correct: %s.\n", &buf[4]);
-+ *fatal = true;
- return false;
- }
-
-@@ -252,6 +257,7 @@ bool tic_Login(struct TIC_conf *tic, con
- {
- tic_Logout(tic, NULL);
- dolog(LOG_ERR, "Response not accepted: %s.\n", &buf[4]);
-+ *fatal = true;
- return false;
- }
-
---- a/unix-console/main.c
-+++ b/unix-console/main.c
-@@ -76,8 +76,9 @@ int list_tunnels(void);
- int list_tunnels(void)
- {
- struct TIC_sTunnel *hsTunnel, *t;
-+ bool is_fatal = false;
-
-- if (!tic_Login(g_aiccu->tic, g_aiccu->username, g_aiccu->password, g_aiccu->server)) return 0;
-+ if (!tic_Login(g_aiccu->tic, g_aiccu->username, g_aiccu->password, g_aiccu->server, &is_fatal)) return 0;
-
- hsTunnel = tic_ListTunnels(g_aiccu->tic);
-
-@@ -153,9 +154,26 @@ struct TIC_Tunnel *get_tunnel(void)
-
- struct TIC_sTunnel *hsTunnel, *t;
- struct TIC_Tunnel *hTunnel;
-+ bool is_fatal = false;
-+ int retry_intv = 10;
-
- /* Login to the TIC Server */
-- if (!tic_Login(g_aiccu->tic, g_aiccu->username, g_aiccu->password, g_aiccu->server)) return NULL;
-+ while (!tic_Login(g_aiccu->tic, g_aiccu->username, g_aiccu->password, g_aiccu->server, &is_fatal))
-+ {
-+ if (!is_fatal)
-+ {
-+ dolog(LOG_ERR, "Retrying TIC login in %d seconds...\n", retry_intv);
-+ sleep(retry_intv);
-+
-+ if (retry_intv < 120)
-+ retry_intv += 10;
-+ }
-+ else
-+ {
-+ dolog(LOG_ERR, "Fatal error occured during login, aborting\n");
-+ return NULL;
-+ }
-+ }
-
- /*
- * Don't try to list the tunnels when
---- a/common/tic.h
-+++ b/common/tic.h
-@@ -120,7 +120,7 @@ struct TIC_conf
- **********************************************************/
-
- /* Login to/Logout from the TIC Server */
--bool tic_Login(struct TIC_conf *tic, const char *username, const char *password, const char *server);
-+bool tic_Login(struct TIC_conf *tic, const char *username, const char *password, const char *server, bool *fatal);
- void tic_Logout(struct TIC_conf *tic, const char *quitmsg);
-
- /* Check if the time is in range */