icera: fix parsing of IP config options

Some of the IP address items will be 0.0.0.0 depending on what the
other items are, like when the duplicate gateway is set on newer
devices, the first gateway address may be 0.0.0.0.  Since that's
not a valid IP address, just don't set that member of the config.

Second, the intent with the duplicate gateway is only to use that
when the first gateway was not given (ie, was 0.0.0.0) so fix the
check for that.
This commit is contained in:
Dan Williams
2012-08-31 10:41:57 -05:00
parent 20539a88e6
commit 61d41978c1
+12 -9
View File
@@ -179,7 +179,7 @@ ip_config_ready (MMBaseModem *modem,
break;
}
} else if (i == 1) { /* IP address */
guint32 tmp;
guint32 tmp = 0;
if (!inet_pton (AF_INET, items[i], &tmp)) {
mm_warn ("Couldn't parse IP address '%s'", items[i]);
@@ -190,7 +190,7 @@ ip_config_ready (MMBaseModem *modem,
mm_bearer_ip_config_set_method (ip_config, MM_BEARER_IP_METHOD_STATIC);
mm_bearer_ip_config_set_address (ip_config, items[i]);
} else if (i == 2) { /* Gateway */
guint32 tmp;
guint32 tmp = 0;
if (!inet_pton (AF_INET, items[i], &tmp)) {
mm_warn ("Couldn't parse gateway address '%s'", items[i]);
@@ -198,9 +198,10 @@ ip_config_ready (MMBaseModem *modem,
break;
}
mm_bearer_ip_config_set_gateway (ip_config, items[i]);
if (tmp)
mm_bearer_ip_config_set_gateway (ip_config, items[i]);
} else if (i == 3 || i == 4) { /* DNS entries */
guint32 tmp;
guint32 tmp = 0;
if (!inet_pton (AF_INET, items[i], &tmp)) {
mm_warn ("Couldn't parse DNS address '%s'", items[i]);
@@ -208,9 +209,10 @@ ip_config_ready (MMBaseModem *modem,
break;
}
dns[dns_i++] = items[i];
if (tmp)
dns[dns_i++] = items[i];
} else if (i == 8) { /* Netmask */
guint32 tmp;
guint32 tmp = 0;
if (!inet_pton (AF_INET, items[i], &tmp)) {
mm_warn ("Couldn't parse netmask '%s'", items[i]);
@@ -220,8 +222,8 @@ ip_config_ready (MMBaseModem *modem,
mm_bearer_ip_config_set_prefix (ip_config, mm_netmask_to_cidr (items[i]));
} else if (i == 9) { /* Duplicate Gateway */
if (!!mm_bearer_ip_config_get_gateway (ip_config)) {
guint32 tmp;
if (!mm_bearer_ip_config_get_gateway (ip_config)) {
guint32 tmp = 0;
if (!inet_pton (AF_INET, items[i], &tmp)) {
mm_warn ("Couldn't parse (duplicate) gateway address '%s'", items[i]);
@@ -229,7 +231,8 @@ ip_config_ready (MMBaseModem *modem,
break;
}
mm_bearer_ip_config_set_gateway (ip_config, items[i]);
if (tmp)
mm_bearer_ip_config_set_gateway (ip_config, items[i]);
}
}
}