From d394d1c4f7db593f025c8463904e81a22680e635 Mon Sep 17 00:00:00 2001 From: ying1210 Date: Wed, 11 Dec 2024 15:33:15 +0800 Subject: [PATCH 1/4] mlo info report Signed-off-by: ying1210 --- .../service_common/wpa_common_cmd.c | 97 +++++++++++++++++++ .../service_common/wpa_common_cmd.h | 2 + .../service_common/wpa_hal_struct.h | 13 +++ .../service_common/wpa_supplicant_hal.c | 73 ++++++++++++++ .../service_common/wpa_supplicant_hal.h | 1 + .../hdi_service/wpa_interface_service.c | 1 + 6 files changed, 187 insertions(+) diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c index 426f2eff70..c50c08e0bf 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c @@ -42,6 +42,7 @@ const int QUOTATION_MARKS_FLAG_YES = 0; const int QUOTATION_MARKS_FLAG_NO = 1; const int MAX_NETWORKS_NUM = 100; +const int MAX_MLO_LINK_NUM = 2; pthread_mutex_t g_interfaceLock = PTHREAD_MUTEX_INITIALIZER; static WpaSsidField g_wpaSsidFields[] = { @@ -1967,3 +1968,99 @@ void ClearHdfWpaRemoteObj(void) } (void)OsalMutexUnlock(&HdfWpaStubDriver()->mutex); } + +static int32_t WpaFillWpaMloLinkedInfo(struct HdiMloLinkedInfo *hdiMloInfo, + struct WpaMloLinkedInfo *wpaMloInfo) +{ + int32_t ret = HDF_SUCCESS; + if (hdiMloInfo == NULL || wpaMloInfo == NULL) { + HDF_LOGE("%{public}s: hdiMloInfo or wpaMloInfo is NULL!", __func__); + return HDF_ERR_INVALID_PARAM; + } + do { + hdiMloInfo->linkId = wpaMloInfo->linkId; + hdiMloInfo->freq = wpaMloInfo->freq; + uint8_t tmpBssid[EHT_ADDR_LEN] = {0}; + hwaddr_aton(wpaMloInfo->apLinkAddr, tmpBssid); + if (FillData(&hdiMloInfo->apLinkAddr, &hdiMloInfo->apLinkAddrLen, + tmpBssid, EHT_ADDR_LEN) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: fill apLinkAddr fail", __func__); + ret = HDF_FAILURE; + } + hwaddr_aton(wpaMloInfo->staLinkAddr, tmpBssid); + if (FillData(&hdiMloInfo->staLinkAddr, &hdiMloInfo->staLinkAddrLen, + tmpBssid, EHT_ADDR_LEN) != HDF_SUCCESS) { + HDF_LOGE("%{public}s: fill staLinkAddr fail", __func__); + ret = HDF_FAILURE; + } + } while(0); + if (ret != HDF_SUCCESS) { + if (hdiMloInfo->apLinkAddr != NULL) { + OsalMemFree(hdiMloInfo->apLinkAddr); + hdiMloInfo->apLinkAddr = NULL; + } + if (hdiMloInfo->staLinkAddr != NULL) { + OsalMemFree(hdiMloInfo->staLinkAddr); + hdiMloInfo->staLinkAddr = NULL; + } + } + return ret; +} + +int32_t WpaInterfaceGetWpaMloLinkedInfo(struct IWpaInterface *self, const char *ifName, char *apMldAddr, + uint32_t apMldAddrLen, struct HdiMloLinkedInfo *hdiMloInfo, uint32_t *hdiMloInfoLen) +{ + (void)self; + HDF_LOGI("enter %{public}s ", __func__); + pthread_mutex_lock(&g_interfaceLock); + if (ifName == NULL || hdiMloInfo == NULL || hdiMloInfoLen == NULL) { + pthread_mutex_unlock(&g_interfaceLock); + HDF_LOGE("%{public}s: input parameter invalid!", __func__); + return HDF_ERR_INVALID_PARAM; + } + WifiWpaStaInterface *pStaIfc = GetWifiStaInterface(ifName); + if (pStaIfc == NULL) { + pthread_mutex_unlock(&g_interfaceLock); + HDF_LOGE("%{public}s: pStaIfc = NULL", __func__); + return HDF_FAILURE; + } + WpaMloStatusInfo *wpaInfo = (WpaMloStatusInfo *)calloc(1, sizeof(WpaMloStatusInfo)); + if (wpaInfo == NULL) { + pthread_mutex_unlock(&g_interfaceLock); + HDF_LOGE("%{public}s: wpaInfo = NULL", __func__); + return HDF_FAILURE; + } + wpaInfo->linkNum = MAX_MLO_LINK_NUM; + int ret = pStaIfc->wpaCliCmdGetMloLinkedInfo(pStaIfc, wpaInfo); + if (ret < 0) { + pthread_mutex_unlock(&g_interfaceLock); + free(wpaInfo); + HDF_LOGE("%{public}s: wpaCliCmdGetMloLinkedInfo fail! ret = %{public}d", __func__, ret); + return HDF_FAILURE; + } + uint8_t tmpBssid[EHT_ADDR_LEN] = {0}; + hwaddr_aton(wpaInfo->apMldAddr, tmpBssid); + if (strcpy(apMldAddr, apMldAddrLen, tmpBssid, EHT_ADDR_LEN) != HDF_SUCCESS) { + pthread_mutex_unlock(&g_interfaceLock); + free(wpaInfo); + HDF_LOGE("%{public}s: fill apMldAddr fail", __func__); + ret = HDF_FAILURE; + } + WpaMloLinkedInfo *tmpLink = wpaInfo->linkInfo; + for (uint32_t i = 0; i < (wpaInfo->linkNum > MAX_MLO_LINK_NUM ? MAX_MLO_LINK_NUM : wpaInfo->linkNum); + i++) { + if (WpaFillWpaMloLinkedInfo(hdiMloInfo, tmpLink) != HDF_SUCCESS) { + pthread_mutex_unlock(&g_interfaceLock); + free(wpaInfo); + HDF_LOGE("%{public}s: fill apMldAddr fail", __func__); + ret = HDF_FAILURE; + } + hdiMloInfo++; + tmpLink++; + } + *hdiMloInfoLen = wpaInfo->linkNum; + pthread_mutex_unlock(&g_interfaceLock); + free(wpaInfo); + HDF_LOGI("%{public}s: wpaCliCmdGetMloLinkedInfo success ret = %{public}d", __func__, ret); + return HDF_SUCCESS; +} diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h index 424656bef9..d18081e15a 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h @@ -104,6 +104,8 @@ int32_t WpaInterfaceGetRequirePmf(struct IWpaInterface *self, const char *ifName int32_t WpaInterfaceSetCountryCode(struct IWpaInterface *self, const char *ifName, const char *countryCode); int32_t WpaInterfaceReassociate(struct IWpaInterface *self, const char *ifName); int32_t WpaInterfaceStaShellCmd(struct IWpaInterface *self, const char *ifName, const char *cmd); +int32_t WpaInterfaceGetWpaMloLinkedInfo(struct IWpaInterface *self, const char *ifName, char *apMldAddr, + uint32_t apMldAddrLen, struct HdiMloLinkedInfo *hdiMloInfo, uint32_t *hdiMloInfoLen); void HdfWpaDelRemoteObj(struct IWpaCallback *self); void ClearHdfWpaRemoteObj(void); diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h index a57ce85b6b..460b1d2e47 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h @@ -172,6 +172,19 @@ typedef struct WpaSignalInfo { int rxBytes; int txFailed; } WpaSignalInfo; + +typedef struct WpaMloStatusInfo { + int linkId; + int freq; + char apLinkAddr[WIFI_BSSID_LENGTH]; + char staLinkAddr[WIFI_BSSID_LENGTH]; +} + +typedef struct WpaMloStatusInfo { + int linkNum; + char apMldAddr[WIFI_BSSID_LENGTH]; + WpaMloStatusInfo linkInfo[MAX_MLO_LINK_NUM]; +} #ifdef __cplusplus } #endif diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.c b/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.c index c80affdf0c..f4533bf273 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.c +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.c @@ -1552,6 +1552,78 @@ static int WpaCliCmdStaShellCmd(WifiWpaStaInterface *this, const char *params) return WpaCliCmd(cmd, buf, sizeof(buf)); } +static int FillMloLinkedInfo(char *buf, size_t bufLen, WpaMloStatusInfo *wpaMloInfo) +{ + if (buf == NULL || wpaMloInfo == NULL) { + HDF_LOGE("FillMloLinkedInfo, buf null ir wpaMloInfo null"); + return -1; + } + char *savedPtr = NULL; + char *token = strtok_r(buf, "=", &savedPtr); + uint32_t linkNum = 0; + WpaMloLinkedInfo *linkInfo = wpaMloInfo->linkInfo; + while (token != NULL && linkInfo != NULL) { + if (strcmp(token, "ap_mld_addr") == 0) { + token = strtok_r(NULL, "\n", &savedPtr); + if (strcpy(wpaMloInfo->apMldAddr, WIFI_BSSID_LENGTH, token) != EOK) { + HDF_LOGE("%{public}s, strcpy apMldAddr err", __func__); + return -1; + } + } else if (strcmp(token, "link_id") == 0) { + token = strtok_r(NULL, "\n", &savedPtr); + linkInfo->linkId = atoi(token); + linkNum ++; + } else if (strcmp(token, "freq") == 0) { + token = strtok_r(NULL, "\n", &savedPtr); + linkInfo->freq = atoi(token); + } else if (strcmp(token, "ap_link_addr") == 0) { + token = strtok_r(NULL, "\n", &savedPtr); + if (linkNum > wpaMloInfo->linkNum || + strcpy(linkInfo->apLinkAddr, WIFI_BSSID_LENGTH, token) != EOK) { + HDF_LOGE("%{public}s, strcpy apLinkAddr err", __func__); + return -1; + } + } else if (strcmp(token, "sta_link_addr") == 0) { + token = strtok_r(NULL, "\n", &savedPtr); + if (linkNum > wpaMloInfo->linkNum || + strcpy(linkInfo->staLinkAddr, WIFI_BSSID_LENGTH, token) != EOK) { + HDF_LOGE("%{public}s, strcpy stainkAddr err", __func__); + return -1; + } + linkInfo++; + } else { + strtok_r(NULL, "\n", &savedPtr); + } + token = strtok_r(NULL, "=", &savedPtr); + } + wpaMloInfo->linkNum = linkNum; + return 0; +} + +static int WpaCliCmdGetMloLinkedInfo(WifiWpaStaInterface *this, WpaMloStatusInfo *wpaMloInfo) +{ + if (this == NULL || wpaMloInfo == NULL) { + HDF_LOGE("WpaCliCmdGetMloLinkedInfo, interface null ir wpaMloInfo null"); + return -1; + } + char cmd[CMD_BUFFER_SIZE] = {0}; + char buf[REPLY_BUF_LENGTH] = {0}; + if (snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "IFNAME=%s MLO_STATUS %s", + this->ifname) < 0) { + HDF_LOGE("WpaCliCmdGetMloLinkedInfo, snprintf_s err"); + return -1; + } + if (WpaCliCmd(cmd, buf, sizeof(buf)) != 0) { + HDF_LOGE("WpaCliCmdGetMloLinkedInfo, err"); + return -1; + } + if (FillMloLinkedInfo(buf, sizeof(buf), wpaMloInfo) != 0) { + HDF_LOGE("WpaCliCmdGetMloLinkedInfo FillMloLinkedInfo, err"); + return -1; + } + return 0; +} + WifiWpaStaInterface *GetWifiStaInterface(const char *name) { WifiWpaStaInterface *p = g_wpaStaInterface; @@ -1614,6 +1686,7 @@ WifiWpaStaInterface *GetWifiStaInterface(const char *name) p->wpaCliCmdGetRequirePmf = WpaCliCmdGetRequirePmf; p->wpaCliCmdGetConnectionCapabilities = WpaCliCmdGetConnectionCapabilities; p->wpaCliCmdStaShellCmd = WpaCliCmdStaShellCmd; + p->wpaCliCmdGetMloLinkedInfo = WpaCliCmdGetMloLinkedInfo; p->next = g_wpaStaInterface; g_wpaStaInterface = p; diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.h index ab5ec8d0c5..6b5604c9eb 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.h @@ -118,6 +118,7 @@ struct WifiWpaStaInterface { int (*wpaCliCmdGetRequirePmf)(WifiWpaStaInterface *this, int *enable); int (*wpaCliCmdGetConnectionCapabilities)(WifiWpaStaInterface *this, struct ConnectionCapabilities *connectionCap); int (*wpaCliCmdStaShellCmd)(WifiWpaStaInterface *this, const char *params); + int (*wpaCliCmdGetMloLinkedInfo)(WifiWpaStaInterface *this, struct WpaMloStatusInfo *wpaMloInfo); }; WifiWpaStaInterface *GetWifiStaInterface(const char *name); diff --git a/wlan/wpa/interfaces/hdi_service/wpa_interface_service.c b/wlan/wpa/interfaces/hdi_service/wpa_interface_service.c index ea99099239..fe3758dff1 100644 --- a/wlan/wpa/interfaces/hdi_service/wpa_interface_service.c +++ b/wlan/wpa/interfaces/hdi_service/wpa_interface_service.c @@ -122,6 +122,7 @@ struct IWpaInterface *WpaInterfaceImplGetInstance(void) service->interface.P2pSaveConfig = WpaInterfaceP2pSaveConfig; service->interface.VendorProcessCmd = WpaInterfaceVendorExtProcessCmd; + service->interface.GetWpaMloLinkedInfo = WpaInterfaceGetWpaMloLinkedInfo; return &service->interface; } -- Gitee From ac3dfe9451ab725f13eb6b55457f1b6da4afbf7e Mon Sep 17 00:00:00 2001 From: ying1210 Date: Wed, 11 Dec 2024 10:10:50 +0000 Subject: [PATCH 2/4] update wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h. Signed-off-by: ying1210 --- wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h index 460b1d2e47..24b0d6b645 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h @@ -173,7 +173,7 @@ typedef struct WpaSignalInfo { int txFailed; } WpaSignalInfo; -typedef struct WpaMloStatusInfo { +typedef struct WpaMloLinkedInfo { int linkId; int freq; char apLinkAddr[WIFI_BSSID_LENGTH]; -- Gitee From 60bed936672510555d04c337586a997485792b68 Mon Sep 17 00:00:00 2001 From: ying1210 Date: Thu, 12 Dec 2024 21:21:27 +0800 Subject: [PATCH 3/4] change interface to common Signed-off-by: ying1210 --- .../service_common/wpa_common_cmd.c | 82 ++----------------- .../service_common/wpa_common_cmd.h | 4 +- .../service_common/wpa_hal_struct.h | 13 --- .../service_common/wpa_supplicant_hal.c | 77 ++++------------- .../service_common/wpa_supplicant_hal.h | 2 +- .../hdi_service/wpa_interface_service.c | 2 +- 6 files changed, 26 insertions(+), 154 deletions(-) diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c index c50c08e0bf..97ab3812da 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.c @@ -1969,51 +1969,13 @@ void ClearHdfWpaRemoteObj(void) (void)OsalMutexUnlock(&HdfWpaStubDriver()->mutex); } -static int32_t WpaFillWpaMloLinkedInfo(struct HdiMloLinkedInfo *hdiMloInfo, - struct WpaMloLinkedInfo *wpaMloInfo) -{ - int32_t ret = HDF_SUCCESS; - if (hdiMloInfo == NULL || wpaMloInfo == NULL) { - HDF_LOGE("%{public}s: hdiMloInfo or wpaMloInfo is NULL!", __func__); - return HDF_ERR_INVALID_PARAM; - } - do { - hdiMloInfo->linkId = wpaMloInfo->linkId; - hdiMloInfo->freq = wpaMloInfo->freq; - uint8_t tmpBssid[EHT_ADDR_LEN] = {0}; - hwaddr_aton(wpaMloInfo->apLinkAddr, tmpBssid); - if (FillData(&hdiMloInfo->apLinkAddr, &hdiMloInfo->apLinkAddrLen, - tmpBssid, EHT_ADDR_LEN) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: fill apLinkAddr fail", __func__); - ret = HDF_FAILURE; - } - hwaddr_aton(wpaMloInfo->staLinkAddr, tmpBssid); - if (FillData(&hdiMloInfo->staLinkAddr, &hdiMloInfo->staLinkAddrLen, - tmpBssid, EHT_ADDR_LEN) != HDF_SUCCESS) { - HDF_LOGE("%{public}s: fill staLinkAddr fail", __func__); - ret = HDF_FAILURE; - } - } while(0); - if (ret != HDF_SUCCESS) { - if (hdiMloInfo->apLinkAddr != NULL) { - OsalMemFree(hdiMloInfo->apLinkAddr); - hdiMloInfo->apLinkAddr = NULL; - } - if (hdiMloInfo->staLinkAddr != NULL) { - OsalMemFree(hdiMloInfo->staLinkAddr); - hdiMloInfo->staLinkAddr = NULL; - } - } - return ret; -} - -int32_t WpaInterfaceGetWpaMloLinkedInfo(struct IWpaInterface *self, const char *ifName, char *apMldAddr, - uint32_t apMldAddrLen, struct HdiMloLinkedInfo *hdiMloInfo, uint32_t *hdiMloInfoLen) +int32_t WpaInterfaceGetWpaStaData(struct IWpaInterface *self, const char *ifName, const char *staParam, + char *staData, uint32_t staDataLen) { (void)self; HDF_LOGI("enter %{public}s ", __func__); pthread_mutex_lock(&g_interfaceLock); - if (ifName == NULL || hdiMloInfo == NULL || hdiMloInfoLen == NULL) { + if (ifName == NULL || staParam == NULL || staData == NULL) { pthread_mutex_unlock(&g_interfaceLock); HDF_LOGE("%{public}s: input parameter invalid!", __func__); return HDF_ERR_INVALID_PARAM; @@ -2024,43 +1986,15 @@ int32_t WpaInterfaceGetWpaMloLinkedInfo(struct IWpaInterface *self, const char * HDF_LOGE("%{public}s: pStaIfc = NULL", __func__); return HDF_FAILURE; } - WpaMloStatusInfo *wpaInfo = (WpaMloStatusInfo *)calloc(1, sizeof(WpaMloStatusInfo)); - if (wpaInfo == NULL) { - pthread_mutex_unlock(&g_interfaceLock); - HDF_LOGE("%{public}s: wpaInfo = NULL", __func__); - return HDF_FAILURE; - } - wpaInfo->linkNum = MAX_MLO_LINK_NUM; - int ret = pStaIfc->wpaCliCmdGetMloLinkedInfo(pStaIfc, wpaInfo); + + int ret = pStaIfc->wpaCliCmdGetWpaStaData(pStaIfc, staParam, staData, staDataLen); if (ret < 0) { pthread_mutex_unlock(&g_interfaceLock); - free(wpaInfo); - HDF_LOGE("%{public}s: wpaCliCmdGetMloLinkedInfo fail! ret = %{public}d", __func__, ret); + HDF_LOGE("%{public}s: wpaCliCmdGetWpaStaData fail! ret = %{public}d", __func__, ret); return HDF_FAILURE; } - uint8_t tmpBssid[EHT_ADDR_LEN] = {0}; - hwaddr_aton(wpaInfo->apMldAddr, tmpBssid); - if (strcpy(apMldAddr, apMldAddrLen, tmpBssid, EHT_ADDR_LEN) != HDF_SUCCESS) { - pthread_mutex_unlock(&g_interfaceLock); - free(wpaInfo); - HDF_LOGE("%{public}s: fill apMldAddr fail", __func__); - ret = HDF_FAILURE; - } - WpaMloLinkedInfo *tmpLink = wpaInfo->linkInfo; - for (uint32_t i = 0; i < (wpaInfo->linkNum > MAX_MLO_LINK_NUM ? MAX_MLO_LINK_NUM : wpaInfo->linkNum); - i++) { - if (WpaFillWpaMloLinkedInfo(hdiMloInfo, tmpLink) != HDF_SUCCESS) { - pthread_mutex_unlock(&g_interfaceLock); - free(wpaInfo); - HDF_LOGE("%{public}s: fill apMldAddr fail", __func__); - ret = HDF_FAILURE; - } - hdiMloInfo++; - tmpLink++; - } - *hdiMloInfoLen = wpaInfo->linkNum; + pthread_mutex_unlock(&g_interfaceLock); - free(wpaInfo); - HDF_LOGI("%{public}s: wpaCliCmdGetMloLinkedInfo success ret = %{public}d", __func__, ret); + HDF_LOGI("%{public}s: wpaCliCmdGetWpaStaData success ret = %{public}d", __func__, ret); return HDF_SUCCESS; } diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h index d18081e15a..e4f6fa10b2 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_common_cmd.h @@ -104,8 +104,8 @@ int32_t WpaInterfaceGetRequirePmf(struct IWpaInterface *self, const char *ifName int32_t WpaInterfaceSetCountryCode(struct IWpaInterface *self, const char *ifName, const char *countryCode); int32_t WpaInterfaceReassociate(struct IWpaInterface *self, const char *ifName); int32_t WpaInterfaceStaShellCmd(struct IWpaInterface *self, const char *ifName, const char *cmd); -int32_t WpaInterfaceGetWpaMloLinkedInfo(struct IWpaInterface *self, const char *ifName, char *apMldAddr, - uint32_t apMldAddrLen, struct HdiMloLinkedInfo *hdiMloInfo, uint32_t *hdiMloInfoLen); +int32_t WpaInterfaceGetWpaStaData(struct IWpaInterface *self, const char *ifName, const char *staParam, + char *staData, uint32_t staDataLen); void HdfWpaDelRemoteObj(struct IWpaCallback *self); void ClearHdfWpaRemoteObj(void); diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h index 460b1d2e47..a57ce85b6b 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h @@ -172,19 +172,6 @@ typedef struct WpaSignalInfo { int rxBytes; int txFailed; } WpaSignalInfo; - -typedef struct WpaMloStatusInfo { - int linkId; - int freq; - char apLinkAddr[WIFI_BSSID_LENGTH]; - char staLinkAddr[WIFI_BSSID_LENGTH]; -} - -typedef struct WpaMloStatusInfo { - int linkNum; - char apMldAddr[WIFI_BSSID_LENGTH]; - WpaMloStatusInfo linkInfo[MAX_MLO_LINK_NUM]; -} #ifdef __cplusplus } #endif diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.c b/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.c index f4533bf273..b9ab43019c 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.c +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.c @@ -1552,76 +1552,27 @@ static int WpaCliCmdStaShellCmd(WifiWpaStaInterface *this, const char *params) return WpaCliCmd(cmd, buf, sizeof(buf)); } -static int FillMloLinkedInfo(char *buf, size_t bufLen, WpaMloStatusInfo *wpaMloInfo) +static int WpaCliCmdGetWpaStaData(WifiWpaStaInterface *this, const char *argv, char *staData, unsigned int size) { - if (buf == NULL || wpaMloInfo == NULL) { - HDF_LOGE("FillMloLinkedInfo, buf null ir wpaMloInfo null"); + if (this == NULL || argv == NULL || staData == NULL) { + HDF_LOGE("WpaCliCmdGetWpaStaData, interface null ir wpaMloInfo null"); return -1; - } - char *savedPtr = NULL; - char *token = strtok_r(buf, "=", &savedPtr); - uint32_t linkNum = 0; - WpaMloLinkedInfo *linkInfo = wpaMloInfo->linkInfo; - while (token != NULL && linkInfo != NULL) { - if (strcmp(token, "ap_mld_addr") == 0) { - token = strtok_r(NULL, "\n", &savedPtr); - if (strcpy(wpaMloInfo->apMldAddr, WIFI_BSSID_LENGTH, token) != EOK) { - HDF_LOGE("%{public}s, strcpy apMldAddr err", __func__); - return -1; - } - } else if (strcmp(token, "link_id") == 0) { - token = strtok_r(NULL, "\n", &savedPtr); - linkInfo->linkId = atoi(token); - linkNum ++; - } else if (strcmp(token, "freq") == 0) { - token = strtok_r(NULL, "\n", &savedPtr); - linkInfo->freq = atoi(token); - } else if (strcmp(token, "ap_link_addr") == 0) { - token = strtok_r(NULL, "\n", &savedPtr); - if (linkNum > wpaMloInfo->linkNum || - strcpy(linkInfo->apLinkAddr, WIFI_BSSID_LENGTH, token) != EOK) { - HDF_LOGE("%{public}s, strcpy apLinkAddr err", __func__); - return -1; - } - } else if (strcmp(token, "sta_link_addr") == 0) { - token = strtok_r(NULL, "\n", &savedPtr); - if (linkNum > wpaMloInfo->linkNum || - strcpy(linkInfo->staLinkAddr, WIFI_BSSID_LENGTH, token) != EOK) { - HDF_LOGE("%{public}s, strcpy stainkAddr err", __func__); - return -1; - } - linkInfo++; - } else { - strtok_r(NULL, "\n", &savedPtr); - } - token = strtok_r(NULL, "=", &savedPtr); } - wpaMloInfo->linkNum = linkNum; - return 0; -} - -static int WpaCliCmdGetMloLinkedInfo(WifiWpaStaInterface *this, WpaMloStatusInfo *wpaMloInfo) -{ - if (this == NULL || wpaMloInfo == NULL) { - HDF_LOGE("WpaCliCmdGetMloLinkedInfo, interface null ir wpaMloInfo null"); - return -1; - } - char cmd[CMD_BUFFER_SIZE] = {0}; - char buf[REPLY_BUF_LENGTH] = {0}; - if (snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "IFNAME=%s MLO_STATUS %s", - this->ifname) < 0) { - HDF_LOGE("WpaCliCmdGetMloLinkedInfo, snprintf_s err"); + char cmd[CMD_BUFFER_SIZE] = {0}; + char buf[REPLY_BUF_LENGTH] = {0}; + if (snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "IFNAME=%s %s", this->ifname, argv) < 0) { + HDF_LOGE("WpaCliCmdGetWpaStaData, snprintf_s err"); return -1; } if (WpaCliCmd(cmd, buf, sizeof(buf)) != 0) { - HDF_LOGE("WpaCliCmdGetMloLinkedInfo, err"); + HDF_LOGE("WpaCliCmdGetWpaStaData, err"); return -1; - } - if (FillMloLinkedInfo(buf, sizeof(buf), wpaMloInfo) != 0) { - HDF_LOGE("WpaCliCmdGetMloLinkedInfo FillMloLinkedInfo, err"); + } + if (strncpy_s(staData, size, buf, sizeof(buf)) != EOK) { + HDF_LOGE("WpaCliCmdGetWpaStaData, copy res err"); return -1; - } - return 0; + } + return 0; } WifiWpaStaInterface *GetWifiStaInterface(const char *name) @@ -1686,7 +1637,7 @@ WifiWpaStaInterface *GetWifiStaInterface(const char *name) p->wpaCliCmdGetRequirePmf = WpaCliCmdGetRequirePmf; p->wpaCliCmdGetConnectionCapabilities = WpaCliCmdGetConnectionCapabilities; p->wpaCliCmdStaShellCmd = WpaCliCmdStaShellCmd; - p->wpaCliCmdGetMloLinkedInfo = WpaCliCmdGetMloLinkedInfo; + p->wpaCliCmdGetWpaStaData = WpaCliCmdGetWpaStaData; p->next = g_wpaStaInterface; g_wpaStaInterface = p; diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.h index 6b5604c9eb..ffe09763a7 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_supplicant_hal.h @@ -118,7 +118,7 @@ struct WifiWpaStaInterface { int (*wpaCliCmdGetRequirePmf)(WifiWpaStaInterface *this, int *enable); int (*wpaCliCmdGetConnectionCapabilities)(WifiWpaStaInterface *this, struct ConnectionCapabilities *connectionCap); int (*wpaCliCmdStaShellCmd)(WifiWpaStaInterface *this, const char *params); - int (*wpaCliCmdGetMloLinkedInfo)(WifiWpaStaInterface *this, struct WpaMloStatusInfo *wpaMloInfo); + int (*wpaCliCmdGetWpaStaData)(WifiWpaStaInterface *this, const char *argv, char *staData, unsigned int size); }; WifiWpaStaInterface *GetWifiStaInterface(const char *name); diff --git a/wlan/wpa/interfaces/hdi_service/wpa_interface_service.c b/wlan/wpa/interfaces/hdi_service/wpa_interface_service.c index fe3758dff1..90220f9cc8 100644 --- a/wlan/wpa/interfaces/hdi_service/wpa_interface_service.c +++ b/wlan/wpa/interfaces/hdi_service/wpa_interface_service.c @@ -122,7 +122,7 @@ struct IWpaInterface *WpaInterfaceImplGetInstance(void) service->interface.P2pSaveConfig = WpaInterfaceP2pSaveConfig; service->interface.VendorProcessCmd = WpaInterfaceVendorExtProcessCmd; - service->interface.GetWpaMloLinkedInfo = WpaInterfaceGetWpaMloLinkedInfo; + service->interface.GetWpaStaData = WpaInterfaceGetWpaStaData; return &service->interface; } -- Gitee From e3f71a61e0f8442d6500c2d5c731de7b3e8228bf Mon Sep 17 00:00:00 2001 From: ying1210 Date: Fri, 13 Dec 2024 15:51:28 +0800 Subject: [PATCH 4/4] change interface to common Signed-off-by: ying1210 --- wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h | 1 - 1 file changed, 1 deletion(-) diff --git a/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h b/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h index 2d6a5055a2..a57ce85b6b 100644 --- a/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h +++ b/wlan/wpa/interfaces/hdi_service/service_common/wpa_hal_struct.h @@ -172,7 +172,6 @@ typedef struct WpaSignalInfo { int rxBytes; int txFailed; } WpaSignalInfo; - #ifdef __cplusplus } #endif -- Gitee