From: Shivani Baranwal Date: Mon, 5 Aug 2024 06:33:44 +0000 (+0530) Subject: P2P2: Command to remove all P2P2 identity keys X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df37010ad15671af8c951e118c7fb0241cf7e34c;p=thirdparty%2Fhostap.git P2P2: Command to remove all P2P2 identity keys Add a control interface command to allow all P2P2 identity keys to be removed from configuration. Signed-off-by: Shivani Baranwal --- diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 625326411..2ac34df7e 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -13014,6 +13014,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, } else if (os_strcmp(buf, "P2P_LO_STOP") == 0) { if (wpas_p2p_lo_stop(wpa_s)) reply_len = -1; + } else if (os_strcmp(buf, "P2P_REMOVE_IDENTITY") == 0) { + if (wpas_p2p_remove_all_identity(wpa_s)) + reply_len = -1; #endif /* CONFIG_P2P */ #ifdef CONFIG_WIFI_DISPLAY } else if (os_strncmp(buf, "WFD_SUBELEM_SET ", 16) == 0) { diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 042fc2cbc..114fd5545 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -1397,6 +1397,22 @@ static void wpas_p2p_group_started(struct wpa_supplicant *wpa_s, } +int wpas_p2p_remove_all_identity(struct wpa_supplicant *wpa_s) +{ + struct wpa_dev_ik *ik; + + for (ik = wpa_s->conf->identity; ik; ik = ik->next) + wpa_config_remove_identity(wpa_s->conf, ik->id); + + if (wpa_s->conf->update_config && + wpa_config_write(wpa_s->confname, wpa_s->conf)) { + wpa_printf(MSG_DEBUG, "P2P: Failed to update configuration"); + return -1; + } + return 0; +} + + static void wpas_p2p_store_identity(struct wpa_supplicant *wpa_s, u8 cipher, const u8 *dik_data, size_t dik_len, const u8 *pmk, size_t pmk_len, diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 24e742b5e..4337e2508 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -188,6 +188,7 @@ void wpas_p2p_process_usd_elems(struct wpa_supplicant *wpa_s, const u8 *buf, unsigned int freq); int wpas_p2p_pasn_auth_tx_status(struct wpa_supplicant *wpa_s, const u8 *data, size_t data_len, bool acked); +int wpas_p2p_remove_all_identity(struct wpa_supplicant *wpa_s); #ifdef CONFIG_P2P