From f0d126d3398d211e94895cc62b56d95ddb2171ac Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 28 Dec 2009 00:42:51 +0200 Subject: [PATCH] Add ctrl_iface events for BSS added/removed --- src/common/wpa_ctrl.h | 4 ++++ wpa_supplicant/bss.c | 4 ++-- wpa_supplicant/notify.c | 13 +++++++++---- wpa_supplicant/notify.h | 6 ++++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index 913353259..d2cf92059 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -48,6 +48,10 @@ extern "C" { #define WPA_EVENT_EAP_FAILURE "CTRL-EVENT-EAP-FAILURE " /** New scan results available */ #define WPA_EVENT_SCAN_RESULTS "CTRL-EVENT-SCAN-RESULTS " +/** A BSS entry was added (followed by BSS entry id and BSSID) */ +#define WPA_EVENT_BSS_ADDED "CTRL-EVENT-BSS-ADDED " +/** A BSS entry was added (followed by BSS entry id and BSSID) */ +#define WPA_EVENT_BSS_REMOVED "CTRL-EVENT-BSS-REMOVED " /** WPS overlap detected in PBC mode */ #define WPS_EVENT_OVERLAP "WPS-OVERLAP-DETECTED " diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index 03234589a..96ab955ac 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -60,7 +60,7 @@ static void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) wpa_printf(MSG_DEBUG, "BSS: Remove id %u BSSID " MACSTR " SSID '%s'", bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(bss->ssid, bss->ssid_len)); - wpas_notify_bss_removed(wpa_s, bss->bssid); + wpas_notify_bss_removed(wpa_s, bss->bssid, bss->id); os_free(bss); } @@ -127,7 +127,7 @@ static void wpa_bss_add(struct wpa_supplicant *wpa_s, wpa_s->num_bss++; wpa_printf(MSG_DEBUG, "BSS: Add new id %u BSSID " MACSTR " SSID '%s'", bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len)); - wpas_notify_bss_added(wpa_s, res->bssid); + wpas_notify_bss_added(wpa_s, bss->bssid, bss->id); if (wpa_s->num_bss > WPA_BSS_MAX_COUNT) { /* Remove the oldest entry */ wpa_bss_remove(wpa_s, dl_list_first(&wpa_s->bss, diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index f398ee9d9..6c2f44704 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -12,9 +12,10 @@ * See README and COPYING for more details. */ -#include "includes.h" +#include "utils/includes.h" -#include "common.h" +#include "utils/common.h" +#include "common/wpa_ctrl.h" #include "config.h" #include "wpa_supplicant_i.h" #include "wps_supplicant.h" @@ -239,20 +240,24 @@ void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, - u8 bssid[]) + u8 bssid[], unsigned int id) { struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks(); if (cbs) cbs->register_bss(wpa_s, bssid); + wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, + id, MAC2STR(bssid)); } void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, - u8 bssid[]) + u8 bssid[], unsigned int id) { struct wpas_dbus_callbacks *cbs = wpas_dbus_get_callbacks(); if (cbs) cbs->unregister_bss(wpa_s, bssid); + wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, + id, MAC2STR(bssid)); } diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index 437a9020f..02f87a3e5 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -47,8 +47,10 @@ void wpas_notify_network_added(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); -void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, u8 bssid[]); -void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, u8 bssid[]); +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_blob_added(struct wpa_supplicant *wpa_s, const char *name); void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name);