Use DHCP server as gateway when it is absent
Some routers can return 0.0.0.0 as gateway address, use DHCP server as gateway in such instances Change-Id: I7e8db8e619475efce53ce391f77f2c13c3b7268c
This commit is contained in:
parent
112445b8a7
commit
bdaaec1ba0
1 changed files with 9 additions and 3 deletions
|
|
@ -79,6 +79,15 @@ static int fill_ip_info(const char *interface,
|
|||
snprintf(prop_name, sizeof(prop_name), "%s.%s.gateway", DHCP_PROP_NAME_PREFIX, interface);
|
||||
property_get(prop_name, gateway, NULL);
|
||||
|
||||
snprintf(prop_name, sizeof(prop_name), "%s.%s.server", DHCP_PROP_NAME_PREFIX, interface);
|
||||
property_get(prop_name, server, NULL);
|
||||
|
||||
//TODO: Handle IPv6 when we change system property usage
|
||||
if (strcmp(gateway, "0.0.0.0") == 0) {
|
||||
//DHCP server is our best bet as gateway
|
||||
strncpy(gateway, server, PROPERTY_VALUE_MAX);
|
||||
}
|
||||
|
||||
snprintf(prop_name, sizeof(prop_name), "%s.%s.mask", DHCP_PROP_NAME_PREFIX, interface);
|
||||
if (property_get(prop_name, prop_value, NULL)) {
|
||||
int p;
|
||||
|
|
@ -107,9 +116,6 @@ static int fill_ip_info(const char *interface,
|
|||
snprintf(prop_name, sizeof(prop_name), "%s.%s.dns2", DHCP_PROP_NAME_PREFIX, interface);
|
||||
property_get(prop_name, dns2, NULL);
|
||||
|
||||
snprintf(prop_name, sizeof(prop_name), "%s.%s.server", DHCP_PROP_NAME_PREFIX, interface);
|
||||
property_get(prop_name, server, NULL);
|
||||
|
||||
snprintf(prop_name, sizeof(prop_name), "%s.%s.leasetime", DHCP_PROP_NAME_PREFIX, interface);
|
||||
if (property_get(prop_name, prop_value, NULL)) {
|
||||
*lease = atol(prop_value);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue