]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Support driver preferred freq list for Autonomous GO case
authorAhmad Kholaif <akholaif@qca.qualcomm.com>
Mon, 10 Aug 2015 00:44:12 +0000 (17:44 -0700)
committerJouni Malinen <j@w1.fi>
Mon, 10 Aug 2015 18:27:42 +0000 (21:27 +0300)
When starting an autonomous GO without specifying the operating channel,
query the driver for the preferred frequency list, and use it to select
the operating channel of the GO (if supported).

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
wpa_supplicant/p2p_supplicant.c

index 4e4c25f236006f0a13150b8871f4675a769e014e..066ff22e3c71b7d010d9f112037a50e668b6bcd3 100644 (file)
@@ -5322,6 +5322,38 @@ static int wpas_p2p_select_go_freq(struct wpa_supplicant *wpa_s, int freq)
 {
        unsigned int r;
 
+       if (!wpa_s->conf->num_p2p_pref_chan && !freq) {
+               unsigned int i, size = P2P_MAX_PREF_CHANNELS;
+               unsigned int pref_freq_list[P2P_MAX_PREF_CHANNELS];
+               int res;
+
+               res = wpa_drv_get_pref_freq_list(wpa_s, WPA_IF_P2P_GO,
+                                                &size, pref_freq_list);
+               if (!res && size > 0) {
+                       i = 0;
+                       while (wpas_p2p_disallowed_freq(wpa_s->global,
+                                                       pref_freq_list[i]) &&
+                              i < size) {
+                               wpa_printf(MSG_DEBUG,
+                                          "P2P: preferred_freq_list[%d]=%d is disallowed",
+                                          i, pref_freq_list[i]);
+                               i++;
+                       }
+                       if (i != size) {
+                               freq = pref_freq_list[i];
+                               wpa_printf(MSG_DEBUG,
+                                          "P2P: Using preferred_freq_list[%d]=%d",
+                                          i, freq);
+                       } else {
+                               wpa_printf(MSG_DEBUG,
+                                          "P2P: All driver preferred frequencies are disallowed for P2P use");
+                       }
+               } else {
+                       wpa_printf(MSG_DEBUG,
+                                  "P2P: No preferred frequency list available");
+               }
+       }
+
        if (freq == 2) {
                wpa_printf(MSG_DEBUG, "P2P: Request to start GO on 2.4 GHz "
                           "band");