Browse Source

Add ctrl_iface events for BSS added/removed

Jouni Malinen 15 years ago
parent
commit
f0d126d339
4 changed files with 19 additions and 8 deletions
  1. 4 0
      src/common/wpa_ctrl.h
  2. 2 2
      wpa_supplicant/bss.c
  3. 9 4
      wpa_supplicant/notify.c
  4. 4 2
      wpa_supplicant/notify.h

+ 4 - 0
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 "

+ 2 - 2
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,

+ 9 - 4
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));
 }
 
 

+ 4 - 2
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);