]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - wpa_supplicant/ctrl_iface.c
P2P: Add VHT parameter to P2P operations
[thirdparty/hostap.git] / wpa_supplicant / ctrl_iface.c
index 2dc64dda51f58fdb4620519c6cbd8bba3bb347f9..809ae0c2ef43670b86a7e9572004ab2fe24c7654 100644 (file)
@@ -3688,12 +3688,12 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
        int go_intent = -1;
        int freq = 0;
        int pd;
-       int ht40;
+       int ht40, vht;
 
        /* <addr> <"pbc" | "pin" | PIN> [label|display|keypad]
         * [persistent|persistent=<network id>]
         * [join] [auth] [go_intent=<0..15>] [freq=<in MHz>] [provdisc]
-        * [ht40] */
+        * [ht40] [vht] */
 
        if (hwaddr_aton(cmd, addr))
                return -1;
@@ -3721,7 +3721,9 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
        auth = os_strstr(pos, " auth") != NULL;
        automatic = os_strstr(pos, " auto") != NULL;
        pd = os_strstr(pos, " provdisc") != NULL;
-       ht40 = (os_strstr(cmd, " ht40") != NULL) || wpa_s->conf->p2p_go_ht40;
+       vht = (os_strstr(cmd, " vht") != NULL) || wpa_s->conf->p2p_go_vht;
+       ht40 = (os_strstr(cmd, " ht40") != NULL) || wpa_s->conf->p2p_go_ht40 ||
+               vht;
 
        pos2 = os_strstr(pos, " go_intent=");
        if (pos2) {
@@ -3762,7 +3764,7 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
        new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
                                   persistent_group, automatic, join,
                                   auth, go_intent, freq, persistent_id, pd,
-                                  ht40);
+                                  ht40, vht);
        if (new_pin == -2) {
                os_memcpy(buf, "FAIL-CHANNEL-UNAVAILABLE\n", 25);
                return 25;
@@ -4126,7 +4128,7 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd)
        struct wpa_ssid *ssid;
        u8 *_peer = NULL, peer[ETH_ALEN];
        int freq = 0, pref_freq = 0;
-       int ht40;
+       int ht40, vht;
 
        id = atoi(cmd);
        pos = os_strstr(cmd, " peer=");
@@ -4160,9 +4162,12 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd)
                        return -1;
        }
 
-       ht40 = (os_strstr(cmd, " ht40") != NULL) || wpa_s->conf->p2p_go_ht40;
+       vht = (os_strstr(cmd, " vht") != NULL) || wpa_s->conf->p2p_go_vht;
+       ht40 = (os_strstr(cmd, " ht40") != NULL) || wpa_s->conf->p2p_go_ht40 ||
+               vht;
 
-       return wpas_p2p_invite(wpa_s, _peer, ssid, NULL, freq, ht40, pref_freq);
+       return wpas_p2p_invite(wpa_s, _peer, ssid, NULL, freq, ht40, vht,
+                              pref_freq);
 }
 
 
@@ -4209,7 +4214,8 @@ static int p2p_ctrl_invite(struct wpa_supplicant *wpa_s, char *cmd)
 
 
 static int p2p_ctrl_group_add_persistent(struct wpa_supplicant *wpa_s,
-                                        char *cmd, int freq, int ht40)
+                                        char *cmd, int freq, int ht40,
+                                        int vht)
 {
        int id;
        struct wpa_ssid *ssid;
@@ -4223,32 +4229,34 @@ static int p2p_ctrl_group_add_persistent(struct wpa_supplicant *wpa_s,
                return -1;
        }
 
-       return wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq, ht40, NULL,
-                                            0);
+       return wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq, ht40, vht,
+                                            NULL, 0);
 }
 
 
 static int p2p_ctrl_group_add(struct wpa_supplicant *wpa_s, char *cmd)
 {
-       int freq = 0, ht40;
+       int freq = 0, ht40, vht;
        char *pos;
 
        pos = os_strstr(cmd, "freq=");
        if (pos)
                freq = atoi(pos + 5);
 
-       ht40 = (os_strstr(cmd, "ht40") != NULL) || wpa_s->conf->p2p_go_ht40;
+       vht = (os_strstr(cmd, "vht") != NULL) || wpa_s->conf->p2p_go_vht;
+       ht40 = (os_strstr(cmd, "ht40") != NULL) || wpa_s->conf->p2p_go_ht40 ||
+               vht;
 
        if (os_strncmp(cmd, "persistent=", 11) == 0)
                return p2p_ctrl_group_add_persistent(wpa_s, cmd + 11, freq,
-                                                    ht40);
+                                                    ht40, vht);
        if (os_strcmp(cmd, "persistent") == 0 ||
            os_strncmp(cmd, "persistent ", 11) == 0)
