1 /*
2  * Copyright (C) 2021-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 #ifndef OHOS_IDL_IWIFI_STRUCT_H
16 #define OHOS_IDL_IWIFI_STRUCT_H
17 
18 #include <stdint.h>
19 #include <stdbool.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 #define WIFI_IDL_FALSE 0
25 #define WIFI_IDL_TRUE 1
26 #define WIFI_SSID_LENGTH 132
27 #define WIFI_BSSID_LENGTH 18
28 #define WIFI_REASON_LENGTH 32
29 #define WIFI_NETWORK_FLAGS_LENGTH 64
30 #define WIFI_SCAN_INFO_CAPABILITY_LENGTH 256
31 #define WIFI_NETWORK_CONFIG_NAME_LENGTH 64
32 #define WIFI_NETWORK_CONFIG_VALUE_LENGTH 2048
33 #define WIFI_MAX_MAC_ADDR_LENGTH 17
34 #define WIFI_AP_PASSWORD_LENGTH 64
35 #define WIFI_INTERFACE_NAME_SIZE 32
36 #define WIFI_PIN_CODE_LENGTH 8
37 #define WIFI_MAX_TLVS_LENGTH 4096
38 #define WIFI_MAX_CHIP_IDS 4096
39 
40 /* IWifiIface */
41 /*
42  * This is a temporary definition. The empty structure compilation alarm needs
43  * to be deleted, affecting other alarms.
44  */
45 typedef struct TagIWifiIface {
46     int index;
47     int type;
48     char name[WIFI_INTERFACE_NAME_SIZE];
49     char macAddr[WIFI_MAX_MAC_ADDR_LENGTH + 1];
50 } IWifiIface;
51 
52 /* IWifiClientIface */
53 /*
54  * This is a temporary definition. The empty structure compilation alarm needs
55  * to be deleted, affecting other alarms.
56  */
57 typedef struct TagIWifiClientIface {
58     char name[WIFI_INTERFACE_NAME_SIZE];
59     int type;
60 } IWifiClientIface;
61 
62 /* IWifiApIface */
63 /*
64  * This is a temporary definition. The empty structure compilation alarm needs
65  * to be deleted, affecting other alarms.
66  */
67 typedef struct TagIWifiApIface {
68     char name[WIFI_INTERFACE_NAME_SIZE];
69     int type;
70 } IWifiApIface;
71 
72 /* IWifiChip */
73 /*
74  * This is a temporary definition. The empty structure compilation alarm needs
75  * to be deleted, affecting other alarms.
76  */
77 typedef struct TagIWifiChip {
78     int i;
79 } IWifiChip;
80 
81 typedef struct StSupplicantEventCallback {
82     void (*onScanNotify)(int32_t result);
83 } ISupplicantEventCallback;
84 
85 typedef struct ScanSettings {
86     int freqSize;
87     int *freqs;
88     int hiddenSsidSize;
89     char **hiddenSsid;
90     int scanStyle;
91 } ScanSettings;
92 
93 typedef struct ScanInfoElem {
94     unsigned int id;
95     char* content;
96     int size;
97 } ScanInfoElem;
98 
99 typedef struct ScanInfo {
100     char ssid[WIFI_SSID_LENGTH];
101     char bssid[WIFI_BSSID_LENGTH];
102     int freq;
103     int channelWidth;
104     int centerFrequency0;
105     int centerFrequency1;
106     ScanInfoElem* infoElems;
107     int ieSize;
108     int64_t features;
109     int siglv;
110     char flags[WIFI_SCAN_INFO_CAPABILITY_LENGTH];
111     int64_t timestamp;
112     int ant;
113     int isVhtInfoExist;
114     int isHtInfoExist;
115     int isHeInfoExist;
116     int isErpExist;
117     int maxRates;
118     int extMaxRates;
119     bool isHiLinkNetwork;
120 } ScanInfo;
121 
122 typedef struct WifiNetworkInfo {
123     int id;
124     char ssid[WIFI_SSID_LENGTH];
125     char bssid[WIFI_BSSID_LENGTH];
126     char flags[WIFI_NETWORK_FLAGS_LENGTH];
127 } WifiNetworkInfo;
128 
129 typedef struct PnoScanSettings {
130     int scanInterval;
131     int minRssi2Dot4Ghz;
132     int minRssi5Ghz;
133     int freqSize;
134     int *freqs;
135     int hiddenSsidSize;
136     char **hiddenSsid;
137     int savedSsidSize;
138     char **savedSsid;
139 } PnoScanSettings;
140 
141 /* Wifi Network configuration parameter flag */
142 typedef enum DeviceConfigType {
143     DEVICE_CONFIG_SSID = 0,            /* SSID */
144     DEVICE_CONFIG_PSK = 1,             /* psk */
145     DEVICE_CONFIG_KEYMGMT = 2,         /* key_mgmt,WPA-PSK,WPA-NONE,WPA-EAP */
146     DEVICE_CONFIG_PRIORITY = 3,        /* wpaNetwork Priority */
147     DEVICE_CONFIG_SCAN_SSID = 4,       /* Set this bit to 1 and deliver it when the hidden network is connected. */
148     DEVICE_CONFIG_EAP = 5,             /* EPA mode:/EAP/PEAP */
149     DEVICE_CONFIG_IDENTITY = 6,        /* Account name */
150     DEVICE_CONFIG_PASSWORD = 7,        /* Account password */
151     DEVICE_CONFIG_BSSID = 8,           /* bssid */
152     DEVICE_CONFIG_AUTH_ALGORITHMS = 9, /* auth algorithms */
153     DEVICE_CONFIG_WEP_KEY_IDX = 10,    /* wep key idx */
154     DEVICE_CONFIG_WEP_KEY_0 = 11,
155     DEVICE_CONFIG_WEP_KEY_1 = 12,
156     DEVICE_CONFIG_WEP_KEY_2 = 13,
157     DEVICE_CONFIG_WEP_KEY_3 = 14,
158     DEVICE_CONFIG_EAP_CLIENT_CERT = 15,
159     DEVICE_CONFIG_EAP_PRIVATE_KEY = 16,
160     DEVICE_CONFIG_EAP_PHASE2METHOD = 17,
161     DEVICE_CONFIG_IEEE80211W = 18,
162     DEVICE_CONFIG_ALLOW_PROTOCOLS = 19,
163     DEVICE_CONFIG_GROUP_CIPHERS = 20,
164     DEVICE_CONFIG_PAIRWISE_CIPHERS = 21,
165     DEVICE_CONFIG_SAE_PASSWD = 22,
166     DEVICE_CONFIG_EAP_CA_CERT = 23,
167     DEVICE_CONFIG_EAP_CERT_PWD = 24,
168     DEVICE_CONFIG_GROUP_MGMT_CIPHERS = 25,
169     DEVICE_CONFIG_WAPI_PSK = 26,
170     DEVICE_CONFIG_WAPI_PSK_TYPE = 27,
171     DEVICE_CONFIG_WAPI_USER_CERT = 28,
172     DEVICE_CONFIG_WAPI_CA_CERT = 29,
173     DEVICE_CONFIG_END_POS, /* Number of network configuration parameters, which is used as the last parameter. */
174 } DeviceConfigType;
175 
176 typedef struct WpaSsidField {
177     DeviceConfigType field;
178     char fieldName[WIFI_NETWORK_CONFIG_NAME_LENGTH];
179     int flag; /* 0 need add "" 1 no need */
180 } WpaSsidField;
181 
182 typedef struct SetNetworkConfig {
183     DeviceConfigType cfgParam;                       /* param */
184     char cfgValue[WIFI_NETWORK_CONFIG_VALUE_LENGTH]; /* param value */
185 } SetNetworkConfig;
186 
187 typedef struct GetNetworkConfig {
188     int networkId;
189     char param[WIFI_NETWORK_CONFIG_NAME_LENGTH];
190     char value[WIFI_NETWORK_CONFIG_VALUE_LENGTH];
191 } GetNetworkConfig;
192 
193 typedef struct WifiWpsParam {
194     int anyFlag;
195     int multiAp;
196     char bssid[WIFI_BSSID_LENGTH];
197     char pinCode[WIFI_PIN_CODE_LENGTH + 1];
198 } WifiWpsParam;
199 
200 typedef struct WifiRoamCapability {
201     int maxBlocklistSize;
202     int maxTrustlistSize;
203 } WifiRoamCapability;
204 
205 typedef struct WpaSignalInfo {
206     int signal;
207     int txrate;
208     int rxrate;
209     int noise;
210     int frequency;
211     int txPackets;
212     int rxPackets;
213     int snr;
214     int chload;
215     int ulDelay;
216     int txBytes;
217     int rxBytes;
218     int txFailed;
219 } WpaSignalInfo;
220 
221 typedef struct HostapdConfig {
222     char ssid[WIFI_SSID_LENGTH];
223     int32_t ssidLen;
224     char preSharedKey[WIFI_AP_PASSWORD_LENGTH];
225     int32_t preSharedKeyLen;
226     int32_t securityType;
227     int32_t band;
228     int32_t channel;
229     int32_t maxConn;
230 } HostapdConfig;
231 
232 typedef struct CStationInfo {
233     int type;
234     char mac[WIFI_MAX_MAC_ADDR_LENGTH + 1];
235 } CStationInfo;
236 
237 struct NeedParseIe {
238     ScanInfoElem* ieExtern;
239     ScanInfoElem* ieVhtOper;
240     ScanInfoElem* ieHtOper;
241     ScanInfoElem* ieMaxRate;
242     ScanInfoElem* ieErp;
243     ScanInfoElem* ieExtMaxRate;
244 };
245 
246 typedef struct IWifiApEventCallback {
247     void (*onStaJoinOrLeave)(const CStationInfo *info, int id);
248     void (*onApEnableOrDisable)(int event, int id);
249 } IWifiApEventCallback;
250 
251 typedef enum IfaceType { TYPE_STA, TYPE_AP, TYPE_P2P, TYPE_NAN } IfaceType;
252 
253 /*----------------p2p struct defines begin-------------------------*/
254 #define WIFI_P2P_TMP_MSG_LENGTH_128 128
255 #define WIFI_P2P_TMP_MSG_LENGTH_64 64
256 #define WIFI_P2P_MAX_GROUP_IFACE_NAME_LENGTH 64
257 #define WIFI_P2P_DEVICE_TYPE_LENGTH 64
258 #define WIFI_P2P_DEVICE_NAME_LENGTH 128
259 #define WIFI_P2P_WFD_DEVICE_INFO_LENGTH 128
260 #define WIFI_P2P_IDL_SERVER_NAME_LENGTH 256
261 #define WIFI_P2P_IDL_SERVER_INFO_LENGTH 256
262 #define WIFI_P2P_GROUP_CONFIG_VALUE_LENGTH 256
263 
264 typedef struct P2pDeviceInfo {
265     char srcAddress[WIFI_MAX_MAC_ADDR_LENGTH + 1];
266     char p2pDeviceAddress[WIFI_MAX_MAC_ADDR_LENGTH + 1];
267     char primaryDeviceType[WIFI_P2P_DEVICE_TYPE_LENGTH];
268     char deviceName[WIFI_P2P_DEVICE_NAME_LENGTH];
269     int configMethods;
270     int deviceCapabilities;
271     int groupCapabilities;
272     char wfdDeviceInfo[WIFI_P2P_WFD_DEVICE_INFO_LENGTH];
273     unsigned int wfdLength;
274     char operSsid[WIFI_P2P_DEVICE_NAME_LENGTH];
275 } P2pDeviceInfo;
276 
277 typedef struct P2pGroupInfo {
278     int isGo;
279     int isPersistent;
280     int frequency;
281     char groupName[WIFI_P2P_MAX_GROUP_IFACE_NAME_LENGTH];
282     char ssid[WIFI_SSID_LENGTH];
283     char psk[WIFI_P2P_TMP_MSG_LENGTH_128];
284     char passphrase[WIFI_P2P_TMP_MSG_LENGTH_128];
285     char goDeviceAddress[WIFI_MAX_MAC_ADDR_LENGTH + 1];
286 } P2pGroupInfo;
287 
288 typedef struct P2pInvitationInfo {
289     int type; /* 0:Received, 1:Accepted */
290     int persistentNetworkId;
291     int operatingFrequency;
292     char srcAddress[WIFI_MAX_MAC_ADDR_LENGTH + 1];
293     char goDeviceAddress[WIFI_MAX_MAC_ADDR_LENGTH + 1];
294     char bssid[WIFI_MAX_MAC_ADDR_LENGTH + 1];
295 } P2pInvitationInfo;
296 
297 typedef struct P2pServDiscReqInfo {
298     int freq;
299     int dialogToken;
300     int updateIndic;
301     int tlvsLength;
302     char mac[WIFI_MAX_MAC_ADDR_LENGTH + 1];
303     unsigned char *tlvs;
304 } P2pServDiscReqInfo;
305 
306 typedef struct P2pServiceInfo {
307     int mode; /* 0/1, upnp/bonjour  */
308     int version;
309     char name[WIFI_P2P_IDL_SERVER_NAME_LENGTH];
310     char query[WIFI_P2P_IDL_SERVER_INFO_LENGTH];
311     char resp[WIFI_P2P_IDL_SERVER_INFO_LENGTH];
312 } P2pServiceInfo;
313 
314 typedef struct P2pNetworkInfo {
315     int id;
316     char ssid[WIFI_SSID_LENGTH];
317     char bssid[WIFI_MAX_MAC_ADDR_LENGTH + 1];
318     char flags[WIFI_P2P_TMP_MSG_LENGTH_64];
319 } P2pNetworkInfo;
320 
321 typedef struct P2pNetworkList {
322     int infoNum;
323     P2pNetworkInfo *infos;
324 } P2pNetworkList;
325 
326 typedef struct P2pConnectInfo {
327     int persistent; /* |persistent=<network id>] */
328     int mode; /* [join|auth] */
329     int goIntent; /* [go_intent=<0..15>] */
330     int provdisc; /* [provdisc] */
331     char peerDevAddr[WIFI_MAX_MAC_ADDR_LENGTH + 1];
332     char pin[WIFI_PIN_CODE_LENGTH + 1]; /* <pbc|pin|PIN#|p2ps> */
333 } P2pConnectInfo;
334 
335 /* Wifi P2P Group Network configuration parameter flag */
336 typedef enum P2pGroupConfigType {
337     GROUP_CONFIG_SSID = 0,
338     GROUP_CONFIG_BSSID,
339     GROUP_CONFIG_PSK,
340     GROUP_CONFIG_PROTO,
341     GROUP_CONFIG_KEY_MGMT,
342     GROUP_CONFIG_PAIRWISE,
343     GROUP_CONFIG_AUTH_ALG,
344     GROUP_CONFIG_MODE,
345     GROUP_CONFIG_DISABLED,
346     GROUP_CONFIG_END_POS,
347 } P2pGroupConfigType;
348 
349 typedef struct P2pGroupConfig {
350     P2pGroupConfigType cfgParam;                       /* param */
351     char cfgValue[WIFI_P2P_GROUP_CONFIG_VALUE_LENGTH]; /* param value */
352 } P2pGroupConfig;
353 
354 typedef struct Hid2dConnectInfo {
355     char ssid[WIFI_SSID_LENGTH];
356     char bssid[WIFI_MAX_MAC_ADDR_LENGTH + 1];
357     char passphrase[WIFI_P2P_TMP_MSG_LENGTH_128];
358     int frequency;
359     int isLegacyGo;
360 } Hid2dConnectInfo;
361 /* ----------------p2p struct defines end--------------------------- */
362 
363 #ifdef __cplusplus
364 }
365 #endif
366 #endif
367