diff options
author | Dan Williams <dcbw@redhat.com> | 2012-08-28 12:16:26 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2012-08-29 08:53:35 -0500 |
commit | c8153b1ecdec1995258b114c90b575af1e721d3d (patch) | |
tree | d45af6a591485250837bc9089a148c363b834743 | |
parent | d2654a287c309346cc46b535dd974b0a5fc06fd4 (diff) |
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/mm-modem-hso.c | 2 | ||||
-rw-r--r-- | plugins/mm-modem-icera.c | 19 | ||||
-rw-r--r-- | src/mm-modem.c | 5 | ||||
-rw-r--r-- | src/mm-modem.h | 2 |
4 files changed, 26 insertions, 2 deletions
diff --git a/plugins/mm-modem-hso.c b/plugins/mm-modem-hso.c index 511e8628..d9ad4e08 100644 --- a/plugins/mm-modem-hso.c +++ b/plugins/mm-modem-hso.c @@ -495,6 +495,8 @@ ip4_config_invoke (MMCallbackInfo *info) callback (info->modem, GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-address")), + GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-netmask")), + GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-gateway")), (GArray *) mm_callback_info_get_data (info, "ip4-dns"), info->error, info->user_data); } diff --git a/plugins/mm-modem-icera.c b/plugins/mm-modem-icera.c index 67ce6025..93563a88 100644 --- a/plugins/mm-modem-icera.c +++ b/plugins/mm-modem-icera.c @@ -690,6 +690,8 @@ ip4_config_invoke (MMCallbackInfo *info) callback (info->modem, GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-address")), + GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-netmask")), + GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-gateway")), (GArray *) mm_callback_info_get_data (info, "ip4-dns"), info->error, info->user_data); } @@ -726,7 +728,11 @@ get_ip4_config_done (MMAtSerialPort *port, cid = _get_cid (MM_MODEM_ICERA (info->modem)); dns_array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 2); - /* %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, + */ items = g_strsplit (response->str + strlen (IPDPADDR_TAG), ", ", 0); for (iter = items, i = 0; *iter; iter++, i++) { @@ -744,12 +750,23 @@ get_ip4_config_done (MMAtSerialPort *port, } else if (i == 1) { /* IP address */ if (inet_pton (AF_INET, *iter, &tmp) > 0) mm_callback_info_set_data (info, "ip4-address", GUINT_TO_POINTER (tmp), NULL); + } else if (i == 2) { /* Gateway */ + if ((inet_pton (AF_INET, *iter, &tmp) > 0) && (tmp > 0)) + mm_callback_info_set_data (info, "ip4-gateway", GUINT_TO_POINTER (tmp), NULL); } else if (i == 3) { /* DNS 1 */ if (inet_pton (AF_INET, *iter, &tmp) > 0) g_array_append_val (dns_array, tmp); } else if (i == 4) { /* DNS 2 */ if (inet_pton (AF_INET, *iter, &tmp) > 0) g_array_append_val (dns_array, tmp); + } else if (i == 8) { /* Netmask */ + if (inet_pton (AF_INET, *iter, &tmp) > 0) + mm_callback_info_set_data (info, "ip4-netmask", GUINT_TO_POINTER (tmp), NULL); + } else if (i == 9) { /* Duplicate gateway */ + if (mm_callback_info_get_data (info, "ip4-gateway") == NULL) { + if (inet_pton (AF_INET, *iter, &tmp) > 0) + mm_callback_info_set_data (info, "ip4-gateway", GUINT_TO_POINTER (tmp), NULL); + } } } diff --git a/src/mm-modem.c b/src/mm-modem.c index 990178f1..0a3df4da 100644 --- a/src/mm-modem.c +++ b/src/mm-modem.c @@ -249,6 +249,8 @@ get_ip4_invoke (MMCallbackInfo *info) callback (info->modem, GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-address")), + GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-netmask")), + GPOINTER_TO_UINT (mm_callback_info_get_data (info, "ip4-gateway")), (GArray *) mm_callback_info_get_data (info, "ip4-dns"), info->error, info->user_data); } @@ -291,6 +293,8 @@ value_array_add_uint (GValueArray *array, guint32 i) static void get_ip4_done (MMModem *modem, guint32 address, + guint32 netmask, + guint32 gateway, GArray *dns, GError *error, gpointer user_data) @@ -309,7 +313,6 @@ get_ip4_done (MMModem *modem, if (dns) { if (dns->len > 0) - dns1 = g_array_index (dns, guint32, 0); if (dns->len > 1) dns2 = g_array_index (dns, guint32, 1); diff --git a/src/mm-modem.h b/src/mm-modem.h index d129f674..ada1079a 100644 --- a/src/mm-modem.h +++ b/src/mm-modem.h @@ -117,6 +117,8 @@ typedef void (*MMModemStringFn) (MMModem *modem, typedef void (*MMModemIp4Fn) (MMModem *modem, guint32 address, + guint32 netmask, + guint32 gateway, GArray *dns, GError *error, gpointer user_data); |