]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Update P2P_INVITE processing for SSID randomization
authorVinay Gannevaram <quic_vganneva@quicinc.com>
Sat, 11 Jan 2025 06:08:10 +0000 (11:38 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 24 Jan 2025 09:22:40 +0000 (11:22 +0200)
With SSID randomization for P2P2 group reinvocation, the control
interface command P2P_INVITE requires the peer device address to be
present, but the network id is not required.

Signed-off-by: Vinay Gannevaram <quic_vganneva@quicinc.com>
wpa_supplicant/ctrl_iface.c

index 76012955beb07329b1a70623d1fe0e873787f4f8..0b29dc705cdbeba32bbb311da6a4dce574768ba1 100644 (file)
@@ -7099,7 +7099,7 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd)
 {
        char *pos;
        int id;
-       struct wpa_ssid *ssid;
+       struct wpa_ssid *ssid = NULL;
        u8 *_peer = NULL, peer[ETH_ALEN];
        int freq = 0, pref_freq = 0;
        int ht40, vht, he, max_oper_chwidth, chwidth = 0, freq2 = 0;
@@ -7107,7 +7107,8 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd)
        bool allow_6ghz;
        bool p2p2;
 
-       id = atoi(cmd);
+       p2p2 = os_strstr(cmd, " p2p2") != NULL;
+
        pos = os_strstr(cmd, " peer=");
        if (pos) {
                pos += 6;
@@ -7115,11 +7116,19 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd)
                        return -1;
                _peer = peer;
        }
-       ssid = wpa_config_get_network(wpa_s->conf, id);
-       if (ssid == NULL || ssid->disabled != 2) {
-               wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find SSID id=%d "
-                          "for persistent P2P group",
-                          id);
+
+       if (os_strncmp(cmd, "persistent=", 11) == 0) {
+               id = atoi(cmd + 11);
+               ssid = wpa_config_get_network(wpa_s->conf, id);
+               if (!ssid || ssid->disabled != 2) {
+                       wpa_printf(MSG_DEBUG,
+                                  "CTRL_IFACE: Could not find SSID id=%d for persistent P2P group",
+                                  id);
+                       return -1;
+               }
+       } else if (p2p2 && !_peer) {
+               wpa_printf(MSG_DEBUG,
+                          "CTRL_IFACE: Could not find peer for persistent P2P group");
                return -1;
        }
 
@@ -7162,8 +7171,6 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd)
        if (allow_6ghz && chwidth == 40)
                max_oper_chwidth = CONF_OPER_CHWIDTH_40MHZ_6GHZ;
 
-       p2p2 = os_strstr(cmd, " p2p2") != NULL;
-
        return wpas_p2p_invite(wpa_s, _peer, ssid, NULL, freq, freq2, ht40, vht,
                               max_oper_chwidth, pref_freq, he, edmg,
                               allow_6ghz, p2p2);
@@ -7206,8 +7213,8 @@ static int p2p_ctrl_invite_group(struct wpa_supplicant *wpa_s, char *cmd)
 
 static int p2p_ctrl_invite(struct wpa_supplicant *wpa_s, char *cmd)
 {
-       if (os_strncmp(cmd, "persistent=", 11) == 0)
-               return p2p_ctrl_invite_persistent(wpa_s, cmd + 11);
+       if (os_strncmp(cmd, "persistent", 10) == 0)
+               return p2p_ctrl_invite_persistent(wpa_s, cmd);
        if (os_strncmp(cmd, "group=", 6) == 0)
                return p2p_ctrl_invite_group(wpa_s, cmd + 6);