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