mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 04:08:01 +02:00
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.
(cherry picked from commit 29a53b1cd7)
This commit is contained in:
parent
fbe98ba107
commit
c961c36c8f
3 changed files with 51 additions and 96 deletions
|
|
@ -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,
|
||||
|
|
@ -260,10 +255,6 @@ supplicant_interface_acquire (NMDeviceWifi *self)
|
|||
NM_SUPPLICANT_INTERFACE_STATE,
|
||||
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),
|
||||
|
|
@ -1629,14 +1620,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;
|
||||
|
||||
|
|
@ -1651,40 +1641,40 @@ 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;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
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);
|
||||
_ap_dump (self, found_ap, "updated", 0);
|
||||
} else {
|
||||
_ap_dump (self, ap, "added", 0);
|
||||
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE);
|
||||
}
|
||||
gs_unref_object NMWifiAP *ap = NULL;
|
||||
|
||||
g_object_unref (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)) {
|
||||
/* 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));
|
||||
}
|
||||
}
|
||||
|
||||
ap_add_remove (self, ACCESS_POINT_ADDED, ap, TRUE);
|
||||
_ap_dump (self, ap, "added", 0);
|
||||
}
|
||||
|
||||
/* Update the current AP if the supplicant notified a current BSS change
|
||||
* before it sent the current BSS's scan result.
|
||||
|
|
@ -1695,32 +1685,6 @@ supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
|
|||
schedule_ap_list_dump (self);
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
@ -1734,19 +1698,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,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_data (G_OBJECT (proxy), BSS_PROXY_INITED, 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_data (G_OBJECT (bss_proxy), BSS_PROXY_INITED)) {
|
||||
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),
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue