Merge request !1346 from 'disconnect-request'
bearer: add new "disconnect-request" logic https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1346
This commit is contained in:
@@ -138,6 +138,7 @@ print_bearer_info (MMBearer *bearer)
|
||||
g_autoptr(MMBearerProperties) properties = NULL;
|
||||
g_autoptr(MMBearerStats) stats = NULL;
|
||||
g_autoptr(GError) connection_error = NULL;
|
||||
gboolean disconnect_request = FALSE;
|
||||
gint profile_id;
|
||||
gchar *profile_id_str;
|
||||
|
||||
@@ -147,6 +148,7 @@ print_bearer_info (MMBearer *bearer)
|
||||
stats = mm_bearer_get_stats (bearer);
|
||||
profile_id = mm_bearer_get_profile_id (bearer);
|
||||
connection_error = mm_bearer_get_connection_error (bearer);
|
||||
disconnect_request = mm_bearer_get_disconnect_request (bearer);
|
||||
|
||||
profile_id_str = (profile_id != MM_3GPP_PROFILE_ID_UNKNOWN) ? g_strdup_printf ("%d", profile_id) : NULL;
|
||||
|
||||
@@ -156,6 +158,7 @@ print_bearer_info (MMBearer *bearer)
|
||||
mmcli_output_string (MMC_F_BEARER_STATUS_CONNECTED, mm_bearer_get_connected (bearer) ? "yes" : "no");
|
||||
mmcli_output_string_take (MMC_F_BEARER_STATUS_CONNECTION_ERROR_NAME, connection_error ? g_dbus_error_encode_gerror (connection_error) : NULL);
|
||||
mmcli_output_string (MMC_F_BEARER_STATUS_CONNECTION_ERROR_MESSAGE, connection_error ? connection_error->message : NULL);
|
||||
mmcli_output_string (MMC_F_BEARER_STATUS_DISCONNECT_REQUEST, disconnect_request ? "yes" : "no");
|
||||
mmcli_output_string (MMC_F_BEARER_STATUS_SUSPENDED, mm_bearer_get_suspended (bearer) ? "yes" : "no");
|
||||
mmcli_output_string (MMC_F_BEARER_STATUS_MULTIPLEXED, mm_bearer_get_multiplexed (bearer) ? "yes" : "no");
|
||||
mmcli_output_string (MMC_F_BEARER_STATUS_INTERFACE, mm_bearer_get_interface (bearer));
|
||||
|
||||
@@ -242,6 +242,7 @@ static FieldInfo field_infos[] = {
|
||||
[MMC_F_BEARER_STATUS_CONNECTED] = { "bearer.status.connected", "connected", MMC_S_BEARER_STATUS, },
|
||||
[MMC_F_BEARER_STATUS_CONNECTION_ERROR_NAME] = { "bearer.status.connection-error.name", "connection error name", MMC_S_BEARER_STATUS, },
|
||||
[MMC_F_BEARER_STATUS_CONNECTION_ERROR_MESSAGE] = { "bearer.status.connection-error.message", "connection error message", MMC_S_BEARER_STATUS, },
|
||||
[MMC_F_BEARER_STATUS_DISCONNECT_REQUEST] = { "bearer.status.disconnect-request", "disconnect request", MMC_S_BEARER_STATUS, },
|
||||
[MMC_F_BEARER_STATUS_SUSPENDED] = { "bearer.status.suspended", "suspended", MMC_S_BEARER_STATUS, },
|
||||
[MMC_F_BEARER_STATUS_MULTIPLEXED] = { "bearer.status.multiplexed", "multiplexed", MMC_S_BEARER_STATUS, },
|
||||
[MMC_F_BEARER_STATUS_INTERFACE] = { "bearer.status.interface", "interface", MMC_S_BEARER_STATUS, },
|
||||
|
||||
@@ -260,6 +260,7 @@ typedef enum {
|
||||
MMC_F_BEARER_STATUS_CONNECTED,
|
||||
MMC_F_BEARER_STATUS_CONNECTION_ERROR_NAME,
|
||||
MMC_F_BEARER_STATUS_CONNECTION_ERROR_MESSAGE,
|
||||
MMC_F_BEARER_STATUS_DISCONNECT_REQUEST,
|
||||
MMC_F_BEARER_STATUS_SUSPENDED,
|
||||
MMC_F_BEARER_STATUS_MULTIPLEXED,
|
||||
MMC_F_BEARER_STATUS_INTERFACE,
|
||||
|
||||
@@ -1448,6 +1448,7 @@ mm_bearer_dup_path
|
||||
mm_bearer_get_interface
|
||||
mm_bearer_dup_interface
|
||||
mm_bearer_get_connected
|
||||
mm_bearer_get_disconnect_request
|
||||
mm_bearer_get_suspended
|
||||
mm_bearer_get_multiplexed
|
||||
mm_bearer_get_ip_timeout
|
||||
@@ -2345,6 +2346,7 @@ mm_gdbus_bearer_dup_properties
|
||||
mm_gdbus_bearer_get_connected
|
||||
mm_gdbus_bearer_get_connection_error
|
||||
mm_gdbus_bearer_dup_connection_error
|
||||
mm_gdbus_bearer_get_disconnect_request
|
||||
mm_gdbus_bearer_get_suspended
|
||||
mm_gdbus_bearer_get_multiplexed
|
||||
mm_gdbus_bearer_get_bearer_type
|
||||
@@ -2363,6 +2365,7 @@ mm_gdbus_bearer_call_disconnect_sync
|
||||
mm_gdbus_bearer_interface_info
|
||||
mm_gdbus_bearer_set_connected
|
||||
mm_gdbus_bearer_set_connection_error
|
||||
mm_gdbus_bearer_set_disconnect_request
|
||||
mm_gdbus_bearer_set_interface
|
||||
mm_gdbus_bearer_set_ip4_config
|
||||
mm_gdbus_bearer_set_ip6_config
|
||||
|
||||
@@ -115,6 +115,16 @@
|
||||
-->
|
||||
<property name="ConnectionError" type="(ss)" access="read" />
|
||||
|
||||
<!--
|
||||
DisconnectRequest:
|
||||
|
||||
Indicates that the bearer is no longer useable and the connection
|
||||
manager should terminate it as soon as possible.
|
||||
|
||||
Since: 1.26
|
||||
-->
|
||||
<property name="DisconnectRequest" type="b" access="read" />
|
||||
|
||||
<!--
|
||||
Suspended:
|
||||
|
||||
|
||||
@@ -517,6 +517,27 @@ PROPERTY_ERROR_DEFINE_FAILABLE (connection_error,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_bearer_get_disconnect_request:
|
||||
* @self: A #MMBearer.
|
||||
*
|
||||
* Gets whether a disconnect request is pending for this bearer
|
||||
*
|
||||
* Returns: %TRUE if the #MMBearer is waiting for disconnection,
|
||||
* #FALSE otherwise.
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
gboolean
|
||||
mm_bearer_get_disconnect_request (MMBearer *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_BEARER (self), FALSE);
|
||||
|
||||
return mm_gdbus_bearer_get_disconnect_request (MM_GDBUS_BEARER (self));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_bearer_connect_finish:
|
||||
* @self: A #MMBearer.
|
||||
|
||||
@@ -76,6 +76,8 @@ gchar *mm_bearer_dup_interface (MMBearer *self);
|
||||
|
||||
gboolean mm_bearer_get_connected (MMBearer *self);
|
||||
|
||||
gboolean mm_bearer_get_disconnect_request (MMBearer *self);
|
||||
|
||||
gboolean mm_bearer_get_reload_stats_supported (MMBearer *self);
|
||||
|
||||
gboolean mm_bearer_get_suspended (MMBearer *self);
|
||||
|
||||
+10
-6
@@ -472,7 +472,7 @@ dispatcher_connection_run_ready (MMDispatcherConnection *dispatcher,
|
||||
|
||||
static void
|
||||
bearer_run_dispatcher_scripts (MMBaseBearer *self,
|
||||
gboolean connected)
|
||||
MMDispatcherConnectionEvent event)
|
||||
{
|
||||
MMDispatcherConnection *dispatcher;
|
||||
const gchar *interface;
|
||||
@@ -486,7 +486,7 @@ bearer_run_dispatcher_scripts (MMBaseBearer *self,
|
||||
g_dbus_object_get_object_path (G_DBUS_OBJECT (self->priv->modem)),
|
||||
self->priv->path,
|
||||
interface,
|
||||
connected,
|
||||
event,
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback)dispatcher_connection_run_ready,
|
||||
g_object_ref (self));
|
||||
@@ -500,6 +500,7 @@ bearer_reset_interface_status (MMBaseBearer *self)
|
||||
mm_gdbus_bearer_set_profile_id (MM_GDBUS_BEARER (self), MM_3GPP_PROFILE_ID_UNKNOWN);
|
||||
mm_gdbus_bearer_set_multiplexed (MM_GDBUS_BEARER (self), FALSE);
|
||||
mm_gdbus_bearer_set_connected (MM_GDBUS_BEARER (self), FALSE);
|
||||
mm_gdbus_bearer_set_disconnect_request (MM_GDBUS_BEARER (self), FALSE);
|
||||
mm_gdbus_bearer_set_suspended (MM_GDBUS_BEARER (self), FALSE);
|
||||
mm_gdbus_bearer_set_interface (MM_GDBUS_BEARER (self), NULL);
|
||||
mm_gdbus_bearer_set_ip4_config (
|
||||
@@ -531,7 +532,7 @@ bearer_update_status (MMBaseBearer *self,
|
||||
g_autoptr(GString) report = NULL;
|
||||
|
||||
/* Report disconnection via dispatcher scripts, before resetting the interface */
|
||||
bearer_run_dispatcher_scripts (self, FALSE);
|
||||
bearer_run_dispatcher_scripts (self, MM_DISPATCHER_CONNECTION_EVENT_DISCONNECTED);
|
||||
|
||||
bearer_reset_interface_status (self);
|
||||
/* Cleanup flag to ignore disconnection reports */
|
||||
@@ -599,7 +600,7 @@ bearer_update_status_connected (MMBaseBearer *self,
|
||||
connection_monitor_start (self);
|
||||
|
||||
/* Run dispatcher scripts */
|
||||
bearer_run_dispatcher_scripts (self, TRUE);
|
||||
bearer_run_dispatcher_scripts (self, MM_DISPATCHER_CONNECTION_EVENT_CONNECTED);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -1491,11 +1492,14 @@ mm_base_bearer_disconnect_force (MMBaseBearer *self)
|
||||
return;
|
||||
|
||||
if (self->priv->ignore_disconnection_reports) {
|
||||
mm_obj_dbg (self, "disconnection should be forced but it's explicitly ignored");
|
||||
mm_obj_msg (self, "disconnection should be forced, but we can't. Request disconnection instead.");
|
||||
mm_gdbus_bearer_set_disconnect_request (MM_GDBUS_BEARER(self), TRUE);
|
||||
bearer_run_dispatcher_scripts (self,
|
||||
MM_DISPATCHER_CONNECTION_EVENT_DISCONNECT_REQUEST);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_obj_dbg (self, "forcing disconnection");
|
||||
mm_obj_msg (self, "forcing disconnection");
|
||||
|
||||
/* If currently connecting, try to cancel that operation. */
|
||||
if (self->priv->status == MM_BEARER_STATUS_CONNECTING) {
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#endif
|
||||
|
||||
#define OPERATION_DESCRIPTION "connection status report"
|
||||
#define CONNECTED_STRING "connected"
|
||||
#define DISCONNECTED_STRING "disconnected"
|
||||
|
||||
/* Maximum time a connection dispatcher command is allowed to run before
|
||||
* us killing it */
|
||||
@@ -51,15 +49,30 @@ G_DEFINE_TYPE (MMDispatcherConnection, mm_dispatcher_connection, MM_TYPE_DISPATC
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
gchar *modem_dbus_path;
|
||||
gchar *bearer_dbus_path;
|
||||
gchar *data_port;
|
||||
gboolean connected;
|
||||
GList *dispatcher_scripts;
|
||||
GFile *current;
|
||||
guint n_failures;
|
||||
gchar *modem_dbus_path;
|
||||
gchar *bearer_dbus_path;
|
||||
gchar *data_port;
|
||||
MMDispatcherConnectionEvent event;
|
||||
GList *dispatcher_scripts;
|
||||
GFile *current;
|
||||
guint n_failures;
|
||||
} ConnectionRunContext;
|
||||
|
||||
static gchar *
|
||||
mm_dispatcher_connection_event_to_string (MMDispatcherConnectionEvent event)
|
||||
{
|
||||
switch (event) {
|
||||
case MM_DISPATCHER_CONNECTION_EVENT_CONNECTED:
|
||||
return g_strdup ("connected");
|
||||
case MM_DISPATCHER_CONNECTION_EVENT_DISCONNECTED:
|
||||
return g_strdup ("disconnected");
|
||||
case MM_DISPATCHER_CONNECTION_EVENT_DISCONNECT_REQUEST:
|
||||
return g_strdup ("disconnect-request");
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_run_context_free (ConnectionRunContext *ctx)
|
||||
{
|
||||
@@ -137,7 +150,7 @@ connection_run_next (GTask *task)
|
||||
g_ptr_array_add (aux, g_strdup (ctx->modem_dbus_path));
|
||||
g_ptr_array_add (aux, g_strdup (ctx->bearer_dbus_path));
|
||||
g_ptr_array_add (aux, g_strdup (ctx->data_port));
|
||||
g_ptr_array_add (aux, g_strdup (ctx->connected ? CONNECTED_STRING : DISCONNECTED_STRING));
|
||||
g_ptr_array_add (aux, mm_dispatcher_connection_event_to_string (ctx->event));
|
||||
g_ptr_array_add (aux, NULL);
|
||||
argv = (GStrv) g_ptr_array_free (aux, FALSE);
|
||||
|
||||
@@ -168,7 +181,7 @@ mm_dispatcher_connection_run (MMDispatcherConnection *self,
|
||||
const gchar *modem_dbus_path,
|
||||
const gchar *bearer_dbus_path,
|
||||
const gchar *data_port,
|
||||
gboolean connected,
|
||||
MMDispatcherConnectionEvent event,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@@ -187,7 +200,7 @@ mm_dispatcher_connection_run (MMDispatcherConnection *self,
|
||||
ctx->modem_dbus_path = g_strdup (modem_dbus_path);
|
||||
ctx->bearer_dbus_path = g_strdup (bearer_dbus_path);
|
||||
ctx->data_port = g_strdup (data_port);
|
||||
ctx->connected = connected;
|
||||
ctx->event = event;
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify)connection_run_context_free);
|
||||
|
||||
/* Iterate over all enabled dirs and collect all dispatcher script paths */
|
||||
|
||||
@@ -32,13 +32,19 @@ typedef struct _MMDispatcherConnection MMDispatcherConnection;
|
||||
typedef struct _MMDispatcherConnectionClass MMDispatcherConnectionClass;
|
||||
typedef struct _MMDispatcherConnectionPrivate MMDispatcherConnectionPrivate;
|
||||
|
||||
typedef enum { /*< underscore_name=mm_dispatcher_connection_event >*/
|
||||
MM_DISPATCHER_CONNECTION_EVENT_CONNECTED,
|
||||
MM_DISPATCHER_CONNECTION_EVENT_DISCONNECTED,
|
||||
MM_DISPATCHER_CONNECTION_EVENT_DISCONNECT_REQUEST,
|
||||
} MMDispatcherConnectionEvent;
|
||||
|
||||
GType mm_dispatcher_connection_get_type (void);
|
||||
MMDispatcherConnection *mm_dispatcher_connection_get (void);
|
||||
void mm_dispatcher_connection_run (MMDispatcherConnection *self,
|
||||
const gchar *modem_dbus_path,
|
||||
const gchar *bearer_dbus_path,
|
||||
const gchar *data_port,
|
||||
gboolean connected,
|
||||
MMDispatcherConnectionEvent event,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
Reference in New Issue
Block a user