base-bearer: report connection error on network initiated disconnections
By default, fallback to "unknown" mobile equipment error when the modem gets disconnected by the network and we don't have any way to know a more detailed reason.
This commit is contained in:
@@ -777,8 +777,9 @@ disconnect_3gpp (MMBroadbandBearer *_self,
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
report_connection_status (MMBaseBearer *bearer,
|
||||
MMBearerConnectionStatus status)
|
||||
report_connection_status (MMBaseBearer *bearer,
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
MMBroadbandBearerHuawei *self = MM_BROADBAND_BEARER_HUAWEI (bearer);
|
||||
|
||||
@@ -801,7 +802,8 @@ report_connection_status (MMBaseBearer *bearer,
|
||||
/* Report disconnected right away */
|
||||
MM_BASE_BEARER_CLASS (mm_broadband_bearer_huawei_parent_class)->report_connection_status (
|
||||
bearer,
|
||||
MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
|
||||
MM_BEARER_CONNECTION_STATUS_DISCONNECTED,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -700,7 +700,8 @@ dial_3gpp (MMBroadbandBearer *_self,
|
||||
|
||||
static void
|
||||
report_connection_status (MMBaseBearer *_self,
|
||||
MMBearerConnectionStatus status)
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
MMBroadbandBearerIcera *self = MM_BROADBAND_BEARER_ICERA (_self);
|
||||
|
||||
@@ -729,7 +730,8 @@ report_connection_status (MMBaseBearer *_self,
|
||||
* disconnected. Make sure we only pass 'DISCONNECTED' to the parent */
|
||||
MM_BASE_BEARER_CLASS (mm_broadband_bearer_icera_parent_class)->report_connection_status (
|
||||
_self,
|
||||
MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
|
||||
MM_BEARER_CONNECTION_STATUS_DISCONNECTED,
|
||||
connection_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -799,7 +799,8 @@ disconnect_3gpp (MMBroadbandBearer *_self,
|
||||
|
||||
static void
|
||||
report_connection_status (MMBaseBearer *_self,
|
||||
MMBearerConnectionStatus status)
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
MMBroadbandBearerMbm *self = MM_BROADBAND_BEARER_MBM (_self);
|
||||
|
||||
@@ -829,7 +830,8 @@ report_connection_status (MMBaseBearer *_self,
|
||||
* disconnected. Make sure we only pass 'DISCONNECTED' to the parent */
|
||||
MM_BASE_BEARER_CLASS (mm_broadband_bearer_mbm_parent_class)->report_connection_status (
|
||||
_self,
|
||||
MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
|
||||
MM_BEARER_CONNECTION_STATUS_DISCONNECTED,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -699,7 +699,8 @@ disconnect_3gpp (MMBroadbandBearer *self,
|
||||
|
||||
static void
|
||||
report_connection_status (MMBaseBearer *_self,
|
||||
MMBearerConnectionStatus status)
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
MMBroadbandBearerHso *self = MM_BROADBAND_BEARER_HSO (_self);
|
||||
|
||||
@@ -719,9 +720,7 @@ report_connection_status (MMBaseBearer *_self,
|
||||
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED) {
|
||||
/* If no connection attempt on-going, make sure we mark ourselves as
|
||||
* disconnected */
|
||||
MM_BASE_BEARER_CLASS (mm_broadband_bearer_hso_parent_class)->report_connection_status (
|
||||
_self,
|
||||
status);
|
||||
MM_BASE_BEARER_CLASS (mm_broadband_bearer_hso_parent_class)->report_connection_status (_self, status,connection_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+26
-9
@@ -37,6 +37,7 @@
|
||||
#include "mm-base-modem.h"
|
||||
#include "mm-log-object.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
#include "mm-error-helpers.h"
|
||||
#include "mm-bearer-stats.h"
|
||||
|
||||
/* We require up to 20s to get a proper IP when using PPP */
|
||||
@@ -1368,8 +1369,9 @@ mm_base_bearer_disconnect_force (MMBaseBearer *self)
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
report_connection_status (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status)
|
||||
report_connection_status (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
/* The only status expected at this point is DISCONNECTED or CONNECTED,
|
||||
* although here we just process the DISCONNECTED one.
|
||||
@@ -1378,8 +1380,10 @@ report_connection_status (MMBaseBearer *self,
|
||||
|
||||
/* In the generic bearer implementation we just need to reset the
|
||||
* interface status */
|
||||
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED)
|
||||
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED) {
|
||||
bearer_update_connection_error (self, connection_error);
|
||||
bearer_update_status (self, MM_BEARER_STATUS_DISCONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1409,15 +1413,28 @@ report_connection_status (MMBaseBearer *self,
|
||||
* pppd should detect it) and disconnect the bearer through DBus.
|
||||
*/
|
||||
void
|
||||
mm_base_bearer_report_connection_status (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status)
|
||||
mm_base_bearer_report_connection_status_detailed (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
if ((status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED) && self->priv->ignore_disconnection_reports) {
|
||||
mm_obj_dbg (self, "ignoring disconnection report");
|
||||
return;
|
||||
/* Reporting disconnection? */
|
||||
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED || status == MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED) {
|
||||
if (self->priv->ignore_disconnection_reports) {
|
||||
mm_obj_dbg (self, "ignoring disconnection report");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Setup a generic default error if none explicitly given when reporting
|
||||
* bearer disconnections. */
|
||||
if (!connection_error) {
|
||||
g_autoptr(GError) default_connection_error = NULL;
|
||||
|
||||
default_connection_error = mm_mobile_equipment_error_for_code (MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN, self);
|
||||
return MM_BASE_BEARER_GET_CLASS (self)->report_connection_status (self, status, default_connection_error);
|
||||
}
|
||||
}
|
||||
|
||||
return MM_BASE_BEARER_GET_CLASS (self)->report_connection_status (self, status);
|
||||
return MM_BASE_BEARER_GET_CLASS (self)->report_connection_status (self, status, connection_error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -146,8 +146,9 @@ struct _MMBaseBearerClass {
|
||||
GError **error);
|
||||
|
||||
/* Report connection status of this bearer */
|
||||
void (* report_connection_status) (MMBaseBearer *bearer,
|
||||
MMBearerConnectionStatus status);
|
||||
void (* report_connection_status) (MMBaseBearer *bearer,
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error);
|
||||
};
|
||||
|
||||
GType mm_base_bearer_get_type (void);
|
||||
@@ -177,7 +178,11 @@ gboolean mm_base_bearer_disconnect_finish (MMBaseBearer *self,
|
||||
|
||||
void mm_base_bearer_disconnect_force (MMBaseBearer *self);
|
||||
|
||||
void mm_base_bearer_report_connection_status (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status);
|
||||
void mm_base_bearer_report_connection_status_detailed (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error);
|
||||
|
||||
/* When unknown, just pass NULL */
|
||||
#define mm_base_bearer_report_connection_status(self, status) mm_base_bearer_report_connection_status_detailed (self, status, NULL)
|
||||
|
||||
#endif /* MM_BASE_BEARER_H */
|
||||
|
||||
@@ -1520,15 +1520,16 @@ mm_bearer_mbim_get_session_id (MMBearerMbim *self)
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
report_connection_status (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status)
|
||||
report_connection_status (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED)
|
||||
/* Cleanup all connection related data */
|
||||
reset_bearer_connection (MM_BEARER_MBIM (self));
|
||||
|
||||
/* Chain up parent's report_connection_status() */
|
||||
MM_BASE_BEARER_CLASS (mm_bearer_mbim_parent_class)->report_connection_status (self, status);
|
||||
MM_BASE_BEARER_CLASS (mm_bearer_mbim_parent_class)->report_connection_status (self, status, connection_error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
+3
-2
@@ -2523,7 +2523,8 @@ disconnect (MMBaseBearer *_self,
|
||||
|
||||
static void
|
||||
report_connection_status (MMBaseBearer *_self,
|
||||
MMBearerConnectionStatus status)
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
MMBearerQmi *self = MM_BEARER_QMI (_self);
|
||||
|
||||
@@ -2535,7 +2536,7 @@ report_connection_status (MMBaseBearer *_self,
|
||||
}
|
||||
|
||||
/* Chain up parent's report_connection_status() */
|
||||
MM_BASE_BEARER_CLASS (mm_bearer_qmi_parent_class)->report_connection_status (_self, status);
|
||||
MM_BASE_BEARER_CLASS (mm_bearer_qmi_parent_class)->report_connection_status (_self, status, connection_error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -1707,8 +1707,9 @@ out:
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
report_connection_status (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status)
|
||||
report_connection_status (MMBaseBearer *self,
|
||||
MMBearerConnectionStatus status,
|
||||
const GError *connection_error)
|
||||
{
|
||||
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED)
|
||||
/* Cleanup all connection related data */
|
||||
@@ -1717,7 +1718,8 @@ report_connection_status (MMBaseBearer *self,
|
||||
/* Chain up parent's report_connection_status() */
|
||||
MM_BASE_BEARER_CLASS (mm_broadband_bearer_parent_class)->report_connection_status (
|
||||
self,
|
||||
status);
|
||||
status,
|
||||
connection_error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user