diff options
author | Dan Williams <dcbw@redhat.com> | 2015-04-06 11:36:34 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2015-04-10 10:17:45 -0500 |
commit | 0bdee17402057a8fc0e054de828113208bd76b5b (patch) | |
tree | 0dcf4aa9a76f18c88022d19e55988160ad70f1ff | |
parent | 37760fdc8341843e18ff13f01a8814a26c731e89 (diff) | |
download | NetworkManager-0bdee17402057a8fc0e054de828113208bd76b5b.tar.gz |
wifi: update AP properties from supplicant signals
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 2 | ||||
-rw-r--r-- | src/devices/wifi/nm-wifi-ap.c | 48 | ||||
-rw-r--r-- | src/devices/wifi/nm-wifi-ap.h | 4 |
3 files changed, 37 insertions, 17 deletions
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index c14749a8ab..87c1abfa29 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1709,7 +1709,7 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface, /* Update the AP's last-seen property */ ap = get_ap_by_supplicant_path (self, object_path); if (ap) - nm_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ()); + nm_ap_update_from_properties (ap, object_path, properties); /* Remove outdated access points */ schedule_scanlist_cull (self); diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index 3ebf3a5a2d..ae318b0197 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -34,6 +34,7 @@ #include "nm-setting-wireless.h" #include "nm-glib-compat.h" +#include "gsystem-local-alloc.h" #include "nm-access-point-glue.h" @@ -370,14 +371,13 @@ security_from_vardict (GVariant *security) return flags; } -NMAccessPoint * -nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties) +void +nm_ap_update_from_properties (NMAccessPoint *ap, + const char *supplicant_path, + GVariant *properties) { - const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; const char *addr; const guint8 *bytes; - NMAccessPoint *ap; GVariant *v; gsize len; gboolean b = FALSE; @@ -385,9 +385,8 @@ nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties) gint16 i16; guint16 u16; - g_return_val_if_fail (properties != NULL, NULL); - - ap = nm_ap_new (); + g_return_if_fail (ap != NULL); + g_return_if_fail (properties != NULL); g_object_freeze_notify (G_OBJECT (ap)); @@ -421,6 +420,9 @@ nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties) g_variant_unref (v); } + if (!nm_ap_get_ssid (ap)) + nm_ap_set_broadcast (ap, FALSE); + v = g_variant_lookup_value (properties, "BSSID", G_VARIANT_TYPE_BYTESTRING); if (v) { bytes = g_variant_get_fixed_array (v, &len, 1); @@ -459,7 +461,28 @@ nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties) g_variant_unref (v); } - nm_ap_set_supplicant_path (ap, supplicant_path); + if (!nm_ap_get_supplicant_path (ap)) + nm_ap_set_supplicant_path (ap, supplicant_path); + + nm_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ()); + + g_object_thaw_notify (G_OBJECT (ap)); +} + +NMAccessPoint * +nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties) +{ + const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + NMAccessPoint *ap; + const char *addr; + + g_return_val_if_fail (supplicant_path != NULL, NULL); + g_return_val_if_fail (properties != NULL, NULL); + + ap = nm_ap_new (); + + nm_ap_update_from_properties (ap, supplicant_path, properties); /* ignore APs with invalid BSSIDs */ addr = nm_ap_get_address (ap); @@ -469,13 +492,6 @@ nm_ap_new_from_properties (const char *supplicant_path, GVariant *properties) return NULL; } - nm_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ()); - - if (!nm_ap_get_ssid (ap)) - nm_ap_set_broadcast (ap, FALSE); - - g_object_thaw_notify (G_OBJECT (ap)); - return ap; } diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h index 0b896f6677..01a104d669 100644 --- a/src/devices/wifi/nm-wifi-ap.h +++ b/src/devices/wifi/nm-wifi-ap.h @@ -60,6 +60,10 @@ NMAccessPoint * nm_ap_new_from_properties (const char *supplicant_path, NMAccessPoint * nm_ap_new_fake_from_connection (NMConnection *connection); void nm_ap_export_to_dbus (NMAccessPoint *ap); +void nm_ap_update_from_properties (NMAccessPoint *ap, + const char *supplicant_path, + GVariant *properties); + const char *nm_ap_get_dbus_path (NMAccessPoint *ap); const char *nm_ap_get_supplicant_path (NMAccessPoint *ap); |