mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 19:50:08 +01:00
core: handle new device states
The device states aren't used yet, but handle them anyway.
This commit is contained in:
parent
14b23ba399
commit
23943e7ce2
5 changed files with 41 additions and 34 deletions
|
|
@ -754,6 +754,12 @@ nm_modem_device_state_changed (NMModem *self,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_state_is_active (NMDeviceState state)
|
||||
{
|
||||
return (state >= NM_DEVICE_STATE_IP_CONFIG && state <= NM_DEVICE_STATE_DEACTIVATING);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_modem_hw_is_up (NMModem *self, NMDevice *device)
|
||||
{
|
||||
|
|
@ -764,7 +770,7 @@ nm_modem_hw_is_up (NMModem *self, NMDevice *device)
|
|||
NMDeviceState state;
|
||||
|
||||
state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device));
|
||||
if (priv->pending_ip4_config || state == NM_DEVICE_STATE_IP_CONFIG || state == NM_DEVICE_STATE_ACTIVATED)
|
||||
if (priv->pending_ip4_config || _state_is_active (state))
|
||||
return nm_system_device_is_up (device);
|
||||
}
|
||||
|
||||
|
|
@ -781,7 +787,7 @@ nm_modem_hw_bring_up (NMModem *self, NMDevice *device, gboolean *no_firmware)
|
|||
NMDeviceState state;
|
||||
|
||||
state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device));
|
||||
if (priv->pending_ip4_config || state == NM_DEVICE_STATE_IP_CONFIG || state == NM_DEVICE_STATE_ACTIVATED)
|
||||
if (priv->pending_ip4_config || _state_is_active (state))
|
||||
return nm_system_device_set_up_down (device, TRUE, no_firmware);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -425,6 +425,8 @@ ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data)
|
|||
case NM_DEVICE_STATE_PREPARE:
|
||||
case NM_DEVICE_STATE_CONFIG:
|
||||
case NM_DEVICE_STATE_NEED_AUTH:
|
||||
case NM_DEVICE_STATE_IP_CHECK:
|
||||
case NM_DEVICE_STATE_SECONDARIES:
|
||||
case NM_DEVICE_STATE_ACTIVATED:
|
||||
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data)
|
|||
case NM_DEVICE_STATE_PREPARE:
|
||||
case NM_DEVICE_STATE_CONFIG:
|
||||
case NM_DEVICE_STATE_NEED_AUTH:
|
||||
case NM_DEVICE_STATE_IP_CHECK:
|
||||
case NM_DEVICE_STATE_SECONDARIES:
|
||||
case NM_DEVICE_STATE_ACTIVATED:
|
||||
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1190,6 +1190,8 @@ nm_device_handle_autoip4_event (NMDevice *self,
|
|||
aipd_timeout_remove (self);
|
||||
nm_device_activate_schedule_stage4_ip4_config_get (self);
|
||||
break;
|
||||
case NM_DEVICE_STATE_IP_CHECK:
|
||||
case NM_DEVICE_STATE_SECONDARIES:
|
||||
case NM_DEVICE_STATE_ACTIVATED:
|
||||
priv->aipd_addr = ip.s_addr;
|
||||
if (!handle_autoip_change (self, &reason))
|
||||
|
|
@ -2961,29 +2963,20 @@ gboolean
|
|||
nm_device_is_activating (NMDevice *device)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
||||
NMDeviceState state;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
||||
|
||||
switch (nm_device_get_state (device)) {
|
||||
case NM_DEVICE_STATE_PREPARE:
|
||||
case NM_DEVICE_STATE_CONFIG:
|
||||
case NM_DEVICE_STATE_NEED_AUTH:
|
||||
case NM_DEVICE_STATE_IP_CONFIG:
|
||||
state = nm_device_get_state (device);
|
||||
if (state >= NM_DEVICE_STATE_PREPARE && state <= NM_DEVICE_STATE_SECONDARIES)
|
||||
return TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* There's a small race between the time when stage 1 is scheduled
|
||||
* and when the device actually sets STATE_PREPARE when the activation
|
||||
* handler is actually run. If there's an activation handler scheduled
|
||||
* we're activating anyway.
|
||||
*/
|
||||
if (priv->act_source_id)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
return priv->act_source_id ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -3457,6 +3450,12 @@ set_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_is_connected (NMDeviceState state)
|
||||
{
|
||||
return (state >= NM_DEVICE_STATE_IP_CONFIG && state <= NM_DEVICE_STATE_DEACTIVATING);
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
|
|
@ -3475,7 +3474,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, priv->iface);
|
||||
break;
|
||||
case NM_DEVICE_INTERFACE_PROP_IP_IFACE:
|
||||
if ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG))
|
||||
if (_is_connected (state))
|
||||
g_value_set_string (value, nm_device_get_ip_iface (self));
|
||||
else
|
||||
g_value_set_string (value, NULL);
|
||||
|
|
@ -3493,33 +3492,25 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, priv->ip4_address);
|
||||
break;
|
||||
case NM_DEVICE_INTERFACE_PROP_IP4_CONFIG:
|
||||
if ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG)) {
|
||||
if (priv->ip4_config) {
|
||||
g_value_set_boxed (value, nm_ip4_config_get_dbus_path (priv->ip4_config));
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_value_set_boxed (value, "/");
|
||||
if (_is_connected (state) && priv->ip4_config)
|
||||
g_value_set_boxed (value, nm_ip4_config_get_dbus_path (priv->ip4_config));
|
||||
else
|
||||
g_value_set_boxed (value, "/");
|
||||
break;
|
||||
case NM_DEVICE_INTERFACE_PROP_DHCP4_CONFIG:
|
||||
if ( ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG))
|
||||
&& priv->dhcp4_client)
|
||||
if (_is_connected (state) && priv->dhcp4_client)
|
||||
g_value_set_boxed (value, nm_dhcp4_config_get_dbus_path (priv->dhcp4_config));
|
||||
else
|
||||
g_value_set_boxed (value, "/");
|
||||
break;
|
||||
case NM_DEVICE_INTERFACE_PROP_IP6_CONFIG:
|
||||
if ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG)) {
|
||||
if (priv->ip6_config) {
|
||||
g_value_set_boxed (value, nm_ip6_config_get_dbus_path (priv->ip6_config));
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_value_set_boxed (value, "/");
|
||||
if (_is_connected (state) && priv->ip6_config)
|
||||
g_value_set_boxed (value, nm_ip6_config_get_dbus_path (priv->ip6_config));
|
||||
else
|
||||
g_value_set_boxed (value, "/");
|
||||
break;
|
||||
case NM_DEVICE_INTERFACE_PROP_DHCP6_CONFIG:
|
||||
if ( ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG))
|
||||
&& priv->dhcp6_client)
|
||||
if (_is_connected (state) && priv->dhcp6_client)
|
||||
g_value_set_boxed (value, nm_dhcp6_config_get_dbus_path (priv->dhcp6_config));
|
||||
else
|
||||
g_value_set_boxed (value, "/");
|
||||
|
|
|
|||
|
|
@ -297,8 +297,14 @@ get_dev_state_string (NMDeviceState state)
|
|||
return "connecting (need authentication)";
|
||||
else if (state == NM_DEVICE_STATE_IP_CONFIG)
|
||||
return "connecting (getting IP configuration)";
|
||||
else if (state == NM_DEVICE_STATE_IP_CHECK)
|
||||
return "connecting (checking IP connectivity)";
|
||||
else if (state == NM_DEVICE_STATE_SECONDARIES)
|
||||
return "connecting (starting dependent connections)";
|
||||
else if (state == NM_DEVICE_STATE_ACTIVATED)
|
||||
return "connected";
|
||||
else if (state == NM_DEVICE_STATE_DEACTIVATING)
|
||||
return "disconnecting";
|
||||
else if (state == NM_DEVICE_STATE_FAILED)
|
||||
return "connection failed";
|
||||
return "unknown";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue