• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 
16 #ifndef HDI_STRUCT_TOOLKIT_H
17 #define HDI_STRUCT_TOOLKIT_H
18 #ifdef HDI_WPA_INTERFACE_SUPPORT
19 #include "wifi_hdi_wpa_client.h"
20 #include "wifi_hdi_wpa_sta_impl.h"
21 #include "wifi_hdi_wpa_callback.h"
22 #include "wifi_hdi_wpa_ap_impl.h"
23 #include "wifi_hdi_wpa_p2p_impl.h"
24 #include "wifi_hdi_util.h"
25 #include "wifi_common_util.h"
26 #include "hdi_struct_toolkit.h"
27 #include <securec.h>
28 #include <unistd.h>
29 #include <osal_mem.h>
30 
FreeHdiWifiWpaNetworkInfo(HdiWifiWpaNetworkInfo * hdiWifiWpaNetworkInfo)31 static void FreeHdiWifiWpaNetworkInfo(HdiWifiWpaNetworkInfo *hdiWifiWpaNetworkInfo)
32 {
33     free(hdiWifiWpaNetworkInfo->ssid);
34     free(hdiWifiWpaNetworkInfo->bssid);
35     free(hdiWifiWpaNetworkInfo->flags);
36     hdiWifiWpaNetworkInfo->ssid = nullptr;
37     hdiWifiWpaNetworkInfo->bssid = nullptr;
38     hdiWifiWpaNetworkInfo->flags = nullptr;
39     hdiWifiWpaNetworkInfo = nullptr;
40 }
41 
FreeHdiP2pNetworkInfo(HdiP2pNetworkInfo * hdiP2pNetworkInfo)42 static void FreeHdiP2pNetworkInfo(HdiP2pNetworkInfo *hdiP2pNetworkInfo)
43 {
44     if (hdiP2pNetworkInfo == nullptr) {
45         return;
46     }
47     if (hdiP2pNetworkInfo->ssid) {
48         OsalMemFree(hdiP2pNetworkInfo->ssid);
49     }
50     if (hdiP2pNetworkInfo->bssid) {
51         OsalMemFree(hdiP2pNetworkInfo->bssid);
52     }
53     if (hdiP2pNetworkInfo->flags) {
54         OsalMemFree(hdiP2pNetworkInfo->flags);
55     }
56     if (hdiP2pNetworkInfo->clientList) {
57         OsalMemFree(hdiP2pNetworkInfo->clientList);
58     }
59     hdiP2pNetworkInfo->ssid = nullptr;
60     hdiP2pNetworkInfo->bssid = nullptr;
61     hdiP2pNetworkInfo->flags = nullptr;
62     hdiP2pNetworkInfo->clientList = nullptr;
63 }
64 
FreeHdiP2pNetworkList(HdiP2pNetworkList * hdiP2pNetworkList)65 static void FreeHdiP2pNetworkList(HdiP2pNetworkList *hdiP2pNetworkList)
66 {
67     for (int i = 0; i < hdiP2pNetworkList->infoNum; i++) {
68         FreeHdiP2pNetworkInfo(&hdiP2pNetworkList->infos[i]);
69     }
70     if (hdiP2pNetworkList->infos) {
71         OsalMemFree(hdiP2pNetworkList->infos);
72     }
73     hdiP2pNetworkList->infos = nullptr;
74     hdiP2pNetworkList = nullptr;
75 }
76 
FreeHdiP2pDeviceInfo(HdiP2pDeviceInfo * hdiP2pDeviceInfo)77 static void FreeHdiP2pDeviceInfo(HdiP2pDeviceInfo *hdiP2pDeviceInfo)
78 {
79     free(hdiP2pDeviceInfo->srcAddress);
80     free(hdiP2pDeviceInfo->p2pDeviceAddress);
81     free(hdiP2pDeviceInfo->primaryDeviceType);
82     free(hdiP2pDeviceInfo->deviceName);
83     free(hdiP2pDeviceInfo->wfdDeviceInfo);
84     free(hdiP2pDeviceInfo->operSsid);
85     hdiP2pDeviceInfo->srcAddress = nullptr;
86     hdiP2pDeviceInfo->p2pDeviceAddress = nullptr;
87     hdiP2pDeviceInfo->primaryDeviceType = nullptr;
88     hdiP2pDeviceInfo->deviceName = nullptr;
89     hdiP2pDeviceInfo->wfdDeviceInfo = nullptr;
90     hdiP2pDeviceInfo->operSsid = nullptr;
91     hdiP2pDeviceInfo = nullptr;
92 }
93 #endif
94 #endif