]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add wpa_supplicant SET get_pref_freq_list_override
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 15 Feb 2017 13:38:59 +0000 (15:38 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 16 Feb 2017 10:08:22 +0000 (12:08 +0200)
This can be used to override driver get_pref_freq_list() operation for
more convenient testing of preferred frequency list functionality.

Override string format:
<if_type1>:<freq1>,<freq2>,... <if_type2>:...

if_type: 0=STATION, 2=AP, 3=P2P_GO, 4=P2P_CLIENT, 8=TDLS, 9=IBSS

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/driver_i.h
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 295e50fa8ffad017d8a03eeffc143026ed4ac1da..40380fa18ba988aa77488ae93145ae019c3aca97 100644 (file)
@@ -577,6 +577,12 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
                wpa_s->ignore_assoc_disallow = !!atoi(value);
        } else if (os_strcasecmp(cmd, "reject_btm_req_reason") == 0) {
                wpa_s->reject_btm_req_reason = atoi(value);
+       } else if (os_strcasecmp(cmd, "get_pref_freq_list_override") == 0) {
+               os_free(wpa_s->get_pref_freq_list_override);
+               if (!value[0])
+                       wpa_s->get_pref_freq_list_override = NULL;
+               else
+                       wpa_s->get_pref_freq_list_override = os_strdup(value);
 #endif /* CONFIG_TESTING_OPTIONS */
 #ifndef CONFIG_NO_CONFIG_BLOBS
        } else if (os_strcmp(cmd, "blob") == 0) {
@@ -7219,6 +7225,46 @@ static int wpas_ctrl_iface_signal_monitor(struct wpa_supplicant *wpa_s,
 }
 
 
+#ifdef CONFIG_TESTING_OPTIONS
+int wpas_ctrl_iface_get_pref_freq_list_override(struct wpa_supplicant *wpa_s,
+                                               enum wpa_driver_if_type if_type,
+                                               unsigned int *num,
+                                               unsigned int *freq_list)
+{
+       char *pos = wpa_s->get_pref_freq_list_override;
+       char *end;
+       unsigned int count = 0;
+
+       /* Override string format:
+        *  <if_type1>:<freq1>,<freq2>,... <if_type2>:... */
+
+       while (pos) {
+               if (atoi(pos) == (int) if_type)
+                       break;
+               pos = os_strchr(pos, ' ');
+               if (pos)
+                       pos++;
+       }
+       if (!pos)
+               return -1;
+       pos = os_strchr(pos, ':');
+       if (!pos)
+               return -1;
+       pos++;
+       end = os_strchr(pos, ' ');
+       while (pos && (!end || pos < end) && count < *num) {
+               freq_list[count++] = atoi(pos);
+               pos = os_strchr(pos, ',');
+               if (pos)
+                       pos++;
+       }
+
+       *num = count;
+       return 0;
+}
+#endif /* CONFIG_TESTING_OPTIONS */
+
+
 static int wpas_ctrl_iface_get_pref_freq_list(
        struct wpa_supplicant *wpa_s, char *cmd, char *buf, size_t buflen)
 {
@@ -7510,6 +7556,8 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
        wpa_s->ignore_assoc_disallow = 0;
        wpa_s->reject_btm_req_reason = 0;
        wpa_sm_set_test_assoc_ie(wpa_s->wpa, NULL);
+       os_free(wpa_s->get_pref_freq_list_override);
+       wpa_s->get_pref_freq_list_override = NULL;
 #endif /* CONFIG_TESTING_OPTIONS */
 
        wpa_s->disconnected = 0;
index 4758c161c631868c1bd554ddc68904603e441beb..0af63c9f15ed55af01e57d504a9e8ddc5938c1f7 100644 (file)
@@ -902,6 +902,11 @@ static inline int wpa_drv_get_pref_freq_list(struct wpa_supplicant *wpa_s,
                                             unsigned int *num,
                                             unsigned int *freq_list)
 {
+#ifdef CONFIG_TESTING_OPTIONS
+       if (wpa_s->get_pref_freq_list_override)
+               return wpas_ctrl_iface_get_pref_freq_list_override(
+                       wpa_s, if_type, num, freq_list);
+#endif /* CONFIG_TESTING_OPTIONS */
        if (!wpa_s->driver->get_pref_freq_list)
                return -1;
        return wpa_s->driver->get_pref_freq_list(wpa_s->drv_priv, if_type,
index 11bb7b93c08a50659edcc78aaae3234df78a305d..a3392efd37b42c2be25442d2b4a41310f88fdc1c 100644 (file)
@@ -452,6 +452,8 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
 #ifdef CONFIG_TESTING_OPTIONS
        l2_packet_deinit(wpa_s->l2_test);
        wpa_s->l2_test = NULL;
+       os_free(wpa_s->get_pref_freq_list_override);
+       wpa_s->get_pref_freq_list_override = NULL;
 #endif /* CONFIG_TESTING_OPTIONS */
 
        if (wpa_s->conf != NULL) {
index b873f47260a8fffe033b068196c75ce1b166854e..95f4d9b2553d4cca457091582f5efcaac13c0690 100644 (file)
@@ -1061,6 +1061,7 @@ struct wpa_supplicant {
        struct l2_packet_data *l2_test;
        unsigned int extra_roc_dur;
        enum wpa_supplicant_test_failure test_failure;
+       char *get_pref_freq_list_override;
        unsigned int reject_btm_req_reason;
        unsigned int p2p_go_csa_on_inv:1;
        unsigned int ignore_auth_resp:1;
@@ -1387,4 +1388,9 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                                     struct wpa_ssid *group,
                                     int only_first_ssid, int debug_print);
 
+int wpas_ctrl_iface_get_pref_freq_list_override(struct wpa_supplicant *wpa_s,
+                                               enum wpa_driver_if_type if_type,
+                                               unsigned int *num,
+                                               unsigned int *freq_list);
+
 #endif /* WPA_SUPPLICANT_I_H */