1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci/** 17094332d3Sopenharmony_ci * @addtogroup WLAN 18094332d3Sopenharmony_ci * @{ 19094332d3Sopenharmony_ci * 20094332d3Sopenharmony_ci * @brief Provides cross-OS migration, component adaptation, and modular assembly and compilation. 21094332d3Sopenharmony_ci * 22094332d3Sopenharmony_ci * Based on the unified APIs provided by the WLAN module, developers of the Hardware Driver Interface 23094332d3Sopenharmony_ci * (HDI) are capable of creating, disabling, scanning for, and connecting to WLAN hotspots, managing WLAN chips, 24094332d3Sopenharmony_ci * network devices, and power, and applying for, releasing, and moving network data buffers. 25094332d3Sopenharmony_ci * 26094332d3Sopenharmony_ci * @since 1.0 27094332d3Sopenharmony_ci * @version 1.0 28094332d3Sopenharmony_ci */ 29094332d3Sopenharmony_ci 30094332d3Sopenharmony_ci/** 31094332d3Sopenharmony_ci * @file wifi_hal_base_feature.h 32094332d3Sopenharmony_ci * 33094332d3Sopenharmony_ci * @brief Declares basic WLAN features. 34094332d3Sopenharmony_ci * 35094332d3Sopenharmony_ci * @since 1.0 36094332d3Sopenharmony_ci * @version 1.0 37094332d3Sopenharmony_ci */ 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_ci#ifndef WIFI_HAL_BASE_FEATURE_H 40094332d3Sopenharmony_ci#define WIFI_HAL_BASE_FEATURE_H 41094332d3Sopenharmony_ci 42094332d3Sopenharmony_ci#include <stdint.h> 43094332d3Sopenharmony_ci 44094332d3Sopenharmony_ci#ifdef __cplusplus 45094332d3Sopenharmony_ci#if __cplusplus 46094332d3Sopenharmony_ciextern "C" { 47094332d3Sopenharmony_ci#endif 48094332d3Sopenharmony_ci#endif 49094332d3Sopenharmony_ci 50094332d3Sopenharmony_ci/** 51094332d3Sopenharmony_ci * @brief Indicates the maximum length of the network interface name. 52094332d3Sopenharmony_ci * 53094332d3Sopenharmony_ci * @since 1.0 54094332d3Sopenharmony_ci * @version 1.0 55094332d3Sopenharmony_ci */ 56094332d3Sopenharmony_ci#define IFNAME_MAX_LEN 16 57094332d3Sopenharmony_ci/** 58094332d3Sopenharmony_ci * @brief Indicates the length of the MAC address. 59094332d3Sopenharmony_ci * 60094332d3Sopenharmony_ci * @since 1.0 61094332d3Sopenharmony_ci * @version 1.0 62094332d3Sopenharmony_ci */ 63094332d3Sopenharmony_ci#define WIFI_MAC_ADDR_LENGTH 6 64094332d3Sopenharmony_ci/** 65094332d3Sopenharmony_ci * @brief Defines the access failure error. 66094332d3Sopenharmony_ci * 67094332d3Sopenharmony_ci * @since 1.0 68094332d3Sopenharmony_ci * @version 1.0 69094332d3Sopenharmony_ci */ 70094332d3Sopenharmony_ci#define ERR_UNAUTH_ACCESS (-6) 71094332d3Sopenharmony_ci 72094332d3Sopenharmony_ci/** 73094332d3Sopenharmony_ci * @brief Enumerates feature types. 74094332d3Sopenharmony_ci * 75094332d3Sopenharmony_ci * @since 1.0 76094332d3Sopenharmony_ci * @version 1.0 77094332d3Sopenharmony_ci */ 78094332d3Sopenharmony_citypedef enum { 79094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_UNSPECIFIED, /**< Unspecified type */ 80094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_ADHOC, /**< Ad hoc network */ 81094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_STATION, /**< Station */ 82094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_AP, /**< Access point (AP) */ 83094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_AP_VLAN, /**< Virtual AP */ 84094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_WDS, /**< Wireless distributed system */ 85094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_MONITOR, /**< Listening */ 86094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_MESH_POINT, /**< Mesh network */ 87094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_P2P_CLIENT, /**< P2P client */ 88094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_P2P_GO, /**< P2P group owner */ 89094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_P2P_DEVICE, /**< P2P device */ 90094332d3Sopenharmony_ci PROTOCOL_80211_IFTYPE_NUM, /**< Number of network ports */ 91094332d3Sopenharmony_ci} FeatureType; 92094332d3Sopenharmony_ci 93094332d3Sopenharmony_ci/** 94094332d3Sopenharmony_ci * @brief Defines basic WLAN features, such as obtaining the network interface name, setting the MAC address, 95094332d3Sopenharmony_ci * and setting the transmit power. 96094332d3Sopenharmony_ci * 97094332d3Sopenharmony_ci * @since 1.0 98094332d3Sopenharmony_ci * @version 1.0 99094332d3Sopenharmony_ci */ 100094332d3Sopenharmony_cistruct IWiFiBaseFeature { 101094332d3Sopenharmony_ci char ifName[IFNAME_MAX_LEN]; /**< Network interface name */ 102094332d3Sopenharmony_ci int32_t type; /**< Feature type, as enumerated in {@link FeatureType} */ 103094332d3Sopenharmony_ci 104094332d3Sopenharmony_ci /** 105094332d3Sopenharmony_ci * @brief Obtains the name of a network interface. 106094332d3Sopenharmony_ci * 107094332d3Sopenharmony_ci * @param baseFeature Indicates the pointer to the basic feature, as described in {@link IWiFiBaseFeature}. 108094332d3Sopenharmony_ci * 109094332d3Sopenharmony_ci * @return Returns network interface name if the network interface name is obtained; 110094332d3Sopenharmony_ci * returns NULL otherwise. 111094332d3Sopenharmony_ci * 112094332d3Sopenharmony_ci * @since 1.0 113094332d3Sopenharmony_ci * @version 1.0 114094332d3Sopenharmony_ci */ 115094332d3Sopenharmony_ci const char *(*getNetworkIfaceName)(const struct IWiFiBaseFeature *baseFeature); 116094332d3Sopenharmony_ci 117094332d3Sopenharmony_ci /** 118094332d3Sopenharmony_ci * @brief Obtains the type of a basic feature. 119094332d3Sopenharmony_ci * 120094332d3Sopenharmony_ci * @param baseFeature Indicates the pointer to the basic feature, as described in {@link IWiFiBaseFeature}. 121094332d3Sopenharmony_ci * 122094332d3Sopenharmony_ci * @return Returns feature type if the feature type is obtained; returns a negative value otherwise. 123094332d3Sopenharmony_ci * 124094332d3Sopenharmony_ci * @since 1.0 125094332d3Sopenharmony_ci * @version 1.0 126094332d3Sopenharmony_ci */ 127094332d3Sopenharmony_ci int32_t (*getFeatureType)(const struct IWiFiBaseFeature *baseFeature); 128094332d3Sopenharmony_ci 129094332d3Sopenharmony_ci /** 130094332d3Sopenharmony_ci * @brief Sets the MAC address. 131094332d3Sopenharmony_ci * 132094332d3Sopenharmony_ci * @param baseFeature Indicates the pointer to the basic feature, as described in {@link IWiFiBaseFeature}. 133094332d3Sopenharmony_ci * @param mac Indicates the pointer to the MAC address. 134094332d3Sopenharmony_ci * @param len Indicates the length of the MAC address. 135094332d3Sopenharmony_ci * 136094332d3Sopenharmony_ci * @return Returns <b>0</b> if the MAC address is set; returns a negative value otherwise. 137094332d3Sopenharmony_ci * 138094332d3Sopenharmony_ci * @since 1.0 139094332d3Sopenharmony_ci * @version 1.0 140094332d3Sopenharmony_ci */ 141094332d3Sopenharmony_ci int32_t (*setMacAddress)(const struct IWiFiBaseFeature *baseFeature, unsigned char *mac, uint8_t len); 142094332d3Sopenharmony_ci 143094332d3Sopenharmony_ci /** 144094332d3Sopenharmony_ci * @brief Obtains the device MAC address. 145094332d3Sopenharmony_ci * 146094332d3Sopenharmony_ci * @param baseFeature Indicates the pointer to the basic feature, as described in {@link IWiFiBaseFeature}. 147094332d3Sopenharmony_ci * @param mac Indicates the pointer to the MAC address. 148094332d3Sopenharmony_ci * @param len Indicates the length of the MAC address. 149094332d3Sopenharmony_ci * 150094332d3Sopenharmony_ci * @return Returns <b>0</b> if the MAC address is obtained; returns a negative value otherwise. 151094332d3Sopenharmony_ci * 152094332d3Sopenharmony_ci * @since 1.0 153094332d3Sopenharmony_ci * @version 1.0 154094332d3Sopenharmony_ci */ 155094332d3Sopenharmony_ci int32_t (*getDeviceMacAddress)(const struct IWiFiBaseFeature *baseFeature, unsigned char *mac, uint8_t len); 156094332d3Sopenharmony_ci 157094332d3Sopenharmony_ci /** 158094332d3Sopenharmony_ci * @brief Obtains the frequencies supported by the 2.4 GHz or 5 GHz band. 159094332d3Sopenharmony_ci * 160094332d3Sopenharmony_ci * @param baseFeature Indicates the pointer to the basic feature, as described in {@link IWiFiBaseFeature}. 161094332d3Sopenharmony_ci * @param band Indicates the frequency band, either 2.4 GHz or 5 GHz. 162094332d3Sopenharmony_ci * @param freqs Indicates the pointer to the supported frequencies. 163094332d3Sopenharmony_ci * @param count Indicates the number of elements in the frequency array. 164094332d3Sopenharmony_ci * @param num Indicates the number of supported frequencies. 165094332d3Sopenharmony_ci * 166094332d3Sopenharmony_ci * @return Returns <b>0</b> if the supported frequencies are obtained; returns a negative value otherwise. 167094332d3Sopenharmony_ci * 168094332d3Sopenharmony_ci * @since 1.0 169094332d3Sopenharmony_ci * @version 1.0 170094332d3Sopenharmony_ci */ 171094332d3Sopenharmony_ci int32_t (*getValidFreqsWithBand)(const struct IWiFiBaseFeature *baseFeature, int32_t band, int32_t *freqs, 172094332d3Sopenharmony_ci uint32_t count, uint32_t *num); 173094332d3Sopenharmony_ci 174094332d3Sopenharmony_ci /** 175094332d3Sopenharmony_ci * @brief Sets the transmit power. 176094332d3Sopenharmony_ci * 177094332d3Sopenharmony_ci * @param baseFeature Indicates the pointer to the basic feature, as described in {@link IWiFiBaseFeature}. 178094332d3Sopenharmony_ci * @param power Indicates the transmit power to set. 179094332d3Sopenharmony_ci * 180094332d3Sopenharmony_ci * @return Returns <b>0</b> if the transmit power is set; returns a negative value otherwise. 181094332d3Sopenharmony_ci * 182094332d3Sopenharmony_ci * @since 1.0 183094332d3Sopenharmony_ci * @version 1.0 184094332d3Sopenharmony_ci */ 185094332d3Sopenharmony_ci int32_t (*setTxPower)(const struct IWiFiBaseFeature *baseFeature, int32_t power); 186094332d3Sopenharmony_ci 187094332d3Sopenharmony_ci /** 188094332d3Sopenharmony_ci * @brief Obtains the chip ID of the current driver. 189094332d3Sopenharmony_ci * 190094332d3Sopenharmony_ci * @param baseFeature Indicates the pointer to the {@link IWiFiBaseFeature}. 191094332d3Sopenharmony_ci * @param chipId Indicates the pointer to the chip ID. 192094332d3Sopenharmony_ci * 193094332d3Sopenharmony_ci * @return Returns <b>0</b> if the chip ID is obtained; returns a negative value otherwise. 194094332d3Sopenharmony_ci * 195094332d3Sopenharmony_ci * @since 1.0 196094332d3Sopenharmony_ci * @version 1.0 197094332d3Sopenharmony_ci */ 198094332d3Sopenharmony_ci int32_t (*getChipId)(const struct IWiFiBaseFeature *baseFeature, uint8_t *chipId); 199094332d3Sopenharmony_ci 200094332d3Sopenharmony_ci /** 201094332d3Sopenharmony_ci * @brief Obtains names of all the NICs of the current chip based on the chip ID. 202094332d3Sopenharmony_ci * 203094332d3Sopenharmony_ci * @param chipId Indicates the chip ID. 204094332d3Sopenharmony_ci * @param ifNames Indicates the pointer to the NIC names. 205094332d3Sopenharmony_ci * @param num Indicates the pointer to the number of NICs. 206094332d3Sopenharmony_ci * 207094332d3Sopenharmony_ci * @return Returns <b>0</b> if the NIC names are obtained; returns a negative value otherwise. 208094332d3Sopenharmony_ci * 209094332d3Sopenharmony_ci * @since 1.0 210094332d3Sopenharmony_ci * @version 1.0 211094332d3Sopenharmony_ci */ 212094332d3Sopenharmony_ci int32_t (*getIfNamesByChipId)(const uint8_t chipId, char **ifNames, uint32_t *num); 213094332d3Sopenharmony_ci 214094332d3Sopenharmony_ci /** 215094332d3Sopenharmony_ci * @brief reset to factory mac address(permanent hardware address). 216094332d3Sopenharmony_ci * 217094332d3Sopenharmony_ci * @param ifName Indicates the NIC name. 218094332d3Sopenharmony_ci * 219094332d3Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful. 220094332d3Sopenharmony_ci * @return Returns a negative value if the operation fails. 221094332d3Sopenharmony_ci * 222094332d3Sopenharmony_ci * @since 4.1 223094332d3Sopenharmony_ci * @version 1.2 224094332d3Sopenharmony_ci */ 225094332d3Sopenharmony_ci int32_t (*resetToFactoryMacAddress)(const char *ifNames); 226094332d3Sopenharmony_ci}; 227094332d3Sopenharmony_ci 228094332d3Sopenharmony_ci/** 229094332d3Sopenharmony_ci * @brief Initializes a specified basic feature. This function is called during {@link FeatureType} creation. 230094332d3Sopenharmony_ci * 231094332d3Sopenharmony_ci * @param fe Indicates the double pointer to the basic feature. 232094332d3Sopenharmony_ci * 233094332d3Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful; returns a negative value representing {@link HDF_STATUS} 234094332d3Sopenharmony_ci * if the operation fails. 235094332d3Sopenharmony_ci * 236094332d3Sopenharmony_ci * @since 1.0 237094332d3Sopenharmony_ci * @version 1.0 238094332d3Sopenharmony_ci */ 239094332d3Sopenharmony_ciint32_t InitBaseFeature(struct IWiFiBaseFeature **fe); 240094332d3Sopenharmony_ci 241094332d3Sopenharmony_ci#ifdef __cplusplus 242094332d3Sopenharmony_ci#if __cplusplus 243094332d3Sopenharmony_ci} 244094332d3Sopenharmony_ci#endif 245094332d3Sopenharmony_ci#endif 246094332d3Sopenharmony_ci 247094332d3Sopenharmony_ci#endif 248094332d3Sopenharmony_ci/** @} */ 249