diff options
author | Szymon Jakubczak <szym@google.com> | 2010-06-09 16:11:09 -0400 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2010-08-25 08:13:42 -0700 |
commit | 8c85a00db6da092ec3766facd49132fa4fc319a1 (patch) | |
tree | 4d7015b3de6955bb0ef9b10efeef039fd9e0a542 /libnetutils/dhcp_utils.c | |
parent | 2c72df998799738662a77cef3f522fdc6ae22fde (diff) | |
download | system_core-8c85a00db6da092ec3766facd49132fa4fc319a1.zip system_core-8c85a00db6da092ec3766facd49132fa4fc319a1.tar.gz system_core-8c85a00db6da092ec3766facd49132fa4fc319a1.tar.bz2 |
- creates proper ifc.h and dhcp.h headers for libnetutils
- adds ifc_set_hwaddr
- adds hwaddr command to netcfg
- code reuse: dhcp_configure calls ifc_configure; inet_ntoa is used for printing
- consistency: use net.XXX.dnsX properties in favor of dhcp.XXX.dnsX properties
(see related change to WifiStateTracker)
- updated system/core/nexus to use new headers, although not sure if
anybody still uses nexus
Change-Id: Idd70c0ac6e89b38e86816578c33eff805d30cac4
Diffstat (limited to 'libnetutils/dhcp_utils.c')
-rw-r--r-- | libnetutils/dhcp_utils.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libnetutils/dhcp_utils.c b/libnetutils/dhcp_utils.c index 0f8a6c4..cb0960f 100644 --- a/libnetutils/dhcp_utils.c +++ b/libnetutils/dhcp_utils.c @@ -115,6 +115,14 @@ static void fill_ip_info(const char *interface, } } +static const char *ipaddr_to_string(in_addr_t addr) +{ + struct in_addr in_addr; + + in_addr.s_addr = addr; + return inet_ntoa(in_addr); +} + /* * Start the dhcp client daemon, and wait for it to finish * configuring the interface. @@ -165,7 +173,13 @@ int dhcp_do_request(const char *interface, return -1; } if (strcmp(prop_value, "ok") == 0) { + char dns_prop_name[PROPERTY_KEY_MAX]; fill_ip_info(interface, ipaddr, gateway, mask, dns1, dns2, server, lease); + /* copy the dhcp.XXX.dns properties to net.XXX.dns */ + snprintf(dns_prop_name, sizeof(dns_prop_name), "net.%s.dns1", interface); + property_set(dns_prop_name, *dns1 ? ipaddr_to_string(*dns1) : ""); + snprintf(dns_prop_name, sizeof(dns_prop_name), "net.%s.dns2", interface); + property_set(dns_prop_name, *dns2 ? ipaddr_to_string(*dns2) : ""); return 0; } else { snprintf(errmsg, sizeof(errmsg), "DHCP result was %s", prop_value); |