summaryrefslogtreecommitdiff
path: root/vpn/plugins/openvpn.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2013-03-28 12:55:08 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-04-03 08:46:51 (GMT)
commit0a7f60d8087db15ae84ddc442b7c3dd01c2e39c5 (patch)
tree84a86cd690f15e8c7e269a24d0d92de4139e2b1b /vpn/plugins/openvpn.c
parent1634fcbb35f2968866b773ed2f9460d0d0f303b8 (diff)
downloadconnman-0a7f60d8087db15ae84ddc442b7c3dd01c2e39c5.zip
connman-0a7f60d8087db15ae84ddc442b7c3dd01c2e39c5.tar.gz
connman-0a7f60d8087db15ae84ddc442b7c3dd01c2e39c5.tar.bz2
openvpn: Update domain name if received from OpenVPN server
Diffstat (limited to 'vpn/plugins/openvpn.c')
-rw-r--r--vpn/plugins/openvpn.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/vpn/plugins/openvpn.c b/vpn/plugins/openvpn.c
index d938eb1..486944d 100644
--- a/vpn/plugins/openvpn.c
+++ b/vpn/plugins/openvpn.c
@@ -107,6 +107,29 @@ static struct nameserver_entry *ov_append_dns_entries(const char *key,
return entry;
}
+static char *ov_get_domain_name(const char *key, const char *value)
+{
+ gchar **options;
+ char *domain = NULL;
+
+ if (g_str_has_prefix(key, "foreign_option_") == FALSE)
+ return NULL;
+
+ options = g_strsplit(value, " ", 3);
+ if (options[0] != NULL &&
+ !strcmp(options[0], "dhcp-option") &&
+ options[1] != NULL &&
+ !strcmp(options[1], "DOMAIN") &&
+ options[2] != NULL) {
+
+ domain = g_strdup(options[2]);
+ }
+
+ g_strfreev(options);
+
+ return domain;
+}
+
static gint cmp_ns(gconstpointer a, gconstpointer b)
{
struct nameserver_entry *entry_a = (struct nameserver_entry *)a;
@@ -184,6 +207,13 @@ static int ov_notify(DBusMessage *msg, struct vpn_provider *provider)
if ((ns_entry = ov_append_dns_entries(key, value)) != NULL)
nameserver_list = g_slist_prepend(nameserver_list,
ns_entry);
+ else {
+ char *domain = ov_get_domain_name(key, value);
+ if (domain != NULL) {
+ vpn_provider_set_domain(provider, domain);
+ g_free(domain);
+ }
+ }
dbus_message_iter_next(&dict);
}