1/* 2 * Copyright (c) 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 16#ifndef OHOS_HDI_WLAN_V1_0_IWLANINTERFACE_H 17#define OHOS_HDI_WLAN_V1_0_IWLANINTERFACE_H 18 19#include <stdbool.h> 20#include <stdint.h> 21#include <hdf_base.h> 22#include "wlan/v1_0/iwlan_callback.h" 23#include "wlan/v1_0/wlan_types.h" 24 25#ifdef __cplusplus 26extern "C" { 27#endif /* __cplusplus */ 28 29struct HdfRemoteService; 30 31#define IWLANINTERFACE_INTERFACE_DESC "ohos.hdi.wlan.v1_0.IWlanInterface" 32 33#define IWLAN_INTERFACE_MAJOR_VERSION 1 34#define IWLAN_INTERFACE_MINOR_VERSION 0 35 36#ifndef HDI_BUFF_MAX_SIZE 37#define HDI_BUFF_MAX_SIZE (1024 * 200) 38#endif 39 40#ifndef HDI_CHECK_VALUE_RETURN 41#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \ 42 if ((lv) compare (rv)) { \ 43 return ret; \ 44 } \ 45} while (false) 46#endif 47 48#ifndef HDI_CHECK_VALUE_RET_GOTO 49#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \ 50 if ((lv) compare (rv)) { \ 51 ret = value; \ 52 goto table; \ 53 } \ 54} while (false) 55#endif 56 57enum { 58 CMD_WLAN_INTERFACE_GET_VERSION = 0, 59 CMD_WLAN_INTERFACE_START = 1, 60 CMD_WLAN_INTERFACE_STOP = 2, 61 CMD_WLAN_INTERFACE_CREATE_FEATURE = 3, 62 CMD_WLAN_INTERFACE_DESTROY_FEATURE = 4, 63 CMD_WLAN_INTERFACE_GET_ASSOCIATED_STAS = 5, 64 CMD_WLAN_INTERFACE_GET_CHIP_ID = 6, 65 CMD_WLAN_INTERFACE_GET_DEVICE_MAC_ADDRESS = 7, 66 CMD_WLAN_INTERFACE_GET_FEATURE_BY_IF_NAME = 8, 67 CMD_WLAN_INTERFACE_GET_FEATURE_TYPE = 9, 68 CMD_WLAN_INTERFACE_GET_FREQS_WITH_BAND = 10, 69 CMD_WLAN_INTERFACE_GET_IF_NAMES_BY_CHIP_ID = 11, 70 CMD_WLAN_INTERFACE_GET_NETWORK_IFACE_NAME = 12, 71 CMD_WLAN_INTERFACE_GET_SUPPORT_COMBO = 13, 72 CMD_WLAN_INTERFACE_GET_SUPPORT_FEATURE = 14, 73 CMD_WLAN_INTERFACE_REGISTER_EVENT_CALLBACK = 15, 74 CMD_WLAN_INTERFACE_UNREGISTER_EVENT_CALLBACK = 16, 75 CMD_WLAN_INTERFACE_RESET_DRIVER = 17, 76 CMD_WLAN_INTERFACE_SET_COUNTRY_CODE = 18, 77 CMD_WLAN_INTERFACE_SET_MAC_ADDRESS = 19, 78 CMD_WLAN_INTERFACE_SET_SCANNING_MAC_ADDRESS = 20, 79 CMD_WLAN_INTERFACE_SET_TX_POWER = 21, 80 CMD_WLAN_INTERFACE_GET_NET_DEV_INFO = 22, 81 CMD_WLAN_INTERFACE_START_SCAN = 23, 82 CMD_WLAN_INTERFACE_GET_POWER_MODE = 24, 83 CMD_WLAN_INTERFACE_SET_POWER_MODE = 25, 84 CMD_WLAN_INTERFACE_START_CHANNEL_MEAS = 26, 85 CMD_WLAN_INTERFACE_GET_CHANNEL_MEAS_RESULT = 27, 86 CMD_WLAN_INTERFACE_SET_PROJECTION_SCREEN_PARAM = 28, 87 CMD_WLAN_INTERFACE_WIFI_SEND_CMD_IOCTL = 29, 88 CMD_WLAN_INTERFACE_GET_STA_INFO = 30, 89}; 90 91struct IWlanInterface { 92 int32_t (*Start)(struct IWlanInterface *self); 93 94 int32_t (*Stop)(struct IWlanInterface *self); 95 96 int32_t (*CreateFeature)(struct IWlanInterface *self, int32_t type, struct HdfFeatureInfo* ifeature); 97 98 int32_t (*DestroyFeature)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature); 99 100 int32_t (*GetAssociatedStas)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, 101 struct HdfStaInfo* staInfo, uint32_t* staInfoLen, uint32_t* num); 102 103 int32_t (*GetChipId)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, uint8_t* chipId); 104 105 int32_t (*GetDeviceMacAddress)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, uint8_t* mac, 106 uint32_t* macLen, uint8_t len); 107 108 int32_t (*GetFeatureByIfName)(struct IWlanInterface *self, const char* ifName, struct HdfFeatureInfo* ifeature); 109 110 int32_t (*GetFeatureType)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, int32_t* featureType); 111 112 int32_t (*GetFreqsWithBand)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, 113 const struct HdfWifiInfo* wifiInfo, int32_t* freq, uint32_t* freqLen); 114 115 int32_t (*GetIfNamesByChipId)(struct IWlanInterface *self, uint8_t chipId, char* ifName, uint32_t ifNameLen, 116 uint32_t* num); 117 118 int32_t (*GetNetworkIfaceName)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, char* ifName, 119 uint32_t ifNameLen); 120 121 int32_t (*GetSupportCombo)(struct IWlanInterface *self, uint64_t* combo); 122 123 int32_t (*GetSupportFeature)(struct IWlanInterface *self, uint8_t* supType, uint32_t* supTypeLen); 124 125 int32_t (*RegisterEventCallback)(struct IWlanInterface *self, struct IWlanCallback* cbFunc, const char* ifName); 126 127 int32_t (*UnregisterEventCallback)(struct IWlanInterface *self, struct IWlanCallback* cbFunc, const char* ifName); 128 129 int32_t (*ResetDriver)(struct IWlanInterface *self, uint8_t chipId, const char* ifName); 130 131 int32_t (*SetCountryCode)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, const char* code, 132 uint32_t len); 133 134 int32_t (*SetMacAddress)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, const uint8_t* mac, 135 uint32_t macLen); 136 137 int32_t (*SetScanningMacAddress)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, 138 const uint8_t* scanMac, uint32_t scanMacLen); 139 140 int32_t (*SetTxPower)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, int32_t power); 141 142 int32_t (*GetNetDevInfo)(struct IWlanInterface *self, struct HdfNetDeviceInfoResult* netDeviceInfoResult); 143 144 int32_t (*StartScan)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, 145 const struct HdfWifiScan* scan); 146 147 int32_t (*GetPowerMode)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, uint8_t* mode); 148 149 int32_t (*SetPowerMode)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, uint8_t mode); 150 151 int32_t (*StartChannelMeas)(struct IWlanInterface *self, const char* ifName, 152 const struct MeasChannelParam* measChannelParam); 153 154 int32_t (*GetChannelMeasResult)(struct IWlanInterface *self, const char* ifName, 155 struct MeasChannelResult* measChannelResult); 156 157 int32_t (*SetProjectionScreenParam)(struct IWlanInterface *self, const char* ifName, 158 const struct ProjectionScreenCmdParam* param); 159 160 int32_t (*WifiSendCmdIoctl)(struct IWlanInterface *self, const char* ifName, int32_t cmdId, const int8_t* paramBuf, 161 uint32_t paramBufLen); 162 163 int32_t (*GetStaInfo)(struct IWlanInterface *self, const char* ifName, struct WifiStationInfo* info, 164 const uint8_t* mac, uint32_t macLen); 165 166 int32_t (*GetVersion)(struct IWlanInterface *self, uint32_t* majorVer, uint32_t* minorVer); 167 168 struct HdfRemoteService* (*AsObject)(struct IWlanInterface *self); 169}; 170 171// external method used to create client object, it support ipc and passthrought mode 172struct IWlanInterface *IWlanInterfaceGet(bool isStub); 173struct IWlanInterface *IWlanInterfaceGetInstance(const char *serviceName, bool isStub); 174 175// external method used to create release object, it support ipc and passthrought mode 176void IWlanInterfaceRelease(struct IWlanInterface *instance, bool isStub); 177void IWlanInterfaceReleaseInstance(const char *serviceName, struct IWlanInterface *instance, bool isStub); 178#ifdef __cplusplus 179} 180#endif /* __cplusplus */ 181 182#endif // OHOS_HDI_WLAN_V1_0_IWLANINTERFACE_H