summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-02-15 11:17:55 +0100
committerThomas Haller <thaller@redhat.com>2017-02-17 14:41:26 +0100
commit29a53b1cd7fb48984221c71b38b049c3ced9b560 (patch)
treec8fdf0414996a08a5a389db83718c5f03951eca3
parentc47026715ec6a9612752f469358a7251aabbdee7 (diff)
downloadNetworkManager-29a53b1cd7fb48984221c71b38b049c3ced9b560.tar.gz
supplicant: merge NEW_BSS signal with BSS_UPDATED
Before, the NEW_BSS signal was not careful to emit the signal only when the BSS is seen for the first time. Consequently, supplicant_iface_new_bss_cb() checked whether it already knows about the new BSS. Merge NEW_BSS and BSS_UPDATED. Now we emit BSS_UPDATED when either the BSS is new or changed. Also, in supplicant_iface_new_bss_cb() (now supplicant_iface_bss_updated_cb()) no longer constructs an @ap instance if we have a @found_ap. In some situations there can be a value of having a separate ADD signal. But only when there the consumers care, and if the consumers can trust that ADD is not just an UPDATE. The only consumer doesn't care and it not not be trusted, so merge the signals.
-rw-r--r--src/devices/wifi/nm-device-wifi.c125
-rw-r--r--src/supplicant/nm-supplicant-interface.c17
-rw-r--r--src/supplicant/nm-supplicant-interface.h1
3 files changed, 49 insertions, 94 deletions
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 88560a1896..6af76b598a 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -157,11 +157,6 @@ static void supplicant_iface_state_cb (NMSupplicantInterface *iface,
int disconnect_reason,
gpointer user_data);
-static void supplicant_iface_new_bss_cb (NMSupplicantInterface * iface,
- const char *object_path,
- GVariant *properties,
- NMDeviceWifi * self);
-
static void supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
const char *object_path,
GVariant *properties,
@@ -261,10 +256,6 @@ supplicant_interface_acquire (NMDeviceWifi *self)
G_CALLBACK (supplicant_iface_state_cb),
self);
g_signal_connect (priv->sup_iface,
- NM_SUPPLICANT_INTERFACE_NEW_BSS,
- G_CALLBACK (supplicant_iface_new_bss_cb),
- self);
- g_signal_connect (priv->sup_iface,
NM_SUPPLICANT_INTERFACE_BSS_UPDATED,
G_CALLBACK (supplicant_iface_bss_updated_cb),
self);
@@ -1634,14 +1625,13 @@ try_fill_ssid_for_hidden_ap (NMDeviceWifi *self,
}
static void
-supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
- const char *object_path,
- GVariant *properties,
- NMDeviceWifi *self)
+supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
+ const char *object_path,
+ GVariant *properties,
+ NMDeviceWifi *self)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMDeviceState state;
- NMWifiAP *ap;
NMWifiAP *found_ap = NULL;
const GByteArray *ssid;
@@ -1656,41 +1646,41 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
if (NM_DEVICE_WIFI_GET_PRIVATE (self)->mode == NM_802_11_MODE_AP)
return;
- ap = nm_wifi_ap_new_from_properties (object_path, properties);
- if (!ap) {
- _LOGD (LOGD_WIFI, "invalid AP properties received for %s", object_path);
- return;
- }
+ found_ap = get_ap_by_supplicant_path (self, object_path);
+ if (found_ap) {
+ nm_wifi_ap_update_from_properties (found_ap, object_path, properties);
+ _ap_dump (self, found_ap, "updated", 0);
+ } else {
+ gs_unref_object NMWifiAP *ap = NULL;
- /* Let the manager try to fill in the SSID from seen-bssids lists */
- ssid = nm_wifi_ap_get_ssid (ap);
- if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) {
- /* Try to fill the SSID from the AP database */
- try_fill_ssid_for_hidden_ap (self, ap);
+ ap = nm_wifi_ap_new_from_properties (object_path, properties);
+ if (!ap) {
+ _LOGD (LOGD_WIFI, "invalid AP properties received for %s", object_path);
+ return;
+ }
+ /* Let the manager try to fill in the SSID from seen-bssids lists */
ssid = nm_wifi_ap_get_ssid (ap);
- if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) {
- /* Yay, matched it, no longer treat as hidden */
- _LOGD (LOGD_WIFI, "matched hidden AP %s => '%s'",
- nm_wifi_ap_get_address (ap), nm_utils_escape_ssid (ssid->data, ssid->len));
- } else {
- /* Didn't have an entry for this AP in the database */
- _LOGD (LOGD_WIFI, "failed to match hidden AP %s",
- nm_wifi_ap_get_address (ap));
+ if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) {
+ /* Try to fill the SSID from the AP database */
+ try_fill_ssid_for_hidden_ap (self, ap);
+
+ ssid = nm_wifi_ap_get_ssid (ap);
+ if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) {
+ /* Yay, matched it, no longer treat as hidden */
+ _LOGD (LOGD_WIFI, "matched hidden AP %s => '%s'",
+ nm_wifi_ap_get_address (ap), nm_utils_escape_ssid (ssid->data, ssid->len));
+ } else {
+ /* Didn't have an entry for this AP in the database */
+ _LOGD (LOGD_WIFI, "failed to match hidden AP %s",
+ nm_wifi_ap_get_address (ap));
+ }
}
- }
- found_ap = get_ap_by_supplicant_path (self, object_path);
- if (found_ap) {
- _ap_dump (self, ap, "updated", 0);
- nm_wifi_ap_update_from_properties (found_ap, object_path, properties);
- } else {
- _ap_dump (self, ap, "added", 0);
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE);
+ _ap_dump (self, ap, "added", 0);
}
- g_object_unref (ap);
-
/* Update the current AP if the supplicant notified a current BSS change
* before it sent the current BSS's scan result.
*/
@@ -1701,32 +1691,6 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
}
static void
-supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
- const char *object_path,
- GVariant *properties,
- NMDeviceWifi *self)
-{
- NMDeviceState state;
- NMWifiAP *ap;
-
- g_return_if_fail (self != NULL);
- g_return_if_fail (object_path != NULL);
- g_return_if_fail (properties != NULL);
-
- /* Ignore new APs when unavailable or unmanaged */
- state = nm_device_get_state (NM_DEVICE (self));
- if (state <= NM_DEVICE_STATE_UNAVAILABLE)
- return;
-
- ap = get_ap_by_supplicant_path (self, object_path);
- if (ap) {
- _ap_dump (self, ap, "updated", 0);
- nm_wifi_ap_update_from_properties (ap, object_path, properties);
- schedule_ap_list_dump (self);
- }
-}
-
-static void
supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface,
const char *object_path,
NMDeviceWifi *self)
@@ -1739,19 +1703,20 @@ supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface,
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
ap = get_ap_by_supplicant_path (self, object_path);
- if (ap) {
- if (ap == priv->current_ap) {
- /* The current AP cannot be removed (to prevent NM indicating that
- * it is connected, but to nothing), but it must be removed later
- * when the current AP is changed or cleared. Set 'fake' to
- * indicate that this AP is now unknown to the supplicant.
- */
- nm_wifi_ap_set_fake (ap, TRUE);
- } else {
- _ap_dump (self, ap, "removed", 0);
- ap_add_remove (self, ACCESS_POINT_REMOVED, ap, TRUE);
- schedule_ap_list_dump (self);
- }
+ if (!ap)
+ return;
+
+ if (ap == priv->current_ap) {
+ /* The current AP cannot be removed (to prevent NM indicating that
+ * it is connected, but to nothing), but it must be removed later
+ * when the current AP is changed or cleared. Set 'fake' to
+ * indicate that this AP is now unknown to the supplicant.
+ */
+ nm_wifi_ap_set_fake (ap, TRUE);
+ } else {
+ _ap_dump (self, ap, "removed", 0);
+ ap_add_remove (self, ACCESS_POINT_REMOVED, ap, TRUE);
+ schedule_ap_list_dump (self);
}
}
diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c
index 62cf96be63..2590b1de44 100644
--- a/src/supplicant/nm-supplicant-interface.c
+++ b/src/supplicant/nm-supplicant-interface.c
@@ -62,8 +62,7 @@ typedef struct _AddNetworkData {
enum {
STATE, /* change in the interface's state */
REMOVED, /* interface was removed by the supplicant */
- NEW_BSS, /* interface saw a new access point from a scan */
- BSS_UPDATED, /* a BSS property changed */
+ BSS_UPDATED, /* a new BSS appeared or an existing had properties changed */
BSS_REMOVED, /* supplicant removed BSS from its scan list */
SCAN_DONE, /* wifi scan is complete */
CREDENTIALS_REQUEST, /* 802.1x identity or password requested */
@@ -229,7 +228,7 @@ on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_da
g_object_set_qdata (G_OBJECT (proxy), bss_proxy_inited_quark (), GUINT_TO_POINTER (TRUE));
- g_signal_emit (self, signals[NEW_BSS], 0,
+ g_signal_emit (self, signals[BSS_UPDATED], 0,
g_dbus_proxy_get_object_path (proxy),
g_variant_ref_sink (props));
}
@@ -577,13 +576,13 @@ wpas_iface_scan_done (GDBusProxy *proxy,
/* Cache last scan completed time */
priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
- /* Emit NEW_BSS so that wifi device has the APs (in case it removed them) */
+ /* Emit BSS_UPDATED so that wifi device has the APs (in case it removed them) */
g_hash_table_iter_init (&iter, priv->bss_proxies);
while (g_hash_table_iter_next (&iter, (gpointer) &bss_path, (gpointer) &bss_proxy)) {
if (g_object_get_qdata (G_OBJECT (bss_proxy), bss_proxy_inited_quark ())) {
props = _get_bss_proxy_properties (self, bss_proxy);
if (props) {
- g_signal_emit (self, signals[NEW_BSS], 0,
+ g_signal_emit (self, signals[BSS_UPDATED], 0,
bss_path,
g_variant_ref_sink (props));
g_variant_unref (props);
@@ -1634,14 +1633,6 @@ nm_supplicant_interface_class_init (NMSupplicantInterfaceClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 0);
- signals[NEW_BSS] =
- g_signal_new (NM_SUPPLICANT_INTERFACE_NEW_BSS,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VARIANT);
-
signals[BSS_UPDATED] =
g_signal_new (NM_SUPPLICANT_INTERFACE_BSS_UPDATED,
G_OBJECT_CLASS_TYPE (object_class),
diff --git a/src/supplicant/nm-supplicant-interface.h b/src/supplicant/nm-supplicant-interface.h
index 97ee38e689..d60d4a544c 100644
--- a/src/supplicant/nm-supplicant-interface.h
+++ b/src/supplicant/nm-supplicant-interface.h
@@ -64,7 +64,6 @@ typedef enum {
/* Signals */
#define NM_SUPPLICANT_INTERFACE_STATE "state"
#define NM_SUPPLICANT_INTERFACE_REMOVED "removed"
-#define NM_SUPPLICANT_INTERFACE_NEW_BSS "new-bss"
#define NM_SUPPLICANT_INTERFACE_BSS_UPDATED "bss-updated"
#define NM_SUPPLICANT_INTERFACE_BSS_REMOVED "bss-removed"
#define NM_SUPPLICANT_INTERFACE_SCAN_DONE "scan-done"