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 struct WifiDirectLink { 89 int32_t linkId; 90 char localIp[IP_STR_MAX_LEN]; 91 char remoteIp[IP_STR_MAX_LEN]; 92 int32_t remotePort; 93 enum WifiDirectLinkType linkType; 94 enum WifiDirectBandWidth bandWidth; 95 bool isReuse; 96 int channelId; 97 }; 98 99 struct WifiDirectSinkLink { 100 char remoteUuid[UUID_BUF_LEN]; 101 int channelId; 102 enum WifiDirectBandWidth bandWidth; 103 enum WifiDirectLinkType linkType; 104 105 char localIp[IP_STR_MAX_LEN]; 106 char remoteIp[IP_STR_MAX_LEN]; 107 108 char remoteMac[MAC_ADDR_STR_LEN]; 109 }; 110 111 enum WifiDirectNegoChannelType { 112 NEGO_CHANNEL_NULL = 0, 113 NEGO_CHANNEL_AUTH = 1, 114 NEGO_CHANNEL_COC = 2, 115 NEGO_CHANNEL_ACTION = 3, 116 NEGO_CHANNEL_SHARE = 4, 117 }; 118 119 struct WifiDirectNegotiateChannel { 120 enum WifiDirectNegoChannelType type; 121 union { 122 AuthHandle authHandle; 123 int32_t channelId; 124 uint32_t actionAddr; 125 } handle; 126 }; 127 128 enum IpAddrType { 129 IPV4, 130 IPV6 131 }; 132 133 enum StatisticLinkType { 134 STATISTIC_P2P = 0, 135 STATISTIC_HML = 1, 136 STATISTIC_TRIGGER_HML = 2, 137 STATISTIC_LINK_TYPE_NUM = 3, 138 }; 139 140 enum StatisticBootLinkType { 141 STATISTIC_NONE = 0, 142 STATISTIC_WLAN = 1, 143 STATISTIC_BLE = 2, 144 STATISTIC_BR = 3, 145 STATISTIC_COC = 4, 146 STATISTIC_ACTION = 5, 147 STATISTIC_RENEGOTIATE = 6, 148 STATISTIC_BOOT_LINK_TYPE_NUM = 7, 149 }; 150 151 struct WifiDirectDfxInfo { 152 enum StatisticLinkType linkType; 153 enum StatisticBootLinkType bootLinkType; 154 int renegotiate; 155 int reuse; 156 int costTime; 157 uint16_t challengeCode; 158 int32_t frequency; 159 }; 160 161 struct WifiDirectConnectInfo { 162 uint32_t requestId; 163 int32_t pid; 164 enum WifiDirectConnectType connectType; 165 struct WifiDirectNegotiateChannel negoChannel; 166 bool reuseOnly; 167 uint32_t expectApiRole; 168 bool isStrict; 169 char remoteNetworkId[NETWORK_ID_BUF_LEN]; 170 char remoteMac[MAC_ADDR_STR_LEN]; 171 bool isNetworkDelegate; 172 int32_t bandWidth; 173 enum IpAddrType ipAddrType; 174 struct WifiDirectDfxInfo dfxInfo; 175 }; 176 177 struct WifiDirectDisconnectInfo { 178 uint32_t requestId; 179 int32_t pid; 180 int32_t linkId; 181 struct WifiDirectNegotiateChannel negoChannel; 182 }; 183 184 struct WifiDirectForceDisconnectInfo { 185 uint32_t requestId; 186 int32_t pid; 187 char remoteUuid[UUID_BUF_LEN]; 188 enum WifiDirectLinkType linkType; 189 struct WifiDirectNegotiateChannel negoChannel; 190 }; 191 192 struct WifiDirectConnectCallback { 193 void (*onConnectSuccess)(uint32_t requestId, const struct WifiDirectLink *link); 194 void (*onConnectFailure)(uint32_t requestId, int32_t reason); 195 }; 196 197 struct WifiDirectDisconnectCallback { 198 void (*onDisconnectSuccess)(uint32_t requestId); 199 void (*onDisconnectFailure)(uint32_t requestId, int32_t reason); 200 }; 201 202 #ifdef __cplusplus 203 } 204 #endif 205 #endif 206