]> git.ipfire.org Git - people/stevee/aiccu.git/commitdiff
Add setup script functionality to Linux client master
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 26 Aug 2015 18:58:56 +0000 (18:58 +0000)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 26 Aug 2015 18:58:56 +0000 (18:58 +0000)
Environment variables are set to pass information about
the tunnel to the called script.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
common/aiccu_linux.c

index b86ad6755958302bd970c2021d6c49a4275a97cb..f8257bd9d07ebea0fd05e0957c92eb336216938a 100755 (executable)
@@ -41,6 +41,8 @@ bool aiccu_os_install(void)
 
 bool aiccu_os_setup(struct TIC_Tunnel *hTunnel)
 {
+       char buffer[1024];
+
        if (hTunnel->uses_tundev == 0)
        {
                aiccu_exec(
@@ -91,6 +93,24 @@ bool aiccu_os_setup(struct TIC_Tunnel *hTunnel)
                        g_aiccu->ipv6_interface);
        }
 
+       if (g_aiccu->setupscript)
+       {
+               setenv("ACTION", "up", 1);
+               setenv("TUNNEL_TYPE", hTunnel->sType, 1);
+               setenv("INTERFACE", g_aiccu->ipv6_interface, 1);
+               setenv("REMOTE_ADDRESS", hTunnel->sIPv6_POP, 1);
+
+               snprintf(buffer, sizeof(buffer), "%s/%u",
+                       hTunnel->sIPv6_Local, hTunnel->nIPv6_PrefixLength);
+               setenv("LOCAL_ADDRESS", buffer, 1);
+               setenv("LINK_LOCAL_ADDRESS", hTunnel->sIPv6_LinkLocal, 1);
+
+               snprintf(buffer, sizeof(buffer), "%u", hTunnel->nMTU);
+               setenv("MTU", buffer, 1);
+
+               aiccu_exec("%s", g_aiccu->setupscript);
+       }
+
        return true;
 }
 
@@ -118,5 +138,12 @@ void aiccu_os_delete(struct TIC_Tunnel *hTunnel)
                        "ip tunnel del %s",
                        g_aiccu->ipv6_interface);
        }
+
+       {
+               setenv("ACTION", "down", 1);
+               setenv("INTERFACE", g_aiccu->ipv6_interface, 1);
+
+               aiccu_exec("%s", g_aiccu->setupscript);
+       }
 }