Skip to content
Permalink
Browse files
Add $CISCO_SPLIT_DNS environment variable for vpnc-script
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jun 8, 2012
1 parent 412e4b0 commit 978c3694945b8f7b7f4f62a88dfdf46f8d4aa51e
Showing with 40 additions and 1 deletion.
  1. +13 −1 cstp.c
  2. +1 −0 openconnect-internal.h
  3. +26 −0 tun.c
14 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)
@@ -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;

26 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;

0 comments on commit 978c369

Please sign in to comment.