update wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp.

Signed-off-by: yiyajun <yiyajun@huawei.com>
This commit is contained in:
yiyajun 2022-11-26 08:38:21 +00:00 committed by Gitee
parent 5f085c36eb
commit b563452dc6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -19,55 +19,55 @@
#include "../../../../../../interfaces/kits/c/wifi_device.h"
void EnableWifiTest()
static void EnableWifiTest()
{
EnableWifi();
}
void DisableWifiTest()
static void DisableWifiTest()
{
DisableWifi();
}
void ScanTest()
static void ScanTest()
{
Scan();
}
void DisconnectTest()
static void DisconnectTest()
{
Disconnect();
}
void RemoveDeviceTest(const uint8_t* data, size_t size)
static void RemoveDeviceTest(const uint8_t* data, size_t size)
{
if (size <= 0) {
if (size == 0) {
return;
}
int networkId = static_cast<int>(data[0]);
RemoveDevice(networkId);
}
void DisableDeviceConfigTest(const uint8_t* data, size_t size)
static void DisableDeviceConfigTest(const uint8_t* data, size_t size)
{
if (size <= 0) {
if (size == 0) {
return;
}
int networkId = static_cast<int>(data[0]);
DisableDeviceConfig(networkId);
}
void EnableDeviceConfigTest(const uint8_t* data, size_t size)
static void EnableDeviceConfigTest(const uint8_t* data, size_t size)
{
if (size <= 0) {
if (size == 0) {
return;
}
int networkId = static_cast<int>(data[0]);
EnableDeviceConfig(networkId);
}
void ConnectToTest(const uint8_t* data, size_t size)
static void ConnectToTest(const uint8_t* data, size_t size)
{
if (size <= 0) {
if (size == 0) {
return;
}
int networkId = static_cast<int>(data[0]);
ConnectTo(networkId);
}
void AddDeviceConfigTest(const uint8_t* data, size_t size)
static void AddDeviceConfigTest(const uint8_t* data, size_t size)
{
int index = 0;
WifiDeviceConfig config;
@ -86,19 +86,13 @@ void AddDeviceConfigTest(const uint8_t* data, size_t size)
config.freq = static_cast<int>(data[index++]);
config.wapiPskType = static_cast<int>(data[index++]);
config.isHiddenSsid = static_cast<int>(data[index++]);
IpType ipType = STATIC_IP;
if (ipType % 2 == 1) {
ipType = DHCP;
} else if (ipType % 2 == 0) {
ipType = UNKNOWN;
}
config.ipType = static_cast<IpType>(static_cast<int>(data[index++]) % TWO);
}
int result = static_cast<int>(data[index++]);
AddDeviceConfig(&config, &result);
}
void AdvanceScanTest(const uint8_t* data, size_t size)
static void AdvanceScanTest(const uint8_t* data, size_t size)
{
int index = 0;
WifiScanParams params;
if (size >= sizeof(WifiScanParams)) {
if (memcpy_s(params.ssid, WIFI_MAX_SSID_LEN, data, WIFI_MAX_SSID_LEN - 1) != EOK) {
@ -107,6 +101,7 @@ void AdvanceScanTest(const uint8_t* data, size_t size)
if (memcpy_s(params.bssid, WIFI_MAC_LEN, data, WIFI_MAC_LEN - 1) != EOK) {
return;
}
int index = 0;
params.scanType = WIFI_FREQ_SCAN;
params.freqs = static_cast<int>(data[index++]);
params.band = static_cast<int>(data[index++]);
@ -114,12 +109,12 @@ void AdvanceScanTest(const uint8_t* data, size_t size)
}
AdvanceScan(&params);
}
void GetSignalLevelTest(const uint8_t* data, size_t size)
static void GetSignalLevelTest(const uint8_t* data, size_t size)
{
int rssi = 0;
int band = 0;
int index = 0;
if (size >= 2) {
if (size >= TWO) {
int index = 0;
rssi = static_cast<int>(data[index++]);
band = static_cast<int>(data[index++]);
}