[PATCH] dbus: add BSS changes notifications
Witold Sowa
witold.sowa
Mon Jan 4 11:41:57 PST 2010
Send PropertiesChanged signal from BSS object with dict of properties
that has changed and theirs values if any changes occurred.
---
wpa_supplicant/bss.c | 67 ++++++++++++++++++++++++++++++++++++++++
wpa_supplicant/dbus/dbus_new.c | 54 ++++++++++++++++++++++++++++++++
wpa_supplicant/dbus/dbus_new.h | 14 ++++++++
wpa_supplicant/notify.c | 58 ++++++++++++++++++++++++++++++++++
wpa_supplicant/notify.h | 16 +++++++++
5 files changed, 209 insertions(+), 0 deletions(-)
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index bd8d061..269875a 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -135,10 +135,77 @@ static void wpa_bss_add(struct wpa_supplicant *wpa_s,
}
}
+static int are_ies_equal(const struct wpa_bss *old,
+ const struct wpa_scan_res *new,
+ u32 ie)
+{
+ const u8 *old_ie, *new_ie;
+ int new_ie_len, old_ie_len;
+
+ switch (ie) {
+ case WPA_IE_VENDOR_TYPE:
+ case WPS_IE_VENDOR_TYPE:
+ old_ie = wpa_bss_get_vendor_ie(old, WPA_IE_VENDOR_TYPE);
+ new_ie = wpa_scan_get_vendor_ie(new, WPA_IE_VENDOR_TYPE);
+ break;
+ case WLAN_EID_RSN:
+ case WLAN_EID_SUPP_RATES:
+ case WLAN_EID_EXT_SUPP_RATES:
+ old_ie = wpa_bss_get_ie(old, WLAN_EID_RSN);
+ new_ie = wpa_scan_get_ie(new, WLAN_EID_RSN);
+ break;
+ default:
+ wpa_printf(MSG_DEBUG, "bss: %s: cannot compare IEs", __func__);
+ return 0;
+ }
+
+ old_ie_len = old_ie ? old_ie[1] + 2 : 0;
+ new_ie_len = new_ie ? new_ie[1] + 2 : 0;
+
+ return (old_ie_len == new_ie_len &&
+ os_memcmp(old_ie, new_ie, old_ie_len) == 0);
+
+}
+
+static void notify_bss_changes(struct wpa_supplicant *wpa_s,
+ const struct wpa_bss *old,
+ const struct wpa_scan_res *new)
+{
+ int caps = old->caps ^ new->caps;
+
+ if (old->freq != new->freq)
+ wpas_notify_bss_freq_changed(wpa_s, old->id);
+
+ if (old->level != new->level)
+ wpas_notify_bss_signal_changed(wpa_s, old->id);
+
+
+ if (caps & IEEE80211_CAP_PRIVACY)
+ wpas_notify_bss_privacy_changed(wpa_s, old->id);
+ if (caps & IEEE80211_CAP_IBSS)
+ wpas_notify_bss_mode_changed(wpa_s, old->id);
+
+
+ if (!are_ies_equal(old, new, WPA_IE_VENDOR_TYPE))
+ wpas_notify_bss_wpaie_changed(wpa_s, old->id);
+
+ if (!are_ies_equal(old, new, WLAN_EID_RSN))
+ wpas_notify_bss_rsnie_changed(wpa_s, old->id);
+
+ if (!are_ies_equal(old, new, WPS_IE_VENDOR_TYPE))
+ wpas_notify_bss_wpsie_changed(wpa_s, old->id);
+
+ if (!are_ies_equal(old, new, WLAN_EID_SUPP_RATES) ||
+ !are_ies_equal(old, new, WLAN_EID_EXT_SUPP_RATES))
+ wpas_notify_bss_rates_changed(wpa_s, old->id);
+}
+
static void wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
struct wpa_scan_res *res)
{
+ notify_bss_changes(wpa_s, bss, res);
+
bss->scan_miss_count = 0;
bss->last_update_idx = wpa_s->bss_update_idx;
wpa_bss_copy_res(bss, res);
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 9fc496d..67b76ce 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -699,6 +699,60 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
}
+/**
+ * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
+ * @wpa_s: %wpa_supplicant network interface data
+ * @property: indicates which property has changed
+ * @id: unique BSS identifier
+ *
+ * Sends ProertyChanged signals with path, interface and arguments
+ * depending on which property has changed.
+ */
+void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
+ enum wpas_dbus_bss_prop property,
+ unsigned int id)
+{
+ char path[WPAS_DBUS_OBJECT_PATH_MAX];
+ char *prop;
+
+ switch (property) {
+ case WPAS_DBUS_BSS_PROP_SIGNAL:
+ prop = "Signal";
+ break;
+ case WPAS_DBUS_BSS_PROP_FREQ:
+ prop = "Frequency";
+ break;
+ case WPAS_DBUS_BSS_PROP_MODE:
+ prop = "Mode";
+ break;
+ case WPAS_DBUS_BSS_PROP_PRIVACY:
+ prop = "Privacy";
+ break;
+ case WPAS_DBUS_BSS_PROP_RATES:
+ prop = "Rates";
+ break;
+ case WPAS_DBUS_BSS_PROP_WPAIE:
+ prop = "WPAIE";
+ break;
+ case WPAS_DBUS_BSS_PROP_RSNIE:
+ prop = "RSNIE";
+ break;
+ case WPAS_DBUS_BSS_PROP_WPSIE:
+ prop = "WPSIE";
+ break;
+ default:
+ wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
+ __func__, property);
+ return;
+ }
+
+ snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
+ wpa_s->dbus_new_path, id);
+
+ wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
+ WPAS_DBUS_NEW_IFACE_BSSID, prop);
+}
/**
* wpas_dbus_signal_debug_level_changed - Signals change of debug param
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index e20ab76..d00ae64 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -32,6 +32,17 @@ enum wpas_dbus_prop {
WPAS_DBUS_PROP_CURRENT_NETWORK,
};
+enum wpas_dbus_bss_prop {
+ WPAS_DBUS_BSS_PROP_SIGNAL,
+ WPAS_DBUS_BSS_PROP_FREQ,
+ WPAS_DBUS_BSS_PROP_MODE,
+ WPAS_DBUS_BSS_PROP_PRIVACY,
+ WPAS_DBUS_BSS_PROP_RATES,
+ WPAS_DBUS_BSS_PROP_WPAIE,
+ WPAS_DBUS_BSS_PROP_RSNIE,
+ WPAS_DBUS_BSS_PROP_WPSIE,
+};
+
#define WPAS_DBUS_OBJECT_PATH_MAX 150
#define WPAS_DBUS_NEW_SERVICE "fi.w1.wpa_supplicant1"
@@ -80,6 +91,9 @@ int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s);
int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s);
void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
enum wpas_dbus_prop property);
+void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
+ enum wpas_dbus_bss_prop property,
+ unsigned int id);
void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id);
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 970ba9b..1ec199b 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -209,6 +209,64 @@ void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
}
+void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id)
+{
+ wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
+}
+
+
+void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id)
+{
+ wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
+ id);
+}
+
+
+void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id)
+{
+ wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
+ id);
+}
+
+
+void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id)
+{
+ wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
+}
+
+
+void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id)
+{
+ wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPAIE, id);
+}
+
+
+void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id)
+{
+ wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSNIE, id);
+}
+
+
+void wpas_notify_bss_wpsie_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id)
+{
+ wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPSIE, id);
+}
+
+
+void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id)
+{
+ wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
+}
+
+
void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
{
wpas_dbus_signal_blob_added(wpa_s, name);
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index 4cdd255..868a435 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -51,6 +51,22 @@ void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, u8 bssid[],
unsigned int id);
void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, u8 bssid[],
unsigned int id);
+void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id);
+void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id);
+void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id);
+void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id);
+void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id);
+void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id);
+void wpas_notify_bss_wpsie_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id);
+void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
+ unsigned int id);
void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name);
void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name);
--
1.6.0.2
More information about the Hostap
mailing list