-               return wpas_p2p_group_add(wpa_s, 1, freq, ht40);
+               return wpas_p2p_group_add(wpa_s, 1, freq, ht40, vht);
        if (os_strncmp(cmd, "freq=", 5) == 0)
-               return wpas_p2p_group_add(wpa_s, 0, freq, ht40);
+               return wpas_p2p_group_add(wpa_s, 0, freq, ht40, vht);
        if (ht40)
-               return wpas_p2p_group_add(wpa_s, 0, freq, ht40);
+               return wpas_p2p_group_add(wpa_s, 0, freq, ht40, vht);
 
        wpa_printf(MSG_DEBUG, "CTRL: Invalid P2P_GROUP_ADD parameters '%s'",
                   cmd);
@@ -4351,48 +4359,21 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
 static int p2p_ctrl_disallow_freq(struct wpa_supplicant *wpa_s,
                                  const char *param)
 {
-       struct wpa_freq_range *freq = NULL, *n;
-       unsigned int count = 0, i;
-       const char *pos, *pos2, *pos3;
+       unsigned int i;
 
        if (wpa_s->global->p2p == NULL)
                return -1;
 
-       /*
-        * param includes comma separated frequency range.
-        * For example: 2412-2432,2462,5000-6000
-        */
-       pos = param;
-       while (pos && pos[0]) {
-               n = os_realloc_array(freq, count + 1,
-                                    sizeof(struct wpa_freq_range));
-               if (n == NULL) {
-                       os_free(freq);
-                       return -1;
-               }
-               freq = n;
-               freq[count].min = atoi(pos);
-               pos2 = os_strchr(pos, '-');
-               pos3 = os_strchr(pos, ',');
-               if (pos2 && (!pos3 || pos2 < pos3)) {
-                       pos2++;
-                       freq[count].max = atoi(pos2);
-               } else
-                       freq[count].max = freq[count].min;
-               pos = pos3;
-               if (pos)
-                       pos++;
-               count++;
-       }
+       if (freq_range_list_parse(&wpa_s->global->p2p_disallow_freq, param) < 0)
+               return -1;
 
-       for (i = 0; i < count; i++) {
+       for (i = 0; i < wpa_s->global->p2p_disallow_freq.num; i++) {
+               struct wpa_freq_range *freq;
+               freq = &wpa_s->global->p2p_disallow_freq.range[i];
                wpa_printf(MSG_DEBUG, "P2P: Disallowed frequency range %u-%u",
-                          freq[i].min, freq[i].max);
+                          freq->min, freq->max);
        }
 
-       os_free(wpa_s->global->p2p_disallow_freq);
-       wpa_s->global->p2p_disallow_freq = freq;
-       wpa_s->global->num_p2p_disallow_freq = count;
        wpas_p2p_update_channel_list(wpa_s);
        return 0;
 }
@@ -5162,6 +5143,8 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
 #ifdef CONFIG_WPS
        wpas_wps_cancel(wpa_s);
 #endif /* CONFIG_WPS */
+       wpa_s->after_wps = 0;
+       wpa_s->known_wps_freq = 0;
 
 #ifdef CONFIG_TDLS_TESTING
        extern unsigned int tdls_testing;
@@ -5435,7 +5418,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
                if (wpas_p2p_group_remove(wpa_s, buf + 17))
                        reply_len = -1;
        } else if (os_strcmp(buf, "P2P_GROUP_ADD") == 0) {
-               if (wpas_p2p_group_add(wpa_s, 0, 0, 0))
+               if (wpas_p2p_group_add(wpa_s, 0, 0, 0, 0))
                        reply_len = -1;
        } else if (os_strncmp(buf, "P2P_GROUP_ADD ", 14) == 0) {
                if (p2p_ctrl_group_add(wpa_s, buf + 14))
@@ -5595,6 +5578,8 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
                             (wpa_s->wpa_state == WPA_COMPLETED))) {
                                wpa_s->normal_scans = 0;
                                wpa_s->scan_req = MANUAL_SCAN_REQ;
+                               wpa_s->after_wps = 0;
+                               wpa_s->known_wps_freq = 0;
                                wpa_supplicant_req_scan(wpa_s, 0, 0);
                        } else if (wpa_s->sched_scanning) {
                                wpa_printf(MSG_DEBUG, "Stop ongoing "