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 INTERFACE_INFO_H 16 #define INTERFACE_INFO_H 17 18 #include <mutex> 19 #include "info_container.h" 20 #include "ipv4_info.h" 21 #include "link_info.h" 22 #include "wifi_direct_defines.h" 23 24 namespace OHOS::SoftBus { 25 26 enum class InterfaceInfoKey { 27 DYNAMIC_MAC = 0, 28 INTERFACE_NAME = 1, 29 CAPABILITY = 2, 30 WIFI_DIRECT_ROLE = 3, 31 BASE_MAC = 4, 32 PHYSICAL_RATE = 5, 33 SUPPORT_BAND = 6, 34 CHANNEL_AND_BANDWIDTH = 7, 35 COEXIST_CHANNEL_LIST = 8, 36 HML_LINK_COUNT = 9, 37 ISLAND_DEVICE_COUNT = 10, 38 COEXIST_VAP_COUNT = 11, 39 IPV4 = 12, 40 CHANNEL_5G_LIST = 13, 41 SSID = 14, 42 PORT = 15, 43 IS_WIDE_BAND_SUPPORT = 16, 44 CENTER_20M = 17, 45 CENTER_FREQUENCY1 = 18, 46 CENTER_FREQUENCY2 = 19, 47 BANDWIDTH = 20, 48 WIFI_CFG_INFO = 21, 49 IS_ENABLE = 22, 50 CONNECTED_DEVICE_COUNT = 23, 51 PSK = 24, 52 REUSE_COUNT = 25, 53 IS_AVAILABLE = 26, 54 COEXIST_RULE = 27, 55 LINK_MODE = 28, 56 LISTEN_MODULE = 29, 57 }; 58 59 class InterfaceInfo : public Serializable, public InfoContainer<InterfaceInfoKey> { 60 public: 61 enum InterfaceType { 62 P2P, 63 HML, 64 MAX, 65 }; 66 67 int Marshalling(WifiDirectProtocol &protocol, std::vector<uint8_t> &output) const override; 68 int Unmarshalling(WifiDirectProtocol &protocol, const std::vector<uint8_t> &input) override; 69 70 static void MarshallingString( 71 WifiDirectProtocol &protocol, InterfaceInfoKey key, Serializable::ValueType type, const std::string &value); 72 73 /* Get/Set */ 74 void SetName(const std::string &value); 75 std::string GetName() const; 76 77 std::vector<uint8_t> GetChannelAndBandWidth() const; 78 79 void SetIpString(const Ipv4Info &ipv4Info); 80 Ipv4Info GetIpString() const; 81 82 void SetRole(LinkInfo::LinkMode value); 83 LinkInfo::LinkMode GetRole() const; 84 85 void SetSsid(const std::string &value); 86 std::string GetSsid() const; 87 88 // P2P links share the same listen port, so define port in interface info 89 void SetP2pListenPort(const int &value); 90 int GetP2pListenPort() const; 91 92 // P2P links share the same listen module, so define module in interface info 93 void SetP2pListenModule(const int &value); 94 int GetP2pListenModule() const; 95 96 void SetP2pGroupConfig(const std::string &groupConfig); 97 std::string GetP2pGroupConfig() const; 98 99 void SetDynamicMac(const std::string &value); 100 std::string GetDynamicMac() const; 101 102 void SetPsk(const std::string &value); 103 std::string GetPsk() const; 104 105 void SetCenter20M(int value); 106 int GetCenter20M() const; 107 108 void SetBandWidth(int value); 109 int GetBandWidth() const; 110 111 void SetIsEnable(bool value); 112 bool IsEnable() const; 113 114 void SetConnectedDeviceCount(int32_t value); 115 int32_t GetConnectedDeviceCount() const; 116 117 void SetBaseMac(const std::string &value); 118 std::string GetBaseMac() const; 119 120 void SetCapability(int32_t value); 121 int32_t GetCapability() const; 122 123 void SetReuseCount(int value); 124 int GetReuseCount() const; 125 126 void SetChannel5GList(const std::vector<int> &value); 127 std::vector<int> GetChannel5GList() const; 128 129 void SetIsAvailable(bool value); 130 bool IsAvailable() const; 131 void RefreshIsAvailable(); 132 133 void SetPhysicalRate(int value); 134 int GetPhysicalRate() const; 135 136 void IncreaseRefCount(); 137 void DecreaseRefCount(); 138 }; 139 } // namespace OHOS::SoftBus 140 #endif