diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-04 11:25:14 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-05 18:55:55 +0200 |
commit | a42234dd1c680e7604008fc2e66be849c7bf70de (patch) | |
tree | 2e4e35576465519edfa822c7171eae8e2608f0ad | |
parent | 68a7d1a3ac0a62379280dbd40c632113273df00f (diff) |
bearers: update connection logic in 3GPP+3GPP2 devices
https://bugzilla.gnome.org/show_bug.cgi?id=701333
-rw-r--r-- | src/mm-bearer-mbim.c | 26 | ||||
-rw-r--r-- | src/mm-bearer-qmi.c | 31 | ||||
-rw-r--r-- | src/mm-broadband-bearer.c | 59 |
3 files changed, 112 insertions, 4 deletions
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index bddc9da8..a26ef4d8 100644 --- a/src/mm-bearer-mbim.c +++ b/src/mm-bearer-mbim.c @@ -26,6 +26,7 @@ #define _LIBMM_INSIDE_MM #include <libmm-glib.h> +#include "mm-iface-modem.h" #include "mm-modem-helpers-mbim.h" #include "mm-serial-enums-types.h" #include "mm-bearer-mbim.h" @@ -777,10 +778,35 @@ _connect (MMBearer *self, ConnectContext *ctx; MMPort *data; MbimDevice *device; + MMBaseModem *modem = NULL; + const gchar *apn; if (!peek_ports (self, &device, &data, callback, user_data)) return; + g_object_get (self, + MM_BEARER_MODEM, &modem, + NULL); + g_assert (modem); + + /* Check whether we have an APN */ + apn = mm_bearer_properties_get_apn (mm_bearer_peek_config (MM_BEARER (self))); + + /* Is this a 3GPP only modem and no APN was given? If so, error */ + if (mm_iface_modem_is_3gpp_only (MM_IFACE_MODEM (modem)) && !apn) { + g_simple_async_report_error_in_idle ( + G_OBJECT (self), + callback, + user_data, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "3GPP connection logic requires APN setting"); + g_object_unref (modem); + return; + } + + g_object_unref (modem); + mm_dbg ("Launching connection with data port (%s/%s)", mm_port_subsys_get_string (mm_port_get_subsys (data)), mm_port_get_device (data)); diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c index 9e8d2bc4..bc97ec97 100644 --- a/src/mm-bearer-qmi.c +++ b/src/mm-bearer-qmi.c @@ -26,6 +26,7 @@ #define _LIBMM_INSIDE_MM #include <libmm-glib.h> +#include "mm-iface-modem.h" #include "mm-bearer-qmi.h" #include "mm-modem-helpers-qmi.h" #include "mm-serial-enums-types.h" @@ -788,6 +789,7 @@ _connect (MMBearer *self, MMPort *data; MMQmiPort *qmi; GError *error = NULL; + const gchar *apn; g_object_get (self, MM_BEARER_MODEM, &modem, @@ -821,6 +823,35 @@ _connect (MMBearer *self, return; } + /* Check whether we have an APN */ + apn = mm_bearer_properties_get_apn (mm_bearer_peek_config (MM_BEARER (self))); + + /* Is this a 3GPP only modem and no APN was given? If so, error */ + if (mm_iface_modem_is_3gpp_only (MM_IFACE_MODEM (modem)) && !apn) { + g_simple_async_report_error_in_idle ( + G_OBJECT (self), + callback, + user_data, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "3GPP connection logic requires APN setting"); + g_object_unref (modem); + return; + } + + /* Is this a 3GPP2 only modem and APN was given? If so, error */ + if (mm_iface_modem_is_cdma_only (MM_IFACE_MODEM (modem)) && apn) { + g_simple_async_report_error_in_idle ( + G_OBJECT (self), + callback, + user_data, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "3GPP2 doesn't support APN setting"); + g_object_unref (modem); + return; + } + g_object_unref (modem); mm_dbg ("Launching connection with QMI port (%s/%s) and data port (%s/%s)", diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c index b09da226..09dd1871 100644 --- a/src/mm-broadband-bearer.c +++ b/src/mm-broadband-bearer.c @@ -1131,6 +1131,7 @@ connect (MMBearer *self, MMBaseModem *modem = NULL; MMAtSerialPort *primary; ConnectContext *ctx; + const gchar *apn; /* Don't try to connect if already connected */ if (MM_BROADBAND_BEARER (self)->priv->port) { @@ -1177,6 +1178,54 @@ connect (MMBearer *self, return; } + /* Default bearer connection logic + * + * 1) 3GPP-only modem: + * 1a) If no APN given, error. + * 1b) If APN given, run 3GPP connection logic. + * 1c) If APN given, but empty (""), run 3GPP connection logic and try + * to use default subscription APN. + * + * 2) 3GPP2-only modem: + * 2a) If no APN given, run CDMA connection logic. + * 2b) If APN given, error. + * + * 3) 3GPP and 3GPP2 modem: + * 3a) If no APN given, run CDMA connection logic. + * 3b) If APN given, run 3GPP connection logic. + * 1c) If APN given, but empty (""), run 3GPP connection logic and try + * to use default subscription APN. + */ + + /* Check whether we have an APN */ + apn = mm_bearer_properties_get_apn (mm_bearer_peek_config (MM_BEARER (self))); + + /* Is this a 3GPP only modem and no APN was given? If so, error */ + if (mm_iface_modem_is_3gpp_only (MM_IFACE_MODEM (modem)) && !apn) { + g_simple_async_report_error_in_idle ( + G_OBJECT (self), + callback, + user_data, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "3GPP connection logic requires APN setting"); + g_object_unref (modem); + return; + } + + /* Is this a 3GPP2 only modem and APN was given? If so, error */ + if (mm_iface_modem_is_cdma_only (MM_IFACE_MODEM (modem)) && apn) { + g_simple_async_report_error_in_idle ( + G_OBJECT (self), + callback, + user_data, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "3GPP2 doesn't support APN setting"); + g_object_unref (modem); + return; + } + /* In this context, we only keep the stuff we'll need later */ ctx = g_slice_new0 (ConnectContext); ctx->self = g_object_ref (self); @@ -1185,8 +1234,9 @@ connect (MMBearer *self, user_data, connect); - /* If the modem has 3GPP capabilities, launch 3GPP-based connection */ - if (mm_iface_modem_is_3gpp (MM_IFACE_MODEM (modem))) { + /* If the modem has 3GPP capabilities and an APN, launch 3GPP-based connection */ + if (mm_iface_modem_is_3gpp (MM_IFACE_MODEM (modem)) && apn) { + mm_dbg ("Launching 3GPP connection attempt with APN '%s'", apn); MM_BROADBAND_BEARER_GET_CLASS (self)->connect_3gpp ( MM_BROADBAND_BEARER (self), MM_BROADBAND_MODEM (modem), @@ -1199,8 +1249,9 @@ connect (MMBearer *self, return; } - /* Otherwise, launch CDMA-specific connection */ - if (mm_iface_modem_is_cdma (MM_IFACE_MODEM (modem))) { + /* Otherwise, launch CDMA-specific connection. */ + if (mm_iface_modem_is_cdma (MM_IFACE_MODEM (modem)) && !apn) { + mm_dbg ("Launching 3GPP2 connection attempt"); MM_BROADBAND_BEARER_GET_CLASS (self)->connect_cdma ( MM_BROADBAND_BEARER (self), MM_BROADBAND_MODEM (modem), |