mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-11-23 07:00:07 +00:00
commit
8c5052eab9
@ -551,6 +551,15 @@ public:
|
||||
* @return ErrCode - operation result
|
||||
*/
|
||||
virtual ErrCode GetDeviceConfig(const int &networkId, WifiDeviceConfig &config) = 0;
|
||||
|
||||
/**
|
||||
* @Description set data packet identification mark rule
|
||||
*
|
||||
* @param uid - target app uid
|
||||
* @param protocol - target protocol type
|
||||
* @return enable - enable/disable dpi mark
|
||||
*/
|
||||
virtual ErrCode SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable) = 0;
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -74,6 +74,7 @@ enum class DevInterfaceCode {
|
||||
WIFI_SVR_CMD_SET_TX_POWER = 0x1041, /* set tx power */
|
||||
WIFI_SVR_CMD_SET_LOW_TX_POWER = 0x1042, /* set low tx power */
|
||||
WIFI_SVR_CMD_START_CONNECT_TO_USER_SELECT_NETWORK = 0x1043, /* connect to user select target bssid */
|
||||
WIFI_SVR_CMD_SET_DPI_MARK_RULE = 0x1044, /* set dpi mark rule */
|
||||
|
||||
/* 以下CALL BACK类code,不需要进行权限校验 */
|
||||
WIFI_CBK_CMD_STATE_CHANGE = 0x3000, /* STA state change event */
|
||||
|
@ -60,6 +60,7 @@
|
||||
GetSignalLevel;
|
||||
SetLowLatencyMode;
|
||||
SetLowTxPower;
|
||||
SetDpiMarkRule;
|
||||
IsBandTypeSupported;
|
||||
Get5GHzChannelList;
|
||||
RegisterWifiEvent;
|
||||
|
@ -612,5 +612,12 @@ ErrCode WifiDeviceImpl::GetDeviceConfig(const int &networkId, WifiDeviceConfig &
|
||||
RETURN_IF_FAIL(GetWifiDeviceProxy());
|
||||
return client_->GetDeviceConfig(networkId, config);
|
||||
}
|
||||
|
||||
ErrCode WifiDeviceImpl::SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
RETURN_IF_FAIL(GetWifiDeviceProxy());
|
||||
return client_->SetDpiMarkRule(ifaceName, uid, protocol, enable);
|
||||
}
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -576,6 +576,15 @@ public:
|
||||
* @return ErrCode - operation result
|
||||
*/
|
||||
ErrCode GetDeviceConfig(const int &networkId, WifiDeviceConfig &config) override;
|
||||
|
||||
/**
|
||||
* @Description set data packet identification mark rule
|
||||
*
|
||||
* @param uid - target app uid
|
||||
* @param protocol - target protocol type
|
||||
* @return enable - enable/disable dpi mark
|
||||
*/
|
||||
ErrCode SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable) override;
|
||||
private:
|
||||
bool GetWifiDeviceProxy();
|
||||
std::atomic<int> systemAbilityId_;
|
||||
|
@ -2331,5 +2331,41 @@ ErrCode WifiDeviceProxy::GetDeviceConfig(const int &networkId, WifiDeviceConfig
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiDeviceProxy::SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable)
|
||||
{
|
||||
if (mRemoteDied) {
|
||||
WIFI_LOGE("failed to `%{public}s`,remote service is died!", __func__);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
MessageOption option;
|
||||
MessageParcel data, reply;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WIFI_LOGE("Write interface token error: %{public}s", __func__);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
data.WriteInt32(0);
|
||||
data.WriteCString(ifaceName.c_str());
|
||||
data.WriteInt32(uid);
|
||||
data.WriteInt32(protocol);
|
||||
data.WriteInt32(enable);
|
||||
int error = Remote()->SendRequest(static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_DPI_MARK_RULE),
|
||||
data, reply, option);
|
||||
if (error != ERR_NONE) {
|
||||
WIFI_LOGE("Set Attr(%{public}d) failed,error code is %{public}d",
|
||||
static_cast<int32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_DPI_MARK_RULE), error);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
int exception = reply.ReadInt32();
|
||||
if (exception) {
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
int ret = reply.ReadInt32();
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
return ErrCode(ret);
|
||||
}
|
||||
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -551,6 +551,15 @@ public:
|
||||
* @return ErrCode - operation result
|
||||
*/
|
||||
ErrCode GetDeviceConfig(const int &networkId, WifiDeviceConfig &config) override;
|
||||
|
||||
/**
|
||||
* @Description set data packet identification mark rule
|
||||
*
|
||||
* @param uid - target app uid
|
||||
* @param protocol - target protocol type
|
||||
* @return enable - enable/disable dpi mark
|
||||
*/
|
||||
ErrCode SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable) override;
|
||||
#ifdef OHOS_ARCH_LITE
|
||||
/**
|
||||
* @Description Handle remote object died event.
|
||||
|
@ -548,6 +548,15 @@ public:
|
||||
* @return ErrCode - operation result
|
||||
*/
|
||||
virtual ErrCode GetDeviceConfig(const int &networkId, WifiDeviceConfig &config) = 0;
|
||||
|
||||
/**
|
||||
* @Description set data packet identification mark rule
|
||||
*
|
||||
* @param uid - target app uid
|
||||
* @param protocol - target protocol type
|
||||
* @return enable - enable/disable dpi mark
|
||||
*/
|
||||
virtual ErrCode SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable) = 0;
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -76,6 +76,14 @@ bool WifiAuthCenter::IsNativeProcess()
|
||||
}
|
||||
#endif
|
||||
|
||||
int WifiAuthCenter::VerifySameProcessPermission(const int &pid, const int &uid)
|
||||
{
|
||||
if (g_permissinAlwaysGrant) {
|
||||
return PERMISSION_GRANTED;
|
||||
}
|
||||
return WifiPermissionHelper::VerifySameProcessPermission(pid, uid);
|
||||
}
|
||||
|
||||
int WifiAuthCenter::VerifySetWifiInfoPermission(const int &pid, const int &uid)
|
||||
{
|
||||
if (g_permissinAlwaysGrant) {
|
||||
|
@ -46,6 +46,15 @@ public:
|
||||
*/
|
||||
static bool IsNativeProcess();
|
||||
|
||||
/**
|
||||
* @Description Verify whether the app has the same process permission
|
||||
*
|
||||
* @param pid - the app's process id
|
||||
* @param uid - the app id
|
||||
* @return int - PERMISSION_DENIED or PERMISSION_GRANTED
|
||||
*/
|
||||
int VerifySameProcessPermission(const int &pid, const int &uid);
|
||||
|
||||
/**
|
||||
* @Description Verify whether the app has the permission to operator wifi
|
||||
*
|
||||
|
@ -51,6 +51,18 @@ int WifiPermissionHelper::VerifyPermission(const std::string &permissionName, co
|
||||
#endif
|
||||
}
|
||||
|
||||
int WifiPermissionHelper::VerifySameProcessPermission(const int &pid, const int &uid)
|
||||
{
|
||||
#ifdef OHOS_ARCH_LITE
|
||||
return PERMISSION_GRANTED;
|
||||
#else
|
||||
if (uid == static_cast<int>(getuid()) && pid == static_cast<int>(getpid())) {
|
||||
return PERMISSION_GRANTED;
|
||||
}
|
||||
return PERMISSION_DENIED;
|
||||
#endif
|
||||
}
|
||||
|
||||
int WifiPermissionHelper::VerifySetWifiInfoPermission(const int &pid, const int &uid)
|
||||
{
|
||||
if (VerifyPermission("ohos.permission.SET_WIFI_INFO", pid, uid, 0) == PERMISSION_DENIED) {
|
||||
|
@ -36,6 +36,15 @@ public:
|
||||
*/
|
||||
static int VerifyPermission(const std::string &permissionName, const int &pid, const int &uid, const int &tokenId);
|
||||
|
||||
/**
|
||||
* @Description : Verify Same Process Permission.
|
||||
*
|
||||
* @param pid - Process ID.[in]
|
||||
* @param uid - User ID.[in]
|
||||
* @return int
|
||||
*/
|
||||
static int VerifySameProcessPermission(const int &pid, const int &uid);
|
||||
|
||||
/**
|
||||
* @Description : Verify Set Wifi Information Permission.
|
||||
*
|
||||
|
@ -33,6 +33,11 @@ int WifiPermissionUtils::VerifyGetWifiInfoPermission()
|
||||
return PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
int WifiPermissionUtils::VerifySameProcessPermission()
|
||||
{
|
||||
return PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
int WifiPermissionUtils::VerifyWifiConnectionPermission()
|
||||
{
|
||||
return PERMISSION_GRANTED;
|
||||
@ -108,6 +113,12 @@ int WifiPermissionUtils::VerifyGetWifiInfoPermission()
|
||||
IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid());
|
||||
}
|
||||
|
||||
int WifiPermissionUtils::VerifySameProcessPermission()
|
||||
{
|
||||
return WifiAuthCenter::GetInstance().VerifySameProcessPermission(
|
||||
IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid());
|
||||
}
|
||||
|
||||
int WifiPermissionUtils::VerifyWifiConnectionPermission()
|
||||
{
|
||||
return WifiAuthCenter::GetInstance().VerifyWifiConnectionPermission(
|
||||
|
@ -29,6 +29,7 @@ class WifiPermissionUtils {
|
||||
public:
|
||||
static int VerifySetWifiInfoPermission();
|
||||
static int VerifyGetWifiInfoPermission();
|
||||
static int VerifySameProcessPermission();
|
||||
static int VerifyWifiConnectionPermission();
|
||||
static int VerifyGetScanInfosPermission();
|
||||
static int VerifyGetWifiLocalMacPermission();
|
||||
|
@ -715,6 +715,24 @@ ErrCode WifiDeviceServiceImpl::SetTxPower(int power)
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiDeviceServiceImpl::SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable)
|
||||
{
|
||||
if (WifiPermissionUtils::VerifySameProcessPermission() == PERMISSION_DENIED) {
|
||||
WIFI_LOGE("SetDpiMarkRule:VerifySameProcessPermission PERMISSION_DENIED!");
|
||||
return WIFI_OPT_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
if (!IsStaServiceRunning()) {
|
||||
return WIFI_OPT_STA_NOT_OPENED;
|
||||
}
|
||||
|
||||
if (WifiStaHalInterface::GetInstance().SetDpiMarkRule(ifaceName, uid, protocol, enable) != WIFI_HAL_OPT_OK) {
|
||||
WIFI_LOGE("SetDpiMarkRule failed");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
void WifiDeviceServiceImpl::ReplaceConfigWhenCandidateConnected(std::vector<WifiDeviceConfig> &result)
|
||||
{
|
||||
WifiLinkedInfo linkedInfo;
|
||||
|
@ -73,6 +73,8 @@ public:
|
||||
|
||||
ErrCode GetDeviceConfigs(std::vector<WifiDeviceConfig> &result, bool isCandidate) override;
|
||||
|
||||
ErrCode SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable) override;
|
||||
|
||||
ErrCode EnableDeviceConfig(int networkId, bool attemptEnable) override;
|
||||
|
||||
ErrCode DisableDeviceConfig(int networkId) override;
|
||||
|
@ -123,6 +123,8 @@ void WifiDeviceStub::InitHandleMapEx2()
|
||||
};
|
||||
handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIG)] = [this](uint32_t code,
|
||||
MessageParcel &data, MessageParcel &reply) { OnGetDeviceConfig(code, data, reply); };
|
||||
handleFuncMap[static_cast<uint32_t>(DevInterfaceCode::WIFI_SVR_CMD_SET_DPI_MARK_RULE)] = [this](uint32_t code,
|
||||
MessageParcel &data, MessageParcel &reply) { OnSetDpiMarkRule(code, data, reply); };
|
||||
}
|
||||
|
||||
void WifiDeviceStub::InitHandleMap()
|
||||
@ -1258,5 +1260,24 @@ void WifiDeviceStub::OnGetDeviceConfig(uint32_t code, MessageParcel &data, Messa
|
||||
return;
|
||||
}
|
||||
|
||||
void WifiDeviceStub::OnSetDpiMarkRule(uint32_t code, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
WIFI_LOGD("run %{public}s code %{public}u, datasize %{public}zu", __func__, code, data.GetRawDataSize());
|
||||
ErrCode ret = WIFI_OPT_FAILED;
|
||||
const char *readStr = data.ReadCString();
|
||||
int uid = data.ReadInt32();
|
||||
int protocol = data.ReadInt32();
|
||||
int enable = data.ReadInt32();
|
||||
if (readStr == nullptr) {
|
||||
ret = WIFI_OPT_INVALID_PARAM;
|
||||
} else {
|
||||
std::string ifaceName = readStr;
|
||||
ret = SetDpiMarkRule(ifaceName, uid, protocol, enable);
|
||||
}
|
||||
reply.WriteInt32(0);
|
||||
reply.WriteInt32(ret);
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -93,7 +93,8 @@ private:
|
||||
void OnSetSatelliteState(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnSetLowTxPower(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnSetTxPower(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnGetDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnGetDeviceConfig(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
void OnSetDpiMarkRule(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
private:
|
||||
void ReadEapConfig(MessageParcel &data, WifiEapConfig &wifiEapConfig);
|
||||
|
Loading…
Reference in New Issue
Block a user