]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Fix shared freq check and support AP mode validation
authorJouni Malinen <j@w1.fi>
Sun, 8 Apr 2012 17:42:45 +0000 (20:42 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 8 Apr 2012 17:42:45 +0000 (20:42 +0300)
The previous commit did not use the correct pointer in all operations
and was specific to station mode interfaces. Fix and extend it to work
with AP/GO interfaces, too.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/p2p_supplicant.c

index fa675fe26b5f1b9d6cc1c3f5204f28f3aaeb4b1a..9d31fdbb972cc907ccb23aaee4790c4998ef00ee 100644 (file)
@@ -2619,15 +2619,19 @@ static int wpas_check_freq_conflict(struct wpa_supplicant *wpa_s, int freq)
                        continue;
                if (iface->current_ssid == NULL || iface->assoc_freq == 0)
                        continue;
-               if (wpa_drv_get_bssid(iface, bssid) == 0) {
-                       if (freq != (int) wpa_s->assoc_freq) {
-                               wpa_printf(MSG_DEBUG, "P2P: Frequency "
-                                          "conflict - %s connected on %d MHz "
-                                          "- new connection on %d MHz",
-                                          wpa_s->ifname, wpa_s->assoc_freq,
-                                          freq);
-                               return 1;
-                       }
+               if (iface->current_ssid->mode == WPAS_MODE_AP ||
+                   iface->current_ssid->mode == WPAS_MODE_P2P_GO)
+                       shared_freq = iface->current_ssid->frequency;
+               else if (wpa_drv_get_bssid(iface, bssid) == 0)
+                       shared_freq = iface->assoc_freq;
+               else
+                       shared_freq = 0;
+
+               if (shared_freq && freq != shared_freq) {
+                       wpa_printf(MSG_DEBUG, "P2P: Frequency conflict - %s "
+                                  "connected on %d MHz - new connection on "
+                                  "%d MHz", iface->ifname, shared_freq, freq);
+                       return 1;
                }
        }