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