From patchwork Mon Sep 9 10:30:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Bursztyka X-Patchwork-Id: 273550 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id E32252C013B for ; Mon, 9 Sep 2013 20:31:55 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4EBCC9C10A; Mon, 9 Sep 2013 06:31:43 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hn2wQt6Z2rbY; Mon, 9 Sep 2013 06:31:42 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id DA7D09C0F8; Mon, 9 Sep 2013 06:31:28 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4D7AE9C075 for ; Mon, 9 Sep 2013 06:31:26 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t-lvhOfC3vHn for ; Mon, 9 Sep 2013 06:31:20 -0400 (EDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9A2339C0AC for ; Mon, 9 Sep 2013 06:31:19 -0400 (EDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 09 Sep 2013 03:31:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,866,1371106800"; d="scan'208";a="375434267" Received: from rd-180.fi.intel.com ([10.237.68.34]) by orsmga001.jf.intel.com with ESMTP; 09 Sep 2013 03:30:56 -0700 From: Tomasz Bursztyka To: hostap@lists.shmoo.com Subject: [RFC v1 PATCH 1/2] events: Handle survey event properly into wpa_supplicant Date: Mon, 9 Sep 2013 13:30:48 +0300 Message-Id: <1378722649-6558-2-git-send-email-tomasz.bursztyka@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1378722649-6558-1-git-send-email-tomasz.bursztyka@linux.intel.com> References: <1378722649-6558-1-git-send-email-tomasz.bursztyka@linux.intel.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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. Signed-off-by: Tomasz Bursztyka --- src/ap/drv_callbacks.c | 132 ++++++++++++++++++++++++------------------------ src/ap/hostapd.h | 4 ++ wpa_supplicant/events.c | 7 +++ 3 files changed, 77 insertions(+), 66 deletions(-) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index d6bc98d..427e31b 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -438,6 +438,72 @@ int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da, } +static struct hostapd_channel_data * hostapd_get_mode_channel( + struct hostapd_iface *iface, unsigned int freq) +{ + int i; + struct hostapd_channel_data *chan; + + for (i = 0; i < iface->current_mode->num_channels; i++) { + chan = &iface->current_mode->channels[i]; + if (!chan) + return NULL; + if ((unsigned int) chan->freq == freq) + return chan; + } + + return NULL; +} + + +static void hostapd_update_nf(struct hostapd_iface *iface, + struct hostapd_channel_data *chan, + struct freq_survey *survey) +{ + if (!iface->chans_surveyed) { + chan->min_nf = survey->nf; + iface->lowest_nf = survey->nf; + } else { + if (dl_list_empty(&chan->survey_list)) + chan->min_nf = survey->nf; + else if (survey->nf < chan->min_nf) + chan->min_nf = survey->nf; + if (survey->nf < iface->lowest_nf) + iface->lowest_nf = survey->nf; + } +} + + +void hostapd_event_get_survey(struct hostapd_data *hapd, + struct survey_results *survey_results) +{ + struct hostapd_iface *iface = hapd->iface; + struct freq_survey *survey, *tmp; + struct hostapd_channel_data *chan; + + if (dl_list_empty(&survey_results->survey_list)) { + wpa_printf(MSG_DEBUG, "No survey data received"); + return; + } + + dl_list_for_each_safe(survey, tmp, &survey_results->survey_list, + struct freq_survey, list) { + chan = hostapd_get_mode_channel(iface, survey->freq); + if (!chan) + continue; + if (chan->flag & HOSTAPD_CHAN_DISABLED) + continue; + + dl_list_del(&survey->list); + dl_list_add_tail(&chan->survey_list, &survey->list); + + hostapd_update_nf(iface, chan, survey); + + iface->chans_surveyed++; + } +} + + #ifdef HOSTAPD #ifdef CONFIG_IEEE80211R @@ -719,72 +785,6 @@ static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, } -static struct hostapd_channel_data * hostapd_get_mode_channel( - struct hostapd_iface *iface, unsigned int freq) -{ - int i; - struct hostapd_channel_data *chan; - - for (i = 0; i < iface->current_mode->num_channels; i++) { - chan = &iface->current_mode->channels[i]; - if (!chan) - return NULL; - if ((unsigned int) chan->freq == freq) - return chan; - } - - return NULL; -} - - -static void hostapd_update_nf(struct hostapd_iface *iface, - struct hostapd_channel_data *chan, - struct freq_survey *survey) -{ - if (!iface->chans_surveyed) { - chan->min_nf = survey->nf; - iface->lowest_nf = survey->nf; - } else { - if (dl_list_empty(&chan->survey_list)) - chan->min_nf = survey->nf; - else if (survey->nf < chan->min_nf) - chan->min_nf = survey->nf; - if (survey->nf < iface->lowest_nf) - iface->lowest_nf = survey->nf; - } -} - - -static void hostapd_event_get_survey(struct hostapd_data *hapd, - struct survey_results *survey_results) -{ - struct hostapd_iface *iface = hapd->iface; - struct freq_survey *survey, *tmp; - struct hostapd_channel_data *chan; - - if (dl_list_empty(&survey_results->survey_list)) { - wpa_printf(MSG_DEBUG, "No survey data received"); - return; - } - - dl_list_for_each_safe(survey, tmp, &survey_results->survey_list, - struct freq_survey, list) { - chan = hostapd_get_mode_channel(iface, survey->freq); - if (!chan) - continue; - if (chan->flag & HOSTAPD_CHAN_DISABLED) - continue; - - dl_list_del(&survey->list); - dl_list_add_tail(&chan->survey_list, &survey->list); - - hostapd_update_nf(iface, chan, survey); - - iface->chans_surveyed++; - } -} - - void wpa_supplicant_event(void *ctx, enum wpa_event_type event, union wpa_event_data *data) { diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index dbf1b52..0ab9564 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -380,4 +380,8 @@ const struct hostapd_eap_user * hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity, size_t identity_len, int phase2); +struct survey_results; +void hostapd_event_get_survey(struct hostapd_data *hapd, + struct survey_results *survey_results); + #endif /* HOSTAPD_H */ diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 69e4030..0020229 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -3141,6 +3141,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, data->connect_failed_reason.code); #endif /* CONFIG_AP */ break; + case EVENT_SURVEY: { + struct hostapd_data hapd = {}; + hapd.iface = wpa_s->ap_iface; + + hostapd_event_get_survey(&hapd, &data->survey_results); + break; + } default: wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event); break;