Expose all CSTP options to script
authorDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 29 Apr 2009 13:29:42 +0000 (14:29 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 29 Apr 2009 13:29:50 +0000 (14:29 +0100)
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
tun.c

diff --git a/tun.c b/tun.c
index 2bf248b..ca06247 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -147,6 +147,30 @@ static int appendenv(const char *opt, const char *new)
        return setenv(opt, buf, 1);
 }
 
+static void setenv_cstp_opts(struct openconnect_info *vpninfo)
+{
+       char *env_buf;
+       int buflen = 0;
+       int bufofs = 0;
+       struct vpn_option *opt;
+
+       for (opt = vpninfo->cstp_options; opt; opt = opt->next)
+               buflen += 2 + strlen(opt->option) + strlen(opt->value);
+
+       env_buf = malloc(buflen + 1);
+       if (!env_buf)
+               return;
+
+       env_buf[buflen] = 0;
+
+       for (opt = vpninfo->cstp_options; opt; opt = opt->next)
+               bufofs += snprintf(env_buf + bufofs, buflen - bufofs,
+                                  "%s=%s\n", opt->option, opt->value);
+
+       setenv("CISCO_CSTP_OPTIONS", env_buf, 1);
+       free(env_buf);
+}
+
 static void set_script_env(struct openconnect_info *vpninfo)
 {
        struct sockaddr_in *sin = (void *)vpninfo->peer_addr;
@@ -210,6 +234,7 @@ static void set_script_env(struct openconnect_info *vpninfo)
                }
                setenv_int("CISCO_SPLIT_EXC", nr_split_excludes);
        }
+       setenv_cstp_opts(vpninfo);
 }
 
 static int script_config_tun(struct openconnect_info *vpninfo)