Allow Probe Request callbacks to terminate iteration

This commit is contained in:
Jouni Malinen 2009-12-28 13:14:58 +02:00 committed by Jouni Malinen
parent 1c08f8c0f0
commit cd7d80f373
6 changed files with 28 additions and 19 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -2007,7 +2007,7 @@ struct hostapd_frame_info {
struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd,
const u8 *addr);
void hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
const u8 *ie, size_t ie_len);
int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
const u8 *ie, size_t ie_len);
#endif /* DRIVER_H */