diff --git a/wlan/README_zh.md b/wlan/README_zh.md index b8e05ccfdad98bc116e555e5b4b057620c5a3f3c..93c9ea22dfc7666c2728fcced4c88d42914b293c 100644 --- a/wlan/README_zh.md +++ b/wlan/README_zh.md @@ -51,7 +51,7 @@ WLAN驱动模块通过HAL/HDI层(HAL是直调,HDI是通过IPC调用)对Wi-Fi S -

v1_1/iwlan_interface.h(V1_1为版本号,随着接口的增加而改变)

+

v1_2/iwlan_interface.h(V1_2为版本号,随着接口的增加而改变)

int32_t (*Start)(struct IWlanInterface *self);

@@ -371,7 +371,7 @@ HDI接口使用步骤: 代码示例: ``` -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_interface.h" #include "wlan_callback_impl.h" #include "wlan_impl.h" diff --git a/wlan/client/include/wifi_driver_client.h b/wlan/client/include/wifi_driver_client.h index e50b1ed71b90e3ef45b4b846b7309c8eb54b4a8c..f6154e53c26aed43c53f7bc321b6240a3b6aa711 100644 --- a/wlan/client/include/wifi_driver_client.h +++ b/wlan/client/include/wifi_driver_client.h @@ -345,6 +345,7 @@ int32_t GetStationInfo(const char *ifName, StationInfo *info, const uint8_t *mac int32_t WifiStartPnoScan(const char *ifName, const WifiPnoSettings *pnoSettings); int32_t WifiStopPnoScan(const char *ifName); int32_t WifiGetSignalPollInfo(const char *ifName, struct SignalResult *signalResult); +int32_t ClientGetApBandwidth(const char *ifName, uint8_t *bandwidth); /* wpa related interface */ #define MAX_NR_CIPHER_SUITES 5 diff --git a/wlan/client/src/netlink/netlink_cmd_adapter.c b/wlan/client/src/netlink/netlink_cmd_adapter.c index cabc2813b70634d8c0f17ca71b6cba1eec860576..cdd50b1430715388aef0d07890db173d6e9d59fd 100644 --- a/wlan/client/src/netlink/netlink_cmd_adapter.c +++ b/wlan/client/src/netlink/netlink_cmd_adapter.c @@ -69,6 +69,8 @@ #define CMD_SET_GO_DETECT_RADAR "CMD_SET_GO_DETECT_RADAR" #define CMD_SET_DYNAMIC_DBAC_MODE "SET_DYNAMIC_DBAC_MODE" #define CMD_SET_P2P_SCENES "CMD_SET_P2P_SCENES" +#define CMD_GET_AP_BANDWIDTH "GET_AP_BANDWIDTH" + #define P2P_BUF_SIZE 64 #define MAX_PRIV_CMD_SIZE 4096 #define LOW_LITMIT_FREQ_2_4G 2400 @@ -1599,18 +1601,16 @@ int32_t GetChannelMeasResult(const char *ifName, struct MeasResult *measResult) return RET_CODE_NOT_SUPPORT; } -static int32_t SendCommandToDriver(const char *cmd, uint32_t len, const char *ifName) +static int32_t SendCommandToDriver(const char *cmd, uint32_t len, const char *ifName, WifiPrivCmd *out) { struct ifreq ifr; - WifiPrivCmd privCmd = {0}; - uint8_t buf[MAX_PRIV_CMD_SIZE] = {0}; int32_t ret = RET_CODE_FAILURE; - if (cmd == NULL) { - HILOG_ERROR(LOG_CORE, "%{public}s: cmd is null", __FUNCTION__); + if (cmd == NULL || out == NULL) { + HILOG_ERROR(LOG_CORE, "%{public}s: cmd or out is null", __FUNCTION__); return RET_CODE_INVALID_PARAM; } - if (len > MAX_PRIV_CMD_SIZE) { + if (len > out->size) { HILOG_ERROR(LOG_CORE, "%{public}s: Size of command is too large", __FUNCTION__); return RET_CODE_INVALID_PARAM; } @@ -1618,14 +1618,12 @@ static int32_t SendCommandToDriver(const char *cmd, uint32_t len, const char *if HILOG_ERROR(LOG_CORE, "%s: memset_s ifr failed", __FUNCTION__); return RET_CODE_FAILURE; } - if (memcpy_s(buf, MAX_PRIV_CMD_SIZE, cmd, len) != EOK) { + if (memcpy_s(out->buf, out->size, cmd, len) != EOK) { HILOG_ERROR(LOG_CORE, "%{public}s: memcpy_s error", __FUNCTION__); return RET_CODE_FAILURE; } - privCmd.buf = buf; - privCmd.size = sizeof(buf); - privCmd.len = len; - ifr.ifr_data = (void *)&privCmd; + out->len = len; + ifr.ifr_data = (void *)out; if (strcpy_s(ifr.ifr_name, IFNAMSIZ, ifName) != EOK) { HILOG_ERROR(LOG_CORE, "%s: strcpy_s error", __FUNCTION__); return RET_CODE_FAILURE; @@ -1644,11 +1642,6 @@ static int32_t SendCommandToDriver(const char *cmd, uint32_t len, const char *if ret = (errno == EOPNOTSUPP) ? RET_CODE_NOT_SUPPORT : RET_CODE_FAILURE; break; } - (void)memset_s((void *)cmd, len, 0, len); - if (memcpy_s((void *)cmd, len, privCmd.buf, len - 1) != EOK) { - HILOG_ERROR(LOG_CORE, "%{public}s: memcpy_s error", __FUNCTION__); - ret = RET_CODE_FAILURE; - } } while (0); close(sock); @@ -1694,7 +1687,11 @@ static int32_t DisableNextCacOnce(const char *ifName) { char cmdBuf[P2P_BUF_SIZE] = {CMD_SET_CLOSE_GO_CAC}; - return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName); + uint8_t buf[MAX_PRIV_CMD_SIZE] = {0}; + WifiPrivCmd out = {0}; + out.buf = buf; + out.size = MAX_PRIV_CMD_SIZE; + return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName, &out); } static int32_t SetGoChannel(const char *ifName, const int8_t *data, uint32_t len) @@ -1718,7 +1715,12 @@ static int32_t SetGoChannel(const char *ifName, const int8_t *data, uint32_t len HILOG_ERROR(LOG_CORE, "%{public}s: interface state is not OK.", __FUNCTION__); return RET_CODE_NETDOWN; } - return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName); + + uint8_t buf[MAX_PRIV_CMD_SIZE] = {0}; + WifiPrivCmd out = {0}; + out.buf = buf; + out.size = MAX_PRIV_CMD_SIZE; + return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName, &out); } static int32_t SetGoDetectRadar(const char *ifName, const int8_t *data, uint32_t len) @@ -1742,7 +1744,12 @@ static int32_t SetGoDetectRadar(const char *ifName, const int8_t *data, uint32_t HILOG_ERROR(LOG_CORE, "%{public}s: interface state is not OK.", __FUNCTION__); return RET_CODE_NETDOWN; } - return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName); + + uint8_t buf[MAX_PRIV_CMD_SIZE] = {0}; + WifiPrivCmd out = {0}; + out.buf = buf; + out.size = MAX_PRIV_CMD_SIZE; + return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName, &out); } static int32_t SetP2pScenes(const char *ifName, const int8_t *data, uint32_t len) @@ -1766,7 +1773,12 @@ static int32_t SetP2pScenes(const char *ifName, const int8_t *data, uint32_t len HILOG_ERROR(LOG_CORE, "%{public}s: interface state is not OK.", __FUNCTION__); return RET_CODE_NETDOWN; } - return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName); + + uint8_t buf[MAX_PRIV_CMD_SIZE] = {0}; + WifiPrivCmd out = {0}; + out.buf = buf; + out.size = MAX_PRIV_CMD_SIZE; + return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName, &out); } static int32_t SetDynamicDbacMode(const char *ifName, const int8_t *data, uint32_t len) @@ -1790,7 +1802,12 @@ static int32_t SetDynamicDbacMode(const char *ifName, const int8_t *data, uint32 HILOG_ERROR(LOG_CORE, "%{public}s: interface state is not OK.", __FUNCTION__); return RET_CODE_NETDOWN; } - return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName); + + uint8_t buf[MAX_PRIV_CMD_SIZE] = {0}; + WifiPrivCmd out = {0}; + out.buf = buf; + out.size = MAX_PRIV_CMD_SIZE; + return SendCommandToDriver(cmdBuf, P2P_BUF_SIZE, ifName, &out); } int32_t SetProjectionScreenParam(const char *ifName, const ProjectionScreenParam *param) @@ -2647,6 +2664,29 @@ static int32_t SignalInfoHandler(struct nl_msg *msg, void *arg) return NL_SKIP; } +int32_t ClientGetApBandwidth(const char *ifName, uint8_t *bandwidth) +{ + if (ifName == NULL || bandwidth == NULL) { + HILOG_ERROR(LOG_CORE, "%s: param is NULL.", __FUNCTION__); + return RET_CODE_FAILURE; + } + + const char *cmd = CMD_GET_AP_BANDWIDTH; + uint8_t buf[MAX_PRIV_CMD_SIZE] = {0}; + WifiPrivCmd out = {0}; + out.buf = buf; + out.size = MAX_PRIV_CMD_SIZE; + int32_t ret = SendCommandToDriver(cmd, strlen(cmd), ifName, &out); + if (ret != RET_CODE_SUCCESS) { + HILOG_ERROR(LOG_CORE, "%s: send command to driver failed, code=%d", __FUNCTION__, ret); + return ret; + } + *bandwidth = *out.buf; + + HILOG_INFO(LOG_CORE, "%s: AP bandwidth: %d", __FUNCTION__, *bandwidth); + return RET_CODE_SUCCESS; +} + int32_t WifiGetSignalPollInfo(const char *ifName, struct SignalResult *signalResult) { struct nl_msg *msg = NULL; diff --git a/wlan/client/src/sbuf/sbuf_cmd_adapter.c b/wlan/client/src/sbuf/sbuf_cmd_adapter.c index a6a2d8c185f6173bec9d8d81a3dc19c80caf7cc4..5e6fe4c090425cc9e96c48d6568c53911e7d08ad 100644 --- a/wlan/client/src/sbuf/sbuf_cmd_adapter.c +++ b/wlan/client/src/sbuf/sbuf_cmd_adapter.c @@ -1083,6 +1083,40 @@ int32_t WifiStopPnoScan(const char *ifName) return ret; } +int32_t ClientGetApBandwidth(const char *ifName, uint8_t *bandwidth) +{ + int32_t ret; + struct HdfSBuf *data = NULL; + struct HdfSBuf *reply = NULL; + + if (HdfSbufObtainDefault(&data, &reply) != RET_CODE_SUCCESS) { + HDF_LOGE("%s: HdfSbufObtainDefault fail", __FUNCTION__); + return RET_CODE_FAILURE; + } + + do { + if (!HdfSbufWriteString(data, ifName)) { + HDF_LOGE("%s: write ifName fail!", __FUNCTION__); + ret = RET_CODE_FAILURE; + break; + } + ret = SendCmdSync(WIFI_HAL_CMD_GET_AP_BANDWIDTH, data, reply); + if (ret != RET_CODE_SUCCESS) { + HDF_LOGE("%s: SendCmdSync fail, code=%d", __FUNCTION__, ret); + break; + } + if (!HdfSbufReadUint8(reply, bandwidth)) { + HDF_LOGE("%s: HdfSbufReadUint8 failed", __FUNCTION__); + ret = RET_CODE_FAILURE; + break; + } + } while (0); + + HdfSbufRecycle(data); + HdfSbufRecycle(reply); + return ret; +} + int32_t WifiGetSignalPollInfo(const char *ifName, struct SignalResult *signalResult) { int32_t ret = RET_CODE_FAILURE; diff --git a/wlan/client/src/wifi_common_cmd.h b/wlan/client/src/wifi_common_cmd.h index 35cd5c49569f27d01876dd16fe05f24eb16ffce6..3ba0c2e636f576ee8b1c188aa568dc94e82735f2 100644 --- a/wlan/client/src/wifi_common_cmd.h +++ b/wlan/client/src/wifi_common_cmd.h @@ -69,6 +69,7 @@ enum APCommands { CMD_AP_DEL_STATION, CMD_AP_GET_ASSOC_STA, CMD_AP_SET_COUNTRY_CODE, + CMD_AP_GET_BANDWIDTH, }; enum STACommands { @@ -119,6 +120,7 @@ typedef enum { WIFI_HAL_CMD_START_PNO_SCAN = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_START_PNO_SCAN), WIFI_HAL_CMD_STOP_PNO_SCAN = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_STOP_PNO_SCAN), WIFI_HAL_CMD_GET_SIGNAL_INFO = HDF_WIFI_CMD(STA_SERVICE_ID, CMD_STA_GET_SIGNAL_INFO), + WIFI_HAL_CMD_GET_AP_BANDWIDTH = HDF_WIFI_CMD(AP_SERVICE_ID, CMD_AP_GET_BANDWIDTH), } WifiHalCmd; typedef enum { diff --git a/wlan/hal/include/wifi_hal_cmd.h b/wlan/hal/include/wifi_hal_cmd.h index 352aea6d6b14ca43b36ac9340fd4ee1e0c1d4759..80ccfc5664d3f879e029cbb95eb2db83f0bb622d 100644 --- a/wlan/hal/include/wifi_hal_cmd.h +++ b/wlan/hal/include/wifi_hal_cmd.h @@ -44,6 +44,9 @@ int32_t HalCmdStartScanInner(const char *ifName, WifiScan *scan); int32_t HalCmdStartPnoScan(const char *ifName, const WifiPnoSettings *pnoSettings); int32_t HalCmdStopPnoScan(const char *ifName); int32_t HalCmdGetSignalPollInfo(const char *ifName, struct SignalResult *signalResult); +int32_t HalCmdGetFeatureByIfName(const char *ifName, struct IWiFiBaseFeature **ifeature); +int32_t HalCmdGetApBandwidth(const char *ifName, uint8_t *bandwidth); +int32_t HalCmdResetToFactoryMacAddress(const char *ifNames); struct DListHead *GetNetworkHead(void); void ClearIWiFiList(void); diff --git a/wlan/hal/src/wifi_hal.c b/wlan/hal/src/wifi_hal.c index 7fa39533cb04a61f9293b59d51af8e5d603c6bb7..72c20b80a5e819dda425309a44e3cb1ba4e6ea3a 100644 --- a/wlan/hal/src/wifi_hal.c +++ b/wlan/hal/src/wifi_hal.c @@ -182,25 +182,6 @@ static int32_t CreateFeatureInner(int32_t type, struct IWiFiBaseFeature **ifeatu return HDF_SUCCESS; } -static int32_t GetFeatureByIfNameInner(const char *ifName, struct IWiFiBaseFeature **ifeature) -{ - struct DListHead *networkHead = GetNetworkHead(); - struct IWiFiList *networkNode = NULL; - - if (ifName == NULL) { - HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__); - return HDF_ERR_INVALID_PARAM; - } - DLIST_FOR_EACH_ENTRY(networkNode, networkHead, struct IWiFiList, entry) { - if (strcmp(networkNode->ifName, ifName) == HDF_SUCCESS) { - *ifeature = networkNode->ifeature; - return HDF_SUCCESS; - } - } - HDF_LOGE("%s: cannot find feature by ifName, line: %d", __FUNCTION__, __LINE__); - return HDF_FAILURE; -} - static int32_t DestroyFeatureInner(struct IWiFiBaseFeature *ifeature) { struct DListHead *networkHead = GetNetworkHead(); @@ -394,7 +375,7 @@ static int32_t CreateFeature(int32_t type, struct IWiFiBaseFeature **ifeature) static int32_t GetFeatureByIfName(const char *ifName, struct IWiFiBaseFeature **ifeature) { HalMutexLock(); - int32_t ret = GetFeatureByIfNameInner(ifName, ifeature); + int32_t ret = HalCmdGetFeatureByIfName(ifName, ifeature); HalMutexUnlock(); return ret; } diff --git a/wlan/hal/src/wifi_hal_ap_feature.c b/wlan/hal/src/wifi_hal_ap_feature.c index 9303993d13822501a506be87bfe55dd46607d213..7de24ea75d665cb5a9bfa8229282cf3bc32a4acf 100644 --- a/wlan/hal/src/wifi_hal_ap_feature.c +++ b/wlan/hal/src/wifi_hal_ap_feature.c @@ -62,6 +62,14 @@ static int32_t HalSetCountryCode(const struct IWiFiAp *apFeature, const char *co return ret; } +static int32_t HalGetApBandwidth(const char *ifName, uint8_t *bandwidth) +{ + HalMutexLock(); + int32_t ret = HalCmdGetApBandwidth(ifName, bandwidth); + HalMutexUnlock(); + return ret; +} + int32_t InitApFeature(struct IWiFiAp **fe) { if (fe == NULL || *fe == NULL) { @@ -74,6 +82,7 @@ int32_t InitApFeature(struct IWiFiAp **fe) } (*fe)->getAssociatedStas = HalGetAssociatedStas; (*fe)->setCountryCode = HalSetCountryCode; + (*fe)->getApBandwidth = HalGetApBandwidth; return HDF_SUCCESS; } diff --git a/wlan/hal/src/wifi_hal_base_feature.c b/wlan/hal/src/wifi_hal_base_feature.c index 35c568d7a2199c9cb7430024aabb6ea4e9969f07..6d5cf1110247e2eda99b380f3e7866bd9d7570db 100644 --- a/wlan/hal/src/wifi_hal_base_feature.c +++ b/wlan/hal/src/wifi_hal_base_feature.c @@ -164,6 +164,14 @@ static int32_t HalGetIfNamesByChipId(const uint8_t chipId, char **ifNames, uint3 return ret; } +static int32_t HalResetToFactoryMacAddress(const char *ifName) +{ + HalMutexLock(); + int32_t ret = HalCmdResetToFactoryMacAddress(ifName); + HalMutexUnlock(); + return ret; +} + int32_t InitBaseFeature(struct IWiFiBaseFeature **fe) { if (fe == NULL || *fe == NULL) { @@ -178,6 +186,7 @@ int32_t InitBaseFeature(struct IWiFiBaseFeature **fe) (*fe)->setTxPower = HalSetTxPower; (*fe)->getChipId = HalGetChipId; (*fe)->getIfNamesByChipId = HalGetIfNamesByChipId; + (*fe)->resetToFactoryMacAddress = HalResetToFactoryMacAddress; return HDF_SUCCESS; } diff --git a/wlan/hal/src/wifi_hal_cmd.c b/wlan/hal/src/wifi_hal_cmd.c index fbd7e23edbca15a82238406c394a1733bd130da4..4dd6cc72649fce7df4d3dbdb7c27608b3fc181ff 100644 --- a/wlan/hal/src/wifi_hal_cmd.c +++ b/wlan/hal/src/wifi_hal_cmd.c @@ -296,6 +296,58 @@ int32_t HalCmdSetResetDriver(const uint8_t chipId, const char *ifName) return ret; } +int32_t HalCmdGetFeatureByIfName(const char *ifName, struct IWiFiBaseFeature **ifeature) +{ + struct DListHead *networkHead = GetNetworkHead(); + struct IWiFiList *networkNode = NULL; + + if (ifName == NULL || ifeature == NULL) { + HDF_LOGE("%s: input parameter invalid, line: %d", __FUNCTION__, __LINE__); + return HDF_ERR_INVALID_PARAM; + } + DLIST_FOR_EACH_ENTRY(networkNode, networkHead, struct IWiFiList, entry) { + if (strcmp(networkNode->ifName, ifName) == HDF_SUCCESS) { + *ifeature = networkNode->ifeature; + return HDF_SUCCESS; + } + } + HDF_LOGE("%s: cannot find feature by ifName, line: %d", __FUNCTION__, __LINE__); + return HDF_FAILURE; +} + +int32_t HalCmdGetApBandwidth(const char *ifName, uint8_t *bandwidth) +{ + int32_t ret = ClientGetApBandwidth(ifName, bandwidth); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: get ap bandwidth failed, code=%d", __FUNCTION__, ret); + } + return ret; +} + +int32_t HalCmdResetToFactoryMacAddress(const char *ifName) +{ + int32_t ret; + struct IWiFiBaseFeature *ifeature = NULL; + ret = HalCmdGetFeatureByIfName(ifName, &ifeature); + if (ret != HDF_SUCCESS || ifeature == NULL) { + HDF_LOGE("%s: hal cmd get devmac addr failed, code=%d", __FUNCTION__, ret); + return ret; + } + + unsigned char mac[ETH_ADDR_LEN] = {0}; + ret = HalCmdGetDevMacAddr(ifName, ifeature->type, mac, ETH_ADDR_LEN); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: hal cmd get devmac addr failed, code=%d", __FUNCTION__, ret); + return ret; + } + + ret = HalCmdSetMacAddr(ifName, mac, ETH_ADDR_LEN); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: hal cmd set mac addr failed, code=%d", __FUNCTION__, ret); + } + return ret; +} + void ClearIWiFiList(void) { struct IWiFiList *networkList = NULL; diff --git a/wlan/hdi_service/BUILD.gn b/wlan/hdi_service/BUILD.gn index e086c1e868feefeb08947be89d86f5b77770fc9f..c2f6da757597c05d7ed9f5f42dd148e954890393 100644 --- a/wlan/hdi_service/BUILD.gn +++ b/wlan/hdi_service/BUILD.gn @@ -13,7 +13,7 @@ import("//build/ohos.gni") -ohos_shared_library("libwlan_interface_service_1.1") { +ohos_shared_library("libwlan_interface_service_1.2") { include_dirs = [ "../interfaces/include", "../client/include", @@ -30,7 +30,7 @@ ohos_shared_library("libwlan_interface_service_1.1") { "../hal:wifi_hal", "service_extend:libwlan_service_extend", ] - external_deps = [ "drivers_interface_wlan:libwlan_stub_1.1" ] + external_deps = [ "drivers_interface_wlan:libwlan_stub_1.2" ] defines = [ "__OHOS__USER__" ] @@ -70,10 +70,10 @@ ohos_shared_library("libwifi_hdi_c_device") { sources = [ "wlan_interface_drivers.c" ] deps = [ - ":libwlan_interface_service_1.1", + ":libwlan_interface_service_1.2", "service_extend:libwlan_service_extend", ] - external_deps = [ "drivers_interface_wlan:libwlan_stub_1.1" ] + external_deps = [ "drivers_interface_wlan:libwlan_stub_1.2" ] cflags = [ "-Wall", @@ -106,6 +106,6 @@ ohos_shared_library("libwifi_hdi_c_device") { group("hdi_wlan_service") { deps = [ ":libwifi_hdi_c_device", - ":libwlan_interface_service_1.1", + ":libwlan_interface_service_1.2", ] } diff --git a/wlan/hdi_service/service_common/wlan_common_cmd.c b/wlan/hdi_service/service_common/wlan_common_cmd.c index 41f4bd692add64aeb9f01d0cb8b28c6fffeb563c..d9e172daeefc6bbe02bb868dbec62737f073c320 100644 --- a/wlan/hdi_service/service_common/wlan_common_cmd.c +++ b/wlan/hdi_service/service_common/wlan_common_cmd.c @@ -19,8 +19,8 @@ #include #include #include "wlan_extend_cmd.h" -#include "v1_1/iwlan_callback.h" -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_callback.h" +#include "v1_2/iwlan_interface.h" struct IWiFi *g_wifi = NULL; struct IWiFiAp *g_apFeature = NULL; @@ -1428,6 +1428,54 @@ int32_t WlanInterfaceGetSignalPollInfo(struct IWlanInterface *self, const char * return ret; } +int32_t WlanInterfaceGetApBandwidth(struct IWlanInterface *self, const char *ifName, + uint8_t *bandwidth) +{ + int32_t ret; + (void)self; + + if (ifName == NULL || bandwidth == NULL) { + HDF_LOGE("%{public}s input parameter invalid!", __func__); + return HDF_ERR_INVALID_PARAM; + } + if (g_apFeature == NULL || g_apFeature->getApBandwidth == NULL) { + HDF_LOGE("%{public}s g_apFeature or g_staFeature->getApBandwidth is NULL!", __func__); + return HDF_FAILURE; + } + ret = g_apFeature->getApBandwidth(ifName, bandwidth); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s: get signal information failed!, error code: %d", __func__, ret); + } + return ret; +} + +int32_t WlanInterfaceResetToFactoryMacAddress(struct IWlanInterface *self, const char *ifName) +{ + int32_t ret; + + (void)self; + if (ifName == NULL) { + HDF_LOGE("%{public}s input parameter invalid!", __func__); + return HDF_ERR_INVALID_PARAM; + } + + if (g_staFeature != NULL) { + HDF_LOGD("%{public}s g_staFeature is not NULL!", __func__); + ret = g_staFeature->baseFeature.resetToFactoryMacAddress(ifName); + } else if (g_apFeature != NULL) { + HDF_LOGD("%{public}s g_apFeature is not NULL!", __func__); + ret = g_apFeature->baseFeature.resetToFactoryMacAddress(ifName); + } else { + HDF_LOGE("%{public}s: ap and sta feature is Invalid.", __func__); + ret = HDF_FAILURE; + } + + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s get name failed!, error code: %{public}d", __func__, ret); + } + return ret; +} + int32_t WlanInterfaceWifiConstruct(void) { int32_t ret; diff --git a/wlan/hdi_service/service_common/wlan_common_cmd.h b/wlan/hdi_service/service_common/wlan_common_cmd.h index b9122a46ef3e933858968db8effdb489597f8243..953c4c3bb83de9dff2683741c91e98d02f49b08b 100644 --- a/wlan/hdi_service/service_common/wlan_common_cmd.h +++ b/wlan/hdi_service/service_common/wlan_common_cmd.h @@ -64,6 +64,9 @@ int32_t WlanInterfaceStartPnoScan(struct IWlanInterface *self, const char *ifNam int32_t WlanInterfaceStopPnoScan(struct IWlanInterface *self, const char *ifName); int32_t WlanInterfaceGetSignalPollInfo(struct IWlanInterface *self, const char *ifName, struct SignalPollResult *signalResult); +int32_t WlanInterfaceGetApBandwidth(struct IWlanInterface *self, const char *ifName, + uint8_t *bandwidth); +int32_t WlanInterfaceResetToFactoryMacAddress(struct IWlanInterface *self, const char *ifName); int32_t WlanInterfaceWifiConstruct(void); int32_t WlanInterfaceWifiDestruct(void); #endif diff --git a/wlan/hdi_service/service_extend/service_extend_direct/wlan_extend_cmd.c b/wlan/hdi_service/service_extend/service_extend_direct/wlan_extend_cmd.c index b48bd470c9281b44d5e61fb72449ecbf542517db..7197244816dc8a82a3a18307900b01f9da5cf89a 100644 --- a/wlan/hdi_service/service_extend/service_extend_direct/wlan_extend_cmd.c +++ b/wlan/hdi_service/service_extend/service_extend_direct/wlan_extend_cmd.c @@ -17,7 +17,7 @@ #include #include #include -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_interface.h" #include "wifi_hal.h" #include "wlan_common_cmd.h" diff --git a/wlan/hdi_service/service_extend/service_extend_vdi/wlan_extend_cmd.c b/wlan/hdi_service/service_extend/service_extend_vdi/wlan_extend_cmd.c index c54279d7af8c72328357d64ad796c90b7e704dac..05d12b3132b626e20f9a772fb1840493a4573472 100644 --- a/wlan/hdi_service/service_extend/service_extend_vdi/wlan_extend_cmd.c +++ b/wlan/hdi_service/service_extend/service_extend_vdi/wlan_extend_cmd.c @@ -18,7 +18,7 @@ #include #include #include -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_interface.h" #include "wifi_hal.h" #include "wlan_common_cmd.h" #include "wlan_extend_cmd_vdi.h" diff --git a/wlan/hdi_service/service_extend/service_extend_vdi/wlan_extend_cmd_vdi.h b/wlan/hdi_service/service_extend/service_extend_vdi/wlan_extend_cmd_vdi.h index f155b3660588ea6cbf097d128f8e06906a5c197e..304fe377556fc8b427d6abaf9ab6ed06c9b89f63 100644 --- a/wlan/hdi_service/service_extend/service_extend_vdi/wlan_extend_cmd_vdi.h +++ b/wlan/hdi_service/service_extend/service_extend_vdi/wlan_extend_cmd_vdi.h @@ -15,7 +15,7 @@ #ifndef WLAN_EXTEND_VDI_CMD_H #define WLAN_EXTEND_VDI_CMD_H -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_interface.h" #include "hdf_load_vdi.h" #include "wifi_hal.h" diff --git a/wlan/hdi_service/wlan_impl.h b/wlan/hdi_service/wlan_impl.h index 01c4b99f64e53c02c0c495072088090acfeb39d8..9a60b1dd2c9b5e565666503ef186ce60f2d65b79 100644 --- a/wlan/hdi_service/wlan_impl.h +++ b/wlan/hdi_service/wlan_impl.h @@ -25,7 +25,7 @@ #include "hdf_dlist.h" #include "osal_mutex.h" #include "securec.h" -#include "v1_1/wlan_interface_stub.h" +#include "v1_2/wlan_interface_stub.h" #include "wifi_hal.h" #include "wifi_hal_ap_feature.h" #include "wifi_hal_base_feature.h" diff --git a/wlan/hdi_service/wlan_interface_drivers.c b/wlan/hdi_service/wlan_interface_drivers.c index 6e101ab3af8805fc2b8f787328fa11e2a97d2da3..39804be4b605f95ad96098c24fc7caef3e883088 100644 --- a/wlan/hdi_service/wlan_interface_drivers.c +++ b/wlan/hdi_service/wlan_interface_drivers.c @@ -21,7 +21,7 @@ #include #include #include -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_interface.h" #include "wlan_impl.h" struct HdfWlanInterfaceHost { diff --git a/wlan/hdi_service/wlan_interface_service.c b/wlan/hdi_service/wlan_interface_service.c index 6260274d882ee11936e14fa5aa7acc77128d4947..c33de526a82ce60729edbf96c3cf4cb36eda5927 100644 --- a/wlan/hdi_service/wlan_interface_service.c +++ b/wlan/hdi_service/wlan_interface_service.c @@ -17,12 +17,12 @@ #include #include #include -#include "v1_1/iwlan_callback.h" -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_callback.h" +#include "v1_2/iwlan_interface.h" #include "wlan_common_cmd.h" #include "wlan_extend_cmd.h" #include "wlan_impl.h" -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_interface.h" struct WlanInterfaceService { struct IWlanInterface interface; @@ -70,6 +70,8 @@ struct IWlanInterface *WlanInterfaceImplGetInstance(void) service->interface.StartPnoScan = WlanInterfaceStartPnoScan; service->interface.StopPnoScan = WlanInterfaceStopPnoScan; service->interface.GetSignalPollInfo = WlanInterfaceGetSignalPollInfo; + service->interface.GetApBandwidth = WlanInterfaceGetApBandwidth; + service->interface.ResetToFactoryMacAddress = WlanInterfaceResetToFactoryMacAddress; return &service->interface; } diff --git a/wlan/interfaces/include/wifi_hal_ap_feature.h b/wlan/interfaces/include/wifi_hal_ap_feature.h index 0fc9d34025c5add6f8228c05d0223b4582cdca55..8486e937f34afb78c4c03a99c1b1a13eb8d13697 100644 --- a/wlan/interfaces/include/wifi_hal_ap_feature.h +++ b/wlan/interfaces/include/wifi_hal_ap_feature.h @@ -96,6 +96,20 @@ struct IWiFiAp { * @version 1.0 */ int32_t (*setCountryCode)(const struct IWiFiAp *apFeature, const char *code, uint32_t len); + + /** + * @brief Obtain ap current bandwidth. + * + * @param ifName Indicates the NIC name. + * @param bandwidth ap current bandwidth, 1(20M), 2(40M), 4(80M), 8(160M). + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 4.1 + * @version 1.2 + */ + int32_t (*getApBandwidth)(const char *ifName, uint8_t *bandwidth); }; /** diff --git a/wlan/interfaces/include/wifi_hal_base_feature.h b/wlan/interfaces/include/wifi_hal_base_feature.h index 03870c095d240176ec0843026daeea0a068e8e4d..4cf787f9a5c43f82c6fb1b5854a90d12f2b6c89b 100644 --- a/wlan/interfaces/include/wifi_hal_base_feature.h +++ b/wlan/interfaces/include/wifi_hal_base_feature.h @@ -210,6 +210,19 @@ struct IWiFiBaseFeature { * @version 1.0 */ int32_t (*getIfNamesByChipId)(const uint8_t chipId, char **ifNames, uint32_t *num); + + /** + * @brief reset to factory mac address(permanent hardware address). + * + * @param ifName Indicates the NIC name. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 4.1 + * @version 1.2 + */ + int32_t (*resetToFactoryMacAddress)(const char *ifNames); }; /** diff --git a/wlan/test/fuzztest/ap_fuzzer/BUILD.gn b/wlan/test/fuzztest/ap_fuzzer/BUILD.gn index 7fdaa51a2685a15120d295bee8c0c2a46257c61d..51ea2349d4df32f07fdd8d141ee7ad57c48fdf0b 100644 --- a/wlan/test/fuzztest/ap_fuzzer/BUILD.gn +++ b/wlan/test/fuzztest/ap_fuzzer/BUILD.gn @@ -32,7 +32,7 @@ ohos_fuzztest("ApFuzzTest") { deps = [ "$TEST_ROOT_DIR/hdi_service:hdi_wlan_service" ] external_deps = [ - "drivers_interface_wlan:libwlan_proxy_1.1", + "drivers_interface_wlan:libwlan_proxy_1.2", "hdf_core:libhdf_utils", "hilog:libhilog", ] diff --git a/wlan/test/fuzztest/sta_fuzzer/BUILD.gn b/wlan/test/fuzztest/sta_fuzzer/BUILD.gn index 6ab9848cae7d7693e43a573f99f7229130ab3c60..b28abe5cf7a595cee9856755e78191994d8b9bba 100644 --- a/wlan/test/fuzztest/sta_fuzzer/BUILD.gn +++ b/wlan/test/fuzztest/sta_fuzzer/BUILD.gn @@ -34,7 +34,7 @@ ohos_fuzztest("StaFuzzTest") { public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ] external_deps = [ - "drivers_interface_wlan:libwlan_proxy_1.1", + "drivers_interface_wlan:libwlan_proxy_1.2", "hdf_core:libhdf_utils", "hilog:libhilog", ] diff --git a/wlan/test/fuzztest/wlan_common_fuzzer.h b/wlan/test/fuzztest/wlan_common_fuzzer.h index 1bc81666acaf0fa78fd60870e762643e25f7b5ad..749d1d4978242616640eb3b486888f9e34d360f2 100644 --- a/wlan/test/fuzztest/wlan_common_fuzzer.h +++ b/wlan/test/fuzztest/wlan_common_fuzzer.h @@ -16,8 +16,8 @@ #ifndef WLAN_COMMON_FUZZER_H #define WLAN_COMMON_FUZZER_H #include "hdf_log.h" -#include "v1_1/iwlan_interface.h" -#include "v1_1/wlan_types.h" +#include "v1_2/iwlan_interface.h" +#include "v1_2/wlan_types.h" #include "wlan_callback_impl.h" #include "wifi_hal_base_feature.h" #include "securec.h" diff --git a/wlan/test/hdi_service/BUILD.gn b/wlan/test/hdi_service/BUILD.gn index cd96936ebcc5c6070414a4b1e530b5ffef9433ef..3ee6ea1fc945a2f0229508beee19199c135a1a0f 100644 --- a/wlan/test/hdi_service/BUILD.gn +++ b/wlan/test/hdi_service/BUILD.gn @@ -44,7 +44,7 @@ ohos_unittest("WlanHdiServiceTestC") { if (is_standard_system) { external_deps = [ "c_utils:utils", - "drivers_interface_wlan:libwlan_proxy_1.1", + "drivers_interface_wlan:libwlan_proxy_1.2", "hdf_core:libhdf_host", "hdf_core:libhdf_utils", "hilog:libhilog", diff --git a/wlan/test/hdi_service/wlan_callback_impl.h b/wlan/test/hdi_service/wlan_callback_impl.h index 4e0b100340bc97e7eebcb4b5dc72b8c0ac542c88..395477d850811b069899815a51b82d6b3dc741fe 100644 --- a/wlan/test/hdi_service/wlan_callback_impl.h +++ b/wlan/test/hdi_service/wlan_callback_impl.h @@ -13,10 +13,10 @@ * limitations under the License. */ -#ifndef OHOS_HDI_WLAN_V1_1_WLANCALLBACKSERVICE_H -#define OHOS_HDI_WLAN_V1_1_WLANCALLBACKSERVICE_H +#ifndef OHOS_HDI_WLAN_V1_2_WLANCALLBACKSERVICE_H +#define OHOS_HDI_WLAN_V1_2_WLANCALLBACKSERVICE_H -#include "v1_1/iwlan_callback.h" +#include "v1_2/iwlan_callback.h" #ifdef __cplusplus extern "C" { @@ -33,4 +33,4 @@ void WlanCallbackServiceRelease(struct IWlanCallback *instance); } #endif /* __cplusplus */ -#endif // OHOS_HDI_WLAN_V1_1_WLANCALLBACKSERVICE_H \ No newline at end of file +#endif // OHOS_HDI_WLAN_V1_2_WLANCALLBACKSERVICE_H \ No newline at end of file diff --git a/wlan/test/hdi_service/wlan_hdi_direct_test.cpp b/wlan/test/hdi_service/wlan_hdi_direct_test.cpp index d956c207712eafa6b52a095fcbb182315e413489..d730ad81859fd525149d92354f0b90187a029f42 100644 --- a/wlan/test/hdi_service/wlan_hdi_direct_test.cpp +++ b/wlan/test/hdi_service/wlan_hdi_direct_test.cpp @@ -14,7 +14,7 @@ */ #include #include -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_interface.h" #include "wlan_callback_impl.h" #include "wlan_impl.h" diff --git a/wlan/test/hdi_service/wlan_hdi_hal_services_c_test.cpp b/wlan/test/hdi_service/wlan_hdi_hal_services_c_test.cpp index c7c512439e13ef3657e7963d32cc1fdb9b3e0715..6d43378eb2e98bb2ec47c95f2e5c97f0b66efc17 100644 --- a/wlan/test/hdi_service/wlan_hdi_hal_services_c_test.cpp +++ b/wlan/test/hdi_service/wlan_hdi_hal_services_c_test.cpp @@ -14,7 +14,7 @@ */ #include #include -#include "v1_1/iwlan_interface.h" +#include "v1_2/iwlan_interface.h" #include "wlan_callback_impl.h" #include "wlan_impl.h" @@ -1269,4 +1269,67 @@ HWTEST_F(HdfWifiServiceCTest, StartScanTest_051, TestSize.Level1) OsalMemFree(scan.freqs); OsalMemFree(scan.ssids); } + +/** + * @tc.name: GetApBandwidthTest_052 + * @tc.desc: Wifi hdi get AP bandwidth function test + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(HdfWifiServiceCTest, GetApBandwidthTest_052, TestSize.Level1) +{ + uint8_t bandwidth = 0; + const char *ifName = "wlan0"; + + struct HdfFeatureInfo ifeature; + const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP; + + int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature); + if (rc == HDF_SUCCESS) { + rc = g_wlanObj->GetApBandwidth(g_wlanObj, nullptr, &bandwidth); + ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM); + + rc = g_wlanObj->GetApBandwidth(g_wlanObj, ifName, &bandwidth); + bool flag = (rc == HDF_SUCCESS || rc == HDF_FAILURE); + ASSERT_TRUE(flag); + + printf("bandwidth: %u\n", bandwidth); + + rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature); + ASSERT_EQ(rc, HDF_SUCCESS); + } +} + +/** + * @tc.name: ResetToFactoryMacAddressTest_0053 + * @tc.desc: Wifi hdi reset to factory maca address function test + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(HdfWifiServiceCTest, ResetToFactoryMacAddressTest_0053, TestSize.Level1) +{ + const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP; + struct HdfFeatureInfo ifeature; + + int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature); + if (rc == HDF_SUCCESS) { + uint8_t mac[ETH_ADDR_LEN] = {0}; + uint32_t macLen = ETH_ADDR_LEN; + rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, &macLen, ETH_ADDR_LEN); + ASSERT_EQ(rc, HDF_SUCCESS); + + uint8_t tmpMac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd}; + rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, tmpMac, macLen); + bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_ERR_DEVICE_BUSY); + ASSERT_TRUE(flag); + + const char *ifName = "wlan0"; + rc = g_wlanObj->ResetToFactoryMacAddress(g_wlanObj, ifName); + ASSERT_EQ(rc, HDF_SUCCESS); + + rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature); + ASSERT_EQ(rc, HDF_SUCCESS); + } +} + };