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 } ScanInfo; 110 111 typedef struct WifiNetworkInfo { 112 int id; 113 char ssid[WIFI_SSID_LENGTH]; 114 char bssid[WIFI_BSSID_LENGTH]; 115 char flags[WIFI_NETWORK_FLAGS_LENGTH]; 116 } WifiNetworkInfo; 117 118 typedef struct PnoScanSettings { 119 int scanInterval; 120 int minRssi2Dot4Ghz; 121 int minRssi5Ghz; 122 int freqSize; 123 int *freqs; 124 int hiddenSsidSize; 125 char **hiddenSsid; 126 int savedSsidSize; 127 char **savedSsid; 128 } PnoScanSettings; 129 130 /* Wifi Network configuration parameter flag */ 131 typedef enum DeviceConfigType { 132 DEVICE_CONFIG_SSID = 0, /* SSID */ 133 DEVICE_CONFIG_PSK = 1, /* psk */ 134 DEVICE_CONFIG_KEYMGMT = 2, /* key_mgmt,WPA-PSK,WPA-NONE,WPA-EAP */ 135 DEVICE_CONFIG_PRIORITY = 3, /* wpaNetwork Priority */ 136 DEVICE_CONFIG_SCAN_SSID = 4, /* Set this bit to 1 and deliver it when the hidden network is connected. */ 137 DEVICE_CONFIG_EAP = 5, /* EPA mode:/EAP/PEAP */ 138 DEVICE_CONFIG_IDENTITY = 6, /* Account name */ 139 DEVICE_CONFIG_PASSWORD = 7, /* Account password */ 140 DEVICE_CONFIG_BSSID = 8, /* bssid */ 141 DEVICE_CONFIG_AUTH_ALGORITHMS = 9, /* auth algorithms */ 142 DEVICE_CONFIG_WEP_KEY_IDX = 10, /* wep key idx */ 143 DEVICE_CONFIG_WEP_KEY_0 = 11, 144 DEVICE_CONFIG_WEP_KEY_1 = 12, 145 DEVICE_CONFIG_WEP_KEY_2 = 13, 146 DEVICE_CONFIG_WEP_KEY_3 = 14, 147 DEVICE_CONFIG_EAP_CLIENT_CERT = 15, 148 DEVICE_CONFIG_EAP_PRIVATE_KEY = 16, 149 DEVICE_CONFIG_EAP_PHASE2METHOD = 17, 150 DEVICE_CONFIG_END_POS, /* Number of network configuration parameters, which is used as the last parameter. */ 151 } DeviceConfigType; 152 153 typedef struct SetNetworkConfig { 154 DeviceConfigType cfgParam; /* param */ 155 char cfgValue[WIFI_NETWORK_CONFIG_VALUE_LENGTH]; /* param value */ 156 } SetNetworkConfig; 157 158 typedef struct GetNetworkConfig { 159 int networkId; 160 char param[WIFI_NETWORK_CONFIG_NAME_LENGTH]; 161 char value[WIFI_NETWORK_CONFIG_VALUE_LENGTH]; 162 } GetNetworkConfig; 163 164 typedef struct WifiWpsParam { 165 int anyFlag; 166 int multiAp; 167 char bssid[WIFI_BSSID_LENGTH]; 168 char pinCode[WIFI_PIN_CODE_LENGTH + 1]; 169 } WifiWpsParam; 170 171 typedef struct WifiRoamCapability { 172 int maxBlocklistSize; 173 int maxTrustlistSize; 174 } WifiRoamCapability; 175 176 typedef struct WpaSignalInfo { 177 int signal; 178 int txrate; 179 int rxrate; 180 int noise; 181 int frequency; 182 } WpaSignalInfo; 183 184 typedef struct HostapdConfig { 185 char ssid[WIFI_SSID_LENGTH]; 186 int32_t ssidLen; 187 char preSharedKey[WIFI_AP_PASSWORD_LENGTH]; 188 int32_t preSharedKeyLen; 189 int32_t securityType; 190 int32_t band; 191 int32_t channel; 192 int32_t maxConn; 193 } HostapdConfig; 194 195 typedef struct CStationInfo { 196 int type; 197 char mac[WIFI_MAC_ADDR_LENGTH + 1]; 198 } CStationInfo; 199 200 typedef struct IWifiApEventCallback { 201 void (*onStaJoinOrLeave)(const CStationInfo *info, int id); 202 void (*onApEnableOrDisable)(int event, int id); 203 } IWifiApEventCallback; 204 205 typedef enum IfaceType { TYPE_STA, TYPE_AP, TYPE_P2P, TYPE_NAN } IfaceType; 206 207 /*----------------p2p struct defines begin-------------------------*/ 208 #define WIFI_P2P_TMP_MSG_LENGTH_128 128 209 #define WIFI_P2P_TMP_MSG_LENGTH_64 64 210 #define WIFI_P2P_MAX_GROUP_IFACE_NAME_LENGTH 64 211 #define WIFI_P2P_DEVICE_TYPE_LENGTH 64 212 #define WIFI_P2P_DEVICE_NAME_LENGTH 128 213 #define WIFI_P2P_WFD_DEVICE_INFO_LENGTH 32 214 #define WIFI_P2P_IDL_SERVER_NAME_LENGTH 256 215 #define WIFI_P2P_IDL_SERVER_INFO_LENGTH 256 216 #define WIFI_P2P_GROUP_CONFIG_VALUE_LENGTH 256 217 218 typedef struct P2pDeviceInfo { 219 char srcAddress[WIFI_MAC_ADDR_LENGTH + 1]; 220 char p2pDeviceAddress[WIFI_MAC_ADDR_LENGTH + 1]; 221 char primaryDeviceType[WIFI_P2P_DEVICE_TYPE_LENGTH]; 222 char deviceName[WIFI_P2P_DEVICE_NAME_LENGTH]; 223 int configMethods; 224 int deviceCapabilities; 225 int groupCapabilities; 226 char wfdDeviceInfo[WIFI_P2P_WFD_DEVICE_INFO_LENGTH]; 227 unsigned int wfdLength; 228 char operSsid[WIFI_P2P_DEVICE_NAME_LENGTH]; 229 } P2pDeviceInfo; 230 231 typedef struct P2pGroupInfo { 232 int isGo; 233 int isPersistent; 234 int frequency; 235 char groupName[WIFI_P2P_MAX_GROUP_IFACE_NAME_LENGTH]; 236 char ssid[WIFI_SSID_LENGTH]; 237 char psk[WIFI_P2P_TMP_MSG_LENGTH_128]; 238 char passphrase[WIFI_P2P_TMP_MSG_LENGTH_128]; 239 char goDeviceAddress[WIFI_MAC_ADDR_LENGTH + 1]; 240 } P2pGroupInfo; 241 242 typedef struct P2pInvitationInfo { 243 int type; /* 0:Received, 1:Accepted */ 244 int persistentNetworkId; 245 int operatingFrequency; 246 char srcAddress[WIFI_MAC_ADDR_LENGTH + 1]; 247 char goDeviceAddress[WIFI_MAC_ADDR_LENGTH + 1]; 248 char bssid[WIFI_MAC_ADDR_LENGTH + 1]; 249 } P2pInvitationInfo; 250 251 typedef struct P2pServDiscReqInfo { 252 int freq; 253 int dialogToken; 254 int updateIndic; 255 int tlvsLength; 256 char mac[WIFI_MAC_ADDR_LENGTH + 1]; 257 unsigned char *tlvs; 258 } P2pServDiscReqInfo; 259 260 typedef struct P2pServiceInfo { 261 int mode; /* 0/1, upnp/bonjour */ 262 int version; 263 char name[WIFI_P2P_IDL_SERVER_NAME_LENGTH]; 264 char query[WIFI_P2P_IDL_SERVER_INFO_LENGTH]; 265 char resp[WIFI_P2P_IDL_SERVER_INFO_LENGTH]; 266 } P2pServiceInfo; 267 268 typedef struct P2pNetworkInfo { 269 int id; 270 char ssid[WIFI_SSID_LENGTH]; 271 char bssid[WIFI_MAC_ADDR_LENGTH + 1]; 272 char flags[WIFI_P2P_TMP_MSG_LENGTH_64]; 273 } P2pNetworkInfo; 274 275 typedef struct P2pNetworkList { 276 int infoNum; 277 P2pNetworkInfo *infos; 278 } P2pNetworkList; 279 280 typedef struct P2pConnectInfo { 281 int persistent; /* |persistent=<network id>] */ 282 int mode; /* [join|auth] */ 283 int goIntent; /* [go_intent=<0..15>] */ 284 int provdisc; /* [provdisc] */ 285 char peerDevAddr[WIFI_MAC_ADDR_LENGTH + 1]; 286 char pin[WIFI_PIN_CODE_LENGTH + 1]; /* <pbc|pin|PIN#|p2ps> */ 287 } P2pConnectInfo; 288 289 /* Wifi P2P Group Network configuration parameter flag */ 290 typedef enum P2pGroupConfigType { 291 GROUP_CONFIG_SSID = 0, 292 GROUP_CONFIG_BSSID, 293 GROUP_CONFIG_PSK, 294 GROUP_CONFIG_PROTO, 295 GROUP_CONFIG_KEY_MGMT, 296 GROUP_CONFIG_PAIRWISE, 297 GROUP_CONFIG_AUTH_ALG, 298 GROUP_CONFIG_MODE, 299 GROUP_CONFIG_DISABLED, 300 GROUP_CONFIG_END_POS, 301 } P2pGroupConfigType; 302 303 typedef struct P2pGroupConfig { 304 P2pGroupConfigType cfgParam; /* param */ 305 char cfgValue[WIFI_P2P_GROUP_CONFIG_VALUE_LENGTH]; /* param value */ 306 } P2pGroupConfig; 307 308 typedef struct Hid2dConnectInfo { 309 char ssid[WIFI_SSID_LENGTH]; 310 char bssid[WIFI_MAC_ADDR_LENGTH + 1]; 311 char passphrase[WIFI_P2P_TMP_MSG_LENGTH_128]; 312 int frequency; 313 } Hid2dConnectInfo; 314 /* ----------------p2p struct defines end--------------------------- */ 315 316 #ifdef __cplusplus 317 } 318 #endif 319 #endif 320