diff options
author | Dan Williams <dcbw@redhat.com> | 2012-08-28 12:16:26 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2012-08-28 12:16:26 -0500 |
commit | d3d98de5484344773955e4e300b4ad968a720e10 (patch) | |
tree | 6f82444c917b6f2343b160d8cf6ecf51bbec9b7a | |
parent | fb11f26783ee0114aa3e4c93b98e76940e56490b (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 f8e289d3..39a83fee 100644 --- a/plugins/mm-modem-hso.c +++ b/plugins/mm-modem-hso.c @@ -498,6 +498,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 583950a2..54ea9c76 100644 --- a/plugins/mm-modem-icera.c +++ b/plugins/mm-modem-icera.c @@ -691,6 +691,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); } @@ -727,7 +729,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++) { @@ -745,12 +751,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 02774518..341bb784 100644 --- a/src/mm-modem.c +++ b/src/mm-modem.c @@ -251,6 +251,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); } @@ -293,6 +295,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) @@ -311,7 +315,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 de3f33e8..c15df00c 100644 --- a/src/mm-modem.h +++ b/src/mm-modem.h @@ -95,6 +95,8 @@ typedef void (*MMModemStringFn) (MMModem *modem, typedef void (*MMModemIp4Fn) (MMModem *modem, guint32 address, + guint32 netmask, + guint32 gateway, GArray *dns, GError *error, gpointer user_data); |