bearer-mbim: session id 0 by default in all non-multiplexed connections
The original logic in the MBIM modem would assume that if we had more than one network interface in the same modem, we could connect multiple data interfaces, each one with a different session. That logic is actually wrong, when using the master (non-multiplexed) network interface we should always use session id 0, which is the one holding all non-VLAN-tagged traffic. So, remove the logic that automatically creates new bearers with a different session id, as that is really wrong.
This commit is contained in:
@@ -34,18 +34,9 @@
|
||||
|
||||
G_DEFINE_TYPE (MMBearerMbim, mm_bearer_mbim, MM_TYPE_BASE_BEARER)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SESSION_ID,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
static GParamSpec *properties[PROP_LAST];
|
||||
|
||||
struct _MMBearerMbimPrivate {
|
||||
/* The session ID for this bearer */
|
||||
guint32 session_id;
|
||||
|
||||
MMPort *data;
|
||||
};
|
||||
|
||||
@@ -1320,8 +1311,7 @@ report_connection_status (MMBaseBearer *self,
|
||||
|
||||
MMBaseBearer *
|
||||
mm_bearer_mbim_new (MMBroadbandModemMbim *modem,
|
||||
MMBearerProperties *config,
|
||||
guint32 session_id)
|
||||
MMBearerProperties *config)
|
||||
{
|
||||
MMBaseBearer *bearer;
|
||||
|
||||
@@ -1329,9 +1319,8 @@ mm_bearer_mbim_new (MMBroadbandModemMbim *modem,
|
||||
* and that means that the object is not async-initable, so we just use
|
||||
* g_object_new() here */
|
||||
bearer = g_object_new (MM_TYPE_BEARER_MBIM,
|
||||
MM_BASE_BEARER_MODEM, modem,
|
||||
MM_BASE_BEARER_MODEM, modem,
|
||||
MM_BASE_BEARER_CONFIG, config,
|
||||
MM_BEARER_MBIM_SESSION_ID, (guint)session_id,
|
||||
NULL);
|
||||
|
||||
/* Only export valid bearers */
|
||||
@@ -1340,43 +1329,6 @@ mm_bearer_mbim_new (MMBroadbandModemMbim *modem,
|
||||
return bearer;
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MMBearerMbim *self = MM_BEARER_MBIM (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SESSION_ID:
|
||||
self->priv->session_id = g_value_get_uint (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MMBearerMbim *self = MM_BEARER_MBIM (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SESSION_ID:
|
||||
g_value_set_uint (value, self->priv->session_id);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mm_bearer_mbim_init (MMBearerMbim *self)
|
||||
{
|
||||
@@ -1404,8 +1356,6 @@ mm_bearer_mbim_class_init (MMBearerMbimClass *klass)
|
||||
|
||||
/* Virtual methods */
|
||||
object_class->dispose = dispose;
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
||||
base_bearer_class->connect = _connect;
|
||||
base_bearer_class->connect_finish = connect_finish;
|
||||
@@ -1416,14 +1366,4 @@ mm_bearer_mbim_class_init (MMBearerMbimClass *klass)
|
||||
base_bearer_class->reload_stats_finish = reload_stats_finish;
|
||||
base_bearer_class->load_connection_status = NULL;
|
||||
base_bearer_class->load_connection_status_finish = NULL;
|
||||
|
||||
properties[PROP_SESSION_ID] =
|
||||
g_param_spec_uint (MM_BEARER_MBIM_SESSION_ID,
|
||||
"Session ID",
|
||||
"Session ID to use with this bearer",
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_SESSION_ID, properties[PROP_SESSION_ID]);
|
||||
}
|
||||
|
@@ -53,8 +53,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMBearerMbim, g_object_unref)
|
||||
/* MBIM bearer creation implementation.
|
||||
* NOTE it is *not* a broadband bearer, so not async-initable */
|
||||
MMBaseBearer *mm_bearer_mbim_new (MMBroadbandModemMbim *modem,
|
||||
MMBearerProperties *config,
|
||||
guint32 session_id);
|
||||
MMBearerProperties *config);
|
||||
|
||||
guint32 mm_bearer_mbim_get_session_id (MMBearerMbim *self);
|
||||
|
||||
|
@@ -1962,93 +1962,29 @@ modem_reset (MMIfaceModem *_self,
|
||||
/* Create Bearer (Modem interface) */
|
||||
|
||||
static MMBaseBearer *
|
||||
modem_create_bearer_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
modem_create_bearer_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
guint32 session_id;
|
||||
gboolean found;
|
||||
} FindSessionId;
|
||||
|
||||
static void
|
||||
bearer_list_session_id_foreach (MMBaseBearer *bearer,
|
||||
gpointer user_data)
|
||||
modem_create_bearer (MMIfaceModem *self,
|
||||
MMBearerProperties *properties,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
FindSessionId *ctx = user_data;
|
||||
|
||||
if (!ctx->found &&
|
||||
MM_IS_BEARER_MBIM (bearer) &&
|
||||
mm_bearer_mbim_get_session_id (MM_BEARER_MBIM (bearer)) == ctx->session_id)
|
||||
ctx->found = TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
find_next_bearer_session_id (MMBroadbandModemMbim *self)
|
||||
{
|
||||
MMBearerList *bearer_list;
|
||||
guint i;
|
||||
|
||||
g_object_get (self,
|
||||
MM_IFACE_MODEM_BEARER_LIST, &bearer_list,
|
||||
NULL);
|
||||
|
||||
if (!bearer_list)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i <= 255; i++) {
|
||||
FindSessionId ctx;
|
||||
|
||||
ctx.session_id = i;
|
||||
ctx.found = FALSE;
|
||||
|
||||
mm_bearer_list_foreach (bearer_list,
|
||||
bearer_list_session_id_foreach,
|
||||
&ctx);
|
||||
|
||||
if (!ctx.found) {
|
||||
g_object_unref (bearer_list);
|
||||
return (gint)i;
|
||||
}
|
||||
}
|
||||
|
||||
/* no valid session id found */
|
||||
g_object_unref (bearer_list);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
modem_create_bearer (MMIfaceModem *_self,
|
||||
MMBearerProperties *properties,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (_self);
|
||||
MMBaseBearer *bearer;
|
||||
GTask *task;
|
||||
gint session_id;
|
||||
GTask *task;
|
||||
|
||||
/* Note: the session id to be used by the bearer will always be 0
|
||||
* for non-multiplexed sessions, bound to the non-VLAN-tagged traffic
|
||||
* managed by the master network interface */
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
/* Find a new session ID */
|
||||
session_id = find_next_bearer_session_id (self);
|
||||
if (session_id < 0) {
|
||||
g_task_return_new_error (task,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Not enough session IDs");
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We just create a MMBearerMbim */
|
||||
mm_obj_dbg (self, "creating MBIM bearer in MBIM modem");
|
||||
bearer = mm_bearer_mbim_new (self,
|
||||
properties,
|
||||
(guint)session_id);
|
||||
bearer = mm_bearer_mbim_new (MM_BROADBAND_MODEM_MBIM (self), properties);
|
||||
g_task_return_pointer (task, bearer, g_object_unref);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
Reference in New Issue
Block a user