aboutsummaryrefslogtreecommitdiffstats
path: root/src/ap
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-12-28 11:14:58 (GMT)
committerJouni Malinen <j@w1.fi>2009-12-28 11:14:58 (GMT)
commitcd7d80f37303802293ef36518e8643382c5166a4 (patch)
tree4b6b67a230c7a38eb739c417c18c294e29df066d /src/ap
parent1c08f8c0f090257c607e7b89f754b4f9a57c9f55 (diff)
downloadhostap-cd7d80f37303802293ef36518e8643382c5166a4.zip
hostap-cd7d80f37303802293ef36518e8643382c5166a4.tar.gz
hostap-cd7d80f37303802293ef36518e8643382c5166a4.tar.bz2
Allow Probe Request callbacks to terminate iteration
Diffstat (limited to 'src/ap')
-rw-r--r--src/ap/beacon.c5
-rw-r--r--src/ap/drv_callbacks.c14
-rw-r--r--src/ap/hostapd.h6
-rw-r--r--src/ap/utils.c4
-rw-r--r--src/ap/wps_hostapd.c14
5 files changed, 26 insertions, 17 deletions
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 9c65760..4026056 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -209,8 +209,9 @@ void handle_probe_req(struct hostapd_data *hapd,
ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
- hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
- mgmt->sa, ie, ie_len);
+ if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
+ mgmt->sa, ie, ie_len) > 0)
+ return;
if (!hapd->iconf->send_probe_response)
return;
diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index ed71d20..30d87a8 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -378,12 +378,18 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
#endif /* HOSTAPD */
-void hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
+int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
const u8 *ie, size_t ie_len)
{
size_t i;
+ int ret = 0;
- for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
- hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
- sa, ie, ie_len);
+ for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) {
+ if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
+ sa, ie, ie_len) > 0) {
+ ret = 1;
+ break;
+ }
+ }
+ return ret;
}
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index f3cbad2..39fb6c9 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -29,7 +29,7 @@ struct ieee80211_ht_capabilities;
struct full_dynamic_vlan;
struct hostapd_probereq_cb {
- void (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
+ int (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
void *ctx;
};
@@ -249,8 +249,8 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
/* utils.c */
int hostapd_register_probereq_cb(struct hostapd_data *hapd,
- void (*cb)(void *ctx, const u8 *sa,
- const u8 *ie, size_t ie_len),
+ int (*cb)(void *ctx, const u8 *sa,
+ const u8 *ie, size_t ie_len),
void *ctx);
void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
diff --git a/src/ap/utils.c b/src/ap/utils.c
index 7ec77ff..0ff48ae 100644
--- a/src/ap/utils.c
+++ b/src/ap/utils.c
@@ -21,8 +21,8 @@
int hostapd_register_probereq_cb(struct hostapd_data *hapd,
- void (*cb)(void *ctx, const u8 *sa,
- const u8 *ie, size_t ie_len),
+ int (*cb)(void *ctx, const u8 *sa,
+ const u8 *ie, size_t ie_len),
void *ctx)
{
struct hostapd_probereq_cb *n;
diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c
index 2c893f4..235071b 100644
--- a/src/ap/wps_hostapd.c
+++ b/src/ap/wps_hostapd.c
@@ -39,8 +39,8 @@ static int hostapd_wps_upnp_init(struct hostapd_data *hapd,
static void hostapd_wps_upnp_deinit(struct hostapd_data *hapd);
#endif /* CONFIG_WPS_UPNP */
-static void hostapd_wps_probe_req_rx(void *ctx, const u8 *addr,
- const u8 *ie, size_t ie_len);
+static int hostapd_wps_probe_req_rx(void *ctx, const u8 *addr,
+ const u8 *ie, size_t ie_len);
static int hostapd_wps_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
@@ -738,18 +738,18 @@ error:
#endif /* CONFIG_WPS_OOB */
-static void hostapd_wps_probe_req_rx(void *ctx, const u8 *addr,
- const u8 *ie, size_t ie_len)
+static int hostapd_wps_probe_req_rx(void *ctx, const u8 *addr,
+ const u8 *ie, size_t ie_len)
{
struct hostapd_data *hapd = ctx;
struct wpabuf *wps_ie;
if (hapd->wps == NULL)
- return;
+ return 0;
wps_ie = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA);
if (wps_ie == NULL)
- return;
+ return 0;
if (wpabuf_len(wps_ie) > 0) {
wps_registrar_probe_req_rx(hapd->wps->registrar, addr, wps_ie);
@@ -763,6 +763,8 @@ static void hostapd_wps_probe_req_rx(void *ctx, const u8 *addr,
}
wpabuf_free(wps_ie);
+
+ return 0;
}