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 16 #ifndef WIFI_DIRECT_TYPES_H 17 #define WIFI_DIRECT_TYPES_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 #include <stddef.h> 22 23 #include "wifi_direct_defines.h" 24 #include "softbus_common.h" 25 #include "wifi_direct_error_code.h" 26 27 #ifndef NULL 28 #define NULL 0 29 #endif 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 enum WifiDirectConnectType { 36 WIFI_DIRECT_CONNECT_TYPE_AUTH_NEGO_P2P = 0, 37 WIFI_DIRECT_CONNECT_TYPE_AUTH_NEGO_HML = 1, 38 39 WIFI_DIRECT_CONNECT_TYPE_BLE_TRIGGER_HML = 2, 40 WIFI_DIRECT_CONNECT_TYPE_AUTH_TRIGGER_HML = 3, 41 WIFI_DIRECT_CONNECT_TYPE_ACTION_TRIGGER_HML = 4, 42 }; 43 44 enum WifiDirectRole { 45 WIFI_DIRECT_ROLE_AUTO = 1, 46 WIFI_DIRECT_ROLE_GO = 2, 47 WIFI_DIRECT_ROLE_GC = 3, 48 WIFI_DIRECT_ROLE_BRIDGE_GC = 4, 49 WIFI_DIRECT_ROLE_NONE = 5, 50 WIFI_DIRECT_ROLE_HML = 6, 51 WIFI_DIRECT_ROLE_INVALID = 7, 52 }; 53 54 enum WifiDirectApiRole { 55 WIFI_DIRECT_API_ROLE_NONE = 0, 56 WIFI_DIRECT_API_ROLE_STA = 1, 57 WIFI_DIRECT_API_ROLE_AP = 2, 58 WIFI_DIRECT_API_ROLE_GO = 4, 59 WIFI_DIRECT_API_ROLE_GC = 8, 60 WIFI_DIRECT_API_ROLE_HML = 16, 61 }; 62 63 enum P2pGroupConfigIndex { 64 P2P_GROUP_CONFIG_INDEX_SSID = 0, 65 P2P_GROUP_CONFIG_INDEX_BSSID = 1, 66 P2P_GROUP_CONFIG_INDEX_SHARE_KEY = 2, 67 P2P_GROUP_CONFIG_INDEX_FREQ = 3, 68 P2P_GROUP_CONFIG_INDEX_MODE = 4, 69 P2P_GROUP_CONFIG_INDEX_MAX, 70 }; 71 72 enum WifiDirectLinkType { 73 WIFI_DIRECT_LINK_TYPE_INVALID = -1, 74 WIFI_DIRECT_LINK_TYPE_P2P, 75 WIFI_DIRECT_LINK_TYPE_HML, 76 }; 77 78 enum WifiDirectBandWidth { 79 BAND_WIDTH_RANDOM = 0x0, 80 BAND_WIDTH_20M, 81 BAND_WIDTH_40M, 82 BAND_WIDTH_80M, 83 BAND_WIDTH_80P80M, 84 BAND_WIDTH_160M, 85 BAND_WIDTH_BUTT = 0xFF, 86 }; 87 88 typedef enum { 89 CONN_HML_CAP_UNKNOWN = -1, 90 CONN_HML_SUPPORT = 0, 91 CONN_HML_NOT_SUPPORT = 1, 92 } HmlCapabilityCode; 93 94 struct WifiDirectLink { 95 int32_t linkId; 96 char localIp[IP_STR_MAX_LEN]; 97 char remoteIp[IP_STR_MAX_LEN]; 98 int32_t remotePort; 99 enum WifiDirectLinkType linkType; 100 enum WifiDirectBandWidth bandWidth; 101 bool isReuse; 102 int channelId; 103 }; 104 105 struct WifiDirectSinkLink { 106 char remoteUuid[UUID_BUF_LEN]; 107 int channelId; 108 enum WifiDirectBandWidth bandWidth; 109 enum WifiDirectLinkType linkType; 110 111 char localIp[IP_STR_MAX_LEN]; 112 char remoteIp[IP_STR_MAX_LEN]; 113 114 char remoteMac[MAC_ADDR_STR_LEN]; 115 }; 116 117 enum WifiDirectNegoChannelType { 118 NEGO_CHANNEL_NULL = 0, 119 NEGO_CHANNEL_AUTH = 1, 120 NEGO_CHANNEL_COC = 2, 121 NEGO_CHANNEL_ACTION = 3, 122 NEGO_CHANNEL_SHARE = 4, 123 }; 124 125 struct WifiDirectNegotiateChannel { 126 enum WifiDirectNegoChannelType type; 127 union { 128 AuthHandle authHandle; 129 int32_t channelId; 130 uint32_t actionAddr; 131 } handle; 132 }; 133 134 enum IpAddrType { 135 IPV4, 136 IPV6 137 }; 138 139 enum StatisticLinkType { 140 STATISTIC_P2P = 0, 141 STATISTIC_HML = 1, 142 STATISTIC_TRIGGER_HML = 2, 143 STATISTIC_LINK_TYPE_NUM = 3, 144 }; 145 146 enum StatisticBootLinkType { 147 STATISTIC_NONE = 0, 148 STATISTIC_WLAN = 1, 149 STATISTIC_BLE = 2, 150 STATISTIC_BR = 3, 151 STATISTIC_COC = 4, 152 STATISTIC_ACTION = 5, 153 STATISTIC_RENEGOTIATE = 6, 154 STATISTIC_BOOT_LINK_TYPE_NUM = 7, 155 }; 156 157 struct WifiDirectDfxInfo { 158 enum StatisticLinkType linkType; 159 enum StatisticBootLinkType bootLinkType; 160 int renegotiate; 161 int reuse; 162 int costTime; 163 uint16_t challengeCode; 164 int frequency; 165 int staChannel; 166 int hmlChannel; 167 int p2pChannel; 168 int apChannel; 169 }; 170 171 struct WifiDirectConnectInfo { 172 uint32_t requestId; 173 int32_t pid; 174 enum WifiDirectConnectType connectType; 175 bool isStrictProtocol; // for HMLv1 | P2Pv2 176 struct WifiDirectNegotiateChannel negoChannel; 177 bool reuseOnly; 178 uint32_t expectApiRole; 179 bool isStrict; 180 char remoteNetworkId[NETWORK_ID_BUF_LEN]; 181 char remoteMac[MAC_ADDR_STR_LEN]; 182 bool isNetworkDelegate; 183 int32_t bandWidth; 184 enum IpAddrType ipAddrType; 185 186 struct WifiDirectDfxInfo dfxInfo; 187 }; 188 189 struct WifiDirectDisconnectInfo { 190 uint32_t requestId; 191 int32_t pid; 192 int32_t linkId; 193 struct WifiDirectNegotiateChannel negoChannel; 194 }; 195 196 struct WifiDirectForceDisconnectInfo { 197 uint32_t requestId; 198 int32_t pid; 199 char remoteUuid[UUID_BUF_LEN]; 200 enum WifiDirectLinkType linkType; 201 struct WifiDirectNegotiateChannel negoChannel; 202 }; 203 204 struct WifiDirectConnectCallback { 205 void (*onConnectSuccess)(uint32_t requestId, const struct WifiDirectLink *link); 206 void (*onConnectFailure)(uint32_t requestId, int32_t reason); 207 }; 208 209 struct WifiDirectDisconnectCallback { 210 void (*onDisconnectSuccess)(uint32_t requestId); 211 void (*onDisconnectFailure)(uint32_t requestId, int32_t reason); 212 }; 213 214 #ifdef __cplusplus 215 } 216 #endif 217 #endif 218