1 /* 2 * Copyright (C) 2024 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 WPA_SUPPLICANT_HAL_H 16 #define WPA_SUPPLICANT_HAL_H 17 18 #include <sys/types.h> 19 #include <stdlib.h> 20 #include <string.h> 21 #include <malloc.h> 22 #include <stdint.h> 23 #include <stdbool.h> 24 #include "wpa_hal_struct.h" 25 #include "wpa_hal_define.h" 26 #include "wpa_hdi_util.h" 27 #include "v1_1/iwpa_interface.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 #define KEY_MGMT_LENG 20 33 struct WpaHalCmdStatus { 34 char bssid[WIFI_BSSID_LENGTH]; 35 int freq; 36 char ssid[WIFI_SSID_LENGTH]; 37 int id; 38 char keyMgmt[KEY_MGMT_LENG]; 39 char address[WIFI_BSSID_LENGTH]; 40 }; 41 42 struct WpaSetNetworkArgv { 43 int id; /* network id */ 44 DeviceConfigType param; /* set network param */ 45 char value[WIFI_NETWORK_CONFIG_VALUE_LENGTH]; /* set network value */ 46 }; 47 48 typedef struct WpaSsidField { 49 DeviceConfigType field; 50 char fieldName[32]; 51 int flag; /* 0 need add "" 1 no need */ 52 } WpaSsidField; 53 54 struct WpaGetNetworkArgv { 55 int id; /* network id. */ 56 char param[WIFI_NETWORK_CONFIG_VALUE_LENGTH]; /* parameter */ 57 }; 58 59 struct WpaWpsPbcArgv { 60 int anyFlag; 61 int multiAp; 62 char bssid[WIFI_BSSID_LENGTH]; 63 }; 64 65 struct WpaWpsPinArgv { 66 char bssid[WIFI_BSSID_LENGTH]; 67 char pinCode[WIFI_PIN_CODE_LENGTH + 1]; 68 }; 69 70 struct NeedParseIe { 71 ScanInfoElem* ieExtern; 72 ScanInfoElem* ieVhtOper; 73 ScanInfoElem* ieHtOper; 74 ScanInfoElem* ieMaxRate; 75 ScanInfoElem* ieErp; 76 ScanInfoElem* ieExtMaxRate; 77 }; 78 79 typedef struct WifiWpaStaInterface WifiWpaStaInterface; 80 struct WifiWpaStaInterface { 81 int staNo; 82 char ifname[WIFI_IFACE_NAME_MAXLEN]; 83 WifiWpaStaInterface *next; 84 85 int (*wpaCliCmdStatus)(WifiWpaStaInterface *p, const char *ifName, struct WpaHalCmdStatus *pcmd); 86 int (*wpaCliCmdAddNetworks)(WifiWpaStaInterface *p); 87 int (*wpaCliCmdReconnect)(WifiWpaStaInterface *p); 88 int (*wpaCliCmdReassociate)(WifiWpaStaInterface *p); 89 int (*wpaCliCmdDisconnect)(WifiWpaStaInterface *p); 90 int (*wpaCliCmdSaveConfig)(WifiWpaStaInterface *p); 91 int (*wpaCliCmdSetNetwork)(WifiWpaStaInterface *p, const struct WpaSetNetworkArgv *argv); 92 int (*wpaCliCmdEnableNetwork)(WifiWpaStaInterface *p, int networkId); 93 int (*wpaCliCmdSelectNetwork)(WifiWpaStaInterface *p, int networkId); 94 int (*wpaCliCmdDisableNetwork)(WifiWpaStaInterface *p, int networkId); 95 int (*wpaCliCmdRemoveNetwork)(WifiWpaStaInterface *p, int networkId); 96 int (*wpaCliCmdGetNetwork)(WifiWpaStaInterface *p, const struct WpaGetNetworkArgv *argv, char *pcmd, 97 unsigned size); 98 int (*wpaCliCmdWpsPbc)(WifiWpaStaInterface *p, const struct WpaWpsPbcArgv *wpspbc); 99 int (*wpaCliCmdWpsPin)(WifiWpaStaInterface *p, const struct WpaWpsPinArgv *wpspin, int *pincode); 100 int (*wpaCliCmdWpsCancel)(WifiWpaStaInterface *p); 101 int (*wpaCliCmdPowerSave)(WifiWpaStaInterface *p, int enable); 102 int (*wpaCliCmdSetRoamConfig)(WifiWpaStaInterface *p, const char *bssid); 103 int (*wpaCliCmdSetCountryCode)(WifiWpaStaInterface *p, const char *countryCode); 104 int (*wpaCliCmdGetCountryCode)(WifiWpaStaInterface *p, char *countryCode, int codeSize); 105 int (*wpaCliCmdSetAutoConnect)(WifiWpaStaInterface *p, int enable); 106 int (*wpaCliCmdWpaBlockListClear)(WifiWpaStaInterface *p); 107 int (*wpaCliCmdListNetworks)(WifiWpaStaInterface *p, WifiNetworkInfo *pcmd, int *size); 108 int (*wpaCliCmdScan)(WifiWpaStaInterface *p, const ScanSettings *settings); 109 int (*wpaCliCmdScanInfo) (WifiWpaStaInterface *this, unsigned char *resultBuf, unsigned int *resultBufLen); 110 int (*wpaCliCmdGetSignalInfo)(WifiWpaStaInterface *p, WpaSignalInfo *info); 111 int (*wpaCliCmdWpaSetSuspendMode)(WifiWpaStaInterface *p, bool mode); 112 int (*wpaCliCmdWpaSetPowerMode)(WifiWpaStaInterface *p, bool mode); 113 int (*wpaCliCmdGetScanSsid)(WifiWpaStaInterface *this, int *scanSsid); 114 int (*wpaCliCmdGetPskPassphrase)(WifiWpaStaInterface *this, char *psk, unsigned int pskLen); 115 int (*wpaCliCmdGetPsk)(WifiWpaStaInterface *this, unsigned char *psk, unsigned int *pskLen); 116 int (*wpaCliCmdWepKey)(WifiWpaStaInterface *this, int keyIdx, unsigned char *wepKey, unsigned int *wepKeyLen); 117 int (*wpaCliCmdWepKeyTxKeyIdx)(WifiWpaStaInterface *this, int *keyIdx); 118 int (*wpaCliCmdGetRequirePmf)(WifiWpaStaInterface *this, int *enable); 119 int (*wpaCliCmdGetConnectionCapabilities)(WifiWpaStaInterface *this, struct ConnectionCapabilities *connectionCap); 120 int (*wpaCliCmdStaShellCmd)(WifiWpaStaInterface *this, const char *params); 121 }; 122 123 WifiWpaStaInterface *GetWifiStaInterface(const char *name); 124 125 void ReleaseWifiStaInterface(int staNo); 126 127 WifiWpaStaInterface *TraversalWifiStaInterface(void); 128 int GetStaInterfaceNo(const char *ifName); 129 130 int DelScanInfoLine(ScanInfo *pcmd, char *srcBuf, int length); 131 132 #ifdef __cplusplus 133 } 134 #endif 135 #endif 136