diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2010-12-20 13:21:11 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-12-21 01:35:54 +0100 |
commit | a0f2e331c88baa143a9c2a48e4ddb68eea54e10a (patch) | |
tree | 250e8451bfca29d92ba4d08e34e5c4501d388102 /plugins/openvpn.c | |
parent | f4150f238010f224b550bbb2f967a2ba092cae5a (diff) | |
download | connman-a0f2e331c88baa143a9c2a48e4ddb68eea54e10a.tar.gz connman-a0f2e331c88baa143a9c2a48e4ddb68eea54e10a.tar.bz2 connman-a0f2e331c88baa143a9c2a48e4ddb68eea54e10a.zip |
openvpn: Move foreign_option_ parse code into its own function
Do not clutter the ov_notify loop with parsing code.
Diffstat (limited to 'plugins/openvpn.c')
-rw-r--r-- | plugins/openvpn.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/plugins/openvpn.c b/plugins/openvpn.c index ac361880..f4544fec 100644 --- a/plugins/openvpn.c +++ b/plugins/openvpn.c @@ -141,6 +141,35 @@ static void ov_append_route(const char *key, const char *value, GHashTable *rout route->gateway = g_strdup(value); } +static void ov_append_dns_entries(const char *key, const char *value, + char **dns_entries) +{ + if (g_str_has_prefix(key, "foreign_option_")) { + gchar **options; + + options = g_strsplit(value, " ", 3); + if (options[0] != NULL && + !strcmp(options[0], "dhcp-option") && + options[1] != NULL && + !strcmp(options[1], "DNS") && + options[2] != NULL) { + + if (*dns_entries != NULL) { + char *tmp; + + tmp = g_strjoin(" ", *dns_entries, + options[2], NULL); + g_free(*dns_entries); + *dns_entries = tmp; + } else { + *dns_entries = g_strdup(options[2]); + } + } + + g_strfreev(options); + } +} + static int ov_notify(DBusMessage *msg, struct connman_provider *provider) { DBusMessageIter iter, dict; @@ -193,33 +222,10 @@ static int ov_notify(DBusMessage *msg, struct connman_provider *provider) if (!strcmp(key, "ifconfig_remote")) connman_provider_set_string(provider, "Peer", value); - if (g_str_has_prefix(key, "foreign_option_")) { - gchar **options; - - options = g_strsplit(value, " ", 3); - if (options[0] != NULL && - !strcmp(options[0], "dhcp-option") && - options[1] != NULL && - !strcmp(options[1], "DNS") && - options[2] != NULL) { - - if (dns_entries != NULL) { - char *tmp; - - tmp = g_strjoin(" ", dns_entries, - options[2], NULL); - g_free(dns_entries); - dns_entries = tmp; - } else { - dns_entries = g_strdup(options[2]); - } - } - - g_strfreev(options); - } - ov_append_route(key, value, routes); + ov_append_dns_entries(key, value, &dns_entries); + dbus_message_iter_next(&dict); } |