]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Add $CISCO_SPLIT_DNS environment variable for vpnc-script
authorDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 8 Jun 2012 15:10:08 +0000 (16:10 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 8 Jun 2012 16:10:13 +0000 (17:10 +0100)
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
cstp.c
openconnect-internal.h
tun.c

diff --git a/cstp.c b/cstp.c
index 0e9e6c1d195ba6190292467c4d1a204668499dc2..63d9527314d8edd09df1c0fb1801e169bd911160 100644 (file)
--- a/cstp.c
+++ b/cstp.c
@@ -183,7 +183,12 @@ static int start_cstp_connection(struct openconnect_info *vpninfo)
                free(inc);
                inc = next;
        }
-       vpninfo->split_includes = vpninfo->split_excludes = NULL;
+       for (inc = vpninfo->split_dns; inc; ) {
+               struct split_include *next = inc->next;
+               free(inc);
+               inc = next;
+       }
+       vpninfo->split_dns = vpninfo->split_includes = vpninfo->split_excludes = NULL;
 
        /* Create (new) random master key for DTLS connection, if needed */
        if (vpninfo->dtls_times.last_rekey + vpninfo->dtls_times.rekey <
@@ -377,6 +382,13 @@ static int start_cstp_connection(struct openconnect_info *vpninfo)
                        vpninfo->vpn_proxy_pac = new_option->value;
                } else if (!strcmp(buf + 7, "Banner")) {
                        vpninfo->banner = new_option->value;
+               } else if (!strcmp(buf + 7, "Split-DNS")) {
+                       struct split_include *dns = malloc(sizeof(*dns));
+                       if (!dns)
+                               continue;
+                       dns->route = new_option->value;
+                       dns->next = vpninfo->split_dns;
+                       vpninfo->split_dns = dns;
                } else if (!strcmp(buf + 7, "Split-Include")) {
                        struct split_include *inc = malloc(sizeof(*inc));
                        if (!inc)
index 340fc6caa55a5ffa9e58d7df7810f63be37ddcea..fafd8f3294ce63ddcade86b54ecc2b9965ec9a1d 100644 (file)
@@ -209,6 +209,7 @@ struct openconnect_info {
        const char *vpn_nbns[3];
        const char *vpn_domain;
        const char *vpn_proxy_pac;
+       struct split_include *split_dns;
        struct split_include *split_includes;
        struct split_include *split_excludes;
 
diff --git a/tun.c b/tun.c
index c000dbf01b93d8786a5d8c7a83db2f45b7a72e29..464d88232f6022c6c287aa956f1eefb367d31480 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -310,6 +310,32 @@ static void set_script_env(struct openconnect_info *vpninfo)
        if (vpninfo->vpn_proxy_pac)
                setenv("CISCO_PROXY_PAC", vpninfo->vpn_proxy_pac, 1);
 
+       if (vpninfo->split_dns) {
+               char *list;
+               int len = 0;
+               struct split_include *dns = vpninfo->split_dns;
+
+               while (dns) {
+                       len += strlen(dns->route) + 1;
+                       dns = dns->next;
+               }
+               list = malloc(len);
+               if (list) {
+                       char *p = list;
+
+                       dns = vpninfo->split_dns;
+                       while (1) {
+                               strcpy(p, dns->route);
+                               p += strlen(p);
+                               dns = dns->next;
+                               if (!dns)
+                                       break;
+                               *(p++) = ' ';
+                       }
+                       setenv("CISCO_SPLIT_DNS", list, 1);
+                       free(list);
+               }
+       }
        if (vpninfo->split_includes) {
                struct split_include *this = vpninfo->split_includes;
                int nr_split_includes = 0;