1 /* 2 * Copyright (c) 2023 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_COMMON_CMD_H 16 #define WPA_COMMON_CMD_H 17 18 #include "../wpa_impl.h" 19 #include <pthread.h> 20 #include <hdf_remote_service.h> 21 #include "utils/common.h" 22 #include "wpa_supplicant_hal.h" 23 #include "wpa_client.h" 24 #include "wpa_common_cmd_ext.h" 25 26 #define WIFI_SSID_LENGTH 132 27 #define WIFI_BSSID_LENGTH 18 28 #define KEY_MGMT_LENG 20 29 #define WIFI_NETWORK_FLAGS_LENGTH 64 30 #define WIFI_COUNTRY_CODE_MAXLEN 2 31 #define COLUMN_INDEX_ZERO 0 32 #define COLUMN_INDEX_ONE 1 33 #define COLUMN_INDEX_TWO 2 34 #define COUNTRY_CODE_LENGTH_MAX 2 35 #define CMD_SIZE 200 36 #define MAX_CMD_SIZE 1024 37 #define REPLY_SIZE 1024 38 /* get more than 100 p2p lists */ 39 #define P2P_LIST_REPLY_SIZE 7168 40 #define HDI_POS_TEN 10 41 #define HDI_POS_FOURTH 4 42 #define REPLY_SIZE_FACTOR_FIRST 4 43 #define REPLY_SIZE_FACTOR_SECOND 10 44 #define WPA_CMD_BUF_LEN 256 45 #define WPA_SUPPLICANT_NAME "wpa_supplicant" 46 #define CONFIG_ROOR_DIR "/data/service/el1/public/wifi" 47 #define START_CMD "wpa_supplicant -c"CONFIG_ROOR_DIR"/wpa_supplicant/wpa_supplicant.conf"\ 48 " -g@abstract:"CONFIG_ROOR_DIR"/sockets/wpa/wlan0" 49 #define CONFIG_ROOR_DIR_UPDATER "/tmp/service/el1/public/wifi" 50 #define START_CMD_UPDATER "wpa_supplicant -c"CONFIG_ROOR_DIR_UPDATER"/wpa_supplicant/wpa_supplicant.conf"\ 51 " -g@abstract:"CONFIG_ROOR_DIR_UPDATER"/sockets/wpa/wlan0" 52 #define WPA_SLEEP_TIME (100 * 1000) /* 100ms */ 53 #define MAX_WPA_MAIN_ARGC_NUM 20 54 #define MAX_WPA_MAIN_ARGV_LEN 128 55 #define WIFI_NETWORK_CONFIG_NAME_LENGTH 64 56 #define WIFI_NETWORK_CONFIG_VALUE_LENGTH 2048 57 #define CMD_LEN 6 58 #define WPA_MAJOR_VER 2 59 #define WPA_MINOR_VER 0 60 61 int32_t WpaInterfaceAddNetwork(struct IWpaInterface *self, const char *ifName, int32_t *networkId); 62 int32_t WpaInterfaceRemoveNetwork(struct IWpaInterface *self, const char *ifName, int32_t networkId); 63 int32_t WpaInterfaceDisableNetwork(struct IWpaInterface *self, const char *ifName, const int32_t networkId); 64 int32_t WpaInterfaceSetNetwork(struct IWpaInterface *self, const char *ifName, const int32_t networkId, 65 const char *name, const char *value); 66 int32_t WpaInterfaceListNetworks(struct IWpaInterface *self, const char *ifName, 67 struct HdiWifiWpaNetworkInfo *networkInfo, uint32_t *networkInfoLen); 68 int32_t WpaInterfaceSelectNetwork(struct IWpaInterface *self, const char *ifName, 69 const int32_t networkId); 70 int32_t WpaInterfaceEnableNetwork(struct IWpaInterface *self, const char *ifName, 71 const int32_t networkId); 72 int32_t WpaInterfaceReconnect(struct IWpaInterface *self, const char *ifName); 73 int32_t WpaInterfaceDisconnect(struct IWpaInterface *self, const char *ifName); 74 int32_t WpaInterfaceSetPowerSave(struct IWpaInterface *self, const char *ifName, const int32_t enable); 75 int32_t WpaInterfaceAutoConnect(struct IWpaInterface *self, const char *ifName, const int32_t enable); 76 int32_t WpaInterfaceWifiStatus(struct IWpaInterface *self, const char *ifName, 77 struct HdiWpaCmdStatus *status); 78 int32_t WpaInterfaceSaveConfig(struct IWpaInterface *self, const char *ifName); 79 int32_t WpaInterfaceWpsPbcMode(struct IWpaInterface *self, const char *ifName, 80 const struct HdiWifiWpsParam *wpaParam); 81 int32_t WpaInterfaceWpsPinMode(struct IWpaInterface *self, const char *ifName, 82 const struct HdiWifiWpsParam *wpaParam, int *pinCode); 83 int32_t WpaInterfaceWpsCancel(struct IWpaInterface *self, const char *ifName); 84 int32_t WpaInterfaceGetCountryCode(struct IWpaInterface *self, const char *ifName, 85 char *countryCode, uint32_t countryCodeLen); 86 int32_t WpaInterfaceGetNetwork(struct IWpaInterface *self, const char *ifName, 87 const int32_t networkId, const char *param, char *value, uint32_t valueLen); 88 int32_t WpaInterfaceBlocklistClear(struct IWpaInterface *self, const char *ifName); 89 int32_t WpaInterfaceSetSuspendMode(struct IWpaInterface *self, const char *ifName, const int32_t mode); 90 int32_t WpaInterfaceRegisterEventCallback(struct IWpaInterface *self, struct IWpaCallback *cbFunc, 91 const char *ifName); 92 int32_t WpaInterfaceUnregisterEventCallback(struct IWpaInterface *self, struct IWpaCallback *cbFunc, 93 const char *ifName); 94 int32_t WpaInterfaceWifiConstruct(void); 95 int32_t WpaInterfaceWifiDestruct(void); 96 void WpaEventReport(const char *ifName, uint32_t event, void *data); 97 int32_t WpaInterfaceGetConnectionCapabilities(struct IWpaInterface *self, const char *ifName, 98 struct ConnectionCapabilities *connectionCap); 99 int32_t WpaInterfaceGetScanSsid(struct IWpaInterface *self, const char *ifName, int32_t *enable); 100 int32_t WpaInterfaceGetPskPassphrase(struct IWpaInterface *self, const char *ifName, char *psk, uint32_t pskLen); 101 int32_t WpaInterfaceGetPsk(struct IWpaInterface *self, const char *ifName, uint8_t *psk, uint32_t *pskLen); 102 int32_t WpaInterfaceGetWepKey(struct IWpaInterface *self, const char *ifName, int keyIdx, uint8_t *wepKey, 103 uint32_t *wepKeyLen); 104 int32_t WpaInterfaceGetWepTxKeyIdx(struct IWpaInterface *self, const char *ifName, int *keyIdx); 105 int32_t WpaInterfaceGetRequirePmf(struct IWpaInterface *self, const char *ifName, int *enable); 106 int32_t WpaInterfaceSetCountryCode(struct IWpaInterface *self, const char *ifName, const char *countryCode); 107 int32_t WpaInterfaceReassociate(struct IWpaInterface *self, const char *ifName); 108 int32_t WpaInterfaceStaShellCmd(struct IWpaInterface *self, const char *ifName, const char *cmd); 109 int32_t WpaInterfaceGetWpaStaData(struct IWpaInterface *self, const char *ifName, const char *staParam, 110 char *staData, uint32_t staDataLen); 111 112 void HdfWpaDelRemoteObj(struct IWpaCallback *self); 113 void ClearHdfWpaRemoteObj(void); 114 int32_t FillData(uint8_t **dst, uint32_t *dstLen, uint8_t *src, uint32_t srcLen); 115 int32_t WpaGetVersion(struct IWpaInterface *self, uint32_t *majorVer, uint32_t *minorVer); 116 pthread_mutex_t *GetInterfaceLock(); 117 118 bool IsUpdaterMode(void); 119 120 struct StWpaMainParam { 121 int argc; 122 char argv[MAX_WPA_MAIN_ARGC_NUM][MAX_WPA_MAIN_ARGV_LEN]; 123 }; 124 struct RemoteServiceDeathRecipient { 125 struct HdfDeathRecipient recipient; 126 }; 127 #endif 128