From: Vinay Gannevaram Date: Wed, 5 Mar 2025 09:07:46 +0000 (+0530) Subject: P2P2: Get ID of device identity block from wpas_p2p_validate_dira() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95ad71157e3095c52d5212855ca232832b1b5085;p=thirdparty%2Fhostap.git P2P2: Get ID of device identity block from wpas_p2p_validate_dira() Upper layer components can now use the P2P_VALIDATE_DIRA command to retrieve the device identity key identifier, which is necessary to initiate P2P reinvoke to an existing group. Signed-off-by: Vinay Gannevaram --- diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index a89cb5211..3435c1db5 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -6624,12 +6624,15 @@ static int p2p_get_passphrase(struct wpa_supplicant *wpa_s, char *buf, } -static int p2p_ctrl_validate_dira(struct wpa_supplicant *wpa_s, char *cmd) +static int p2p_ctrl_validate_dira(struct wpa_supplicant *wpa_s, char *cmd, + char *buf, size_t buflen) { char *pos, *pos2; u8 addr[ETH_ALEN]; u8 nonce[DEVICE_IDENTITY_NONCE_LEN]; u8 tag[DEVICE_IDENTITY_TAG_LEN]; + int id; + int res; if (hwaddr_aton(cmd, addr)) return -1; @@ -6656,7 +6659,14 @@ static int p2p_ctrl_validate_dira(struct wpa_supplicant *wpa_s, char *cmd) return -1; } - return wpas_p2p_validate_dira(wpa_s, addr, 0, nonce, tag); + id = wpas_p2p_validate_dira(wpa_s, addr, 0, nonce, tag); + if (id <= 0) + return -1; + + res = os_snprintf(buf, buflen, "%u", id); + if (os_snprintf_error(buflen, res)) + return -1; + return res; } @@ -13047,8 +13057,8 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, } else if (os_strcmp(buf, "P2P_GET_DIRA") == 0) { reply_len = wpas_p2p_get_dira(wpa_s, reply, reply_size); } else if (os_strncmp(buf, "P2P_VALIDATE_DIRA ", 18) == 0) { - if (p2p_ctrl_validate_dira(wpa_s, buf + 18) < 0) - reply_len = -1; + reply_len = p2p_ctrl_validate_dira(wpa_s, buf + 18, + reply, reply_size); #ifdef CONFIG_PASN #ifdef CONFIG_TESTING_OPTIONS } else if (os_strcmp(buf, "P2P_GET_PASNPTK") == 0) { diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index d4b69645e..6d2551b89 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -11538,13 +11538,10 @@ int wpas_p2p_validate_dira(struct wpa_supplicant *wpa_s, const u8 *addr, if (cipher != DIRA_CIPHER_VERSION_128) { wpa_printf(MSG_INFO, "P2P2: Unsupported DIRA cipher version %d", cipher); - return -1; - } - - if (wpas_validate_dira(wpa_s, addr, nonce, tag) > 0) return 0; + } - return -1; + return wpas_validate_dira(wpa_s, addr, nonce, tag); }