mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-15 20:00:23 +01:00
modem: get ip-timeout during modem creation
Grab it from the GetAll call where it'll already be instead of asking for it separately.
This commit is contained in:
parent
002155fb09
commit
0e6de5d2cf
3 changed files with 25 additions and 35 deletions
|
|
@ -76,7 +76,8 @@ get_modem_properties (DBusGConnection *connection,
|
|||
char **data_device,
|
||||
char **driver,
|
||||
guint32 *type,
|
||||
guint32 *ip_method)
|
||||
guint32 *ip_method,
|
||||
guint32 *ip_timeout)
|
||||
{
|
||||
DBusGProxy *proxy;
|
||||
GError *err = NULL;
|
||||
|
|
@ -119,6 +120,8 @@ get_modem_properties (DBusGConnection *connection,
|
|||
*data_device = g_value_dup_string (value);
|
||||
else if (g_strcmp0 (prop, "Driver") == 0)
|
||||
*driver = g_value_dup_string (value);
|
||||
else if (g_strcmp0 (prop, "IpTimeout") == 0)
|
||||
*ip_timeout = g_value_get_uint (value);
|
||||
}
|
||||
g_hash_table_unref (props);
|
||||
|
||||
|
|
@ -136,6 +139,7 @@ create_modem (NMModemManager *manager, const char *path)
|
|||
char *data_device = NULL, *driver = NULL, *master_device = NULL;
|
||||
uint modem_type = MM_MODEM_TYPE_UNKNOWN;
|
||||
uint ip_method = MM_MODEM_IP_METHOD_PPP;
|
||||
uint ip_timeout = 0;
|
||||
|
||||
if (g_hash_table_lookup (priv->modems, path)) {
|
||||
nm_log_warn (LOGD_MB, "modem with path %s already exists, ignoring", path);
|
||||
|
|
@ -144,7 +148,7 @@ create_modem (NMModemManager *manager, const char *path)
|
|||
|
||||
if (!get_modem_properties (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
||||
path, &master_device, &data_device, &driver,
|
||||
&modem_type, &ip_method))
|
||||
&modem_type, &ip_method, &ip_timeout))
|
||||
return;
|
||||
|
||||
if (modem_type == MM_MODEM_TYPE_UNKNOWN) {
|
||||
|
|
@ -177,6 +181,7 @@ create_modem (NMModemManager *manager, const char *path)
|
|||
g_free (data_device);
|
||||
|
||||
if (modem) {
|
||||
g_object_set (G_OBJECT (modem), NM_MODEM_IP_TIMEOUT, ip_timeout, NULL);
|
||||
g_hash_table_insert (priv->modems, g_strdup (path), modem);
|
||||
g_signal_emit (manager, signals[MODEM_ADDED], 0, modem, driver);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ enum {
|
|||
PROP_IFACE,
|
||||
PROP_PATH,
|
||||
PROP_IP_METHOD,
|
||||
PROP_IP_TIMEOUT,
|
||||
PROP_ENABLED,
|
||||
|
||||
LAST_PROP
|
||||
|
|
@ -225,7 +226,7 @@ ppp_stage3_ip4_config_start (NMModem *self,
|
|||
const char *ppp_name = NULL;
|
||||
GError *error = NULL;
|
||||
NMActStageReturn ret;
|
||||
guint32 ip_timeout;
|
||||
guint ip_timeout = 20;
|
||||
|
||||
g_return_val_if_fail (self != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
g_return_val_if_fail (NM_IS_MODEM (self), NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
|
@ -247,8 +248,7 @@ ppp_stage3_ip4_config_start (NMModem *self,
|
|||
nm_log_info (LOGD_PPP, "using modem-specified IP timeout: %u seconds",
|
||||
priv->mm_ip_timeout);
|
||||
ip_timeout = priv->mm_ip_timeout;
|
||||
} else
|
||||
ip_timeout = 20;
|
||||
}
|
||||
|
||||
priv->ppp_manager = nm_ppp_manager_new (priv->iface);
|
||||
if (nm_ppp_manager_start (priv->ppp_manager, req, ppp_name, ip_timeout, &error)) {
|
||||
|
|
@ -694,35 +694,6 @@ nm_modem_get_path (NMModem *self)
|
|||
return NM_MODEM_GET_PRIVATE (self)->path;
|
||||
}
|
||||
|
||||
static void
|
||||
get_mm_ip_timeout_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMModem *self = NM_MODEM (user_data);
|
||||
GError *error = NULL;
|
||||
GValue value = { 0, };
|
||||
|
||||
/* On error or if invalid value, just set 0 and we will use the default
|
||||
* configuration afterwards */
|
||||
if (dbus_g_proxy_end_call (proxy, call_id, &error,
|
||||
G_TYPE_VALUE, &value,
|
||||
G_TYPE_INVALID) &&
|
||||
G_VALUE_HOLDS_UINT (&value)) {
|
||||
NM_MODEM_GET_PRIVATE (self)->mm_ip_timeout = g_value_get_uint (&value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
query_mm_ip_timeout (NMModem *self)
|
||||
{
|
||||
dbus_g_proxy_begin_call (NM_MODEM_GET_PRIVATE (self)->props_proxy,
|
||||
"Get", get_mm_ip_timeout_done,
|
||||
self, NULL,
|
||||
G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM,
|
||||
G_TYPE_STRING, "IpTimeout",
|
||||
G_TYPE_INVALID);
|
||||
}
|
||||
|
||||
static void
|
||||
get_mm_enabled_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
|
|
@ -892,7 +863,6 @@ constructor (GType type,
|
|||
object,
|
||||
NULL);
|
||||
|
||||
query_mm_ip_timeout (NM_MODEM (object));
|
||||
query_mm_enabled (NM_MODEM (object));
|
||||
|
||||
return object;
|
||||
|
|
@ -921,6 +891,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_IP_METHOD:
|
||||
g_value_set_uint (value, priv->ip_method);
|
||||
break;
|
||||
case PROP_IP_TIMEOUT:
|
||||
g_value_set_uint (value, priv->mm_ip_timeout);
|
||||
break;
|
||||
case PROP_ENABLED:
|
||||
g_value_set_boolean (value, priv->mm_enabled);
|
||||
break;
|
||||
|
|
@ -954,6 +927,9 @@ set_property (GObject *object, guint prop_id,
|
|||
/* Construct only */
|
||||
priv->ip_method = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_IP_TIMEOUT:
|
||||
priv->mm_ip_timeout = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_ENABLED:
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1036,6 +1012,14 @@ nm_modem_class_init (NMModemClass *klass)
|
|||
MM_MODEM_IP_METHOD_PPP,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP_TIMEOUT,
|
||||
g_param_spec_uint (NM_MODEM_IP_TIMEOUT,
|
||||
"IP timeout",
|
||||
"IP timeout",
|
||||
0, 360, 20,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ENABLED,
|
||||
g_param_spec_boolean (NM_MODEM_ENABLED,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ G_BEGIN_DECLS
|
|||
#define NM_MODEM_DEVICE "device"
|
||||
#define NM_MODEM_IFACE "iface"
|
||||
#define NM_MODEM_IP_METHOD "ip-method"
|
||||
#define NM_MODEM_IP_TIMEOUT "ip-timeout"
|
||||
#define NM_MODEM_ENABLED "enabled"
|
||||
|
||||
#define NM_MODEM_PPP_STATS "ppp-stats"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue