Add test functionality to simulate driver increased ROC duration

The extra_roc_dur parameter can now be used in CONFIG_TESTING_OPTIONS=y
builds to simulate driver behavior where the ROC duration gets increased
without user space request.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-10-25 21:25:00 +03:00
parent a902d5a64b
commit 1f94e4ee3e
4 changed files with 36 additions and 4 deletions

View file

@ -433,6 +433,8 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
wpa_s->ext_eapol_frame_io;
}
#endif /* CONFIG_AP */
} else if (os_strcasecmp(cmd, "extra_roc_dur") == 0) {
wpa_s->extra_roc_dur = atoi(value);
#endif /* CONFIG_TESTING_OPTIONS */
#ifndef CONFIG_NO_CONFIG_BLOBS
} else if (os_strcmp(cmd, "blob") == 0) {
@ -5833,6 +5835,9 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
wpa_s->ext_mgmt_frame_handling = 0;
wpa_s->ext_eapol_frame_io = 0;
#ifdef CONFIG_TESTING_OPTIONS
wpa_s->extra_roc_dur = 0;
#endif /* CONFIG_TESTING_OPTIONS */
}

View file

@ -84,6 +84,7 @@ static void wpas_send_action_cb(void *eloop_ctx, void *timeout_ctx)
wpa_s->off_channel_freq,
iface->assoc_freq);
if (without_roc && wpa_s->off_channel_freq == 0) {
unsigned int duration = 200;
/*
* We may get here if wpas_send_action() found us to be
* on the correct channel, but remain-on-channel cancel
@ -91,9 +92,18 @@ static void wpas_send_action_cb(void *eloop_ctx, void *timeout_ctx)
*/
wpa_printf(MSG_DEBUG, "Off-channel: Schedule "
"remain-on-channel to send Action frame");
#ifdef CONFIG_TESTING_OPTIONS
if (wpa_s->extra_roc_dur) {
wpa_printf(MSG_DEBUG,
"TESTING: Increase ROC duration %u -> %u",
duration,
duration + wpa_s->extra_roc_dur);
duration += wpa_s->extra_roc_dur;
}
#endif /* CONFIG_TESTING_OPTIONS */
if (wpa_drv_remain_on_channel(
wpa_s, wpa_s->pending_action_freq, 200) <
0) {
wpa_s, wpa_s->pending_action_freq,
duration) < 0) {
wpa_printf(MSG_DEBUG, "Off-channel: Failed to "
"request driver to remain on "
"channel (%u MHz) for Action Frame "
@ -308,6 +318,13 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq,
wait_time = wpa_s->max_remain_on_chan;
else if (wait_time == 0)
wait_time = 20;
#ifdef CONFIG_TESTING_OPTIONS
if (wpa_s->extra_roc_dur) {
wpa_printf(MSG_DEBUG, "TESTING: Increase ROC duration %u -> %u",
wait_time, wait_time + wpa_s->extra_roc_dur);
wait_time += wpa_s->extra_roc_dur;
}
#endif /* CONFIG_TESTING_OPTIONS */
if (wpa_drv_remain_on_channel(wpa_s, freq, wait_time) < 0) {
wpa_printf(MSG_DEBUG, "Off-channel: Failed to request driver "
"to remain on channel (%u MHz) for Action "

View file

@ -1853,6 +1853,7 @@ static void wpas_start_listen_cb(struct wpa_radio_work *work, int deinit)
{
struct wpa_supplicant *wpa_s = work->wpa_s;
struct wpas_p2p_listen_work *lwork = work->ctx;
unsigned int duration;
if (deinit) {
if (work->started) {
@ -1877,8 +1878,16 @@ static void wpas_start_listen_cb(struct wpa_radio_work *work, int deinit)
wpa_s->pending_listen_freq = lwork->freq;
wpa_s->pending_listen_duration = lwork->duration;
if (wpa_drv_remain_on_channel(wpa_s, lwork->freq, lwork->duration) < 0)
{
duration = lwork->duration;
#ifdef CONFIG_TESTING_OPTIONS
if (wpa_s->extra_roc_dur) {
wpa_printf(MSG_DEBUG, "TESTING: Increase ROC duration %u -> %u",
duration, duration + wpa_s->extra_roc_dur);
duration += wpa_s->extra_roc_dur;
}
#endif /* CONFIG_TESTING_OPTIONS */
if (wpa_drv_remain_on_channel(wpa_s, lwork->freq, duration) < 0) {
wpa_printf(MSG_DEBUG, "P2P: Failed to request the driver "
"to remain on channel (%u MHz) for Listen "
"state", lwork->freq);

View file

@ -876,6 +876,7 @@ struct wpa_supplicant {
#ifdef CONFIG_TESTING_OPTIONS
struct l2_packet_data *l2_test;
unsigned int extra_roc_dur;
#endif /* CONFIG_TESTING_OPTIONS */
};