aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-08-31 13:56:42 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-31 15:11:30 +0200
commita195dabc93153c7acc220cd9daccbbf4657bbb62 (patch)
tree19eb9689e17ee1d75ed3954322d828d7147c7cab
parent529eecdb9771cbb9140af015e4a8a5fdb3df59a7 (diff)
icera: handle additional IPv4 configuration options
This is the port to git master of the following commit: commit c8153b1ecdec1995258b114c90b575af1e721d3d Author: Dan Williams <dcbw@redhat.com> Date: Tue Aug 28 12:16:26 2012 -0500 icera: handle additional IPv4 configuration options Newer devices like the ZTE/Vodafone K3805-z have an enhanced %IPDPADDR command that includes a netmask and gateway, and these are necessary to configure the device since it uses /24 instead of a /32. Since the device is nice enough to tell us that, we should probably use that information. Unfortunately the MM API doens't expose the netmask and gateway yet, so we'll have to add a GetIP4ConfigEx() method or something like that, but this commit sets us up to do that.
-rw-r--r--plugins/icera/mm-broadband-bearer-icera.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/plugins/icera/mm-broadband-bearer-icera.c b/plugins/icera/mm-broadband-bearer-icera.c
index 64c9b276..ae0dbd3e 100644
--- a/plugins/icera/mm-broadband-bearer-icera.c
+++ b/plugins/icera/mm-broadband-bearer-icera.c
@@ -154,10 +154,16 @@ ip_config_ready (MMBaseModem *modem,
return;
}
- /* %IPDPADDR: <cid>,<ip>,<gw>,<dns1>,<dns2>[,<nbns1>,<nbns2>] */
+ /* %IPDPADDR: <cid>,<ip>,<gw>,<dns1>,<dns2>[,<nbns1>,<nbns2>[,<??>,<netmask>,<gw>]]
+ *
+ * Sierra USB305: %IPDPADDR: 2, 21.93.217.11, 21.93.217.10, 10.177.0.34, 10.161.171.220, 0.0.0.0, 0.0.0.0
+ * K3805-Z: %IPDPADDR: 2, 21.93.217.11, 21.93.217.10, 10.177.0.34, 10.161.171.220, 0.0.0.0, 0.0.0.0, 255.0.0.0, 255.255.255.0, 21.93.217.10,
+ */
response = mm_strip_tag (response, IPDPADDR_TAG);
items = g_strsplit (response, ", ", 0);
+ ip_config = mm_bearer_ip_config_new ();
+
for (i = 0, dns_i = 0; items[i]; i++) {
if (i == 0) { /* CID */
gint num;
@@ -175,21 +181,56 @@ ip_config_ready (MMBaseModem *modem,
} else if (i == 1) { /* IP address */
guint32 tmp;
- if (!inet_pton (AF_INET, items[i], &tmp))
+ if (!inet_pton (AF_INET, items[i], &tmp)) {
+ mm_warn ("Couldn't parse IP address '%s'", items[i]);
+ g_clear_object (&ip_config);
break;
+ }
- ip_config = mm_bearer_ip_config_new ();
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;
+
+ if (!inet_pton (AF_INET, items[i], &tmp)) {
+ mm_warn ("Couldn't parse gateway address '%s'", items[i]);
+ g_clear_object (&ip_config);
+ break;
+ }
+
+ mm_bearer_ip_config_set_gateway (ip_config, items[i]);
} else if (i == 3 || i == 4) { /* DNS entries */
guint32 tmp;
if (!inet_pton (AF_INET, items[i], &tmp)) {
+ mm_warn ("Couldn't parse DNS address '%s'", items[i]);
g_clear_object (&ip_config);
break;
}
dns[dns_i++] = items[i];
+ } else if (i == 8) { /* Netmask */
+ guint32 tmp;
+
+ if (!inet_pton (AF_INET, items[i], &tmp)) {
+ mm_warn ("Couldn't parse netmask '%s'", items[i]);
+ g_clear_object (&ip_config);
+ break;
+ }
+
+ 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 (!inet_pton (AF_INET, items[i], &tmp)) {
+ mm_warn ("Couldn't parse (duplicate) gateway address '%s'", items[i]);
+ g_clear_object (&ip_config);
+ break;
+ }
+
+ mm_bearer_ip_config_set_gateway (ip_config, items[i]);
+ }
}
}