From: Marcel Holtmann Date: Mon, 7 Dec 2009 06:30:40 +0000 (+0100) Subject: Add DHCP value configuration handling X-Git-Tag: 0.48~158 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ccc6c9abbc8034776d3a7106ec5ce5c7fed3c88f;p=platform%2Fupstream%2Fconnman.git Add DHCP value configuration handling --- diff --git a/include/dhcp.h b/include/dhcp.h index 2ec471c..e96d83c 100644 --- a/include/dhcp.h +++ b/include/dhcp.h @@ -48,6 +48,9 @@ void connman_dhcp_unref(struct connman_dhcp *dhcp); int connman_dhcp_get_index(struct connman_dhcp *dhcp); char *connman_dhcp_get_interface(struct connman_dhcp *dhcp); +void connman_dhcp_set_value(struct connman_dhcp *dhcp, + const char *key, const char *value); + void connman_dhcp_bound(struct connman_dhcp *dhcp); void connman_dhcp_renew(struct connman_dhcp *dhcp); void connman_dhcp_fail(struct connman_dhcp *dhcp); diff --git a/src/dhcp.c b/src/dhcp.c index 57b44da..19fab9c 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -86,6 +86,38 @@ char *connman_dhcp_get_interface(struct connman_dhcp *dhcp) } /** + * connman_dhcp_set_value: + * @dhcp: DHCP structure + * @key: unique identifier + * @value: string value + * + * Set string value for specific key + */ +void connman_dhcp_set_value(struct connman_dhcp *dhcp, + const char *key, const char *value) +{ + if (g_strcmp0(key, "Address") == 0) { + g_free(dhcp->element->ipv4.address); + dhcp->element->ipv4.address = g_strdup(value); + } else if (g_strcmp0(key, "Netmask") == 0) { + g_free(dhcp->element->ipv4.netmask); + dhcp->element->ipv4.netmask = g_strdup(value); + } else if (g_strcmp0(key, "Gateway") == 0) { + g_free(dhcp->element->ipv4.gateway); + dhcp->element->ipv4.gateway = g_strdup(value); + } else if (g_strcmp0(key, "Network") == 0) { + g_free(dhcp->element->ipv4.network); + dhcp->element->ipv4.network = g_strdup(value); + } else if (g_strcmp0(key, "Broadcast") == 0) { + g_free(dhcp->element->ipv4.broadcast); + 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); + } +} + +/** * connman_dhcp_bound: * @dhcp: DHCP structure *