Re: [RFC v2 PATCH 1/2] events: Handle survey event properly into wpa_supplicant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 27, 2015 at 12:40:36PM +0100, Ulrich Ölmann wrote:
> Let's reuse hostapd code for such handling. This will be useful to get
> ACS support into wpa_supplicant where this one needs to handle the
> survey event so it fills in the result ACS subsystem will require.

>  src/ap/drv_callbacks.c  | 216 ++++++++++++++++++++++++------------------------

This is hiding the real changes by moving functions unnecessarily.. This
should look more like this to be readable:
 src/ap/drv_callbacks.c  |   10 ++++++----

(i.e., just add couple of #endif/#ifdef and leave the functions where
they are)

> diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> @@ -3924,6 +3924,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
> +	case EVENT_SURVEY: {
> +		struct hostapd_data hapd = {};
> +		hapd.iface = wpa_s->ap_iface;
> +
> +		hostapd_event_get_survey(&hapd, &data->survey_results);

This fails to build at least with the gcc version and parameters I'm
using.. In any case, this looks pretty risky since who knows what
happens if hostapd_event_get_survey() were to use something else from
struct hostapd_data. It is going to be both safer and simpler to make
hostapd_event_get_survey() take in struct hostapd_iface pointer.


This is what the changes look like with these comments addressed:

 src/ap/drv_callbacks.c  | 10 ++++++----
 src/ap/hostapd.h        |  3 +++
 wpa_supplicant/events.c |  8 ++++++++
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index fd07201..9208569 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -945,6 +945,8 @@ static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src,
 	ieee802_1x_receive(hapd, src, data, data_len);
 }
 
+#endif /* HOSTAPD */
+
 
 static struct hostapd_channel_data * hostapd_get_mode_channel(
 	struct hostapd_iface *iface, unsigned int freq)
@@ -1019,10 +1021,9 @@ static void hostapd_single_channel_get_survey(struct hostapd_iface *iface,
 }
 
 
-static void hostapd_event_get_survey(struct hostapd_data *hapd,
-				     struct survey_results *survey_results)
+void hostapd_event_get_survey(struct hostapd_iface *iface,
+			      struct survey_results *survey_results)
 {
-	struct hostapd_iface *iface = hapd->iface;
 	struct freq_survey *survey, *tmp;
 	struct hostapd_channel_data *chan;
 
@@ -1054,6 +1055,7 @@ static void hostapd_event_get_survey(struct hostapd_data *hapd,
 }
 
 
+#ifdef HOSTAPD
 #ifdef NEED_AP_MLME
 
 static void hostapd_event_iface_unavailable(struct hostapd_data *hapd)
@@ -1261,7 +1263,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 			data->connect_failed_reason.code);
 		break;
 	case EVENT_SURVEY:
-		hostapd_event_get_survey(hapd, &data->survey_results);
+		hostapd_event_get_survey(hapd->iface, &data->survey_results);
 		break;
 #ifdef NEED_AP_MLME
 	case EVENT_INTERFACE_UNAVAILABLE:
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 8161a59..a664644 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -493,6 +493,9 @@ int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
 			 int ssi_signal);
 void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
 			     int offset, int width, int cf1, int cf2);
+struct survey_results;
+void hostapd_event_get_survey(struct hostapd_iface *iface,
+			      struct survey_results *survey_results);
 
 const struct hostapd_eap_user *
 hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 5e8ebad..43f3d9b 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3938,6 +3938,14 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 				     data->mesh_peer.ie_len);
 #endif /* CONFIG_MESH */
 		break;
+	case EVENT_SURVEY:
+#ifdef CONFIG_AP
+		if (!wpa_s->ap_iface)
+			break;
+		hostapd_event_get_survey(wpa_s->ap_iface,
+					 &data->survey_results);
+#endif /* CONFIG_AP */
+		break;
 	default:
 		wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event);
 		break;
-- 
1.9.1


-- 
Jouni Malinen                                            PGP id EFC895FA

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux