Re: [MM] [PATCH v2] bearer: allow specifying default IP family for bearers
On 04/22/2013 11:34 PM, Ben Chan wrote: > This patch adds a 'bearer-default-ip-family' property to MMBearer, which > specifies the default IP family to use for a bearer when no explicit > value is given via the simple connect properties. The default IP family > is set to IPv4 in MMBearer but can be overridden by a MMBearer subclass, > which allows a modem plugin to specify an appropriate default value. Pushed, thanks. > --- > libmm-glib/mm-bearer-properties.c | 8 +--- > src/mm-bearer-mbim.c | 14 +++--- > src/mm-bearer-qmi.c | 18 +- > src/mm-bearer.c | 25 + > src/mm-bearer.h | 2 ++ > src/mm-broadband-bearer.c | 16 > 6 files changed, 64 insertions(+), 19 deletions(-) > > diff --git a/libmm-glib/mm-bearer-properties.c > b/libmm-glib/mm-bearer-properties.c > index 6526ed0..2f59fee 100644 > --- a/libmm-glib/mm-bearer-properties.c > +++ b/libmm-glib/mm-bearer-properties.c > @@ -674,13 +674,7 @@ mm_bearer_properties_init (MMBearerProperties *self) > self->priv->allow_roaming = TRUE; > self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN; > self->priv->allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; > - > -/* At some point in the future, this default should probably be changed > - * to IPV4V6. However, presently support for this PDP type is rare. An > - * even better approach would likely be to query which PDP types the > - * modem supports (using AT+CGDCONT=?), and set the default accordingly > - */ > -self->priv->ip_type = MM_BEARER_IP_FAMILY_IPV4; > +self->priv->ip_type = MM_BEARER_IP_FAMILY_UNKNOWN; > } > > static void > diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c > index d96a1b1..bddc9da 100644 > --- a/src/mm-bearer-mbim.c > +++ b/src/mm-bearer-mbim.c > @@ -618,6 +618,7 @@ connect_context_step (ConnectContext *ctx) > const gchar *password; > MbimAuthProtocol auth; > MbimContextIpType ip_type; > +MMBearerIpFamily ip_family; > GError *error = NULL; > > /* Setup parameters to use */ > @@ -658,7 +659,14 @@ connect_context_step (ConnectContext *ctx) > } > } > > -switch (mm_bearer_properties_get_ip_type (ctx->properties)) { > +ip_family = mm_bearer_properties_get_ip_type (ctx->properties); > +if (ip_family == MM_BEARER_IP_FAMILY_UNKNOWN) { > +ip_family = mm_bearer_get_default_ip_family (MM_BEARER > (ctx->self)); > +mm_dbg ("No specific IP family requested, defaulting to %s", > +mm_bearer_ip_family_get_string (ip_family)); > +} > + > +switch (ip_family) { > case MM_BEARER_IP_FAMILY_IPV4: > ip_type = MBIM_CONTEXT_IP_TYPE_IPV4; > break; > @@ -670,8 +678,8 @@ connect_context_step (ConnectContext *ctx) > break; > case MM_BEARER_IP_FAMILY_UNKNOWN: > default: > -mm_dbg ("No specific IP family requested, defaulting to IPv4"); > -ip_type = MBIM_CONTEXT_IP_TYPE_IPV4; > +/* A valid default IP family should have been specified */ > +g_assert_not_reached (); > break; > } > > diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c > index 8f9568d..9e8d2bc 100644 > --- a/src/mm-bearer-qmi.c > +++ b/src/mm-bearer-qmi.c > @@ -846,11 +846,21 @@ _connect (MMBearer *self, > > if (properties) { > MMBearerAllowedAuth auth; > +MMBearerIpFamily ip_family; > > ctx->apn = g_strdup (mm_bearer_properties_get_apn (properties)); > ctx->user = g_strdup (mm_bearer_properties_get_user (properties)); > ctx->password = g_strdup (mm_bearer_properties_get_password > (properties)); > -switch (mm_bearer_properties_get_ip_type (properties)) { > + > +ip_family = mm_bearer_properties_get_ip_type (properties); > +if (ip_family == MM_BEARER_IP_FAMILY_UNKNOWN) { > +ip_family = mm_bearer_get_default_ip_family (self); > +mm_dbg ("No specific IP family requested, defaulting to %s", > +mm_bearer_ip_family_get_string (ip_family)); > +ctx->no_ip_family_preference = TRUE; > +} > + > +switch (ip_family) { > case MM_BEARER_IP_FAMILY_IPV4: > ctx->ipv4 = TRUE; > ctx->ipv6 = FALSE; > @@ -865,10 +875,8 @@ _connect (MMBearer *self, > break; > case MM_BEARER_IP_FAMILY_UNKNOWN: > default: > -mm_dbg ("No specific IP family requested, defaulting to IPv4"); > -ctx->no_ip_family_preference = TRUE; > -ctx->ipv4 = TRUE; > -ctx->ipv6 = FALSE; > +/* A valid default IP family should have been specified */ > +g_assert_not_reached (); > break; > } > > diff --git a/src/m
[MM] [PATCH v2] bearer: allow specifying default IP family for bearers
This patch adds a 'bearer-default-ip-family' property to MMBearer, which specifies the default IP family to use for a bearer when no explicit value is given via the simple connect properties. The default IP family is set to IPv4 in MMBearer but can be overridden by a MMBearer subclass, which allows a modem plugin to specify an appropriate default value. --- libmm-glib/mm-bearer-properties.c | 8 +--- src/mm-bearer-mbim.c | 14 +++--- src/mm-bearer-qmi.c | 18 +- src/mm-bearer.c | 25 + src/mm-bearer.h | 2 ++ src/mm-broadband-bearer.c | 16 6 files changed, 64 insertions(+), 19 deletions(-) diff --git a/libmm-glib/mm-bearer-properties.c b/libmm-glib/mm-bearer-properties.c index 6526ed0..2f59fee 100644 --- a/libmm-glib/mm-bearer-properties.c +++ b/libmm-glib/mm-bearer-properties.c @@ -674,13 +674,7 @@ mm_bearer_properties_init (MMBearerProperties *self) self->priv->allow_roaming = TRUE; self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN; self->priv->allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; - -/* At some point in the future, this default should probably be changed - * to IPV4V6. However, presently support for this PDP type is rare. An - * even better approach would likely be to query which PDP types the - * modem supports (using AT+CGDCONT=?), and set the default accordingly - */ -self->priv->ip_type = MM_BEARER_IP_FAMILY_IPV4; +self->priv->ip_type = MM_BEARER_IP_FAMILY_UNKNOWN; } static void diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index d96a1b1..bddc9da 100644 --- a/src/mm-bearer-mbim.c +++ b/src/mm-bearer-mbim.c @@ -618,6 +618,7 @@ connect_context_step (ConnectContext *ctx) const gchar *password; MbimAuthProtocol auth; MbimContextIpType ip_type; +MMBearerIpFamily ip_family; GError *error = NULL; /* Setup parameters to use */ @@ -658,7 +659,14 @@ connect_context_step (ConnectContext *ctx) } } -switch (mm_bearer_properties_get_ip_type (ctx->properties)) { +ip_family = mm_bearer_properties_get_ip_type (ctx->properties); +if (ip_family == MM_BEARER_IP_FAMILY_UNKNOWN) { +ip_family = mm_bearer_get_default_ip_family (MM_BEARER (ctx->self)); +mm_dbg ("No specific IP family requested, defaulting to %s", +mm_bearer_ip_family_get_string (ip_family)); +} + +switch (ip_family) { case MM_BEARER_IP_FAMILY_IPV4: ip_type = MBIM_CONTEXT_IP_TYPE_IPV4; break; @@ -670,8 +678,8 @@ connect_context_step (ConnectContext *ctx) break; case MM_BEARER_IP_FAMILY_UNKNOWN: default: -mm_dbg ("No specific IP family requested, defaulting to IPv4"); -ip_type = MBIM_CONTEXT_IP_TYPE_IPV4; +/* A valid default IP family should have been specified */ +g_assert_not_reached (); break; } diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c index 8f9568d..9e8d2bc 100644 --- a/src/mm-bearer-qmi.c +++ b/src/mm-bearer-qmi.c @@ -846,11 +846,21 @@ _connect (MMBearer *self, if (properties) { MMBearerAllowedAuth auth; +MMBearerIpFamily ip_family; ctx->apn = g_strdup (mm_bearer_properties_get_apn (properties)); ctx->user = g_strdup (mm_bearer_properties_get_user (properties)); ctx->password = g_strdup (mm_bearer_properties_get_password (properties)); -switch (mm_bearer_properties_get_ip_type (properties)) { + +ip_family = mm_bearer_properties_get_ip_type (properties); +if (ip_family == MM_BEARER_IP_FAMILY_UNKNOWN) { +ip_family = mm_bearer_get_default_ip_family (self); +mm_dbg ("No specific IP family requested, defaulting to %s", +mm_bearer_ip_family_get_string (ip_family)); +ctx->no_ip_family_preference = TRUE; +} + +switch (ip_family) { case MM_BEARER_IP_FAMILY_IPV4: ctx->ipv4 = TRUE; ctx->ipv6 = FALSE; @@ -865,10 +875,8 @@ _connect (MMBearer *self, break; case MM_BEARER_IP_FAMILY_UNKNOWN: default: -mm_dbg ("No specific IP family requested, defaulting to IPv4"); -ctx->no_ip_family_preference = TRUE; -ctx->ipv4 = TRUE; -ctx->ipv6 = FALSE; +/* A valid default IP family should have been specified */ +g_assert_not_reached (); break; } diff --git a/src/mm-bearer.c b/src/mm-bearer.c index 9e96bde..d047e11 100644 --- a/src/mm-bearer.c +++ b/src/mm-bearer.c @@ -57,6 +57,7 @@ enum { PROP_MODEM, PROP_STATUS, PROP_CONFIG, +PROP_DEFAULT_IP_FAMILY, PROP_LAST }; @@ -73,6 +74,8 @@ struct _MMBearerPrivate { MMBearerSt