api,bearer: new 'Multiplexed' property

This property will be TRUE if the bearer has the data session
connected through a multiplexed interface.

If the bearer is disconnected, or connected without multiplexing, the
property will report FALSE.
This commit is contained in:
Aleksander Morgado
2021-02-25 20:41:28 +01:00
parent 05b9ab7c25
commit 73db7f205c
9 changed files with 72 additions and 9 deletions

View File

@@ -148,6 +148,7 @@ print_bearer_info (MMBearer *bearer)
mmcli_output_string (MMC_F_BEARER_STATUS_CONNECTED, mm_bearer_get_connected (bearer) ? "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));
mmcli_output_string_take (MMC_F_BEARER_STATUS_IP_TIMEOUT, g_strdup_printf ("%u", mm_bearer_get_ip_timeout (bearer)));

View File

@@ -208,6 +208,7 @@ static FieldInfo field_infos[] = {
[MMC_F_BEARER_GENERAL_TYPE] = { "bearer.type", "type", MMC_S_BEARER_GENERAL, },
[MMC_F_BEARER_STATUS_CONNECTED] = { "bearer.status.connected", "connected", 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, },
[MMC_F_BEARER_STATUS_IP_TIMEOUT] = { "bearer.status.ip-timeout", "ip timeout", MMC_S_BEARER_STATUS, },
[MMC_F_BEARER_PROPERTIES_APN] = { "bearer.properties.apn", "apn", MMC_S_BEARER_PROPERTIES, },

View File

@@ -224,6 +224,7 @@ typedef enum {
/* Bearer status section */
MMC_F_BEARER_STATUS_CONNECTED,
MMC_F_BEARER_STATUS_SUSPENDED,
MMC_F_BEARER_STATUS_MULTIPLEXED,
MMC_F_BEARER_STATUS_INTERFACE,
MMC_F_BEARER_STATUS_IP_TIMEOUT,
/* Bearer properties section */

View File

@@ -1073,6 +1073,7 @@ mm_bearer_get_interface
mm_bearer_dup_interface
mm_bearer_get_connected
mm_bearer_get_suspended
mm_bearer_get_multiplexed
mm_bearer_get_ip_timeout
mm_bearer_get_bearer_type
mm_bearer_peek_ipv4_config
@@ -1751,6 +1752,7 @@ mm_gdbus_bearer_get_properties
mm_gdbus_bearer_dup_properties
mm_gdbus_bearer_get_connected
mm_gdbus_bearer_get_suspended
mm_gdbus_bearer_get_multiplexed
mm_gdbus_bearer_get_bearer_type
mm_gdbus_bearer_get_stats
mm_gdbus_bearer_dup_stats
@@ -1772,6 +1774,7 @@ mm_gdbus_bearer_set_properties
mm_gdbus_bearer_set_suspended
mm_gdbus_bearer_set_bearer_type
mm_gdbus_bearer_set_stats
mm_gdbus_bearer_set_multiplexed
mm_gdbus_bearer_override_properties
mm_gdbus_bearer_complete_connect
mm_gdbus_bearer_complete_disconnect

View File

@@ -102,6 +102,14 @@
-->
<property name="Suspended" type="b" access="read" />
<!--
Multiplexed:
This property will be %TRUE if the bearer is connected through a
multiplexed network link.
-->
<property name="Multiplexed" type="b" access="read" />
<!--
Ip4Config:

View File

@@ -202,6 +202,28 @@ mm_bearer_get_suspended (MMBearer *self)
/*****************************************************************************/
/**
* mm_bearer_get_multiplexed:
* @self: A #MMBearer.
*
* Checks whether or not the #MMBearer is connected through a multiplexed
* network likn.
*
* Returns: %TRUE if packet data service is connected via a multiplexed network
* link in the #MMBearer, #FALSE otherwise.
*
* Since: 1.18
*/
gboolean
mm_bearer_get_multiplexed (MMBearer *self)
{
g_return_val_if_fail (MM_IS_BEARER (self), FALSE);
return mm_gdbus_bearer_get_multiplexed (MM_GDBUS_BEARER (self));
}
/*****************************************************************************/
/**
* mm_bearer_get_ip_timeout:
* @self: A #MMBearer.

View File

@@ -78,6 +78,8 @@ gboolean mm_bearer_get_connected (MMBearer *self);
gboolean mm_bearer_get_suspended (MMBearer *self);
gboolean mm_bearer_get_multiplexed (MMBearer *self);
guint mm_bearer_get_ip_timeout (MMBearer *self);
MMBearerType mm_bearer_get_bearer_type (MMBearer *self);

View File

@@ -410,6 +410,7 @@ bearer_stats_start (MMBaseBearer *self)
static void
bearer_reset_interface_status (MMBaseBearer *self)
{
mm_gdbus_bearer_set_multiplexed (MM_GDBUS_BEARER (self), FALSE);
mm_gdbus_bearer_set_connected (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);
@@ -467,9 +468,11 @@ bearer_update_status (MMBaseBearer *self,
static void
bearer_update_status_connected (MMBaseBearer *self,
const gchar *interface,
gboolean multiplexed,
MMBearerIpConfig *ipv4_config,
MMBearerIpConfig *ipv6_config)
{
mm_gdbus_bearer_set_multiplexed (MM_GDBUS_BEARER (self), multiplexed);
mm_gdbus_bearer_set_connected (MM_GDBUS_BEARER (self), TRUE);
mm_gdbus_bearer_set_suspended (MM_GDBUS_BEARER (self), FALSE);
mm_gdbus_bearer_set_interface (MM_GDBUS_BEARER (self), interface);
@@ -830,6 +833,7 @@ connect_ready (MMBaseBearer *self,
bearer_update_status_connected (
self,
mm_port_get_device (mm_bearer_connect_result_peek_data (result)),
mm_bearer_connect_result_get_multiplexed (result),
mm_bearer_connect_result_peek_ipv4_config (result),
mm_bearer_connect_result_peek_ipv6_config (result));
mm_bearer_connect_result_unref (result);
@@ -1535,6 +1539,7 @@ mm_base_bearer_init (MMBaseBearer *self)
/* Set defaults */
mm_gdbus_bearer_set_interface (MM_GDBUS_BEARER (self), NULL);
mm_gdbus_bearer_set_multiplexed (MM_GDBUS_BEARER (self), FALSE);
mm_gdbus_bearer_set_connected (MM_GDBUS_BEARER (self), FALSE);
mm_gdbus_bearer_set_suspended (MM_GDBUS_BEARER (self), FALSE);
mm_gdbus_bearer_set_properties (MM_GDBUS_BEARER (self), NULL);
@@ -1660,6 +1665,7 @@ struct _MMBearerConnectResult {
MMPort *data;
MMBearerIpConfig *ipv4_config;
MMBearerIpConfig *ipv6_config;
gboolean multiplexed;
};
MMBearerConnectResult *
@@ -1701,6 +1707,19 @@ mm_bearer_connect_result_peek_ipv6_config (MMBearerConnectResult *result)
return result->ipv6_config;
}
void
mm_bearer_connect_result_set_multiplexed (MMBearerConnectResult *result,
gboolean multiplexed)
{
result->multiplexed = multiplexed;
}
gboolean
mm_bearer_connect_result_get_multiplexed (MMBearerConnectResult *result)
{
return result->multiplexed;
}
MMBearerConnectResult *
mm_bearer_connect_result_new (MMPort *data,
MMBearerIpConfig *ipv4_config,
@@ -1718,5 +1737,6 @@ mm_bearer_connect_result_new (MMPort *data,
result->ipv4_config = g_object_ref (ipv4_config);
if (ipv6_config)
result->ipv6_config = g_object_ref (ipv6_config);
result->multiplexed = FALSE; /* default */
return result;
}

View File

@@ -41,6 +41,11 @@ MMPort *mm_bearer_connect_result_peek_data (MMBearerConnec
MMBearerIpConfig *mm_bearer_connect_result_peek_ipv4_config (MMBearerConnectResult *result);
MMBearerIpConfig *mm_bearer_connect_result_peek_ipv6_config (MMBearerConnectResult *result);
/* by default, if none specified, multiplexed=FALSE */
void mm_bearer_connect_result_set_multiplexed (MMBearerConnectResult *result,
gboolean multiplexed);
gboolean mm_bearer_connect_result_get_multiplexed (MMBearerConnectResult *result);
/*****************************************************************************/
/* Default timeout values to be used in the steps of a connection or