aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-08-31 10:37:49 -0500
committerDan Williams <dcbw@redhat.com>2012-08-31 10:41:57 -0500
commit61d41978c1b217870f399aa38df9af110ca977b1 (patch)
treea4283d35dc2f72ec75c46b4bfe77a6d4ec239075
parent20539a88e66df64d311752d889d239a34b389d87 (diff)
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.
-rw-r--r--plugins/icera/mm-broadband-bearer-icera.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/plugins/icera/mm-broadband-bearer-icera.c b/plugins/icera/mm-broadband-bearer-icera.c
index ae0dbd3e..e5960f4a 100644
--- a/plugins/icera/mm-broadband-bearer-icera.c
+++ b/plugins/icera/mm-broadband-bearer-icera.c
@@ -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]);
}
}
}