]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add test functionality to simulate driver increased ROC duration
authorJouni Malinen <j@w1.fi>
Sat, 25 Oct 2014 18:25:00 +0000 (21:25 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 25 Oct 2014 18:46:38 +0000 (21:46 +0300)
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>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/offchannel.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index cb23a454e57e172555d33608941b687d98f877cb..8cee4bfa7f0d3862c553f6f2fab38837617dd49f 100644 (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 */
 }
 
 
index 77683b618eee31a02baf9429f74798599db604d5..f4515e9b4dac6d6d4d9b8e9465503936c80a5fff 100644 (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 "
index 175923b881d78bf466995a4fd5faec67658363ac..0a197b6ed4fdec0a24fea9d72f590efbc1356b41 100644 (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);
index d774b40cc2fce5af9280da25b6f18db091e07d21..ef1e7bd90c7a4f907ad55b956cad253723f798de 100644 (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 */
 };