summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-04-05 23:31:02 -0500
committerDan Williams <dcbw@redhat.com>2015-04-10 10:17:43 -0500
commit3c19ce7616b15a7f577967912ef999e03a2b45d5 (patch)
treecd7967b3f9662271d2c13b41e61ab401638c6310
parent0aca44c857d8d949b272baacbfbaef08d16618d4 (diff)
downloadNetworkManager-3c19ce7616b15a7f577967912ef999e03a2b45d5.tar.gz
supplicant: track and expose wpa_supplicant's CurrentBSS property
-rw-r--r--src/supplicant-manager/nm-supplicant-interface.c48
-rw-r--r--src/supplicant-manager/nm-supplicant-interface.h6
2 files changed, 48 insertions, 6 deletions
diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c
index 7f79964410..0a39ff9b51 100644
--- a/src/supplicant-manager/nm-supplicant-interface.c
+++ b/src/supplicant-manager/nm-supplicant-interface.c
@@ -64,6 +64,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
enum {
PROP_0 = 0,
PROP_SCANNING,
+ PROP_CURRENT_BSS,
LAST_PROP
};
@@ -91,6 +92,7 @@ typedef struct {
char * net_path;
guint32 blobs_left;
GHashTable * bss_proxies;
+ char * current_bss;
gint32 last_scan; /* timestamp as returned by nm_utils_get_monotonic_timestamp_s() */
@@ -320,6 +322,17 @@ nm_supplicant_interface_get_scanning (NMSupplicantInterface *self)
return FALSE;
}
+const char *
+nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self)
+{
+ NMSupplicantInterfacePrivate *priv;
+
+ g_return_val_if_fail (self != NULL, FALSE);
+
+ priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
+ return priv->state >= NM_SUPPLICANT_INTERFACE_STATE_READY ? priv->current_bss : NULL;
+}
+
gint32
nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self)
{
@@ -550,6 +563,8 @@ props_changed_cb (GDBusProxy *proxy,
gint32 i32;
GVariant *v;
+ g_object_freeze_notify (G_OBJECT (self));
+
if (g_variant_lookup (changed_properties, "Scanning", "b", &b))
set_scanning (self, b);
@@ -570,6 +585,16 @@ props_changed_cb (GDBusProxy *proxy,
g_free (array);
}
+ if (g_variant_lookup (changed_properties, "CurrentBSS", "&o", &s)) {
+ if (strcmp (s, "/") == 0)
+ s = NULL;
+ if (g_strcmp0 (s, priv->current_bss) != 0) {
+ g_free (priv->current_bss);
+ priv->current_bss = g_strdup (s);
+ g_object_notify (G_OBJECT (self), NM_SUPPLICANT_INTERFACE_CURRENT_BSS);
+ }
+ }
+
v = g_variant_lookup_value (changed_properties, "Capabilities", G_VARIANT_TYPE_VARDICT);
if (v) {
parse_capabilities (self, v);
@@ -589,6 +614,8 @@ props_changed_cb (GDBusProxy *proxy,
priv->disconnect_reason);
}
}
+
+ g_object_thaw_notify (G_OBJECT (self));
}
static void
@@ -1268,11 +1295,7 @@ set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
static void
@@ -1281,9 +1304,14 @@ get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
+ NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object);
+
switch (prop_id) {
case PROP_SCANNING:
- g_value_set_boolean (value, NM_SUPPLICANT_INTERFACE_GET_PRIVATE (object)->scanning);
+ g_value_set_boolean (value, priv->scanning);
+ break;
+ case PROP_CURRENT_BSS:
+ g_value_set_string (value, priv->current_bss);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1314,6 +1342,7 @@ dispose (GObject *object)
g_clear_pointer (&priv->net_path, g_free);
g_clear_pointer (&priv->dev, g_free);
g_clear_pointer (&priv->object_path, g_free);
+ g_clear_pointer (&priv->current_bss, g_free);
g_clear_object (&priv->cfg);
@@ -1340,6 +1369,13 @@ nm_supplicant_interface_class_init (NMSupplicantInterfaceClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property
+ (object_class, PROP_CURRENT_BSS,
+ g_param_spec_string (NM_SUPPLICANT_INTERFACE_CURRENT_BSS, "", "",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
/* Signals */
signals[STATE] =
g_signal_new (NM_SUPPLICANT_INTERFACE_STATE,
diff --git a/src/supplicant-manager/nm-supplicant-interface.h b/src/supplicant-manager/nm-supplicant-interface.h
index da3ad57048..6be89f4222 100644
--- a/src/supplicant-manager/nm-supplicant-interface.h
+++ b/src/supplicant-manager/nm-supplicant-interface.h
@@ -54,6 +54,10 @@ enum {
#define NM_IS_SUPPLICANT_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SUPPLICANT_INTERFACE))
#define NM_SUPPLICANT_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SUPPLICANT_INTERFACE, NMSupplicantInterfaceClass))
+/* Properties */
+#define NM_SUPPLICANT_INTERFACE_CURRENT_BSS "current-bss"
+
+/* Signals */
#define NM_SUPPLICANT_INTERFACE_STATE "state"
#define NM_SUPPLICANT_INTERFACE_REMOVED "removed"
#define NM_SUPPLICANT_INTERFACE_NEW_BSS "new-bss"
@@ -145,6 +149,8 @@ const char *nm_supplicant_interface_state_to_string (guint32 state);
gboolean nm_supplicant_interface_get_scanning (NMSupplicantInterface *self);
+const char *nm_supplicant_interface_get_current_bss (NMSupplicantInterface *self);
+
gint32 nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self);
const char *nm_supplicant_interface_get_ifname (NMSupplicantInterface *self);