diff --git a/wlan/chip/hdi_service/iface_tool.cpp b/wlan/chip/hdi_service/iface_tool.cpp index cc9150cea608991d4cda180ab93ff686994473e2..21cb2a8f7ace9822a3bf72fac47a6fd974fcfbb3 100644 --- a/wlan/chip/hdi_service/iface_tool.cpp +++ b/wlan/chip/hdi_service/iface_tool.cpp @@ -33,7 +33,6 @@ namespace Wlan { namespace Chip { namespace V2_0 { const char K_WLAN0_INTERFACE_NAME[] = "wlan0"; -const char K_P2P0_INTERFACE_NAME[] = "p2p0"; const int MAC_LEN = 6; const int MAC_POS_1 = 1; const int MAC_POS_2 = 2; @@ -73,20 +72,13 @@ bool IfaceTool::GetUpState(const char* ifName) return ifr.ifr_flags & IFF_UP; } -bool IfaceTool::SetUpState(const char* ifName, bool requestUp, bool needP2pUp) +bool IfaceTool::SetUpState(const char* ifName, bool requestUp) { UniqueFd sock(socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)); if (sock.Get() < 0) { HDF_LOGE("Failed to open socket to set up/down state %{public}s", strerror(errno)); return false; } - // If the interface is wlan0, we need to set p2p0 up/down state - if (strcmp(ifName, K_WLAN0_INTERFACE_NAME) == 0 && needP2pUp) { - // if wlan0 is down, set p2p0 up to avoid driver deinit that causes connect fail - if ((!GetUpState(K_P2P0_INTERFACE_NAME)) && !requestUp) { - SetUpState(K_P2P0_INTERFACE_NAME, !requestUp); - } - } struct ifreq ifr; if (!GetIfState(ifName, sock.Get(), &ifr)) { return false; @@ -109,7 +101,7 @@ bool IfaceTool::SetUpState(const char* ifName, bool requestUp, bool needP2pUp) bool IfaceTool::SetWifiUpState(bool requestUp) { - return SetUpState(K_WLAN0_INTERFACE_NAME, requestUp, false); + return SetUpState(K_WLAN0_INTERFACE_NAME, requestUp); } bool IfaceTool::SetMacAddress(const char* ifName, const char* mac) diff --git a/wlan/chip/hdi_service/iface_tool.h b/wlan/chip/hdi_service/iface_tool.h index 9f7bd4e9b62c62a86b99c778280a4bc004a55d5a..f058abfbaa910b6172cf9d0334b645267d8a285e 100644 --- a/wlan/chip/hdi_service/iface_tool.h +++ b/wlan/chip/hdi_service/iface_tool.h @@ -34,7 +34,7 @@ public: IfaceTool() = default; virtual ~IfaceTool() = default; virtual bool GetUpState(const char* ifName); - virtual bool SetUpState(const char* ifName, bool requestUp, bool needP2pUp = true); + virtual bool SetUpState(const char* ifName, bool requestUp); virtual bool SetWifiUpState(bool requestUp); virtual bool SetMacAddress(const char* ifName, const char* mac); }; diff --git a/wlan/chip/hdi_service/wifi.cpp b/wlan/chip/hdi_service/wifi.cpp index f09c589adb038680678362802784f8b663af3e57..849c885aeebc36cd26b4d1d2af6fd213d496f258 100644 --- a/wlan/chip/hdi_service/wifi.cpp +++ b/wlan/chip/hdi_service/wifi.cpp @@ -110,7 +110,7 @@ int32_t Wifi::Init() HDF_LOGI("Wifi HAL started"); return HDF_SUCCESS; } else { - HDF_LOGE("Wifi HAL start failed"); + HDF_LOGE("Wifi HAL start failed."); return HDF_FAILURE; } } @@ -233,6 +233,7 @@ void Wifi::OnRemoteDied(const wptr &object) { HDF_LOGI("chip service OnRemoteDied"); runState_ = RunState::STOPPING; + cbHandler_.Invalidate(); for (auto& chip : chips_) { if (chip) { chip->Invalidate(); @@ -241,7 +242,6 @@ void Wifi::OnRemoteDied(const wptr &object) chips_.clear(); auto lock = AcquireGlobalLock(); StopVendorHal(&lock); - cbHandler_.Invalidate(); runState_ = RunState::STOPPED; } diff --git a/wlan/chip/hdi_service/wifi_ext_iface.cpp b/wlan/chip/hdi_service/wifi_ext_iface.cpp index 8a2987e93a9996858df3f5c261b5869af768f82a..20d5c1b0d4b0a0b21615dd6dd53fed96e46d8699 100644 --- a/wlan/chip/hdi_service/wifi_ext_iface.cpp +++ b/wlan/chip/hdi_service/wifi_ext_iface.cpp @@ -88,24 +88,12 @@ int32_t WifiExtIface::SetPowerMode(int32_t powerMode) int32_t WifiExtIface::RegisterChipIfaceCallBack(const sptr& chipIfaceCallback) { - if (chipIfaceCallback == nullptr) { - HDF_LOGE("chipIfaceCallback is null"); - return HDF_FAILURE; - } - HDF_LOGI("register ext callback"); - vendorHal_.lock()->RegisterExtIfaceCallBack(ifName_, chipIfaceCallback); - return HDF_SUCCESS; + return HDF_ERR_NOT_SUPPORT; } int32_t WifiExtIface::UnRegisterChipIfaceCallBack(const sptr& chipIfaceCallback) { - if (chipIfaceCallback == nullptr) { - HDF_LOGE("chipIfaceCallback is null"); - return HDF_FAILURE; - } - HDF_LOGI("unregister ext callback"); - vendorHal_.lock()->UnRegisterExtIfaceCallBack(ifName_, chipIfaceCallback); - return HDF_SUCCESS; + return HDF_ERR_NOT_SUPPORT; } int32_t WifiExtIface::StartScan(const ScanParams& scanParam) @@ -165,41 +153,25 @@ int32_t WifiExtIface::SendCmdToDriver(const std::string& ifName, int32_t cmdId, int32_t WifiExtIface::SendActionFrame(const std::string& ifName, uint32_t freq, const std::vector& frameData) { - WifiError status = vendorHal_.lock()->SendActionFrame(ifName, freq, frameData); - if (status == HAL_SUCCESS) { - return HDF_SUCCESS; - } - return HDF_FAILURE; + return HDF_ERR_NOT_SUPPORT; } int32_t WifiExtIface::RegisterActionFrameReceiver(const std::string& ifName, const std::vector& match) { - WifiError status = vendorHal_.lock()->RegisterActionFrameReceiver(ifName, match); - if (status == HAL_SUCCESS) { - return HDF_SUCCESS; - } - return HDF_FAILURE; + return HDF_ERR_NOT_SUPPORT; } int32_t WifiExtIface::GetCoexictenceChannelList(const std::string& ifName, std::vector& paramBuf) { - WifiError status = vendorHal_.lock()->GetCoexictenceChannelList(ifName, paramBuf); - if (status != HAL_SUCCESS) { - return HDF_FAILURE; - } - return HDF_SUCCESS; + return HDF_ERR_NOT_SUPPORT; } int32_t WifiExtIface::SetProjectionScreenParam(const std::string& ifName, const ProjectionScreenCmdParam& param) { - WifiError status = vendorHal_.lock()->SetProjectionScreenParam(ifName, param); - if (status != HAL_SUCCESS) { - return HDF_FAILURE; - } - return HDF_SUCCESS; + return HDF_ERR_NOT_SUPPORT; +} } } } } } -} \ No newline at end of file diff --git a/wlan/chip/hdi_service/wifi_hal.h b/wlan/chip/hdi_service/wifi_hal.h index f24fea7b673663071da92d2471558e3b530dee85..c56d051f6f0c4cf8efe676e6e02fd90ad8eb3c01 100644 --- a/wlan/chip/hdi_service/wifi_hal.h +++ b/wlan/chip/hdi_service/wifi_hal.h @@ -68,6 +68,16 @@ enum Ieee80211Band { IEEE80211_NUM_BANDS }; +enum ScanBandType { + SCAN_BAND_UNSPECIFIED = 0, /* not specified */ + SCAN_BAND_24_GHZ = 1, /* 2.4 GHz band */ + SCAN_BAND_5_GHZ = 2, /* 5 GHz band without DFS channels */ + SCAN_BAND_BOTH = 3, /* both bands without DFS channels */ + SCAN_BAND_5_GHZ_DFS_ONLY = 4, /* 5 GHz band with DFS channels */ + SCAN_BAND_5_GHZ_WITH_DFS = 6, /* 5 GHz band with DFS channels */ + SCAN_BAND_BOTH_WITH_DFS = 7, /* both bands with DFS channels */ +}; + typedef struct { uint8_t associatedBssid[ETH_ADDR_LEN]; uint32_t associatedFreq; @@ -150,4 +160,4 @@ typedef WifiError (*InitWifiVendorHalFuncTableT)(WifiHalFn *fn); } #endif -#endif \ No newline at end of file +#endif diff --git a/wlan/chip/hdi_service/wifi_vendor_hal.cpp b/wlan/chip/hdi_service/wifi_vendor_hal.cpp index 93f33b7b80c49231696844e024c8a4bd9d8ba311..f94d6f7009d74a930fdc4f37af50fd6cb396fe2e 100644 --- a/wlan/chip/hdi_service/wifi_vendor_hal.cpp +++ b/wlan/chip/hdi_service/wifi_vendor_hal.cpp @@ -153,18 +153,6 @@ void WifiVendorHal::OnAsyncWifiNetlinkMsgReport(uint32_t type, const std::vector } } -void WifiVendorHal::OnAsyncWifiNetlinkMsgExtReport(uint32_t type, const std::vector& recvMsg) -{ - const auto lock = AcquireGlobalLock(); - - HDF_LOGD("OnAsyncWifiNetlinkMsgExtReport::OnWifiNetlinkMessage"); - for (const auto& callback : vendorHalExtCbHandler_.GetCallbacks()) { - if (callback) { - callback->OnWifiNetlinkMessage(type, recvMsg); - } - } -} - WifiError WifiVendorHal::Stop(std::unique_lock* lock, const std::function& onStopCompleteUserCallback) { @@ -249,7 +237,6 @@ WifiError WifiVendorHal::CreateVirtualInterface(const std::string& ifname, HalIf WifiError WifiVendorHal::DeleteVirtualInterface(const std::string& ifname) { - std::unique_lock lock(vendorHalMutex); WifiError status = globalFuncTable_.vendorHalDeleteIface( globalHandle_, ifname.c_str()); return HandleIfaceChangeStatus(ifname, status); @@ -406,7 +393,7 @@ WifiError WifiVendorHal::RegisterExtIfaceCallBack(const std::string& ifaceName, const sptr& chipIfaceCallback) { vendorHalExtCbHandler_.AddCallback(chipIfaceCallback); - WifiExtCallbackHandler handler = {OnAsyncWifiNetlinkMsgExtReport}; + WifiExtCallbackHandler handler = {OnAsyncWifiNetlinkMsgReport}; globalFuncTable_.registerExtIfaceCallBack(ifaceName.c_str(), handler); return HAL_SUCCESS; } @@ -455,4 +442,4 @@ WifiError WifiVendorHal::SetProjectionScreenParam(const std::string& ifaceName, } // namespace Chip } // namespace Wlan } // namespace HDI -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/wlan/chip/hdi_service/wifi_vendor_hal.h b/wlan/chip/hdi_service/wifi_vendor_hal.h index 62d5ff56e5a5819f56878e498d835cf5aa9cbf01..c324a710bdc4ba342b3f2736075f8fb66d3f28c5 100644 --- a/wlan/chip/hdi_service/wifi_vendor_hal.h +++ b/wlan/chip/hdi_service/wifi_vendor_hal.h @@ -21,7 +21,6 @@ #include #include #include -#include #include "wifi_hal.h" #include "iface_tool.h" @@ -74,7 +73,6 @@ public: static void OnAsyncGscanFullResult(int event); static void OnAsyncRssiReport(int32_t index, int32_t c0Rssi, int32_t c1Rssi); static void OnAsyncWifiNetlinkMsgReport(uint32_t type, const std::vector& recvMsg); - static void OnAsyncWifiNetlinkMsgExtReport(uint32_t type, const std::vector& recvMsg); WifiError SetTxPower(const std::string& ifaceName, int mode); WifiError SendCmdToDriver(const std::string& ifaceName, int32_t cmdId, const std::vector& paramBuf, std::vector& result); @@ -99,7 +97,6 @@ private: bool isPrimary_; static CallbackHandler vendorHalCbHandler_; static CallbackHandler vendorHalExtCbHandler_; - std::mutex vendorHalMutex; }; } // namespace v2_0 diff --git a/wlan/chip/hdi_service/wifi_vendor_hal_list.cpp b/wlan/chip/hdi_service/wifi_vendor_hal_list.cpp index c8ea51efba5aa7a004abe04a624af1a082e121e0..8cc67d8184c8613479a2b88698af4983a177d9ad 100644 --- a/wlan/chip/hdi_service/wifi_vendor_hal_list.cpp +++ b/wlan/chip/hdi_service/wifi_vendor_hal_list.cpp @@ -27,7 +27,7 @@ namespace Chip { namespace V2_0 { const std::string VENDOR_HARDWARE_PATH = "libwifi_hal_hw.z.so"; -const std::string VENDOR_DAFAULT_PATH = "libwifi_hal_default.z.so"; +const std::string VENDOR_DEFAULT_PATH = "libwifi_hal_default.z.so"; WifiVendorHalList::WifiVendorHalList( const std::weak_ptr ifaceTool) @@ -50,7 +50,7 @@ std::vector> WifiVendorHalList::GetHals() void WifiVendorHalList::InitVendorHalsDescriptorList() { WifiHalLibDesc desc; - std::string path = VENDOR_DAFAULT_PATH; + std::string path = VENDOR_DEFAULT_PATH; if (strncmp(HAL_SO_NAME, "hardware", strlen(HAL_SO_NAME)) == 0) { path = VENDOR_HARDWARE_PATH; } diff --git a/wlan/chip/hdi_service/wifi_vendor_hal_stubs.cpp b/wlan/chip/hdi_service/wifi_vendor_hal_stubs.cpp index c96443f55e31834e783a7c6547e37e1311647816..b5b3ec1458962801aa531f9d717c2c4a9fb20b16 100644 --- a/wlan/chip/hdi_service/wifi_vendor_hal_stubs.cpp +++ b/wlan/chip/hdi_service/wifi_vendor_hal_stubs.cpp @@ -76,7 +76,6 @@ bool InitHalFuncTableWithStubs(WifiHalFn* halFn) PopulateStubFor(&halFn->sendActionFrame); PopulateStubFor(&halFn->registerActionFrameReceiver); PopulateStubFor(&halFn->getCoexictenceChannelList); - PopulateStubFor(&halFn->setProjectionScreenParam); return true; } diff --git a/wlan/chip/wifi_hal/gscan.cpp b/wlan/chip/wifi_hal/gscan.cpp index 2933093673782feb9ab4db26e6d2dc91e5d7f32e..9c8e23f5eaac0d5c13414b25bb6431234297e701 100644 --- a/wlan/chip/wifi_hal/gscan.cpp +++ b/wlan/chip/wifi_hal/gscan.cpp @@ -57,6 +57,37 @@ public: return ret; } + void AddFreqs(bool& isDfsChannel, uint32_t& freq) + { + switch (mBand) { + case SCAN_BAND_24_GHZ: + if (freq > LOW_LIMIT_FREQ_2_4G && freq < HIGH_LIMIT_FREQ_2_4G) { + mFreqs.push_back(freq); + } + break; + case SCAN_BAND_5_GHZ: + if (isDfsChannel) { + break; + } + if (freq > LOW_LIMIT_FREQ_5G && freq < HIGH_LIMIT_FREQ_5G) { + mFreqs.push_back(freq); + } + break; + case SCAN_BAND_5_GHZ_DFS_ONLY: + if (isDfsChannel && freq > LOW_LIMIT_FREQ_5G && freq < HIGH_LIMIT_FREQ_5G) { + mFreqs.push_back(freq); + } + break; + case SCAN_BAND_5_GHZ_WITH_DFS: + if (freq > LOW_LIMIT_FREQ_5G && freq < HIGH_LIMIT_FREQ_5G) { + mFreqs.push_back(freq); + } + break; + default: + break; + } + } + void GetCenterFreq(struct nlattr *bands) { struct nlattr *attrFreq[NL80211_FREQUENCY_ATTR_MAX + 1]; @@ -68,32 +99,29 @@ public: static struct nla_policy freqPolicy[NL80211_FREQUENCY_ATTR_MAX + 1]; freqPolicy[NL80211_FREQUENCY_ATTR_FREQ].type = NLA_U32; freqPolicy[NL80211_FREQUENCY_ATTR_MAX_TX_POWER].type = NLA_U32; + enum nl80211_dfs_state dfsState; nla_for_each_nested(nlFreq, bands, i) { data = nla_data(nlFreq); len = nla_len(nlFreq); - nla_parse(attrFreq, NL80211_FREQUENCY_ATTR_MAX, (struct nlattr *)data, len, freqPolicy); + if (nla_parse(attrFreq, NL80211_FREQUENCY_ATTR_MAX, (struct nlattr *)data, len, freqPolicy) != 0) { + HDF_LOGE("GetCenterFreq parse failed"); + continue; + } if (attrFreq[NL80211_FREQUENCY_ATTR_FREQ] == nullptr) { continue; } if (attrFreq[NL80211_FREQUENCY_ATTR_DISABLED] != nullptr) { continue; } - freq = nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_FREQ]); - switch (mBand) { - case NL80211_BAND_2GHZ: - if (freq > LOW_LITMIT_FREQ_2_4G && freq < HIGH_LIMIT_FREQ_2_4G) { - mFreqs.push_back(freq); - } - break; - case NL80211_BAND_5GHZ: - if (freq > LOW_LIMIT_FREQ_5G && freq < HIGH_LIMIT_FREQ_5G) { - mFreqs.push_back(freq); - } - break; - default: - break; + bool isDfsChannel = false; + if (attrFreq[NL80211_FREQUENCY_ATTR_DFS_STATE] != nullptr) { + dfsState = static_cast( + nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_DFS_STATE])); + isDfsChannel = (dfsState == NL80211_DFS_USABLE || dfsState == NL80211_DFS_AVAILABLE); } + freq = nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_FREQ]); + AddFreqs(isDfsChannel, freq); } } @@ -140,10 +168,7 @@ WifiError VendorHalGetChannelsInBand(wifiInterfaceHandle handle, HDF_LOGE("Handle is null"); return HAL_INVALID_ARGS; } - if (band > 0 && band <= IEEE80211_NUM_BANDS) { - band = band - 1; - } - if (band >= IEEE80211_NUM_BANDS) { + if (band > SCAN_BAND_BOTH_WITH_DFS || band <= SCAN_BAND_UNSPECIFIED) { HDF_LOGE("Invalid input parameter, band = %{public}d", band); return HAL_INVALID_ARGS; } diff --git a/wlan/chip/wifi_hal/gscan.h b/wlan/chip/wifi_hal/gscan.h index 586964c2b4eaf8527bb2e15afade92a5a366e06e..b142e9aff1a900c46ee0ea5c90b8469865a3451e 100644 --- a/wlan/chip/wifi_hal/gscan.h +++ b/wlan/chip/wifi_hal/gscan.h @@ -18,7 +18,7 @@ #include "wifi_hal.h" -#define LOW_LITMIT_FREQ_2_4G 2400 +#define LOW_LIMIT_FREQ_2_4G 2400 #define HIGH_LIMIT_FREQ_2_4G 2500 #define LOW_LIMIT_FREQ_5G 5100 #define HIGH_LIMIT_FREQ_5G 5900 diff --git a/wlan/chip/wifi_hal/wifi_hal.cpp b/wlan/chip/wifi_hal/wifi_hal.cpp index f32185b7448ac80c9f56c13dc1f082c37a83bb7b..a7fcc9e590d09d1a767517841d2d849d80122012 100644 --- a/wlan/chip/wifi_hal/wifi_hal.cpp +++ b/wlan/chip/wifi_hal/wifi_hal.cpp @@ -1021,6 +1021,7 @@ static WifiError WifiAddIfaceHalInfo(wifiHandle handle, const char* ifname, bool { HalInfo *info = nullptr; int i = 0; + bool hasAdd = false; info = (HalInfo *)handle; if (info == nullptr) { @@ -1050,11 +1051,19 @@ static WifiError WifiAddIfaceHalInfo(wifiHandle handle, const char* ifname, bool ifinfo->isVirtual = isVirtual; info->interfaces[i] = ifinfo; info->numInterfaces++; + hasAdd = true; HDF_LOGI("%{public}s: Added iface: %{public}s at the index %{public}d\n", __FUNCTION__, ifname, i); break; } i++; } + if (!hasAdd && ifinfo != nullptr) { + free(ifinfo); + free(info->interfaces); + info->numInterfaces = 0; + HDF_LOGI("Added iface: %{public}s failed, not found", ifname); + return HAL_OUT_OF_MEMORY; + } return HAL_SUCCESS; } diff --git a/wlan/chip/wifi_hal/wifi_ioctl.h b/wlan/chip/wifi_hal/wifi_ioctl.h index 985e72ba56da10a6b0836be009fe6b0067152d2e..78e8a45e1cc62edd82b2726750915c1ae1de007d 100644 --- a/wlan/chip/wifi_hal/wifi_ioctl.h +++ b/wlan/chip/wifi_hal/wifi_ioctl.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/wlan/chip/wifi_hal/wifi_logger.cpp b/wlan/chip/wifi_hal/wifi_logger.cpp index fee135058229fa7c5ab78ea804e2fdae3f9e86e4..25aed2c88ed169961996b36d1f412ff1efa96176 100644 --- a/wlan/chip/wifi_hal/wifi_logger.cpp +++ b/wlan/chip/wifi_hal/wifi_logger.cpp @@ -28,8 +28,6 @@ #include #include #include -#include -#include #include #include "sync.h" #include "wifi_hal.h" diff --git a/wlan/chip/wifi_hal/wifi_scan.h b/wlan/chip/wifi_hal/wifi_scan.h index afc02c0a0eba711542571f67345e0c5b6799451c..7468d59a810d990638e2663dfa041dba3f559dc9 100644 --- a/wlan/chip/wifi_hal/wifi_scan.h +++ b/wlan/chip/wifi_hal/wifi_scan.h @@ -26,13 +26,11 @@ #define BITNUMS_OF_ONE_BYTE 8 #define SLOW_SCAN_INTERVAL_MULTIPLIER 3 #define FAST_SCAN_ITERATIONS 3 -#define BITNUMS_OF_ONE_BYTE 8 #define SCHED_SCAN_PLANS_ATTR_INDEX1 1 #define SCHED_SCAN_PLANS_ATTR_INDEX2 2 #define MS_PER_SECOND 1000 #define SIGNAL_LEVEL_CONFFICIENT 100 - typedef struct { uint8_t maxNumScanSsids; uint8_t maxNumSchedScanSsids; diff --git a/wlan/client/BUILD.gn b/wlan/client/BUILD.gn index e3404621b5e4b91a4d9d598205e67a13d12970d6..ba4c8b5e52ea0b82b8d1454c1a539784c3ec8af6 100644 --- a/wlan/client/BUILD.gn +++ b/wlan/client/BUILD.gn @@ -120,7 +120,6 @@ if (defined(ohos_lite)) { include_dirs = [ "include", "$CLIENT_ROOT_DIR/interfaces/include", - "//third_party/libnl/libnl-3.7.0/include", "$root_out_dir/include", "$root_out_dir/lib", ] diff --git a/wlan/client/src/netlink/netlink_cmd_adapter.c b/wlan/client/src/netlink/netlink_cmd_adapter.c index ef7f55237fa3c833f9f38ff2442b6e9d2f6c1c6e..c26f763b30505fac4ce153430991a83c79902ca1 100644 --- a/wlan/client/src/netlink/netlink_cmd_adapter.c +++ b/wlan/client/src/netlink/netlink_cmd_adapter.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -79,7 +78,7 @@ #define P2P_BUF_SIZE 64 #define MAX_PRIV_CMD_SIZE 4096 -#define LOW_LITMIT_FREQ_2_4G 2400 +#define LOW_LIMIT_FREQ_2_4G 2400 #define HIGH_LIMIT_FREQ_2_4G 2500 #define LOW_LIMIT_FREQ_5G 5100 #define HIGH_LIMIT_FREQ_5G 5900 @@ -434,7 +433,7 @@ static int32_t PthreadMutexLock(void) static int32_t WaitStartActionLock(void) { int32_t count = 0; - while (g_cookieStart == RET_CODE_FAILURE) { + while (g_cookieStart == 0) { if (count < RETRIES) { HILOG_DEBUG(LOG_CORE, "%{public}s: wait g_cookieStart %{public}d 5ms", __FUNCTION__, count); @@ -467,7 +466,7 @@ int32_t NetlinkSendCmdSync(struct nl_msg *msg, const RespHandler handler, void * HILOG_ERROR(LOG_CORE, "%s: pthread trylock failed", __FUNCTION__); return RET_CODE_FAILURE; } - + /* try to set NETLINK_EXT_ACK to 1, ignoring errors */ int32_t opt = 1; if (setsockopt(nl_socket_get_fd(g_wifiHalInfo.cmdSock), SOL_NETLINK, NETLINK_EXT_ACK, &opt, sizeof(opt)) < 0) { @@ -954,7 +953,7 @@ static void GetCenterFreq(struct nlattr *bands, struct FreqInfoResult *result) switch (result->band) { case NL80211_BAND_2GHZ: if (attrFreq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]) { - if (freq > LOW_LITMIT_FREQ_2_4G && freq < HIGH_LIMIT_FREQ_2_4G) { + if (freq > LOW_LIMIT_FREQ_2_4G && freq < HIGH_LIMIT_FREQ_2_4G) { result->freqs[result->nums] = freq; result->txPower[result->nums] = nla_get_u32(attrFreq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]); result->nums++; @@ -3250,7 +3249,7 @@ void WifiEventTxStatus(const char *ifName, struct nlattr **attr) HILOG_ERROR(LOG_CORE, "%{public}s: is null", __FUNCTION__); return; } - if (WaitStartActionLock() == 0) { + if (WaitStartActionLock() == RET_CODE_FAILURE) { HILOG_ERROR(LOG_CORE, "%{public}s: WaitStartActionLock error", __FUNCTION__); return; } diff --git a/wlan/test/fuzztest/chip_fuzzer/BUILD.gn b/wlan/test/fuzztest/chip_fuzzer/BUILD.gn index 666e96d385f1f136e5eebd369ff6de83b8a98420..3aa60707a46977a50f851ec6d983f2c65f36ff41 100644 --- a/wlan/test/fuzztest/chip_fuzzer/BUILD.gn +++ b/wlan/test/fuzztest/chip_fuzzer/BUILD.gn @@ -43,8 +43,8 @@ ohos_fuzztest("ChipFuzzTest") { "hdf_core:libhdf_utils", "hdf_core:libhdi", "hilog:libhilog", - "init:libbegetutil", "ipc:ipc_single", + "init:libbegetutil", ] cflags = [ @@ -54,21 +54,21 @@ ohos_fuzztest("ChipFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ - "$TEST_ROOT_DIR/chip/hdi_service/hdi_sync_util.cpp", + sources = [ + "chip_fuzzer.cpp", + "$TEST_ROOT_DIR/chip/hdi_service/wifi_ap_iface.cpp", "$TEST_ROOT_DIR/chip/hdi_service/iface_tool.cpp", + "$TEST_ROOT_DIR/chip/hdi_service/wifi_vendor_hal.cpp", "$TEST_ROOT_DIR/chip/hdi_service/iface_util.cpp", - "$TEST_ROOT_DIR/chip/hdi_service/wifi.cpp", - "$TEST_ROOT_DIR/chip/hdi_service/wifi_ap_iface.cpp", - "$TEST_ROOT_DIR/chip/hdi_service/wifi_chip.cpp", "$TEST_ROOT_DIR/chip/hdi_service/wifi_chip_modes.cpp", - "$TEST_ROOT_DIR/chip/hdi_service/wifi_ext_iface.cpp", "$TEST_ROOT_DIR/chip/hdi_service/wifi_p2p_iface.cpp", "$TEST_ROOT_DIR/chip/hdi_service/wifi_sta_iface.cpp", - "$TEST_ROOT_DIR/chip/hdi_service/wifi_vendor_hal.cpp", + "$TEST_ROOT_DIR/chip/hdi_service/wifi_chip.cpp", + "$TEST_ROOT_DIR/chip/hdi_service/wifi_ext_iface.cpp", "$TEST_ROOT_DIR/chip/hdi_service/wifi_vendor_hal_list.cpp", + "$TEST_ROOT_DIR/chip/hdi_service/wifi.cpp", "$TEST_ROOT_DIR/chip/hdi_service/wifi_vendor_hal_stubs.cpp", - "chip_fuzzer.cpp", + "$TEST_ROOT_DIR/chip/hdi_service/hdi_sync_util.cpp", ] } diff --git a/wlan/test/hdi_service/hostapd_hdi_hal_services_c_test.cpp b/wlan/test/hdi_service/hostapd_hdi_hal_services_c_test.cpp index ebc4ba08320afddf2968b0279ce838d4b1cbd7fa..91b425071fef2291c8dbebaa7dada2d546b0082e 100644 --- a/wlan/test/hdi_service/hostapd_hdi_hal_services_c_test.cpp +++ b/wlan/test/hdi_service/hostapd_hdi_hal_services_c_test.cpp @@ -43,7 +43,7 @@ void HdfHostapdHostCTest::SetUpTestCase() g_hostapdCallbackObj = HostapdCallbackServiceGet(); ASSERT_TRUE(g_hostapdObj != nullptr); ASSERT_TRUE(g_hostapdCallbackObj != nullptr); - int32_t rc = g_hostapdObj->StartAp(g_hostapdObj); + int32_t rc = g_hostapdObj->StartApWithCmd(g_hostapdObj, IFNAME, 1); ASSERT_EQ(rc, HDF_SUCCESS); printf("hostapd_interface_service start successful."); } @@ -259,4 +259,5 @@ HWTEST_F(HdfHostapdHostCTest, ReloadApConfigInfo_016, TestSize.Level1) int32_t rc = g_hostapdObj->ReloadApConfigInfo(g_hostapdObj, IFNAME, 1); ASSERT_EQ(rc, HDF_SUCCESS); } + }; diff --git a/wlan/test/unittest/BUILD.gn b/wlan/test/unittest/BUILD.gn index b13d5d1597bd29c77edba2fb7ec764c601dda3f2..b952e8f5a0603c4d5c227cfc91bd9ad61e48e36b 100644 --- a/wlan/test/unittest/BUILD.gn +++ b/wlan/test/unittest/BUILD.gn @@ -178,20 +178,20 @@ if (defined(ohos_lite)) { ] defines = [ "OHOS_ARCH_LITE" ] sources = [ - "$TEST_ROOT_DIR/client/src/sbuf/sbuf_common_adapter.c", "$TEST_ROOT_DIR/client/src/sbuf/sbuf_wpa_cmd_adapter.c", - "$TEST_ROOT_DIR/client/src/wifi_driver_client.c", "$TEST_ROOT_DIR/hostapd/client/src/hostapd_client.c", "$TEST_ROOT_DIR/test/unittest/client/hdf_client_test.cpp", "$TEST_ROOT_DIR/wpa/client/src/wpa_client.c", + "$TEST_ROOT_DIR/client/src/sbuf/sbuf_common_adapter.c", + "$TEST_ROOT_DIR/client/src/wifi_driver_client.c", ] if (drivers_peripheral_wlan_feature_enable_HDF_NL80211) { - sources += [ "$TEST_ROOT_DIR/client/src/sbuf/sbuf_cmd_adapter.c" ] + sources += ["$TEST_ROOT_DIR/client/src/sbuf/sbuf_cmd_adapter.c",] } else { - sources += [ + sources += [ "$TEST_ROOT_DIR/client/src/netlink/netlink_cmd_adapter.c", "$TEST_ROOT_DIR/client/src/netlink/netlink_event_adapter.c", - ] + ] } resource_config_file = @@ -220,6 +220,16 @@ if (defined(ohos_lite)) { module_out_path = module_output_path include_dirs = [ "$TEST_ROOT_DIR/chip/hdi_service" ] sources = [ + "chip/interface_tool_test.cpp", + "chip/wifi_ap_iface_test.cpp", + "chip/wifi_chip_modes_test.cpp", + "chip/wifi_chip_test.cpp", + "chip/wifi_hal_fn.cpp", + "chip/wifi_p2p_iface_test.cpp", + "chip/wifi_sta_iface_test.cpp", + "chip/wifi_test.cpp", + "chip/wifi_vendor_hal_list_test.cpp", + "chip/wifi_vendor_hal_test.cpp", "$TEST_ROOT_DIR/chip/hdi_service/hdi_sync_util.cpp", "$TEST_ROOT_DIR/chip/hdi_service/iface_tool.cpp", "$TEST_ROOT_DIR/chip/hdi_service/iface_util.cpp", @@ -233,16 +243,6 @@ if (defined(ohos_lite)) { "$TEST_ROOT_DIR/chip/hdi_service/wifi_vendor_hal.cpp", "$TEST_ROOT_DIR/chip/hdi_service/wifi_vendor_hal_list.cpp", "$TEST_ROOT_DIR/chip/hdi_service/wifi_vendor_hal_stubs.cpp", - "chip/interface_tool_test.cpp", - "chip/wifi_ap_iface_test.cpp", - "chip/wifi_chip_modes_test.cpp", - "chip/wifi_chip_test.cpp", - "chip/wifi_hal_fn.cpp", - "chip/wifi_p2p_iface_test.cpp", - "chip/wifi_sta_iface_test.cpp", - "chip/wifi_test.cpp", - "chip/wifi_vendor_hal_list_test.cpp", - "chip/wifi_vendor_hal_test.cpp", ] cflags = configFlag diff --git a/wlan/test/unittest/client/hdf_client_test.cpp b/wlan/test/unittest/client/hdf_client_test.cpp index 4f00e523c0ef0e60a61a248d022bf33047b630d2..7b3330882c47ab35e8679b463e58ca0cb4ef4607 100644 --- a/wlan/test/unittest/client/hdf_client_test.cpp +++ b/wlan/test/unittest/client/hdf_client_test.cpp @@ -22,7 +22,6 @@ #endif #include "securec.h" - using namespace testing::ext; namespace ClientTest { @@ -1024,7 +1023,7 @@ HWTEST_F(WifiClientTest, WifiSetDpiMarkRule028, TestSize.Level1) int32_t dstAddr = 0; int32_t buf = 0; WifiSetDpiMarkRule(srcAddr, dstAddr, buf); - EXPECT_FALSE(g_errLog.find("enter") != std::string::npos); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); } /** * @tc.name: WifiInstallWlanExtParam029 @@ -1105,7 +1104,7 @@ HWTEST_F(WifiClientTest, WpaEventReport02, TestSize.Level1) WpaEventReport(WLAN_IFNAME, WPA_EVENT_STATE_CHANGED, (void *) &wpaStateChangedParma); WpaEventReport(WLAN_IFNAME, WPA_EVENT_STATE_CHANGED, nullptr); WpaEventReport(nullptr, WPA_EVENT_STATE_CHANGED, (void *) &wpaStateChangedParma); - EXPECT_FALSE(g_errLog.find("wlan0") != std::string::npos); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); } /** @@ -1140,7 +1139,7 @@ HWTEST_F(WifiClientTest, HostapdEventReport04, TestSize.Level1) HostapdEventReport(WLAN_IFNAME, HOSTAPD_EVENT_AP_STATE, (void *) &hostapdApCbParm); HostapdEventReport(WLAN_IFNAME, HOSTAPD_EVENT_AP_STATE, nullptr); HostapdEventReport(nullptr, HOSTAPD_EVENT_AP_STATE, (void *) &hostapdApCbParm); - EXPECT_FALSE(g_errLog.find("HostapdEventReport") != std::string::npos); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); } /** @@ -1155,7 +1154,7 @@ HWTEST_F(WifiClientTest, WifiSetPowerSaveMode029, TestSize.Level1) int32_t mode = 0; const char *ifName = "wlanTest"; WifiSetPowerSaveMode(ifName, frequency, mode); - EXPECT_FALSE(g_errLog.find("save") != std::string::npos); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); } /** @@ -1167,7 +1166,7 @@ HWTEST_F(WifiClientTest, WifiSetPowerSaveMode029, TestSize.Level1) HWTEST_F(WifiClientTest, ReleaseEventCallback01, TestSize.Level1) { ReleaseEventCallback(); - EXPECT_FALSE(g_errLog.find("wlan0") != std::string::npos); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); } /**