mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-12-18 20:40:11 +00:00
rx listen
Signed-off-by: wujun <2019125625@qq.com>
This commit is contained in:
commit
14fe415a83
@ -173,7 +173,7 @@ if (defined(ohos_lite)) {
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_power_saving",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_power_saving/rx_listen",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/hid2d",
|
||||
"$WIFI_ROOT_DIR/utils/inc",
|
||||
@ -444,7 +444,7 @@ if (defined(ohos_lite)) {
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/etc/init:etc",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/etc/param:etc",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_native:wifi_native",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_pawer_saving:wifi_power_saving_service",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_power_saving:wifi_power_saving_service",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit",
|
||||
"$WIFI_ROOT_DIR/utils:wifi_utils",
|
||||
]
|
||||
|
@ -1,17 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
# Copyright (C) 2023-2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//foundation/communication/wifi/wifi/wifi_lite.gni")
|
||||
@ -34,6 +33,7 @@ local_base_include_dirs = [
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/include",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/log",
|
||||
"//foundation/ability/ability_base/interfaces/kits/native/configuration/include",
|
||||
"//foundation/appexecfwk/adapter/interfaces/innerkits/appexecfwk_base/include",
|
||||
]
|
||||
|
||||
@ -45,6 +45,7 @@ if (defined(ohos_lite)) {
|
||||
deps = [
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit",
|
||||
"$WIFI_ROOT_DIR/utils:wifi_utils",
|
||||
"//third_party/libxml2:xml2"
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@ -80,6 +81,19 @@ if (defined(ohos_lite)) {
|
||||
sources = local_base_sources
|
||||
include_dirs = local_base_include_dirs
|
||||
|
||||
deps = [
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit",
|
||||
"$WIFI_ROOT_DIR/utils:wifi_utils",
|
||||
"//third_party/libxml2:xml2"
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"c_utils:utils",
|
||||
"ability_runtime:app_manager",
|
||||
]
|
||||
|
||||
cflags_cc = [
|
||||
"-std=c++17",
|
||||
"-fno-rtti",
|
||||
@ -90,18 +104,6 @@ if (defined(ohos_lite)) {
|
||||
"-Wl,-E",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit",
|
||||
"$WIFI_ROOT_DIR/utils:wifi_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"c_utils:utils",
|
||||
"ability_runtime:app_manager",
|
||||
]
|
||||
|
||||
part_name = "wifi"
|
||||
subsystem_name = "communication"
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "wifi_rx_listen_arbitration.h"
|
||||
#include "wifi_logger.h"
|
||||
#include "wifi_power_cmd_client.h"
|
||||
#include "app_parser.h"
|
||||
#include "wifi_app_parser.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
|
@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "wifi_power_cmd_client.h"
|
||||
#include <linux/sockios.h>
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <netinet/in.h>
|
||||
@ -21,9 +22,9 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <cerrno>
|
||||
#include <unistd.h>
|
||||
#include "wifi_logger.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
DEFINE_WIFILOG_LABEL("WifiPowerCmdClient");
|
||||
@ -36,7 +37,6 @@ static const char RX_LISTEN_OFF = 'N';
|
||||
static const auto CMD_SET_RX_LISTEN_ON = "SET_RX_LISTEN_PS_SWITCH 1";
|
||||
static const auto CMD_SET_RX_LISTEN_OFF = "SET_RX_LISTEN_PS_SWITCH 0";
|
||||
|
||||
|
||||
WifiPowerCmdClient &Wifi::WifiPowerCmdClient::GetInstance()
|
||||
{
|
||||
static WifiPowerCmdClient instance;
|
||||
@ -52,12 +52,15 @@ int Wifi::WifiPowerCmdClient::SendCmdToDriver(const char *iface, int commandId,
|
||||
}
|
||||
if (commandId == CMD_SET_RX_LISTEN_POWER_SAVING_SWITCH) {
|
||||
ret = SetRxListen(paramBuf);
|
||||
} else {
|
||||
WIFI_LOGD("%{public}s not supported command", __FUNCTION__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int Wifi::WifiPowerCmdClient::SendCommandToDriverByInterfaceName(char *cmdBuf, int cmdSize,
|
||||
const char *interfaceName) const
|
||||
{
|
||||
int ret = -1;
|
||||
if (cmdBuf > MAX_PRIV_CMD_SIZE) {
|
||||
WIFI_LOGE("%{public}s cmdSize too large", __FUNCTION__);
|
||||
return ret;
|
||||
@ -67,9 +70,8 @@ int Wifi::WifiPowerCmdClient::SendCommandToDriverByInterfaceName(char *cmdBuf, i
|
||||
return ret;
|
||||
}
|
||||
struct ifreq ifr;
|
||||
int ret = -1;
|
||||
WifiPrivCmd privCmd = { 0 };
|
||||
unint8_t buf[MAX_PRIV_CMD_SIZE] = {0};
|
||||
uint8_t buf[MAX_PRIV_CMD_SIZE] = {0};
|
||||
(void)memset_s(&ifr, sizeof(ifr), 0, sizeof(ifr));
|
||||
if (memcpy_s(buf, MAX_PRIV_CMD_SIZE, cmdBuf, cmdSize) != EOK) {
|
||||
WIFI_LOGE("%{public}s memcpy_s privCmd buf error", __FUNCTION__);
|
||||
@ -94,7 +96,7 @@ int Wifi::WifiPowerCmdClient::SendCommandToDriverByInterfaceName(char *cmdBuf, i
|
||||
return ret;
|
||||
}
|
||||
(void)memset_s(cmdBuf, cmdSize, 0, cmdSize);
|
||||
if (memcpy_s(cmdBuf, cmdSize, privCmd.buf, cmdSize - 1) != 0) {
|
||||
if (memcpy_s(cmdBuf, cmdSize, privCmd.buf, cmdSize - 1) != EOK) {
|
||||
WIFI_LOGE("%{public}s memcpy_s cmd fail", __FUNCTION__);
|
||||
}
|
||||
close(sock);
|
||||
@ -123,7 +125,7 @@ int Wifi::WifiPowerCmdClient::SetRxListen(const char *paramBuf) const
|
||||
WIFI_LOGE("%{public}s invalid param", __FUNCTION__);
|
||||
return ret;
|
||||
}
|
||||
ret = SendCommandToDriverByInterfaceName(cmdBuf, TINY_BUFF_SIZE, WiFI_IFNAME);
|
||||
ret = SendCommandToDriverByInterfaceName(cmdBuf, TINY_BUFF_SIZE, WIFI_IFNAME);
|
||||
return ret;
|
||||
}
|
||||
} // namespace Wifi
|
||||
|
@ -16,18 +16,18 @@
|
||||
#ifndef OHOS_WIFI_POWER_CMD_CLIENT_H
|
||||
#define OHOS_WIFI_POWER_CMD_CLIENT_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
|
||||
const auto WiFI_IFNAME = "wlan0";
|
||||
const auto WIFI_IFNAME = "wlan0";
|
||||
const int CMD_SET_RX_LISTEN_POWER_SAVING_SWITCH = 125;
|
||||
|
||||
typedef struct {
|
||||
unit8_t *buf;
|
||||
unint32_t size;
|
||||
unint32_t len;
|
||||
uint8_t *buf;
|
||||
uint32_t size;
|
||||
uint32_t len;
|
||||
} WifiPrivCmd;
|
||||
|
||||
class WifiPowerCmdClient {
|
||||
|
@ -23,7 +23,7 @@ namespace OHOS {
|
||||
namespace Wifi {
|
||||
DEFINE_WIFILOG_LABEL("WifiAppXmlParser");
|
||||
|
||||
static constexpr auto WIFI_MONITOR_APP_FILE_PATH = CONFIG_ROOR_DIR "/wifi_monitor_apps.xml";
|
||||
static constexpr auto WIFI_MONITOR_APP_FILE_PATH = CONFIG_ROOR_DIR"/wifi_monitor_apps.xml";
|
||||
static constexpr auto XML_TAG_SECTION_HEADER_MONITOR_APP = "MonitorAPP";
|
||||
static constexpr auto XML_TAG_SECTION_HEADER_GAME_INFO = "GameInfo";
|
||||
static constexpr auto XML_TAG_SECTION_HEADER_APP_WHITE_LIST = "AppWhiteList";
|
||||
@ -115,7 +115,7 @@ void AppParser::InitAppParser()
|
||||
WIFI_LOGD("%{public}s, wifi monitor app xml passed successfully", __FUNCTION__);
|
||||
}
|
||||
|
||||
bool AppParser::ParserInternal(xmlNodePtr node)
|
||||
bool AppParser::ParseInternal(xmlNodePtr node)
|
||||
{
|
||||
if (node == nullptr) {
|
||||
WIFI_LOGE("%{public}s node is null", __FUNCTION__);
|
||||
@ -130,7 +130,11 @@ void AppParser::ParserAppList(const xmlNodePtr &innode)
|
||||
if (xmlStrcmp(innode->name, BAD_CAST(XML_TAG_SECTION_HEADER_MONITOR_APP)) != 0) {
|
||||
WIFI_LOGE("innode name=%{public}s not equal MonitorAPP", innode->name);
|
||||
}
|
||||
for (xmlNodePtr node = innnode->children; node != nullptr; node = node->next) {
|
||||
m_gameAppVec.clear();
|
||||
m_whiteAppVec.clear();
|
||||
m_blackAppVec.clear();
|
||||
m_chariotAppVec.clear();
|
||||
for (xmlNodePtr node = innode->children; node != nullptr; node = node->next) {
|
||||
switch (GetAppTypeAsInt(node)) {
|
||||
case AppType::GAME_APP:
|
||||
m_gameAppVec.push_back(ParseGameAppInfo(node));
|
||||
@ -143,7 +147,7 @@ void AppParser::ParserAppList(const xmlNodePtr &innode)
|
||||
break;
|
||||
case AppType::CHARIOT_APP:
|
||||
m_chariotAppVec.push_back(ParseChariotAppInfo(node));
|
||||
|
||||
break;
|
||||
default:
|
||||
WIFI_LOGD("app type: %{public}s is not monitored", GetNodeValue(node).c_str());
|
||||
break;
|
||||
@ -160,7 +164,7 @@ GameAppInfo AppParser::ParseGameAppInfo(const xmlNodePtr &innode)
|
||||
WIFI_LOGW("%{public}s game name is empty", __FUNCTION__);
|
||||
}
|
||||
gameAppInfo.gameName = gameName;
|
||||
for (xmlNodePtr node = innnode->children; node != nullptr; node = node->next) {
|
||||
for (xmlNodePtr node = innode->children; node != nullptr; node = node->next) {
|
||||
switch (GetGameAppInfoNameAsInt(node)) {
|
||||
case GameAppInfoType::GAME_ID:
|
||||
gameAppInfo.mGameId = GetStringValue(node);
|
||||
@ -214,21 +218,21 @@ ChariotAppInfo AppParser::ParseChariotAppInfo(const xmlNodePtr &innode)
|
||||
|
||||
GameAppInfoType AppParser::GetGameAppInfoNameAsInt(const xmlNodePtr &innode)
|
||||
{
|
||||
std::string tagName = GetNodeValue(node);
|
||||
std::string tagName = GetNodeValue(innode);
|
||||
if (gameInfoTypeMap.find(tagName) != gameInfoTypeMap.end()) {
|
||||
return gameInfoTypeMap.at(tagName);
|
||||
}
|
||||
WIFI_LOGD("%{public} not find targName:%{public}s in gameInfoTypeMap", __FUNCTION__, tagName.c_str());
|
||||
WIFI_LOGD("%{public}s not find targName:%{public}s in gameInfoTypeMap", __FUNCTION__, tagName.c_str());
|
||||
return GameAppInfoType::INVALID;
|
||||
}
|
||||
|
||||
AppType AppParser::GetAppTypeAsInt(const xmlNodePtr &innode)
|
||||
{
|
||||
std::string tagName = GetNodeValue(node);
|
||||
std::string tagName = GetNodeValue(innode);
|
||||
if (appTypeMap.find(tagName) != appTypeMap.end()) {
|
||||
return appTypeMap.at(tagName);
|
||||
}
|
||||
WIFI_LOGD("%{public} not find targName:%{public}s in appTypeMap", __FUNCTION__, tagName.c_str());
|
||||
WIFI_LOGD("%{public}s not find targName:%{public}s in appTypeMap", __FUNCTION__, tagName.c_str());
|
||||
return AppType::OTHER_APP;
|
||||
}
|
||||
} // namespace Wifi
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
|
||||
private:
|
||||
void InitAppParser();
|
||||
bool ParserInternal(xmlNodePtr node) override;
|
||||
bool ParseInternal(xmlNodePtr node) override;
|
||||
void ParserAppList(const xmlNodePtr &innode);
|
||||
GameAppInfo ParseGameAppInfo(const xmlNodePtr &innode);
|
||||
WhiteListAppInfo ParseWhiteAppInfo(const xmlNodePtr &innode);
|
||||
@ -80,10 +80,10 @@ private:
|
||||
AppType GetAppTypeAsInt(const xmlNodePtr &innode);
|
||||
|
||||
private:
|
||||
std::vector<GameAppInfoL> m_gameAppVec {};
|
||||
std::vector<WhiteListAppInfoL> m_whiteAppVec {};
|
||||
std::vector<BlackListAppInfoL> m_blackAppVec {};
|
||||
std::vector<ChariotAppInfoL> m_chariotAppVec {};
|
||||
std::vector<GameAppInfo> m_gameAppVec {};
|
||||
std::vector<WhiteListAppInfo> m_whiteAppVec {};
|
||||
std::vector<BlackListAppInfo> m_blackAppVec {};
|
||||
std::vector<ChariotAppInfo> m_chariotAppVec {};
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user