1 /* 2 * Copyright (C) 2021 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 OHOS_WIFI_HAL_DEFINE_H 17 #define OHOS_WIFI_HAL_DEFINE_H 18 19 /* Contains common header files. */ 20 #include <stdint.h> 21 #include <stdio.h> 22 #include <string.h> 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 #define WIFI_COUNTRY_CODE_MAXLEN 2 28 #define WIFI_IFACE_NAME_MAXLEN 32 29 #define WIFI_P2P_WPS_NAME_LENGTH 128 30 #define WIFI_P2P_WPS_METHODS_LENGTH 256 31 #define WIFI_P2P_WFD_DEVICE_CONF_LENGTH 256 32 #define WIFI_P2P_SERVE_INFO_LENGTH 256 33 #define WIFI_P2P_SERVE_DISCOVER_MSG_LENGTH 256 34 #define WIFI_P2P_SERVER_DISCOVERY_SEQUENCE_LENGTH 64 35 #define WIFI_P2P_GROUP_IFNAME_LENGTH 128 36 #define WIFI_P2P_SERVER_NAME_LENGTH 256 37 #define WIFI_NETWORK_PSK_MAXLEN 64 38 39 typedef enum WifiErrorNo { 40 WIFI_HAL_SUCCESS = 0, /* Success. */ 41 WIFI_HAL_FAILED = 1, /* Failed. */ 42 WIFI_HAL_SCAN_BUSY = 2, /* Scan failed. Scan busy. */ 43 WIFI_HAL_PBC_OVERLAP = 3, /* WPS PBC mode overlap. */ 44 WIFI_HAL_SUPPLICANT_NOT_INIT = 4, /* The wpa_supplicant is not initialized or fails to be initialized. */ 45 WIFI_HAL_OPEN_SUPPLICANT_FAILED = 5, /* Start wpa_supplicant failed. */ 46 WIFI_HAL_CONN_SUPPLICANT_FAILED = 6, /* Connect wpa_supplicant failed. */ 47 WIFI_HAL_HOSTAPD_NOT_INIT = 7, /* Hostapd is not initialized or initialization fails. */ 48 WIFI_HAL_OPEN_HOSTAPD_FAILED = 8, /* Start hostapd failed. */ 49 WIFI_HAL_CONN_HOSTAPD_FAILED = 9, /* Connect hostapd failed. */ 50 WIFI_HAL_NOT_SUPPORT = 10, /* Not supported currently. */ 51 WIFI_HAL_GET_WIFI_COND_FAILED, /* Initialized wificond failed. */ 52 WIFI_HAL_BUFFER_TOO_LITTLE, /* request buffer size too small */ 53 WIFI_HAL_INPUT_MAC_INVALID, 54 WIFI_HAL_GET_VENDOR_HAL_FAILED, /* Initialized vendor hal failed. */ 55 WIFI_HAL_VENDOR_UNKNOWN, 56 WIFI_HAL_VENDOR_UNINITIALIZED, 57 WIFI_HAL_VENDOR_NOT_AVAILABLE, 58 WIFI_HAL_VENDOR_INVALID_ARGS, 59 WIFI_HAL_VENDOR_INVALID_REQUEST_ID, 60 WIFI_HAL_VENDOR_TIMED_OUT, 61 WIFI_HAL_VENDOR_TOO_MANY_REQUESTS, 62 WIFI_HAL_VENDOR_OUT_OF_MEMORY, 63 WIFI_HAL_VENDOR_BUSY, 64 WIFI_HAL_INVALID_PARAM, 65 WIFI_HAL_GET_P2P_GROUP_INFACE_FAILED, 66 } WifiErrorNo; 67 68 /* ID of the callback event for registering the Hal service. */ 69 typedef enum WifiHalEvent { 70 WIFI_FAILURE_EVENT = 100, /* Driver loading/unloading failure. */ 71 WIFI_START_EVENT, /* The driver has been loaded. */ 72 WIFI_STOP_EVENT, /* Driver uninstalled. */ 73 WIFI_ADD_IFACE_EVENT, /* The network device interface has been added. */ 74 WIFI_REMOVE_IFACE_EVENT, /* The network device interface has been deleted. */ 75 WIFI_STA_JOIN_EVENT, /* STA connection notification in AP mode. */ 76 WIFI_STA_LEAVE_EVENT, /* STA disconnection notification in AP mode. */ 77 WIFI_SCAN_INFO_NOTIFY_EVENT, /* Scan info notification. */ 78 WIFI_CONNECT_CHANGED_NOTIFY_EVENT, /* Connection status change notification. */ 79 WIFI_AP_ENABLE_EVENT, /* AP enabling notification. */ 80 WIFI_AP_DISABLE_EVENT, /* AP closure notification. */ 81 WIFI_WPA_STATE_EVENT, /* WPA status change. */ 82 WIFI_SSID_WRONG_KEY, /* Incorrect password. */ 83 WIFI_CONNECTION_FULL_EVENT, /* connection is full */ 84 WIFI_CONNECTION_REJECT_EVENT, /* connection reject */ 85 WIFI_WPS_OVERLAP, /* wps pbc overlap */ 86 WIFI_WPS_TIME_OUT, /* wps connect time out */ 87 WIFI_P2P_SUP_CONNECTION_EVENT, /* Connection result of the wpa_supplicant client */ 88 SUP_CONN_FAILED_EVENT, /* Wpa_supplicant client connection failure event */ 89 P2P_DEVICE_FOUND_EVENT, /* Device discovery event */ 90 P2P_DEVICE_LOST_EVENT, /* Device loss event */ 91 P2P_GO_NEGOTIATION_REQUEST_EVENT, /* Event of receiving a GO negotiation request */ 92 P2P_GO_NEGOTIATION_SUCCESS_EVENT, /* The GO negotiation is successful */ 93 P2P_GO_NEGOTIATION_FAILURE_EVENT, /* The GO negotiation fails */ 94 P2P_INVITATION_RECEIVED_EVENT, /* P2P invitation request event */ 95 P2P_INVITATION_RESULT_EVENT, /* P2P invitation result */ 96 P2P_GROUP_FORMATION_SUCCESS_EVENT, /* The group is created successfully */ 97 P2P_GROUP_FORMATION_FAILURE_EVENT, /* The group is created failure */ 98 P2P_GROUP_STARTED_EVENT, /* Group Start Event */ 99 P2P_GROUP_REMOVED_EVENT, /* Group removed event */ 100 P2P_PROV_DISC_PBC_REQ_EVENT, /* Provision Discovery request event */ 101 P2P_PROV_DISC_PBC_RSP_EVENT, /* Provision Discovery Response Event */ 102 P2P_PROV_DISC_ENTER_PIN_EVENT, /* Provision Discovery PIN input event */ 103 P2P_PROV_DISC_SHOW_PIN_EVENT, /* Provision Discovery Display PIN Event */ 104 P2P_FIND_STOPPED_EVENT, /* Device search stop event */ 105 P2P_SERV_DISC_RESP_EVENT, /* Service response event */ 106 P2P_PROV_DISC_FAILURE_EVENT, /* Provision Discovery failure event */ 107 AP_STA_DISCONNECTED_EVENT, /* STA Disconnected from AP */ 108 AP_STA_CONNECTED_EVENT, /* STA and AP connected event */ 109 P2P_SERV_DISC_REQ_EVENT, /* Service discovery request event */ 110 WIFI_HAL_MAX_EVENT, 111 } WifiHalEvent; 112 113 #define WIFI_BSSID_LENGTH 18 114 #define WIFI_NETWORK_FLAGS_LENGTH 64 115 #define WIFI_SSID_LENGTH 132 116 #define WIFI_SCAN_INFO_CAPABILITY_LENGTH 256 117 #define WIFI_NETWORK_CONFIG_NAME_LENGTH 64 118 #define WIFI_NETWORK_CONFIG_VALUE_LENGTH 256 119 #define WIFI_P2P_GROUP_CONFIG_VALUE_LENGTH 256 120 #define WIFI_MAC_LENGTH 17 121 #define WIFI_AP_PASSWORD_LENGTH 64 122 #define WIFI_PIN_CODE_LENGTH 8 123 124 /* Wifi network configuration parameter flag. */ 125 typedef enum DeviceConfigType { 126 DEVICE_CONFIG_SSID = 0, /* Network Name. */ 127 DEVICE_CONFIG_PSK = 1, /* Password. */ 128 /** 129 * Encryption Mode: WPA-PSK - wpa/wp2; NONE - password less network; WPA-EAP, SAE, wpa3. 130 */ 131 DEVICE_CONFIG_KEYMGMT = 2, 132 DEVICE_CONFIG_PRIORITY = 3, /* WPA network priority */ 133 /** 134 * Set this bit to 1 and deliver it when the hidden network is connected. 135 * In other cases, set this bit to 0 but do not deliver it. 136 */ 137 DEVICE_CONFIG_SCAN_SSID = 4, 138 DEVICE_CONFIG_EAP = 5, /* EPA Mode:/EAP/PEAP. */ 139 DEVICE_CONFIG_IDENTITY = 6, /* Account name. */ 140 DEVICE_CONFIG_PASSWORD = 7, /* Account password. */ 141 DEVICE_CONFIG_BSSID = 8, /* bssid. */ 142 DEVICE_CONFIG_AUTH_ALGORITHMS = 9, /* auth algorithms */ 143 DEVICE_CONFIG_WEP_KEY_IDX = 10, /* wep key idx */ 144 DEVICE_CONFIG_WEP_KEY_0 = 11, 145 DEVICE_CONFIG_WEP_KEY_1 = 12, 146 DEVICE_CONFIG_WEP_KEY_2 = 13, 147 DEVICE_CONFIG_WEP_KEY_3 = 14, 148 /** 149 * Number of network configuration parameters, which is used as the last 150 * parameter. 151 */ 152 DEVICE_CONFIG_END_POS, 153 } DeviceConfigType; 154 155 typedef enum P2pGroupConfigType { 156 GROUP_CONFIG_SSID = 0, 157 GROUP_CONFIG_BSSID, 158 GROUP_CONFIG_PSK, 159 GROUP_CONFIG_PROTO, 160 GROUP_CONFIG_KEY_MGMT, 161 GROUP_CONFIG_PAIRWISE, 162 GROUP_CONFIG_AUTH_ALG, 163 GROUP_CONFIG_MODE, 164 GROUP_CONFIG_DISABLED, 165 GROUP_CONFIG_END_POS, 166 } P2pGroupConfigType; 167 168 /* AP Band */ 169 typedef enum ApBand { 170 AP_NONE_BAND = 0, /* Unknown Band */ 171 AP_2GHZ_BAND = 1, /* 2.4GHz Band */ 172 AP_5GHZ_BAND = 2, /* 5GHz Band */ 173 AP_ANY_BAND = 3, /* Dual-mode frequency band */ 174 AP_DFS_BAND = 4 175 } ApBand; 176 177 /* Encryption Mode */ 178 typedef enum KeyMgmt { 179 NONE = 0, /* WPA not used. */ 180 WPA_PSK = 1, /* WPA pre-shared key ({@ preSharedKey} needs to be specified.) */ 181 /** 182 * WPA with EAP authentication. It is usually used with an external 183 * authentication server. 184 */ 185 WPA_EAP = 2, 186 /** 187 * IEEE 802.1X with EAP authentication and optionally dynamically generated 188 * WEP keys. 189 */ 190 IEEE8021X = 3, 191 /** 192 * WPA2 pre-shared key, which is used for soft APs({@ preSharedKey} needs to 193 * be specified). 194 */ 195 WPA2_PSK = 4, 196 OSEN = 5, 197 FT_PSK = 6, 198 FT_EAP = 7 199 } KeyMgmt; 200 201 /* chip supported interface combination mode */ 202 typedef enum WifiInterfaceCombMode { 203 STA_STA_MODE, 204 STA_AP_MODE, 205 STA_P2P_MODE, 206 STA_NAN_MODE, 207 AP_NAN_MODE, 208 } WifiInterfaceCombMode; 209 210 typedef enum HalWpsMethod { 211 HAL_WPS_METHOD_PBC, 212 HAL_WPS_METHOD_DISPLAY, 213 HAL_WPS_METHOD_KEYPAD, 214 HAL_WPS_METHOD_LABEL, 215 HAL_WPS_METHOD_INVALID 216 } HalWpsMethod; 217 218 #ifdef __cplusplus 219 } 220 #endif 221 #endif