diff options
Diffstat (limited to 'libnetutils')
-rw-r--r-- | libnetutils/dhcp_utils.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/libnetutils/dhcp_utils.c b/libnetutils/dhcp_utils.c index b4caaf9..d0f1315 100644 --- a/libnetutils/dhcp_utils.c +++ b/libnetutils/dhcp_utils.c @@ -92,7 +92,8 @@ static int fill_ip_info(const char *interface, char *dns2, char *server, uint32_t *lease, - char *vendorInfo) + char *vendorInfo, + char *domain) { char prop_name[PROPERTY_KEY_MAX]; char prop_value[PROPERTY_VALUE_MAX]; @@ -111,7 +112,7 @@ static int fill_ip_info(const char *interface, property_get(prop_name, server, NULL); //TODO: Handle IPv6 when we change system property usage - if (strcmp(gateway, "0.0.0.0") == 0) { + if (gateway[0] == '\0' || strncmp(gateway, "0.0.0.0", 7) == 0) { //DHCP server is our best bet as gateway strncpy(gateway, server, PROPERTY_VALUE_MAX); } @@ -153,6 +154,10 @@ static int fill_ip_info(const char *interface, p2p_interface); property_get(prop_name, vendorInfo, NULL); + snprintf(prop_name, sizeof(prop_name), "%s.%s.domain", DHCP_PROP_NAME_PREFIX, + p2p_interface); + property_get(prop_name, domain, NULL); + return 0; } @@ -181,7 +186,8 @@ int dhcp_do_request(const char *interface, char *dns2, char *server, uint32_t *lease, - char *vendorInfo) + char *vendorInfo, + char *domain) { char result_prop_name[PROPERTY_KEY_MAX]; char daemon_prop_name[PROPERTY_KEY_MAX]; @@ -233,16 +239,9 @@ int dhcp_do_request(const char *interface, if (strcmp(prop_value, "ok") == 0) { char dns_prop_name[PROPERTY_KEY_MAX]; if (fill_ip_info(interface, ipaddr, gateway, prefixLength, - dns1, dns2, server, lease, vendorInfo) == -1) { + dns1, dns2, server, lease, vendorInfo, domain) == -1) { return -1; } - - /* copy dns data to system properties - TODO - remove this after we have async - * notification of renewal's */ - 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); @@ -331,7 +330,8 @@ int dhcp_do_request_renew(const char *interface, char *dns2, char *server, uint32_t *lease, - char *vendorInfo) + char *vendorInfo, + char *domain) { char result_prop_name[PROPERTY_KEY_MAX]; char prop_value[PROPERTY_VALUE_MAX] = {'\0'}; @@ -368,7 +368,7 @@ int dhcp_do_request_renew(const char *interface, } if (strcmp(prop_value, "ok") == 0) { fill_ip_info(interface, ipaddr, gateway, prefixLength, - dns1, dns2, server, lease, vendorInfo); + dns1, dns2, server, lease, vendorInfo, domain); return 0; } else { snprintf(errmsg, sizeof(errmsg), "DHCP Renew result was %s", prop_value); |