aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-03-31 23:33:24 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-03-31 23:46:31 +0200
commit2c27a7aadc79f3ded2e0ab13cc757266639f01e1 (patch)
tree4edae2451304c184f10f0eca0bb4ee74c169b080
parent317900635136564cce1ce74ef09a8e5fb012912b (diff)
base-bearer: remove default IP family property
There is no point in providing a configurable default IP family in the bearer object, because we can always assume IPv4 as being the only default expected. Simplify the logic and also provide a new method to get the normalize the IP family, using IPv4 as default always.
-rw-r--r--plugins/huawei/mm-broadband-bearer-huawei.c11
-rw-r--r--src/mm-base-bearer.c25
-rw-r--r--src/mm-base-bearer.h21
-rw-r--r--src/mm-bearer-mbim.c11
-rw-r--r--src/mm-bearer-qmi.c10
-rw-r--r--src/mm-broadband-bearer.c29
-rw-r--r--src/mm-modem-helpers.c14
-rw-r--r--src/mm-modem-helpers.h6
8 files changed, 37 insertions, 90 deletions
diff --git a/plugins/huawei/mm-broadband-bearer-huawei.c b/plugins/huawei/mm-broadband-bearer-huawei.c
index 4bf2bb59..425edda2 100644
--- a/plugins/huawei/mm-broadband-bearer-huawei.c
+++ b/plugins/huawei/mm-broadband-bearer-huawei.c
@@ -345,16 +345,7 @@ connect_3gpp_context_step (GTask *task)
MMBearerIpFamily ip_family;
ip_family = mm_bearer_properties_get_ip_type (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
- if (ip_family == MM_BEARER_IP_FAMILY_NONE ||
- ip_family == MM_BEARER_IP_FAMILY_ANY) {
- gchar *ip_family_str;
-
- ip_family = mm_base_bearer_get_default_ip_family (MM_BASE_BEARER (self));
- ip_family_str = mm_bearer_ip_family_build_string_from_mask (ip_family);
- mm_obj_dbg (self, "no specific IP family requested, defaulting to %s", ip_family_str);
- g_free (ip_family_str);
- }
-
+ mm_3gpp_normalize_ip_family (&ip_family, self);
if (ip_family != MM_BEARER_IP_FAMILY_IPV4) {
g_task_return_new_error (task,
MM_CORE_ERROR,
diff --git a/src/mm-base-bearer.c b/src/mm-base-bearer.c
index 6b8e6439..64a8057c 100644
--- a/src/mm-base-bearer.c
+++ b/src/mm-base-bearer.c
@@ -70,7 +70,6 @@ enum {
PROP_MODEM,
PROP_STATUS,
PROP_CONFIG,
- PROP_DEFAULT_IP_FAMILY,
PROP_LAST
};
@@ -92,8 +91,6 @@ struct _MMBaseBearerPrivate {
gboolean ignore_disconnection_reports;
/* Configuration of the bearer */
MMBearerProperties *config;
- /* Default IP family of this bearer */
- MMBearerIpFamily default_ip_family;
/* Cancellable for connect() */
GCancellable *connect_cancellable;
@@ -1289,12 +1286,6 @@ mm_base_bearer_get_config (MMBaseBearer *self)
NULL);
}
-MMBearerIpFamily
-mm_base_bearer_get_default_ip_family (MMBaseBearer *self)
-{
- return self->priv->default_ip_family;
-}
-
/*****************************************************************************/
static void
@@ -1481,9 +1472,6 @@ set_property (GObject *object,
g_variant_unref (dictionary);
break;
}
- case PROP_DEFAULT_IP_FAMILY:
- self->priv->default_ip_family = g_value_get_flags (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1514,9 +1502,6 @@ get_property (GObject *object,
case PROP_CONFIG:
g_value_set_object (value, self->priv->config);
break;
- case PROP_DEFAULT_IP_FAMILY:
- g_value_set_flags (value, self->priv->default_ip_family);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1539,7 +1524,6 @@ mm_base_bearer_init (MMBaseBearer *self)
self->priv->status = MM_BEARER_STATUS_DISCONNECTED;
self->priv->reason_3gpp = CONNECTION_FORBIDDEN_REASON_NONE;
self->priv->reason_cdma = CONNECTION_FORBIDDEN_REASON_NONE;
- self->priv->default_ip_family = MM_BEARER_IP_FAMILY_IPV4;
self->priv->stats = mm_bearer_stats_new ();
/* Set defaults */
@@ -1651,15 +1635,6 @@ mm_base_bearer_class_init (MMBaseBearerClass *klass)
MM_TYPE_BEARER_PROPERTIES,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CONFIG, properties[PROP_CONFIG]);
-
- properties[PROP_DEFAULT_IP_FAMILY] =
- g_param_spec_flags (MM_BASE_BEARER_DEFAULT_IP_FAMILY,
- "Bearer default IP family",
- "IP family to use for this bearer when no IP family is specified",
- MM_TYPE_BEARER_IP_FAMILY,
- MM_BEARER_IP_FAMILY_IPV4,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_DEFAULT_IP_FAMILY, properties[PROP_DEFAULT_IP_FAMILY]);
}
/*****************************************************************************/
diff --git a/src/mm-base-bearer.h b/src/mm-base-bearer.h
index 73a65067..53d65af7 100644
--- a/src/mm-base-bearer.h
+++ b/src/mm-base-bearer.h
@@ -70,12 +70,11 @@ typedef struct _MMBaseBearer MMBaseBearer;
typedef struct _MMBaseBearerClass MMBaseBearerClass;
typedef struct _MMBaseBearerPrivate MMBaseBearerPrivate;
-#define MM_BASE_BEARER_PATH "bearer-path"
-#define MM_BASE_BEARER_CONNECTION "bearer-connection"
-#define MM_BASE_BEARER_MODEM "bearer-modem"
-#define MM_BASE_BEARER_STATUS "bearer-status"
-#define MM_BASE_BEARER_CONFIG "bearer-config"
-#define MM_BASE_BEARER_DEFAULT_IP_FAMILY "bearer-default-ip-family"
+#define MM_BASE_BEARER_PATH "bearer-path"
+#define MM_BASE_BEARER_CONNECTION "bearer-connection"
+#define MM_BASE_BEARER_MODEM "bearer-modem"
+#define MM_BASE_BEARER_STATUS "bearer-status"
+#define MM_BASE_BEARER_CONFIG "bearer-config"
typedef enum { /*< underscore_name=mm_bearer_status >*/
MM_BEARER_STATUS_DISCONNECTED,
@@ -148,12 +147,10 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMBaseBearer, g_object_unref)
void mm_base_bearer_export (MMBaseBearer *self);
-const gchar *mm_base_bearer_get_path (MMBaseBearer *self);
-MMBearerStatus mm_base_bearer_get_status (MMBaseBearer *self);
-MMBearerProperties *mm_base_bearer_peek_config (MMBaseBearer *self);
-MMBearerProperties *mm_base_bearer_get_config (MMBaseBearer *self);
-MMBearerIpFamily mm_base_bearer_get_default_ip_family (MMBaseBearer *self);
-
+const gchar *mm_base_bearer_get_path (MMBaseBearer *self);
+MMBearerStatus mm_base_bearer_get_status (MMBaseBearer *self);
+MMBearerProperties *mm_base_bearer_peek_config (MMBaseBearer *self);
+MMBearerProperties *mm_base_bearer_get_config (MMBaseBearer *self);
void mm_base_bearer_connect (MMBaseBearer *self,
GAsyncReadyCallback callback,
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
index b8e6af25..d185eca4 100644
--- a/src/mm-bearer-mbim.c
+++ b/src/mm-bearer-mbim.c
@@ -1054,16 +1054,7 @@ connect_context_step (GTask *task)
}
ip_family = mm_bearer_properties_get_ip_type (ctx->properties);
- if (ip_family == MM_BEARER_IP_FAMILY_NONE ||
- ip_family == MM_BEARER_IP_FAMILY_ANY) {
- gchar * str;
-
- ip_family = mm_base_bearer_get_default_ip_family (MM_BASE_BEARER (self));
- str = mm_bearer_ip_family_build_string_from_mask (ip_family);
- mm_obj_dbg (self, "no specific IP family requested, defaulting to %s", str);
- g_free (str);
- }
-
+ mm_3gpp_normalize_ip_family (&ip_family, self);
ctx->requested_ip_type = mm_bearer_ip_family_to_mbim_context_ip_type (ip_family, &error);
if (error) {
g_task_return_error (task, error);
diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c
index 5a348b26..151d0be9 100644
--- a/src/mm-bearer-qmi.c
+++ b/src/mm-bearer-qmi.c
@@ -2068,16 +2068,8 @@ _connect (MMBaseBearer *_self,
ctx->password = g_strdup (mm_bearer_properties_get_password (properties));
ip_family = mm_bearer_properties_get_ip_type (properties);
- if (ip_family == MM_BEARER_IP_FAMILY_NONE ||
- ip_family == MM_BEARER_IP_FAMILY_ANY) {
- gchar *ip_family_str;
-
- ip_family = mm_base_bearer_get_default_ip_family (_self);
- ip_family_str = mm_bearer_ip_family_build_string_from_mask (ip_family);
- mm_obj_dbg (self, "no specific IP family requested, defaulting to %s", ip_family_str);
+ if (mm_3gpp_normalize_ip_family (&ip_family, self))
ctx->no_ip_family_preference = TRUE;
- g_free (ip_family_str);
- }
if (ip_family & MM_BEARER_IP_FAMILY_IPV4)
ctx->ipv4 = TRUE;
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index 73869a0c..925439f2 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -81,26 +81,6 @@ mm_broadband_bearer_get_3gpp_cid (MMBroadbandBearer *self)
}
/*****************************************************************************/
-
-static MMBearerIpFamily
-select_bearer_ip_family (MMBroadbandBearer *self)
-{
- MMBearerIpFamily ip_family;
-
- ip_family = mm_bearer_properties_get_ip_type (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
- if (ip_family == MM_BEARER_IP_FAMILY_NONE || ip_family == MM_BEARER_IP_FAMILY_ANY) {
- gchar *default_family;
-
- ip_family = mm_base_bearer_get_default_ip_family (MM_BASE_BEARER (self));
- default_family = mm_bearer_ip_family_build_string_from_mask (ip_family);
- mm_obj_dbg (self, "no specific IP family requested, defaulting to %s", default_family);
- g_free (default_family);
- }
-
- return ip_family;
-}
-
-/*****************************************************************************/
/* Detailed connect context, used in both CDMA and 3GPP sequences */
typedef struct {
@@ -150,7 +130,9 @@ detailed_connect_context_new (MMBroadbandBearer *self,
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
ctx->primary = g_object_ref (primary);
ctx->secondary = (secondary ? g_object_ref (secondary) : NULL);
- ctx->ip_family = select_bearer_ip_family (self);
+
+ ctx->ip_family = mm_bearer_properties_get_ip_type (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
+ mm_3gpp_normalize_ip_family (&ctx->ip_family, self);
return ctx;
}
@@ -924,7 +906,10 @@ cid_selection_3gpp (MMBroadbandBearer *self,
ctx->modem = g_object_ref (modem);
ctx->primary = g_object_ref (primary);
ctx->cancellable = g_object_ref (cancellable);
- ctx->ip_family = select_bearer_ip_family (self);
+
+ ctx->ip_family = mm_bearer_properties_get_ip_type (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
+ mm_3gpp_normalize_ip_family (&ctx->ip_family, self);
+
g_task_set_task_data (task, ctx, (GDestroyNotify) cid_selection_3gpp_context_free);
/* Validate PDP type */
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index a0702200..ce97cbc2 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -4099,6 +4099,20 @@ mm_3gpp_get_ip_family_from_pdp_type (const gchar *pdp_type)
return MM_BEARER_IP_FAMILY_NONE;
}
+gboolean
+mm_3gpp_normalize_ip_family (MMBearerIpFamily *family,
+ gpointer log_object)
+{
+ /* if nothing specific requested, default to IPv4 */
+ if (*family == MM_BEARER_IP_FAMILY_NONE || *family == MM_BEARER_IP_FAMILY_ANY) {
+ *family = MM_BEARER_IP_FAMILY_IPV4;
+ return TRUE;
+ }
+
+ /* no need to normalize */
+ return FALSE;
+}
+
/*************************************************************************/
/* ICCID validation */
/*
diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h
index b64e8e01..ced2ef6a 100644
--- a/src/mm-modem-helpers.h
+++ b/src/mm-modem-helpers.h
@@ -437,8 +437,10 @@ gboolean mm_3gpp_parse_operator_id (const gchar *operator_id,
guint16 *mnc,
GError **error);
-const gchar *mm_3gpp_get_pdp_type_from_ip_family (MMBearerIpFamily family);
-MMBearerIpFamily mm_3gpp_get_ip_family_from_pdp_type (const gchar *pdp_type);
+const gchar *mm_3gpp_get_pdp_type_from_ip_family (MMBearerIpFamily family);
+MMBearerIpFamily mm_3gpp_get_ip_family_from_pdp_type (const gchar *pdp_type);
+gboolean mm_3gpp_normalize_ip_family (MMBearerIpFamily *family,
+ gpointer log_object);
char *mm_3gpp_parse_iccid (const char *raw_iccid, GError **error);