1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "wpa_common_fuzzer.h"
16
17 #define WLAN_FREQ_MAX_NUM 35
18 #define ETH_ADDR_LEN 6
19 #define BITS_NUM_24 24
20 #define BITS_NUM_16 16
21 #define BITS_NUM_8 8
22 #define REPLY_SIZE 1024
23
24 static uint32_t g_wpaTestSize = 0;
25 struct IWpaCallback *g_wpaCallbackObj = nullptr;
26
SetWpaDataSize(const uint32_t * dataSize)27 uint32_t SetWpaDataSize(const uint32_t *dataSize)
28 {
29 if (dataSize != nullptr) {
30 g_wpaTestSize = *dataSize;
31 return HDF_SUCCESS;
32 }
33 HDF_LOGE("%{public}s: set data size failed!", __FUNCTION__);
34 return HDF_FAILURE;
35 }
36
GetWpaDataSize(uint32_t * dataSize)37 uint32_t GetWpaDataSize(uint32_t *dataSize)
38 {
39 if (dataSize != nullptr) {
40 *dataSize = g_wpaTestSize;
41 return HDF_SUCCESS;
42 }
43 HDF_LOGE("%{public}s: get data size failed!", __FUNCTION__);
44 return HDF_FAILURE;
45 }
46
Convert2Uint32(const uint8_t * ptr)47 uint32_t Convert2Uint32(const uint8_t *ptr)
48 {
49 if (ptr == nullptr) {
50 return 0;
51 }
52 /*
53 * Move the 0th digit 24 to the left, the first digit 16 to the left, the second digit 8 to the left,
54 * and the third digit no left
55 */
56 return (ptr[0] << BITS_NUM_24) | (ptr[1] << BITS_NUM_16) | (ptr[2] << BITS_NUM_8) | (ptr[3]);
57 }
58
PreProcessRawData(const uint8_t * rawData,size_t size,uint8_t * tmpRawData,size_t tmpRawDataSize)59 bool PreProcessRawData(const uint8_t *rawData, size_t size, uint8_t *tmpRawData, size_t tmpRawDataSize)
60 {
61 if (rawData == nullptr || tmpRawData == nullptr) {
62 HDF_LOGE("%{public}s: rawData or tmpRawData is nullptr!", __FUNCTION__);
63 return false;
64 }
65 uint32_t dataSize = size - OFFSET;
66 if (memcpy_s(tmpRawData, tmpRawDataSize, rawData + OFFSET, dataSize) != EOK) {
67 HDF_LOGE("%{public}s: memcpy_s failed!", __FUNCTION__);
68 return false;
69 }
70 if (SetWpaDataSize(&dataSize) != HDF_SUCCESS) {
71 HDF_LOGE("%{public}s: set data size failed!", __FUNCTION__);
72 return false;
73 }
74 return true;
75 }
76
77 /* **********Wpa Interface********** */
FuzzWpaInterfaceStart(struct IWpaInterface * interface,const uint8_t * rawData)78 void FuzzWpaInterfaceStart(struct IWpaInterface *interface, const uint8_t *rawData)
79 {
80 interface->Start(interface);
81 HDF_LOGI("%{public}s: success", __FUNCTION__);
82 }
83
FuzzWpaInterfaceStop(struct IWpaInterface * interface,const uint8_t * rawData)84 void FuzzWpaInterfaceStop(struct IWpaInterface *interface, const uint8_t *rawData)
85 {
86 interface->Stop(interface);
87 HDF_LOGI("%{public}s: success", __FUNCTION__);
88 }
89
FuzzWpaInterfaceScan(struct IWpaInterface * interface,const uint8_t * rawData)90 void FuzzWpaInterfaceScan(struct IWpaInterface *interface, const uint8_t *rawData)
91 {
92 const char *ifName = reinterpret_cast<const char *>(rawData);
93
94 interface->Scan(interface, ifName);
95 HDF_LOGI("%{public}s: success", __FUNCTION__);
96 }
97
FuzzWpaInterfaceScanResult(struct IWpaInterface * interface,const uint8_t * rawData)98 void FuzzWpaInterfaceScanResult(struct IWpaInterface *interface, const uint8_t *rawData)
99 {
100 const char *ifName = reinterpret_cast<const char *>(rawData);
101 unsigned char buf[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
102 uint32_t bufLen = ETH_ADDR_LEN;
103 interface->ScanResult(interface, ifName, buf, &bufLen);
104 HDF_LOGI("%{public}s: success", __FUNCTION__);
105 }
106
FuzzWpaInterfaceAddNetwork(struct IWpaInterface * interface,const uint8_t * rawData)107 void FuzzWpaInterfaceAddNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
108 {
109 const char *ifName = reinterpret_cast<const char *>(rawData);
110 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
111
112 interface->AddNetwork(interface, ifName, &networkId);
113 HDF_LOGI("%{public}s: success", __FUNCTION__);
114 }
115
FuzzWpaInterfaceRemoveNetwork(struct IWpaInterface * interface,const uint8_t * rawData)116 void FuzzWpaInterfaceRemoveNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
117 {
118 const char *ifName = reinterpret_cast<const char *>(rawData);
119 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
120
121 interface->RemoveNetwork(interface, ifName, networkId);
122 HDF_LOGI("%{public}s: success", __FUNCTION__);
123 }
124
FuzzWpaInterfaceDisableNetwork(struct IWpaInterface * interface,const uint8_t * rawData)125 void FuzzWpaInterfaceDisableNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
126 {
127 const char *ifName = reinterpret_cast<const char *>(rawData);
128 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
129
130 interface->DisableNetwork(interface, ifName, networkId);
131 HDF_LOGI("%{public}s: success", __FUNCTION__);
132 }
133
FuzzWpaInterfaceSetNetwork(struct IWpaInterface * interface,const uint8_t * rawData)134 void FuzzWpaInterfaceSetNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
135 {
136 const char *ifName = reinterpret_cast<const char *>(rawData);
137 const char *name = reinterpret_cast<const char *>(rawData);
138 const char *value = reinterpret_cast<const char *>(rawData);
139 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
140
141 interface->SetNetwork(interface, ifName, networkId, name, value);
142 HDF_LOGI("%{public}s: success", __FUNCTION__);
143 }
144
FuzzWpaInterfaceReconnect(struct IWpaInterface * interface,const uint8_t * rawData)145 void FuzzWpaInterfaceReconnect(struct IWpaInterface *interface, const uint8_t *rawData)
146 {
147 const char *ifName = reinterpret_cast<const char *>(rawData);
148
149 interface->Reconnect(interface, ifName);
150 HDF_LOGI("%{public}s: success", __FUNCTION__);
151 }
152
FuzzWpaInterfaceDisconnect(struct IWpaInterface * interface,const uint8_t * rawData)153 void FuzzWpaInterfaceDisconnect(struct IWpaInterface *interface, const uint8_t *rawData)
154 {
155 const char *ifName = reinterpret_cast<const char *>(rawData);
156
157 interface->Disconnect(interface, ifName);
158 HDF_LOGI("%{public}s: success", __FUNCTION__);
159 }
160
FuzzWpaInterfaceSelectNetwork(struct IWpaInterface * interface,const uint8_t * rawData)161 void FuzzWpaInterfaceSelectNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
162 {
163 const char *ifName = reinterpret_cast<const char *>(rawData);
164 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
165
166 interface->SelectNetwork(interface, ifName, networkId);
167 HDF_LOGI("%{public}s: success", __FUNCTION__);
168 }
169
FuzzWpaInterfaceEnableNetwork(struct IWpaInterface * interface,const uint8_t * rawData)170 void FuzzWpaInterfaceEnableNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
171 {
172 const char *ifName = reinterpret_cast<const char *>(rawData);
173 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
174
175 interface->EnableNetwork(interface, ifName, networkId);
176 HDF_LOGI("%{public}s: success", __FUNCTION__);
177 }
178
FuzzWpaInterfaceSetPowerSave(struct IWpaInterface * interface,const uint8_t * rawData)179 void FuzzWpaInterfaceSetPowerSave(struct IWpaInterface *interface, const uint8_t *rawData)
180 {
181 const char *ifName = reinterpret_cast<const char *>(rawData);
182 int32_t enable = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
183
184 interface->SetPowerSave(interface, ifName, enable);
185 HDF_LOGI("%{public}s: success", __FUNCTION__);
186 }
187
FuzzWpaInterfaceAutoConnect(struct IWpaInterface * interface,const uint8_t * rawData)188 void FuzzWpaInterfaceAutoConnect(struct IWpaInterface *interface, const uint8_t *rawData)
189 {
190 const char *ifName = reinterpret_cast<const char *>(rawData);
191 int32_t enable = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
192
193 interface->AutoConnect(interface, ifName, enable);
194 HDF_LOGI("%{public}s: success", __FUNCTION__);
195 }
196
FuzzWpaInterfaceSaveConfig(struct IWpaInterface * interface,const uint8_t * rawData)197 void FuzzWpaInterfaceSaveConfig(struct IWpaInterface *interface, const uint8_t *rawData)
198 {
199 const char *ifName = reinterpret_cast<const char *>(rawData);
200
201 interface->SaveConfig(interface, ifName);
202 HDF_LOGI("%{public}s: success", __FUNCTION__);
203 }
204
FuzzWpaInterfaceWpsCancel(struct IWpaInterface * interface,const uint8_t * rawData)205 void FuzzWpaInterfaceWpsCancel(struct IWpaInterface *interface, const uint8_t *rawData)
206 {
207 const char *ifName = reinterpret_cast<const char *>(rawData);
208
209 interface->WpsCancel(interface, ifName);
210 HDF_LOGI("%{public}s: success", __FUNCTION__);
211 }
212
FuzzWpaInterfaceGetCountryCode(struct IWpaInterface * interface,const uint8_t * rawData)213 void FuzzWpaInterfaceGetCountryCode(struct IWpaInterface *interface, const uint8_t *rawData)
214 {
215 const char *ifName = reinterpret_cast<const char *>(rawData);
216 char countryCode[3] = {0};
217
218 interface->GetCountryCode(interface, ifName, countryCode, 3);
219 HDF_LOGI("%{public}s: success", __FUNCTION__);
220 }
221
FuzzWpaInterfaceGetNetwork(struct IWpaInterface * interface,const uint8_t * rawData)222 void FuzzWpaInterfaceGetNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
223 {
224 const char *ifName = reinterpret_cast<const char *>(rawData);
225 int networkId = 0;
226 char value[32] = {0};
227
228 interface->GetNetwork(interface, ifName, networkId, "ssid", value, 32);
229 HDF_LOGI("%{public}s: success", __FUNCTION__);
230 }
231
FuzzWpaInterfaceBlocklistClear(struct IWpaInterface * interface,const uint8_t * rawData)232 void FuzzWpaInterfaceBlocklistClear(struct IWpaInterface *interface, const uint8_t *rawData)
233 {
234 const char *ifName = reinterpret_cast<const char *>(rawData);
235
236 interface->BlocklistClear(interface, ifName);
237 HDF_LOGI("%{public}s: success", __FUNCTION__);
238 }
239
FuzzWpaInterfaceSetSuspendMode(struct IWpaInterface * interface,const uint8_t * rawData)240 void FuzzWpaInterfaceSetSuspendMode(struct IWpaInterface *interface, const uint8_t *rawData)
241 {
242 const char *ifName = reinterpret_cast<const char *>(rawData);
243 int32_t mode = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
244
245 interface->SetSuspendMode(interface, ifName, mode);
246 HDF_LOGI("%{public}s: success", __FUNCTION__);
247 }
248
FuzzWpaInterfaceGetScanSsid(struct IWpaInterface * interface,const uint8_t * rawData)249 void FuzzWpaInterfaceGetScanSsid(struct IWpaInterface *interface, const uint8_t *rawData)
250 {
251 const char *ifName = reinterpret_cast<const char *>(rawData);
252 int32_t enable = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
253
254 interface->GetScanSsid(interface, ifName, &enable);
255 HDF_LOGI("%{public}s: success", __FUNCTION__);
256 }
257
FuzzWpaInterfaceGetPskPassphrase(struct IWpaInterface * interface,const uint8_t * rawData)258 void FuzzWpaInterfaceGetPskPassphrase(struct IWpaInterface *interface, const uint8_t *rawData)
259 {
260 const char *ifName = reinterpret_cast<const char *>(rawData);
261 char psk[32] = {0};
262
263 interface->GetPskPassphrase(interface, ifName, psk, 32);
264 HDF_LOGI("%{public}s: success", __FUNCTION__);
265 }
266
FuzzWpaInterfaceGetPsk(struct IWpaInterface * interface,const uint8_t * rawData)267 void FuzzWpaInterfaceGetPsk(struct IWpaInterface *interface, const uint8_t *rawData)
268 {
269 const char *ifName = reinterpret_cast<const char *>(rawData);
270 uint8_t psk[32] = {0};
271 uint32_t pskLen = 32;
272
273 interface->GetPsk(interface, ifName, psk, &pskLen);
274 HDF_LOGI("%{public}s: success", __FUNCTION__);
275 }
276
FuzzWpaInterfaceGetWepKey(struct IWpaInterface * interface,const uint8_t * rawData)277 void FuzzWpaInterfaceGetWepKey(struct IWpaInterface *interface, const uint8_t *rawData)
278 {
279 const char *ifName = reinterpret_cast<const char *>(rawData);
280 uint8_t wepKey[16] = {0};
281 uint32_t wepKeyLen = 16;
282
283 interface->GetWepKey(interface, ifName, 1, wepKey, &wepKeyLen);
284 HDF_LOGI("%{public}s: success", __FUNCTION__);
285 }
286
FuzzWpaInterfaceGetWepTxKeyIdx(struct IWpaInterface * interface,const uint8_t * rawData)287 void FuzzWpaInterfaceGetWepTxKeyIdx(struct IWpaInterface *interface, const uint8_t *rawData)
288 {
289 const char *ifName = reinterpret_cast<const char *>(rawData);
290 int keyIdx = *const_cast<int *>(reinterpret_cast<const int *>(rawData));
291
292 interface->GetWepTxKeyIdx(interface, ifName, &keyIdx);
293 HDF_LOGI("%{public}s: success", __FUNCTION__);
294 }
295
FuzzWpaInterfaceGetRequirePmf(struct IWpaInterface * interface,const uint8_t * rawData)296 void FuzzWpaInterfaceGetRequirePmf(struct IWpaInterface *interface, const uint8_t *rawData)
297 {
298 const char *ifName = reinterpret_cast<const char *>(rawData);
299 int enable = *const_cast<int *>(reinterpret_cast<const int *>(rawData));
300
301 interface->GetRequirePmf(interface, ifName, &enable);
302 HDF_LOGI("%{public}s: success", __FUNCTION__);
303 }
304
FuzzWpaInterfaceSetCountryCode(struct IWpaInterface * interface,const uint8_t * rawData)305 void FuzzWpaInterfaceSetCountryCode(struct IWpaInterface *interface, const uint8_t *rawData)
306 {
307 const char *ifName = reinterpret_cast<const char *>(rawData);
308 const char countryCode[3] = {0};
309
310 interface->SetCountryCode(interface, ifName, countryCode);
311 HDF_LOGI("%{public}s: success", __FUNCTION__);
312 }
313
FuzzWpaInterfaceListNetworks(struct IWpaInterface * interface,const uint8_t * rawData)314 void FuzzWpaInterfaceListNetworks(struct IWpaInterface *interface, const uint8_t *rawData)
315 {
316 const char *ifName = reinterpret_cast<const char *>(rawData);
317 struct HdiWifiWpaNetworkInfo networkInfo;
318 (void)memset_s(&networkInfo, sizeof(struct HdiWifiWpaNetworkInfo), 0, sizeof(struct HdiWifiWpaNetworkInfo));
319 uint32_t networkInfoLen = 0;
320
321 interface->ListNetworks(interface, ifName, (struct HdiWifiWpaNetworkInfo *)&networkInfo, &networkInfoLen);
322 HDF_LOGI("%{public}s: success", __FUNCTION__);
323 }
324
FuzzWpaInterfaceWifiStatus(struct IWpaInterface * interface,const uint8_t * rawData)325 void FuzzWpaInterfaceWifiStatus(struct IWpaInterface *interface, const uint8_t *rawData)
326 {
327 const char *ifName = reinterpret_cast<const char *>(rawData);
328 struct HdiWpaCmdStatus wifiStatus;
329 (void)memset_s(&wifiStatus, sizeof(struct HdiWpaCmdStatus), 0, sizeof(struct HdiWpaCmdStatus));
330
331 interface->WifiStatus(interface, ifName, &wifiStatus);
332 HDF_LOGI("%{public}s: success", __FUNCTION__);
333 }
334
FuzzWpaInterfaceWpsPbcMode(struct IWpaInterface * interface,const uint8_t * rawData)335 void FuzzWpaInterfaceWpsPbcMode(struct IWpaInterface *interface, const uint8_t *rawData)
336 {
337 const char *ifName = reinterpret_cast<const char *>(rawData);
338 struct HdiWifiWpsParam wpsParam;
339 (void)memset_s(&wpsParam, sizeof(struct HdiWifiWpsParam), 0, sizeof(struct HdiWifiWpsParam));
340 wpsParam.anyFlag = 1;
341 wpsParam.multiAp = 1;
342 wpsParam.bssidLen = 6;
343 wpsParam.bssid = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * (wpsParam.bssidLen)));
344 if (wpsParam.bssid == nullptr) {
345 return;
346 }
347 wpsParam.bssid[0] = 0x12;
348 wpsParam.bssid[1] = 0x34;
349 wpsParam.bssid[2] = 0x56;
350 wpsParam.bssid[3] = 0x78;
351 wpsParam.bssid[4] = 0xab;
352 wpsParam.bssid[5] = 0xcd;
353
354 interface->WpsPbcMode(interface, ifName, &wpsParam);
355 OsalMemFree(wpsParam.bssid);
356 HDF_LOGI("%{public}s: success", __FUNCTION__);
357 }
358
FuzzWpaInterfaceWpsPinMode(struct IWpaInterface * interface,const uint8_t * rawData)359 void FuzzWpaInterfaceWpsPinMode(struct IWpaInterface *interface, const uint8_t *rawData)
360 {
361 const char *ifName = reinterpret_cast<const char *>(rawData);
362 struct HdiWifiWpsParam wpsParam;
363 (void)memset_s(&wpsParam, sizeof(struct HdiWifiWpsParam), 0, sizeof(struct HdiWifiWpsParam));
364 wpsParam.anyFlag = 1;
365 wpsParam.multiAp = 1;
366 wpsParam.bssidLen = 6;
367 wpsParam.bssid = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * (wpsParam.bssidLen)));
368 if (wpsParam.bssid == nullptr) {
369 return;
370 }
371 wpsParam.bssid[0] = 0x12;
372 wpsParam.bssid[1] = 0x34;
373 wpsParam.bssid[2] = 0x56;
374 wpsParam.bssid[3] = 0x78;
375 wpsParam.bssid[4] = 0xab;
376 wpsParam.bssid[5] = 0xcd;
377 int pinCode = 0;
378
379 interface->WpsPinMode(interface, ifName, &wpsParam, &pinCode);
380 OsalMemFree(wpsParam.bssid);
381 HDF_LOGI("%{public}s: success", __FUNCTION__);
382 }
383
FuzzWpaInterfaceRegisterEventCallback(struct IWpaInterface * interface,const uint8_t * rawData)384 void FuzzWpaInterfaceRegisterEventCallback(struct IWpaInterface *interface, const uint8_t *rawData)
385 {
386 const char *ifName = reinterpret_cast<const char *>(rawData);
387
388 interface->RegisterEventCallback(interface, g_wpaCallbackObj, ifName);
389 HDF_LOGI("%{public}s: success", __FUNCTION__);
390 }
391
FuzzWpaInterfaceUnregisterEventCallback(struct IWpaInterface * interface,const uint8_t * rawData)392 void FuzzWpaInterfaceUnregisterEventCallback(struct IWpaInterface *interface, const uint8_t *rawData)
393 {
394 const char *ifName = reinterpret_cast<const char *>(rawData);
395
396 interface->UnregisterEventCallback(interface, g_wpaCallbackObj, ifName);
397 HDF_LOGI("%{public}s: success", __FUNCTION__);
398 }
399
FuzzWpaInterfaceGetConnectionCapabilities(struct IWpaInterface * interface,const uint8_t * rawData)400 void FuzzWpaInterfaceGetConnectionCapabilities(struct IWpaInterface *interface, const uint8_t *rawData)
401 {
402 const char *ifName = reinterpret_cast<const char *>(rawData);
403 struct ConnectionCapabilities connectionCap;
404 (void)memset_s(&connectionCap, sizeof(struct ConnectionCapabilities), 0, sizeof(struct ConnectionCapabilities));
405
406 interface->GetConnectionCapabilities(interface, ifName, &connectionCap);
407 HDF_LOGI("%{public}s: success", __FUNCTION__);
408 }
409
FuzzWpaInterfaceAddWpaIface(struct IWpaInterface * interface,const uint8_t * rawData)410 void FuzzWpaInterfaceAddWpaIface(struct IWpaInterface *interface, const uint8_t *rawData)
411 {
412 const char *ifName = reinterpret_cast<const char *>(rawData);
413 const char *configname = "/data/service/el1/public/wifi/wpa_supplicant/wpa_supplicant.conf";
414 interface->AddWpaIface(interface, ifName, configname);
415 HDF_LOGI("%{public}s: success", __FUNCTION__);
416 }
417
FuzzWpaInterfaceRemoveWpaIface(struct IWpaInterface * interface,const uint8_t * rawData)418 void FuzzWpaInterfaceRemoveWpaIface(struct IWpaInterface *interface, const uint8_t *rawData)
419 {
420 const char *ifName = reinterpret_cast<const char *>(rawData);
421
422 interface->RemoveWpaIface(interface, ifName);
423 HDF_LOGI("%{public}s: success", __FUNCTION__);
424 }
425
FuzzWpaInterfaceReassociate(struct IWpaInterface * interface,const uint8_t * rawData)426 void FuzzWpaInterfaceReassociate(struct IWpaInterface *interface, const uint8_t *rawData)
427 {
428 const char *ifName = reinterpret_cast<const char *>(rawData);
429
430 interface->Reassociate(interface, ifName);
431 HDF_LOGI("%{public}s: success", __FUNCTION__);
432 }
433
FuzzWpaInterfaceStaShellCmd(struct IWpaInterface * interface,const uint8_t * rawData)434 void FuzzWpaInterfaceStaShellCmd(struct IWpaInterface *interface, const uint8_t *rawData)
435 {
436 const char *ifName = reinterpret_cast<const char *>(rawData);
437 const char *cmd = reinterpret_cast<const char *>(rawData);
438
439 interface->StaShellCmd(interface, ifName, cmd);
440 HDF_LOGI("%{public}s: success", __FUNCTION__);
441 }
442
443
444 /* **********P2p Interface********** */
FuzzWpaInterfaceP2pSetSsidPostfixName(struct IWpaInterface * interface,const uint8_t * rawData)445 void FuzzWpaInterfaceP2pSetSsidPostfixName(struct IWpaInterface *interface, const uint8_t *rawData)
446 {
447 const char *ifName = reinterpret_cast<const char *>(rawData);
448 const char *name = reinterpret_cast<const char *>(rawData);
449
450 interface->P2pSetSsidPostfixName(interface, ifName, name);
451 HDF_LOGI("%{public}s: success", __FUNCTION__);
452 }
453
FuzzWpaInterfaceP2pSetWpsDeviceType(struct IWpaInterface * interface,const uint8_t * rawData)454 void FuzzWpaInterfaceP2pSetWpsDeviceType(struct IWpaInterface *interface, const uint8_t *rawData)
455 {
456 const char *ifName = reinterpret_cast<const char *>(rawData);
457 const char *type = reinterpret_cast<const char *>(rawData);
458
459 interface->P2pSetWpsDeviceType(interface, ifName, type);
460 HDF_LOGI("%{public}s: success", __FUNCTION__);
461 }
462
FuzzWpaInterfaceP2pSetWpsConfigMethods(struct IWpaInterface * interface,const uint8_t * rawData)463 void FuzzWpaInterfaceP2pSetWpsConfigMethods(struct IWpaInterface *interface, const uint8_t *rawData)
464 {
465 const char *ifName = reinterpret_cast<const char *>(rawData);
466 const char *methods = reinterpret_cast<const char *>(rawData);
467
468 interface->P2pSetWpsConfigMethods(interface, ifName, methods);
469 HDF_LOGI("%{public}s: success", __FUNCTION__);
470 }
471
FuzzWpaInterfaceP2pSetGroupMaxIdle(struct IWpaInterface * interface,const uint8_t * rawData)472 void FuzzWpaInterfaceP2pSetGroupMaxIdle(struct IWpaInterface *interface, const uint8_t *rawData)
473 {
474 const char *ifName = reinterpret_cast<const char *>(rawData);
475 int32_t time = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
476
477 interface->P2pSetGroupMaxIdle(interface, ifName, time);
478 HDF_LOGI("%{public}s: success", __FUNCTION__);
479 }
480
FuzzWpaInterfaceP2pSetWfdEnable(struct IWpaInterface * interface,const uint8_t * rawData)481 void FuzzWpaInterfaceP2pSetWfdEnable(struct IWpaInterface *interface, const uint8_t *rawData)
482 {
483 const char *ifName = reinterpret_cast<const char *>(rawData);
484 int32_t enable = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
485
486 interface->P2pSetWfdEnable(interface, ifName, enable);
487 HDF_LOGI("%{public}s: success", __FUNCTION__);
488 }
489
FuzzWpaInterfaceP2pSetPersistentReconnect(struct IWpaInterface * interface,const uint8_t * rawData)490 void FuzzWpaInterfaceP2pSetPersistentReconnect(struct IWpaInterface *interface, const uint8_t *rawData)
491 {
492 const char *ifName = reinterpret_cast<const char *>(rawData);
493 int32_t status = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
494
495 interface->P2pSetPersistentReconnect(interface, ifName, status);
496 HDF_LOGI("%{public}s: success", __FUNCTION__);
497 }
498
FuzzWpaInterfaceP2pSetWpsSecondaryDeviceType(struct IWpaInterface * interface,const uint8_t * rawData)499 void FuzzWpaInterfaceP2pSetWpsSecondaryDeviceType(struct IWpaInterface *interface, const uint8_t *rawData)
500 {
501 const char *ifName = reinterpret_cast<const char *>(rawData);
502 const char *type = reinterpret_cast<const char *>(rawData);
503
504 interface->P2pSetWpsSecondaryDeviceType(interface, ifName, type);
505 HDF_LOGI("%{public}s: success", __FUNCTION__);
506 }
507
FuzzWpaInterfaceP2pSetupWpsPbc(struct IWpaInterface * interface,const uint8_t * rawData)508 void FuzzWpaInterfaceP2pSetupWpsPbc(struct IWpaInterface *interface, const uint8_t *rawData)
509 {
510 const char *ifName = reinterpret_cast<const char *>(rawData);
511 const char *address = reinterpret_cast<const char *>(rawData);
512
513 interface->P2pSetupWpsPbc(interface, ifName, address);
514 HDF_LOGI("%{public}s: success", __FUNCTION__);
515 }
516
FuzzWpaInterfaceP2pSetupWpsPin(struct IWpaInterface * interface,const uint8_t * rawData)517 void FuzzWpaInterfaceP2pSetupWpsPin(struct IWpaInterface *interface, const uint8_t *rawData)
518 {
519 const char *ifName = reinterpret_cast<const char *>(rawData);
520 const char *address = reinterpret_cast<const char *>(rawData);
521 const char *pin = reinterpret_cast<const char *>(rawData);
522 char result[32] = {0};
523 uint32_t resultLen = *const_cast<uint32_t *>(reinterpret_cast<const uint32_t *>(rawData));
524
525
526 interface->P2pSetupWpsPin(interface, ifName, address, pin, result, resultLen);
527 HDF_LOGI("%{public}s: success", __FUNCTION__);
528 }
529
FuzzWpaInterfaceP2pSetPowerSave(struct IWpaInterface * interface,const uint8_t * rawData)530 void FuzzWpaInterfaceP2pSetPowerSave(struct IWpaInterface *interface, const uint8_t *rawData)
531 {
532 const char *ifName = reinterpret_cast<const char *>(rawData);
533 int32_t enable = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
534
535 interface->P2pSetPowerSave(interface, ifName, enable);
536 HDF_LOGI("%{public}s: success", __FUNCTION__);
537 }
538
FuzzWpaInterfaceP2pSetDeviceName(struct IWpaInterface * interface,const uint8_t * rawData)539 void FuzzWpaInterfaceP2pSetDeviceName(struct IWpaInterface *interface, const uint8_t *rawData)
540 {
541 const char *ifName = reinterpret_cast<const char *>(rawData);
542 const char *name = reinterpret_cast<const char *>(rawData);
543
544 interface->P2pSetDeviceName(interface, ifName, name);
545 HDF_LOGI("%{public}s: success", __FUNCTION__);
546 }
547
FuzzWpaInterfaceP2pSetWfdDeviceConfig(struct IWpaInterface * interface,const uint8_t * rawData)548 void FuzzWpaInterfaceP2pSetWfdDeviceConfig(struct IWpaInterface *interface, const uint8_t *rawData)
549 {
550 const char *ifName = reinterpret_cast<const char *>(rawData);
551 const char *config = reinterpret_cast<const char *>(rawData);
552
553 interface->P2pSetWfdDeviceConfig(interface, ifName, config);
554 HDF_LOGI("%{public}s: success", __FUNCTION__);
555 }
556
FuzzWpaInterfaceP2pSetRandomMac(struct IWpaInterface * interface,const uint8_t * rawData)557 void FuzzWpaInterfaceP2pSetRandomMac(struct IWpaInterface *interface, const uint8_t *rawData)
558 {
559 const char *ifName = reinterpret_cast<const char *>(rawData);
560 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
561
562 interface->P2pSetRandomMac(interface, ifName, networkId);
563 HDF_LOGI("%{public}s: success", __FUNCTION__);
564 }
565
FuzzWpaInterfaceP2pStartFind(struct IWpaInterface * interface,const uint8_t * rawData)566 void FuzzWpaInterfaceP2pStartFind(struct IWpaInterface *interface, const uint8_t *rawData)
567 {
568 const char *ifName = reinterpret_cast<const char *>(rawData);
569 int32_t timeout = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
570
571 interface->P2pStartFind(interface, ifName, timeout);
572 HDF_LOGI("%{public}s: success", __FUNCTION__);
573 }
574
FuzzWpaInterfaceP2pSetExtListen(struct IWpaInterface * interface,const uint8_t * rawData)575 void FuzzWpaInterfaceP2pSetExtListen(struct IWpaInterface *interface, const uint8_t *rawData)
576 {
577 const char *ifName = reinterpret_cast<const char *>(rawData);
578 int32_t enable = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
579 int32_t period = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
580 int32_t interval = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
581
582 interface->P2pSetExtListen(interface, ifName, enable, period, interval);
583 HDF_LOGI("%{public}s: success", __FUNCTION__);
584 }
585
FuzzWpaInterfaceP2pSetListenChannel(struct IWpaInterface * interface,const uint8_t * rawData)586 void FuzzWpaInterfaceP2pSetListenChannel(struct IWpaInterface *interface, const uint8_t *rawData)
587 {
588 const char *ifName = reinterpret_cast<const char *>(rawData);
589 int32_t channel = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
590 int32_t regClass = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
591
592 interface->P2pSetListenChannel(interface, ifName, channel, regClass);
593 HDF_LOGI("%{public}s: success", __FUNCTION__);
594 }
595
FuzzWpaInterfaceP2pProvisionDiscovery(struct IWpaInterface * interface,const uint8_t * rawData)596 void FuzzWpaInterfaceP2pProvisionDiscovery(struct IWpaInterface *interface, const uint8_t *rawData)
597 {
598 const char *ifName = reinterpret_cast<const char *>(rawData);
599 const char *peerBssid = reinterpret_cast<const char *>(rawData);
600 int32_t mode = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
601
602 interface->P2pProvisionDiscovery(interface, ifName, peerBssid, mode);
603 HDF_LOGI("%{public}s: success", __FUNCTION__);
604 }
605
FuzzWpaInterfaceP2pAddGroup(struct IWpaInterface * interface,const uint8_t * rawData)606 void FuzzWpaInterfaceP2pAddGroup(struct IWpaInterface *interface, const uint8_t *rawData)
607 {
608 const char *ifName = reinterpret_cast<const char *>(rawData);
609 int32_t isPersistent = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
610 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
611 int32_t freq = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
612
613 interface->P2pAddGroup(interface, ifName, isPersistent, networkId, freq);
614 HDF_LOGI("%{public}s: success", __FUNCTION__);
615 }
616
FuzzWpaInterfaceP2pAddService(struct IWpaInterface * interface,const uint8_t * rawData)617 void FuzzWpaInterfaceP2pAddService(struct IWpaInterface *interface, const uint8_t *rawData)
618 {
619 const char *ifName = reinterpret_cast<const char *>(rawData);
620 struct HdiP2pServiceInfo info = {0};
621 (void)memset_s(&info, sizeof(struct HdiP2pServiceInfo), 0, sizeof(struct HdiP2pServiceInfo));
622 info.mode = 0;
623 info.version = 0;
624 const int nameLen = 32;
625 const int paramLen = 1;
626 info.nameLen = nameLen;
627 info.queryLen = paramLen;
628 info.respLen = paramLen;
629 info.name = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * nameLen));
630 info.query = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * paramLen));
631 info.resp = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * paramLen));
632 if (info.name == nullptr || info.query == nullptr || info.resp == nullptr) {
633 return;
634 }
635 strcpy_s((char *)info.name, sizeof(info.name), "p2p0");
636
637 interface->P2pAddService(interface, ifName, &info);
638 OsalMemFree(info.name);
639 OsalMemFree(info.query);
640 OsalMemFree(info.resp);
641 HDF_LOGI("%{public}s: success", __FUNCTION__);
642 }
643
FuzzWpaInterfaceP2pRemoveService(struct IWpaInterface * interface,const uint8_t * rawData)644 void FuzzWpaInterfaceP2pRemoveService(struct IWpaInterface *interface, const uint8_t *rawData)
645 {
646 const char *ifName = reinterpret_cast<const char *>(rawData);
647 struct HdiP2pServiceInfo info = {0};
648 (void)memset_s(&info, sizeof(struct HdiP2pServiceInfo), 0, sizeof(struct HdiP2pServiceInfo));
649 info.mode = 0;
650 info.version = 0;
651 const int nameLen = 32;
652 const int paramLen = 1;
653 info.nameLen = nameLen;
654 info.queryLen = paramLen;
655 info.respLen = paramLen;
656 info.name = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * nameLen));
657 info.query = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * paramLen));
658 info.resp = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * paramLen));
659 if (info.name == nullptr || info.query == nullptr || info.resp == nullptr) {
660 return;
661 }
662 strcpy_s((char *)info.name, sizeof(info.name), "p2p0");
663
664 interface->P2pRemoveService(interface, ifName, &info);
665 OsalMemFree(info.name);
666 OsalMemFree(info.query);
667 OsalMemFree(info.resp);
668 HDF_LOGI("%{public}s: success", __FUNCTION__);
669 }
670
FuzzWpaInterfaceP2pStopFind(struct IWpaInterface * interface,const uint8_t * rawData)671 void FuzzWpaInterfaceP2pStopFind(struct IWpaInterface *interface, const uint8_t *rawData)
672 {
673 const char *ifName = reinterpret_cast<const char *>(rawData);
674
675 interface->P2pStopFind(interface, ifName);
676 HDF_LOGI("%{public}s: success", __FUNCTION__);
677 }
678
FuzzWpaInterfaceP2pFlush(struct IWpaInterface * interface,const uint8_t * rawData)679 void FuzzWpaInterfaceP2pFlush(struct IWpaInterface *interface, const uint8_t *rawData)
680 {
681 const char *ifName = reinterpret_cast<const char *>(rawData);
682
683 interface->P2pFlush(interface, ifName);
684 HDF_LOGI("%{public}s: success", __FUNCTION__);
685 }
686
FuzzWpaInterfaceP2pFlushService(struct IWpaInterface * interface,const uint8_t * rawData)687 void FuzzWpaInterfaceP2pFlushService(struct IWpaInterface *interface, const uint8_t *rawData)
688 {
689 const char *ifName = reinterpret_cast<const char *>(rawData);
690
691 interface->P2pFlushService(interface, ifName);
692 HDF_LOGI("%{public}s: success", __FUNCTION__);
693 }
694
FuzzWpaInterfaceP2pRemoveNetwork(struct IWpaInterface * interface,const uint8_t * rawData)695 void FuzzWpaInterfaceP2pRemoveNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
696 {
697 const char *ifName = reinterpret_cast<const char *>(rawData);
698 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
699
700 interface->P2pRemoveNetwork(interface, ifName, networkId);
701 HDF_LOGI("%{public}s: success", __FUNCTION__);
702 }
703
FuzzWpaInterfaceP2pSetGroupConfig(struct IWpaInterface * interface,const uint8_t * rawData)704 void FuzzWpaInterfaceP2pSetGroupConfig(struct IWpaInterface *interface, const uint8_t *rawData)
705 {
706 const char *ifName = reinterpret_cast<const char *>(rawData);
707 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
708 const char *name = reinterpret_cast<const char *>(rawData);
709 const char *value = reinterpret_cast<const char *>(rawData);
710
711 interface->P2pSetGroupConfig(interface, ifName, networkId, name, value);
712 HDF_LOGI("%{public}s: success", __FUNCTION__);
713 }
714
FuzzWpaInterfaceP2pInvite(struct IWpaInterface * interface,const uint8_t * rawData)715 void FuzzWpaInterfaceP2pInvite(struct IWpaInterface *interface, const uint8_t *rawData)
716 {
717 const char *ifName = reinterpret_cast<const char *>(rawData);
718 const char *peerBssid = reinterpret_cast<const char *>(rawData);
719 const char *goBssid = reinterpret_cast<const char *>(rawData);
720
721 interface->P2pInvite(interface, ifName, peerBssid, goBssid);
722 HDF_LOGI("%{public}s: success", __FUNCTION__);
723 }
724
FuzzWpaInterfaceP2pReinvoke(struct IWpaInterface * interface,const uint8_t * rawData)725 void FuzzWpaInterfaceP2pReinvoke(struct IWpaInterface *interface, const uint8_t *rawData)
726 {
727 const char *ifName = reinterpret_cast<const char *>(rawData);
728 const char *bssid = reinterpret_cast<const char *>(rawData);
729 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
730
731 interface->P2pReinvoke(interface, ifName, networkId, bssid);
732 HDF_LOGI("%{public}s: success", __FUNCTION__);
733 }
734
FuzzWpaInterfaceP2pGetDeviceAddress(struct IWpaInterface * interface,const uint8_t * rawData)735 void FuzzWpaInterfaceP2pGetDeviceAddress(struct IWpaInterface *interface, const uint8_t *rawData)
736 {
737 const char *ifName = reinterpret_cast<const char *>(rawData);
738 char deviceAddress[32] = {0};
739 uint32_t deviceAddressLen = *const_cast<uint32_t *>(reinterpret_cast<const uint32_t *>(rawData));
740
741 interface->P2pGetDeviceAddress(interface, ifName, deviceAddress, deviceAddressLen);
742 HDF_LOGI("%{public}s: success", __FUNCTION__);
743 }
744
FuzzWpaInterfaceP2pReqServiceDiscovery(struct IWpaInterface * interface,const uint8_t * rawData)745 void FuzzWpaInterfaceP2pReqServiceDiscovery(struct IWpaInterface *interface, const uint8_t *rawData)
746 {
747 const char *ifName = reinterpret_cast<const char *>(rawData);
748 char *replyDisc = static_cast<char *>(calloc(REPLY_SIZE, sizeof(char)));
749 if (replyDisc == nullptr) {
750 return;
751 }
752 uint32_t replyDiscLen = REPLY_SIZE;
753 struct HdiP2pReqService reqService;
754 (void)memset_s(&reqService, sizeof(struct HdiP2pReqService), 0, sizeof(struct HdiP2pReqService));
755 reqService.bssidLen = ETH_ADDR_LEN;
756 reqService.bssid = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * (reqService.bssidLen)));
757 if (reqService.bssid == nullptr) {
758 free(replyDisc);
759 return;
760 }
761 reqService.bssid[0] = 0x12;
762 reqService.bssid[1] = 0x34;
763 reqService.bssid[2] = 0x56;
764 reqService.bssid[3] = 0x78;
765 reqService.bssid[4] = 0xab;
766 reqService.bssid[5] = 0xcd;
767
768 interface->P2pReqServiceDiscovery(interface, ifName, &reqService, replyDisc, replyDiscLen);
769 free(replyDisc);
770 OsalMemFree(reqService.bssid);
771 HDF_LOGI("%{public}s: success", __FUNCTION__);
772 }
773
FuzzWpaInterfaceP2pCancelServiceDiscovery(struct IWpaInterface * interface,const uint8_t * rawData)774 void FuzzWpaInterfaceP2pCancelServiceDiscovery(struct IWpaInterface *interface, const uint8_t *rawData)
775 {
776 const char *ifName = reinterpret_cast<const char *>(rawData);
777 const char *id = reinterpret_cast<const char *>(rawData);
778
779 interface->P2pCancelServiceDiscovery(interface, ifName, id);
780 HDF_LOGI("%{public}s: success", __FUNCTION__);
781 }
782
FuzzWpaInterfaceP2pRespServerDiscovery(struct IWpaInterface * interface,const uint8_t * rawData)783 void FuzzWpaInterfaceP2pRespServerDiscovery(struct IWpaInterface *interface, const uint8_t *rawData)
784 {
785 const char *ifName = reinterpret_cast<const char *>(rawData);
786 struct HdiP2pServDiscReqInfo info;
787 (void)memset_s(&info, sizeof(struct HdiP2pServDiscReqInfo), 0, sizeof(struct HdiP2pServDiscReqInfo));
788
789 interface->P2pRespServerDiscovery(interface, ifName, &info);
790 HDF_LOGI("%{public}s: success", __FUNCTION__);
791 }
792
FuzzWpaInterfaceP2pConnect(struct IWpaInterface * interface,const uint8_t * rawData)793 void FuzzWpaInterfaceP2pConnect(struct IWpaInterface *interface, const uint8_t *rawData)
794 {
795 const char *ifName = reinterpret_cast<const char *>(rawData);
796 struct HdiP2pConnectInfo info;
797 (void)memset_s(&info, sizeof(struct HdiP2pConnectInfo), 0, sizeof(struct HdiP2pConnectInfo));
798 char *replyPin = static_cast<char *>(calloc(REPLY_SIZE, sizeof(char)));
799 if (replyPin == nullptr) {
800 return;
801 }
802 uint32_t replyPinLen = REPLY_SIZE;
803
804 interface->P2pConnect(interface, ifName, &info, replyPin, replyPinLen);
805 free(replyPin);
806 HDF_LOGI("%{public}s: success", __FUNCTION__);
807 }
808
FuzzWpaInterfaceP2pHid2dConnect(struct IWpaInterface * interface,const uint8_t * rawData)809 void FuzzWpaInterfaceP2pHid2dConnect(struct IWpaInterface *interface, const uint8_t *rawData)
810 {
811 const int macAddrIndexOne = 0;
812 const int macAddrIndexTwo = 1;
813 const int macAddrIndexThree = 2;
814 const int macAddrIndexFour = 3;
815 const int macAddrIndexFive = 4;
816 const int macAddrIndexSix = 5;
817 const char *ifName = reinterpret_cast<const char *>(rawData);
818 struct HdiHid2dConnectInfo info;
819 (void)memset_s(&info, sizeof(struct HdiHid2dConnectInfo), 0, sizeof(struct HdiHid2dConnectInfo));
820 info.bssidLen = ETH_ADDR_LEN;
821 info.bssid = static_cast<uint8_t *>(OsalMemCalloc(sizeof(uint8_t) * (info.bssidLen)));
822 if (info.bssid == nullptr) {
823 return;
824 }
825 info.bssid[macAddrIndexOne] = 0x00;
826 info.bssid[macAddrIndexTwo] = 0x00;
827 info.bssid[macAddrIndexThree] = 0x00;
828 info.bssid[macAddrIndexFour] = 0x00;
829 info.bssid[macAddrIndexFive] = 0x00;
830 info.bssid[macAddrIndexSix] = 0x00;
831 interface->P2pHid2dConnect(interface, ifName, &info);
832 OsalMemFree(info.bssid);
833 HDF_LOGI("%{public}s: success", __FUNCTION__);
834 }
835
FuzzWpaInterfaceP2pSetServDiscExternal(struct IWpaInterface * interface,const uint8_t * rawData)836 void FuzzWpaInterfaceP2pSetServDiscExternal(struct IWpaInterface *interface, const uint8_t *rawData)
837 {
838 const char *ifName = reinterpret_cast<const char *>(rawData);
839 int32_t mode = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
840
841 interface->P2pSetServDiscExternal(interface, ifName, mode);
842 HDF_LOGI("%{public}s: success", __FUNCTION__);
843 }
844
FuzzWpaInterfaceP2pRemoveGroup(struct IWpaInterface * interface,const uint8_t * rawData)845 void FuzzWpaInterfaceP2pRemoveGroup(struct IWpaInterface *interface, const uint8_t *rawData)
846 {
847 const char *ifName = reinterpret_cast<const char *>(rawData);
848 const char *groupName = reinterpret_cast<const char *>(rawData);
849
850 interface->P2pRemoveGroup(interface, ifName, groupName);
851 HDF_LOGI("%{public}s: success", __FUNCTION__);
852 }
853
FuzzWpaInterfaceP2pCancelConnect(struct IWpaInterface * interface,const uint8_t * rawData)854 void FuzzWpaInterfaceP2pCancelConnect(struct IWpaInterface *interface, const uint8_t *rawData)
855 {
856 const char *ifName = reinterpret_cast<const char *>(rawData);
857
858 interface->P2pCancelConnect(interface, ifName);
859 HDF_LOGI("%{public}s: success", __FUNCTION__);
860 }
861
FuzzWpaInterfaceP2pGetGroupConfig(struct IWpaInterface * interface,const uint8_t * rawData)862 void FuzzWpaInterfaceP2pGetGroupConfig(struct IWpaInterface *interface, const uint8_t *rawData)
863 {
864 const char *ifName = reinterpret_cast<const char *>(rawData);
865 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
866 const char *param = reinterpret_cast<const char *>(rawData);
867 char value[32] = {0};
868 uint32_t valueLen = *const_cast<uint32_t *>(reinterpret_cast<const uint32_t *>(rawData));
869
870 interface->P2pGetGroupConfig(interface, ifName, networkId, param, value, valueLen);
871 HDF_LOGI("%{public}s: success", __FUNCTION__);
872 }
873
FuzzWpaInterfaceP2pAddNetwork(struct IWpaInterface * interface,const uint8_t * rawData)874 void FuzzWpaInterfaceP2pAddNetwork(struct IWpaInterface *interface, const uint8_t *rawData)
875 {
876 const char *ifName = reinterpret_cast<const char *>(rawData);
877 int32_t networkId = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
878
879 interface->P2pAddNetwork(interface, ifName, &networkId);
880 HDF_LOGI("%{public}s: success", __FUNCTION__);
881 }
882
FuzzWpaInterfaceP2pGetPeer(struct IWpaInterface * interface,const uint8_t * rawData)883 void FuzzWpaInterfaceP2pGetPeer(struct IWpaInterface *interface, const uint8_t *rawData)
884 {
885 const char *ifName = reinterpret_cast<const char *>(rawData);
886 const char *bssid = reinterpret_cast<const char *>(rawData);
887 struct HdiP2pDeviceInfo info;
888 (void)memset_s(&info, sizeof(struct HdiP2pDeviceInfo), 0, sizeof(struct HdiP2pDeviceInfo));
889
890 interface->P2pGetPeer(interface, ifName, bssid, &info);
891 HDF_LOGI("%{public}s: success", __FUNCTION__);
892 }
893
FuzzWpaInterfaceP2pGetGroupCapability(struct IWpaInterface * interface,const uint8_t * rawData)894 void FuzzWpaInterfaceP2pGetGroupCapability(struct IWpaInterface *interface, const uint8_t *rawData)
895 {
896 const char *ifName = reinterpret_cast<const char *>(rawData);
897 const char *bssid = reinterpret_cast<const char *>(rawData);
898 int32_t cap = *const_cast<int32_t *>(reinterpret_cast<const int32_t *>(rawData));
899
900 interface->P2pGetGroupCapability(interface, ifName, bssid, &cap);
901 HDF_LOGI("%{public}s: success", __FUNCTION__);
902 }
903
FuzzWpaInterfaceP2pListNetworks(struct IWpaInterface * interface,const uint8_t * rawData)904 void FuzzWpaInterfaceP2pListNetworks(struct IWpaInterface *interface, const uint8_t *rawData)
905 {
906 const char *ifName = reinterpret_cast<const char *>(rawData);
907 struct HdiP2pNetworkList infoList;
908 (void)memset_s(&infoList, sizeof(struct HdiP2pNetworkList), 0, sizeof(struct HdiP2pNetworkList));
909
910 interface->P2pListNetworks(interface, ifName, &infoList);
911 HDF_LOGI("%{public}s: success", __FUNCTION__);
912 }
913
FuzzWpaInterfaceP2pSaveConfig(struct IWpaInterface * interface,const uint8_t * rawData)914 void FuzzWpaInterfaceP2pSaveConfig(struct IWpaInterface *interface, const uint8_t *rawData)
915 {
916 const char *ifName = reinterpret_cast<const char *>(rawData);
917
918 interface->P2pSaveConfig(interface, ifName);
919 HDF_LOGI("%{public}s: success", __FUNCTION__);
920 }
921