diff options
author | Forest Bond <forest@alittletooquiet.net> | 2010-04-22 15:56:12 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-05-04 11:52:27 +0200 |
commit | 2c02a01212746b9d07d3028be36c2af1ac7f27f4 (patch) | |
tree | 576bceb20121675f633050f1ebe4a920ce1d6458 /src/dhcp.c | |
parent | d8f0947356f95ff641d2fcdc1eb8dfd09707eaba (diff) | |
download | connman-2c02a01212746b9d07d3028be36c2af1ac7f27f4.tar.gz connman-2c02a01212746b9d07d3028be36c2af1ac7f27f4.tar.bz2 connman-2c02a01212746b9d07d3028be36c2af1ac7f27f4.zip |
Split DHCP-provided nameserver string.
The DHCP-provided nameserver string is split up into separate nameservers.
Currently, only one nameserver can be stored in the connman_element.ipv4
structure, so all but the first of the DHCP-provided nameservers are thrown
out.
Diffstat (limited to 'src/dhcp.c')
-rw-r--r-- | src/dhcp.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -96,6 +96,8 @@ char *connman_dhcp_get_interface(struct connman_dhcp *dhcp) void connman_dhcp_set_value(struct connman_dhcp *dhcp, const char *key, const char *value) { + char **nameservers; + if (g_strcmp0(key, "Address") == 0) { g_free(dhcp->element->ipv4.address); dhcp->element->ipv4.address = g_strdup(value); @@ -113,7 +115,14 @@ void connman_dhcp_set_value(struct connman_dhcp *dhcp, dhcp->element->ipv4.broadcast = g_strdup(value); } else if (g_strcmp0(key, "Nameserver") == 0) { g_free(dhcp->element->ipv4.nameserver); - dhcp->element->ipv4.nameserver = g_strdup(value); + nameservers = g_strsplit_set(value, " ", 0); + /* FIXME: The ipv4 structure can only hold one nameserver, so + * we are only able to pass along the first nameserver sent by + * the DHCP server. If this situation changes, we should + * retain all of them. + */ + dhcp->element->ipv4.nameserver = g_strdup(nameservers[0]); + g_strfreev(nameservers); } else if (g_strcmp0(key, "Domainname") == 0) { __connman_utsname_set_domainname(value); } else if (g_strcmp0(key, "Hostname") == 0) { |