api: add MTU to bearer IP config properties

This patch adds a 'mtu' value to the Ip4Config and Ip6Config property of
a Bearer object, which indicates the value of the maximum transmission
unit for the established connection when such information is available
(e.g. via QMI_WDS_GET_RUNTIME_SETTINGS on a QMI modem or
MBIM_CID_IP_CONFIGURATION on a MBIM modem).
This commit is contained in:
Ben Chan
2014-03-25 00:18:32 -07:00
committed by Aleksander Morgado
parent 4de728447a
commit e4db8c5302
3 changed files with 60 additions and 0 deletions

View File

@@ -157,6 +157,15 @@
</listitem>
</varlistentry>
</variablelist>
This property may also include the following items when such information is available:
<variablelist>
<varlistentry><term><literal>"mtu"</literal></term>
<listitem>
Maximum transmission unit (MTU), given as an unsigned integer value (signature <literal>"u"</literal>).
</listitem>
</varlistentry>
</variablelist>
-->
<property name="Ip4Config" type="a{sv}" access="read" />
@@ -215,6 +224,15 @@
</listitem>
</varlistentry>
</variablelist>
This property may also include the following items when such information is available:
<variablelist>
<varlistentry><term><literal>"mtu"</literal></term>
<listitem>
Maximum transmission unit (MTU), given as an unsigned integer value (signature <literal>"u"</literal>).
</listitem>
</varlistentry>
</variablelist>
-->
<property name="Ip6Config" type="a{sv}" access="read" />

View File

@@ -40,6 +40,7 @@ G_DEFINE_TYPE (MMBearerIpConfig, mm_bearer_ip_config, G_TYPE_OBJECT);
#define PROPERTY_DNS2 "dns2"
#define PROPERTY_DNS3 "dns3"
#define PROPERTY_GATEWAY "gateway"
#define PROPERTY_MTU "mtu"
struct _MMBearerIpConfigPrivate {
MMBearerIpMethod method;
@@ -47,6 +48,7 @@ struct _MMBearerIpConfigPrivate {
guint prefix;
gchar **dns;
gchar *gateway;
guint mtu;
};
/*****************************************************************************/
@@ -189,6 +191,33 @@ mm_bearer_ip_config_set_gateway (MMBearerIpConfig *self,
/*****************************************************************************/
/**
* mm_bearer_ip_config_get_mtu:
* @self: a #MMBearerIpConfig.
*
* Gets the MTU to be used with this bearer.
*
* Returns: the MTU.
*/
guint
mm_bearer_ip_config_get_mtu (MMBearerIpConfig *self)
{
g_return_val_if_fail (MM_IS_BEARER_IP_CONFIG (self), 0);
return self->priv->mtu;
}
void
mm_bearer_ip_config_set_mtu (MMBearerIpConfig *self,
guint mtu)
{
g_return_if_fail (MM_IS_BEARER_IP_CONFIG (self));
self->priv->mtu = mtu;
}
/*****************************************************************************/
GVariant *
mm_bearer_ip_config_get_dictionary (MMBearerIpConfig *self)
{
@@ -246,6 +275,12 @@ mm_bearer_ip_config_get_dictionary (MMBearerIpConfig *self)
"{sv}",
PROPERTY_GATEWAY,
g_variant_new_string (self->priv->gateway));
if (self->priv->mtu)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_MTU,
g_variant_new_uint32 (self->priv->mtu));
}
return g_variant_builder_end (&builder);
@@ -306,6 +341,10 @@ mm_bearer_ip_config_new_from_dictionary (GVariant *dictionary,
mm_bearer_ip_config_set_gateway (
self,
g_variant_get_string (value, NULL));
else if (g_str_equal (key, PROPERTY_MTU))
mm_bearer_ip_config_set_mtu (
self,
g_variant_get_uint32 (value));
g_free (key);
g_variant_unref (value);

View File

@@ -60,6 +60,7 @@ const gchar *mm_bearer_ip_config_get_address (MMBearerIpConfig *self);
guint mm_bearer_ip_config_get_prefix (MMBearerIpConfig *self);
const gchar **mm_bearer_ip_config_get_dns (MMBearerIpConfig *self);
const gchar *mm_bearer_ip_config_get_gateway (MMBearerIpConfig *self);
guint mm_bearer_ip_config_get_mtu (MMBearerIpConfig *self);
/*****************************************************************************/
/* ModemManager/libmm-glib/mmcli specific methods */
@@ -84,6 +85,8 @@ void mm_bearer_ip_config_set_dns (MMBearerIpConfig *self,
const gchar **dns);
void mm_bearer_ip_config_set_gateway (MMBearerIpConfig *self,
const gchar *gateway);
void mm_bearer_ip_config_set_mtu (MMBearerIpConfig *self,
guint mtu);
GVariant *mm_bearer_ip_config_get_dictionary (MMBearerIpConfig *self);