Replace hostapd_probe_req_rx() with EVENT_RX_PROBE_REQ driver event

This commit is contained in:
Jouni Malinen 2010-01-03 12:11:44 +02:00
parent 245519e0cd
commit a0e0d3bb15
5 changed files with 72 additions and 38 deletions

View file

@ -321,6 +321,23 @@ static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf,
#endif /* NEED_AP_MLME */ #endif /* NEED_AP_MLME */
static 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++) {
if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
sa, ie, ie_len) > 0) {
ret = 1;
break;
}
}
return ret;
}
void wpa_supplicant_event(void *ctx, wpa_event_type event, void wpa_supplicant_event(void *ctx, wpa_event_type event,
union wpa_event_data *data) union wpa_event_data *data)
{ {
@ -369,6 +386,11 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
data->rx_mgmt.frame_len, data->rx_mgmt.fi); data->rx_mgmt.frame_len, data->rx_mgmt.fi);
break; break;
#endif /* NEED_AP_MLME */ #endif /* NEED_AP_MLME */
case EVENT_RX_PROBE_REQ:
hostapd_probe_req_rx(hapd, data->rx_probe_req.sa,
data->rx_probe_req.ie,
data->rx_probe_req.ie_len);
break;
default: default:
wpa_printf(MSG_DEBUG, "Unknown event %d", event); wpa_printf(MSG_DEBUG, "Unknown event %d", event);
break; break;
@ -376,20 +398,3 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
} }
#endif /* HOSTAPD */ #endif /* HOSTAPD */
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++) {
if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
sa, ie, ie_len) > 0) {
ret = 1;
break;
}
}
return ret;
}

View file

@ -1725,7 +1725,16 @@ typedef enum wpa_event_type {
* *
* This event is used only by driver_test.c and userspace MLME. * This event is used only by driver_test.c and userspace MLME.
*/ */
EVENT_MLME_RX EVENT_MLME_RX,
/**
* EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
*
* This event is used to indicate when a Probe Request frame has been
* received. Information about the received frame is included in
* union wpa_event_data::rx_probe_req.
*/
EVENT_RX_PROBE_REQ,
} wpa_event_type; } wpa_event_type;
@ -1978,6 +1987,26 @@ union wpa_event_data {
int channel; int channel;
int ssi; int ssi;
} mlme_rx; } mlme_rx;
/**
* struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
*/
struct rx_probe_req {
/**
* sa - Source address of the received Probe Request frame
*/
const u8 *sa;
/**
* ie - IEs from the Probe Request body
*/
const u8 *ie;
/**
* ie_len - Length of ie buffer in octets
*/
size_t ie_len;
} rx_probe_req;
}; };
/** /**
@ -2021,7 +2050,6 @@ void wpa_scan_sort_results(struct wpa_scan_results *res);
/* hostapd functions for driver wrappers */ /* hostapd functions for driver wrappers */
struct sta_info;
struct ieee80211_hdr; struct ieee80211_hdr;
int hostapd_notif_new_sta(struct hostapd_data *hapd, const u8 *addr); int hostapd_notif_new_sta(struct hostapd_data *hapd, const u8 *addr);
@ -2039,7 +2067,5 @@ struct hostapd_frame_info {
struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd, struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd,
const u8 *addr); const u8 *addr);
int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
const u8 *ie, size_t ie_len);
#endif /* DRIVER_H */ #endif /* DRIVER_H */

View file

@ -649,9 +649,8 @@ static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
{ {
struct madwifi_driver_data *drv = ctx; struct madwifi_driver_data *drv = ctx;
const struct ieee80211_mgmt *mgmt; const struct ieee80211_mgmt *mgmt;
const u8 *end, *ie;
u16 fc; u16 fc;
size_t ie_len; union wpa_event_data event;
/* Send Probe Request information to WPS processing */ /* Send Probe Request information to WPS processing */
@ -664,11 +663,12 @@ static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_PROBE_REQ) WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_PROBE_REQ)
return; return;
end = buf + len; os_memset(&event, 0, sizeof(event));
ie = mgmt->u.probe_req.variable; event.rx_probe_req.sa = mgmt->sa;
ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req)); event.rx_probe_req.ie = mgmt->u.probe_req.variable;
event.rx_probe_req.ie_len =
hostapd_probe_req_rx(drv->hapd, mgmt->sa, ie, ie_len); len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
wpa_supplicant_event(drv->hapd, EVENT_RX_PROBE_REQ, &event);
} }
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */

View file

@ -749,9 +749,8 @@ static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
{ {
struct madwifi_driver_data *drv = ctx; struct madwifi_driver_data *drv = ctx;
const struct ieee80211_mgmt *mgmt; const struct ieee80211_mgmt *mgmt;
const u8 *end, *ie;
u16 fc; u16 fc;
size_t ie_len; union wpa_event_data event;
/* Send Probe Request information to WPS processing */ /* Send Probe Request information to WPS processing */
@ -764,11 +763,12 @@ static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_PROBE_REQ) WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_PROBE_REQ)
return; return;
end = buf + len; os_memset(&event, 0, sizeof(event));
ie = mgmt->u.probe_req.variable; event.rx_probe_req.sa = mgmt->sa;
ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req)); event.rx_probe_req.ie = mgmt->u.probe_req.variable;
event.rx_probe_req.ie_len =
hostapd_probe_req_rx(drv->hapd, mgmt->sa, ie, ie_len); len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
wpa_supplicant_event(drv->hapd, EVENT_RX_PROBE_REQ, &event);
} }
#endif /* IEEE80211_IOCTL_FILTERFRAME */ #endif /* IEEE80211_IOCTL_FILTERFRAME */
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */

View file

@ -485,6 +485,7 @@ static void test_driver_scan(struct wpa_driver_test_data *drv,
u8 sa[ETH_ALEN]; u8 sa[ETH_ALEN];
u8 ie[512]; u8 ie[512];
size_t ielen; size_t ielen;
union wpa_event_data event;
/* data: optional [ ' ' | STA-addr | ' ' | IEs(hex) ] */ /* data: optional [ ' ' | STA-addr | ' ' | IEs(hex) ] */
@ -511,9 +512,11 @@ static void test_driver_scan(struct wpa_driver_test_data *drv,
MAC2STR(sa)); MAC2STR(sa));
wpa_hexdump(MSG_MSGDUMP, "test_driver: scan IEs", ie, ielen); wpa_hexdump(MSG_MSGDUMP, "test_driver: scan IEs", ie, ielen);
#ifdef HOSTAPD os_memset(&event, 0, sizeof(event));
hostapd_probe_req_rx(drv->ctx, sa, ie, ielen); event.rx_probe_req.sa = sa;
#endif /* HOSTAPD */ event.rx_probe_req.ie = ie;
event.rx_probe_req.ie_len = ielen;
wpa_supplicant_event(drv->ctx, EVENT_RX_PROBE_REQ, &event);
} }
for (bss = drv->bss; bss; bss = bss->next) { for (bss = drv->bss; bss; bss = bss->next) {