diff options
author | Thomas Haller <thaller@redhat.com> | 2020-06-09 09:25:18 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-06-10 19:45:46 +0200 |
commit | 8d6dbd17465275e88acbe49d70d5d3b32d879fb2 (patch) | |
tree | 0e63417d63bafd6f3e2c2d109d0983494ab91e15 | |
parent | 96c9703b50cac9287daf04ca28e932ba6339d53d (diff) | |
download | NetworkManager-8d6dbd17465275e88acbe49d70d5d3b32d879fb2.tar.gz |
core: add "external" flag for active connections of external devices
-rw-r--r-- | libnm-core/nm-dbus-interface.h | 3 | ||||
-rw-r--r-- | src/nm-active-connection.c | 22 |
2 files changed, 22 insertions, 3 deletions
diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index 5b7b4058b7..1e656333c6 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -1024,6 +1024,8 @@ typedef enum { /*< flags >*/ * of the activation is bound to the visilibity of the connection profile, * which in turn depends on "connection.permissions" and whether a session * for the user exists. Since: 1.16 + * @NM_ACTIVATION_STATE_FLAG_EXTERNAL: the active connection was generated to + * represent an external configuration of a networking device. Since: 1.26 * * Flags describing the current activation state. * @@ -1039,6 +1041,7 @@ typedef enum { /*< flags >*/ NM_ACTIVATION_STATE_FLAG_IP6_READY = 0x10, NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES = 0x20, NM_ACTIVATION_STATE_FLAG_LIFETIME_BOUND_TO_PROFILE_VISIBILITY = 0x40, + NM_ACTIVATION_STATE_FLAG_EXTERNAL = 0x80, } NMActivationStateFlags; /** diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index d0e07b62af..08037ebe71 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -163,6 +163,7 @@ NM_UTILS_FLAGS2STR_DEFINE (_state_flags_to_string, NMActivationStateFlags, NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_IP6_READY, "ip6-ready"), NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES, "master-has-slaves"), NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_LIFETIME_BOUND_TO_PROFILE_VISIBILITY, "lifetime-bound-to-profile-visibility"), + NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_EXTERNAL, "external"), ); /*****************************************************************************/ @@ -340,7 +341,12 @@ nm_active_connection_set_state_fail (NMActiveConnection *self, NMActivationStateFlags nm_active_connection_get_state_flags (NMActiveConnection *self) { - return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->state_flags; + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); + + return priv->state_flags + | ( priv->activation_type == NM_ACTIVATION_TYPE_EXTERNAL + ? NM_ACTIVATION_STATE_FLAG_EXTERNAL + : NM_ACTIVATION_STATE_FLAG_NONE); } void @@ -351,6 +357,8 @@ nm_active_connection_set_state_flags_full (NMActiveConnection *self, NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); NMActivationStateFlags f; + nm_assert (!NM_FLAGS_HAS (mask, NM_ACTIVATION_STATE_FLAG_EXTERNAL)); + f = (priv->state_flags & ~mask) | (state_flags & mask); if (f != priv->state_flags) { char buf1[_NM_ACTIVATION_STATE_FLAG_TO_STRING_BUFSIZE]; @@ -869,10 +877,14 @@ _set_activation_type (NMActiveConnection *self, NMActivationType activation_type) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); + gboolean state_flags_changed; if (priv->activation_type == activation_type) return; + state_flags_changed = (priv->activation_type == NM_ACTIVATION_TYPE_EXTERNAL) + != (activation_type == NM_ACTIVATION_TYPE_EXTERNAL); + priv->activation_type = activation_type; if (priv->settings_connection.obj) { @@ -881,6 +893,9 @@ _set_activation_type (NMActiveConnection *self, else g_signal_handlers_disconnect_by_func (priv->settings_connection.obj, _settings_connection_flags_changed, self); } + + if (state_flags_changed) + _notify (self, PROP_STATE_FLAGS); } static void @@ -1253,7 +1268,8 @@ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); + NMActiveConnection *self = NM_ACTIVE_CONNECTION (object); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); char **strv; NMDevice *master_device = NULL; @@ -1300,7 +1316,7 @@ get_property (GObject *object, guint prop_id, } break; case PROP_STATE_FLAGS: - g_value_set_uint (value, priv->state_flags); + g_value_set_uint (value, nm_active_connection_get_state_flags (self)); break; case PROP_DEFAULT: g_value_set_boolean (value, priv->is_default); |