summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--introspection/org.freedesktop.NetworkManager.Connection.Active.xml9
-rw-r--r--libnm-core/nm-dbus-interface.h12
-rw-r--r--libnm/libnm.ver2
-rw-r--r--libnm/nm-active-connection.c39
-rw-r--r--libnm/nm-active-connection.h3
-rw-r--r--src/nm-active-connection.c43
-rw-r--r--src/nm-active-connection.h14
7 files changed, 122 insertions, 0 deletions
diff --git a/introspection/org.freedesktop.NetworkManager.Connection.Active.xml b/introspection/org.freedesktop.NetworkManager.Connection.Active.xml
index 31a485c9ff..3962cf88ee 100644
--- a/introspection/org.freedesktop.NetworkManager.Connection.Active.xml
+++ b/introspection/org.freedesktop.NetworkManager.Connection.Active.xml
@@ -81,6 +81,15 @@
<property name="State" type="u" access="read"/>
<!--
+ StateFlags:
+
+ The state flags of this active connection.
+
+ Returns: <link linkend="NMActivationStateFlags">NMActivationStateFlags</link>
+ -->
+ <property name="StateFlags" type="u" access="read"/>
+
+ <!--
StateChanged:
@state: (<link linkend="NMActiveConnectionState">NMActiveConnectionState</link>) The new state of the active connection.
@reason: (<link linkend="NMActiveConnectionStateReason">NMActiveConnectionStateReason</link>) Reason code describing the change to the new state.
diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h
index 11492def2c..e5125f569a 100644
--- a/libnm-core/nm-dbus-interface.h
+++ b/libnm-core/nm-dbus-interface.h
@@ -877,4 +877,16 @@ typedef enum {
NM_IP_ROUTE_TABLE_SYNC_MODE_FULL = 3,
} NMIPRouteTableSyncMode;
+/**
+ * NMActivationStateFlags:
+ * @NM_ACTIVATION_STATE_FLAG_NONE: an alias for numeric zero, no flags set.
+ *
+ * Flags describing the current activation state.
+ *
+ * Since: 1.10
+ **/
+typedef enum { /*< flags >*/
+ NM_ACTIVATION_STATE_FLAG_NONE = 0,
+} NMActivationStateFlags;
+
#endif /* __NM_DBUS_INTERFACE_H__ */
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 5f3867c4f7..72c6224b3a 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1180,6 +1180,8 @@ global:
libnm_1_10_0 {
global:
+ nm_activation_state_flags_get_type;
+ nm_active_connection_get_state_flags;
nm_client_connectivity_check_get_available;
nm_client_connectivity_check_get_enabled;
nm_client_connectivity_check_set_enabled;
diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c
index 412cb3babb..a0ea8a254b 100644
--- a/libnm/nm-active-connection.c
+++ b/libnm/nm-active-connection.c
@@ -51,6 +51,7 @@ typedef struct {
char *specific_object_path;
GPtrArray *devices;
NMActiveConnectionState state;
+ guint state_flags;
gboolean is_default;
NMIPConfig *ip4_config;
NMDhcpConfig *dhcp4_config;
@@ -71,6 +72,7 @@ enum {
PROP_SPECIFIC_OBJECT_PATH,
PROP_DEVICES,
PROP_STATE,
+ PROP_STATE_FLAGS,
PROP_DEFAULT,
PROP_IP4_CONFIG,
PROP_DHCP4_CONFIG,
@@ -216,6 +218,24 @@ nm_active_connection_get_state (NMActiveConnection *connection)
}
/**
+ * nm_active_connection_get_state_flags:
+ * @connection: a #NMActiveConnection
+ *
+ * Gets the active connection's state flags.
+ *
+ * Returns: the state flags
+ *
+ * Since: 1.10
+ **/
+NMActivationStateFlags
+nm_active_connection_get_state_flags (NMActiveConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVATION_STATE_FLAG_NONE);
+
+ return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->state_flags;
+}
+
+/**
* nm_active_connection_get_state_reason:
* @connection: a #NMActiveConnection
*
@@ -474,6 +494,9 @@ get_property (GObject *object,
case PROP_STATE:
g_value_set_enum (value, nm_active_connection_get_state (self));
break;
+ case PROP_STATE_FLAGS:
+ g_value_set_uint (value, nm_active_connection_get_state_flags (self));
+ break;
case PROP_DEFAULT:
g_value_set_boolean (value, nm_active_connection_get_default (self));
break;
@@ -537,6 +560,7 @@ init_dbus (NMObject *object)
{ "specific-object", &priv->specific_object_path, demarshal_specific_object_path },
{ NM_ACTIVE_CONNECTION_DEVICES, &priv->devices, NULL, NM_TYPE_DEVICE },
{ NM_ACTIVE_CONNECTION_STATE, &priv->state },
+ { NM_ACTIVE_CONNECTION_STATE_FLAGS, &priv->state_flags },
{ NM_ACTIVE_CONNECTION_DEFAULT, &priv->is_default },
{ NM_ACTIVE_CONNECTION_IP4_CONFIG, &priv->ip4_config, NULL, NM_TYPE_IP4_CONFIG },
{ NM_ACTIVE_CONNECTION_DHCP4_CONFIG, &priv->dhcp4_config, NULL, NM_TYPE_DHCP4_CONFIG },
@@ -664,6 +688,21 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
G_PARAM_STATIC_STRINGS));
/**
+ * NMActiveConnection:state-flags:
+ *
+ * The state flags of the active connection.
+ *
+ * Since: 1.10
+ **/
+ g_object_class_install_property
+ (object_class, PROP_STATE_FLAGS,
+ g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE_FLAGS, "", "",
+ 0, G_MAXUINT32,
+ NM_ACTIVATION_STATE_FLAG_NONE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
* NMActiveConnection:default:
*
* Whether the active connection is the default IPv4 one.
diff --git a/libnm/nm-active-connection.h b/libnm/nm-active-connection.h
index 23cd737246..093ca64e1c 100644
--- a/libnm/nm-active-connection.h
+++ b/libnm/nm-active-connection.h
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT_PATH "specific-object-path"
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
#define NM_ACTIVE_CONNECTION_STATE "state"
+#define NM_ACTIVE_CONNECTION_STATE_FLAGS "state-flags"
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
#define NM_ACTIVE_CONNECTION_IP4_CONFIG "ip4-config"
#define NM_ACTIVE_CONNECTION_DHCP4_CONFIG "dhcp4-config"
@@ -76,6 +77,8 @@ const char *nm_active_connection_get_connection_type (NM
const char *nm_active_connection_get_specific_object_path (NMActiveConnection *connection);
const GPtrArray *nm_active_connection_get_devices (NMActiveConnection *connection);
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *connection);
+NM_AVAILABLE_IN_1_10
+NMActivationStateFlags nm_active_connection_get_state_flags (NMActiveConnection *connection);
NM_AVAILABLE_IN_1_8
NMActiveConnectionStateReason nm_active_connection_get_state_reason (NMActiveConnection *connection);
NMDevice *nm_active_connection_get_master (NMActiveConnection *connection);
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index 00414f0d17..61917156dd 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -44,6 +44,8 @@ typedef struct _NMActiveConnectionPrivate {
char *pending_activation_id;
+ NMActivationStateFlags state_flags;
+
NMActiveConnectionState state;
bool is_default:1;
bool is_default6:1;
@@ -73,6 +75,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMActiveConnection,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
PROP_STATE,
+ PROP_STATE_FLAGS,
PROP_DEFAULT,
PROP_IP4_CONFIG,
PROP_DHCP4_CONFIG,
@@ -143,6 +146,10 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_state_to_string, NMActiveConnectionState,
);
#define state_to_string(state) NM_UTILS_LOOKUP_STR (_state_to_string, state)
+NM_UTILS_FLAGS2STR_DEFINE_STATIC (_state_flags_to_string, NMActivationStateFlags,
+ NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_NONE, "none"),
+);
+
/*****************************************************************************/
static void
@@ -279,6 +286,33 @@ nm_active_connection_set_state (NMActiveConnection *self,
}
}
+NMActivationStateFlags
+nm_active_connection_get_state_flags (NMActiveConnection *self)
+{
+ return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->state_flags;
+}
+
+void
+nm_active_connection_set_state_flags_full (NMActiveConnection *self,
+ NMActivationStateFlags state_flags,
+ NMActivationStateFlags mask)
+{
+ NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
+ NMActivationStateFlags f;
+
+ f = (priv->state_flags & ~mask) | (state_flags & mask);
+ if (f != priv->state_flags) {
+ char buf1[G_N_ELEMENTS (_nm_utils_to_string_buffer)];
+ char buf2[G_N_ELEMENTS (_nm_utils_to_string_buffer)];
+
+ _LOGD ("set state-flags %s (was %s)",
+ _state_flags_to_string (f, buf1, sizeof (buf1)),
+ _state_flags_to_string (priv->state_flags, buf2, sizeof (buf2)));
+ priv->state_flags = f;
+ _notify (self, PROP_STATE_FLAGS);
+ }
+}
+
const char *
nm_active_connection_get_settings_connection_id (NMActiveConnection *self)
{
@@ -1105,6 +1139,9 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, NM_ACTIVE_CONNECTION_STATE_ACTIVATING);
}
break;
+ case PROP_STATE_FLAGS:
+ g_value_set_uint (value, priv->state_flags);
+ break;
case PROP_DEFAULT:
g_value_set_boolean (value, priv->is_default);
break;
@@ -1359,6 +1396,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_STATE_FLAGS] =
+ g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE_FLAGS, "", "",
+ 0, G_MAXUINT32, NM_ACTIVATION_STATE_FLAG_NONE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
+
obj_properties[PROP_DEFAULT] =
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT, "", "",
FALSE,
diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h
index 8d3478c79d..5562b42f07 100644
--- a/src/nm-active-connection.h
+++ b/src/nm-active-connection.h
@@ -39,6 +39,7 @@
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
#define NM_ACTIVE_CONNECTION_STATE "state"
+#define NM_ACTIVE_CONNECTION_STATE_FLAGS "state-flags"
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
#define NM_ACTIVE_CONNECTION_IP4_CONFIG "ip4-config"
#define NM_ACTIVE_CONNECTION_DHCP4_CONFIG "dhcp4-config"
@@ -145,6 +146,19 @@ void nm_active_connection_set_state (NMActiveConnection *self,
NMActiveConnectionState state,
NMActiveConnectionStateReason reason);
+NMActivationStateFlags nm_active_connection_get_state_flags (NMActiveConnection *self);
+
+void nm_active_connection_set_state_flags_full (NMActiveConnection *self,
+ NMActivationStateFlags state_flags,
+ NMActivationStateFlags mask);
+
+static inline void
+nm_active_connection_set_state_flags (NMActiveConnection *self,
+ NMActivationStateFlags state_flags)
+{
+ nm_active_connection_set_state_flags_full (self, state_flags, state_flags);
+}
+
NMDevice * nm_active_connection_get_device (NMActiveConnection *self);
gboolean nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device);