• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_STRUCT_H
17 #define WIFI_DIRECT_TYPES_STRUCT_H
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 #include <stddef.h>
22 
23 #include "softbus_common.h"
24 #include "wifi_direct_defines_struct.h"
25 #include "wifi_direct_error_code_struct.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     WIFI_DIRECT_CONNECT_TYPE_SPARKLINK_TRIGGER_HML = 5,
43 };
44 
45 enum WifiDirectRole {
46     WIFI_DIRECT_ROLE_AUTO = 1,
47     WIFI_DIRECT_ROLE_GO = 2,
48     WIFI_DIRECT_ROLE_GC = 3,
49     WIFI_DIRECT_ROLE_BRIDGE_GC = 4,
50     WIFI_DIRECT_ROLE_NONE = 5,
51     WIFI_DIRECT_ROLE_HML = 6,
52     WIFI_DIRECT_ROLE_INVALID = 7,
53 };
54 
55 enum WifiDirectApiRole {
56     WIFI_DIRECT_API_ROLE_NONE = 0,
57     WIFI_DIRECT_API_ROLE_STA = 1,
58     WIFI_DIRECT_API_ROLE_AP = 2,
59     WIFI_DIRECT_API_ROLE_GO = 4,
60     WIFI_DIRECT_API_ROLE_GC = 8,
61     WIFI_DIRECT_API_ROLE_HML = 16,
62 };
63 
64 enum P2pGroupConfigIndex {
65     P2P_GROUP_CONFIG_INDEX_SSID = 0,
66     P2P_GROUP_CONFIG_INDEX_BSSID = 1,
67     P2P_GROUP_CONFIG_INDEX_SHARE_KEY = 2,
68     P2P_GROUP_CONFIG_INDEX_FREQ = 3,
69     P2P_GROUP_CONFIG_INDEX_MODE = 4,
70     P2P_GROUP_CONFIG_INDEX_MAX,
71 };
72 
73 enum WifiDirectLinkType {
74     WIFI_DIRECT_LINK_TYPE_INVALID = -1,
75     WIFI_DIRECT_LINK_TYPE_P2P,
76     WIFI_DIRECT_LINK_TYPE_HML,
77 };
78 
79 enum WifiDirectBandWidth {
80     BAND_WIDTH_RANDOM = 0x0,
81     BAND_WIDTH_20M,
82     BAND_WIDTH_40M,
83     BAND_WIDTH_80M,
84     BAND_WIDTH_80P80M,
85     BAND_WIDTH_160M,
86     BAND_WIDTH_BUTT = 0xFF,
87 };
88 
89 typedef enum {
90     CONN_HML_CAP_UNKNOWN = -1,
91     CONN_HML_SUPPORT = 0,
92     CONN_HML_NOT_SUPPORT = 1,
93 } HmlCapabilityCode;
94 
95 typedef enum {
96     CONN_VIRTUAL_LINK_CAP_UNKNOWN = -1,
97     CONN_VIRTUAL_LINK_SUPPORT = 0,
98     CONN_VIRTUAL_LINK_NOT_SUPPORT = 1,
99 } VirtualLinkCapabilityCode;
100 
101 typedef enum {
102     CONN_VSP_CAP_UNKNOWN = -1,
103     CONN_VSP_SUPPORT = 0,
104     CONN_VSP_NOT_SUPPORT = 1,
105 } VspCapabilityCode;
106 
107 typedef enum {
108     CONN_HML_ENABLED,
109     CONN_HML_DISABLED,
110     CONN_HML_STATE_MAX,
111 } SoftBusHmlState;
112 
113 typedef enum {
114     INVALID_POWER,
115     LOW_POWER,
116     DEFAULT_POWER,
117 } LinkPowerMode;
118 
119 typedef enum {
120     WIFI_DIRECT_SCREEN_OFF,
121     WIFI_DIRECT_SCREEN_ON,
122 } WifiDirectScreenState;
123 
124 struct WifiDirectLink {
125     int32_t linkId;
126     char localIp[IP_STR_MAX_LEN];
127     char remoteIp[IP_STR_MAX_LEN];
128     enum WifiDirectLinkType linkType;
129     enum WifiDirectBandWidth bandWidth;
130     bool isReuse;
131     int channelId;
132     // localIpv6 and remoteIpv6 is only used with remotePort
133     char localIpv6[IP_STR_MAX_LEN];
134     char remoteIpv6[IP_STR_MAX_LEN];
135     int32_t remotePort;
136 };
137 
138 struct WifiDirectSinkLink {
139     char remoteUuid[UUID_BUF_LEN];
140     int channelId;
141     enum WifiDirectBandWidth bandWidth;
142     enum WifiDirectLinkType linkType;
143 
144     char localIp[IP_STR_MAX_LEN];
145     char remoteIp[IP_STR_MAX_LEN];
146 
147     char remoteMac[MAC_ADDR_STR_LEN];
148 };
149 
150 enum WifiDirectNegoChannelType {
151     NEGO_CHANNEL_NULL = 0,
152     NEGO_CHANNEL_AUTH = 1,
153     NEGO_CHANNEL_COC = 2,
154     NEGO_CHANNEL_ACTION = 3,
155     NEGO_CHANNEL_SHARE = 4,
156 };
157 
158 struct WifiDirectNegotiateChannel {
159     enum WifiDirectNegoChannelType type;
160     union {
161         AuthHandle authHandle;
162         int32_t channelId;
163         uint32_t actionAddr;
164     } handle;
165 };
166 
167 enum IpAddrType {
168     IPV4,
169     IPV6
170 };
171 
172 enum StatisticLinkType {
173     STATISTIC_P2P = 0,
174     STATISTIC_HML = 1,
175     STATISTIC_TRIGGER_HML = 2,
176     STATISTIC_LINK_TYPE_NUM = 3,
177 };
178 
179 enum StatisticBootLinkType {
180     STATISTIC_NONE = 0,
181     STATISTIC_WLAN = 1,
182     STATISTIC_BLE = 2,
183     STATISTIC_BR = 3,
184     STATISTIC_COC = 4,
185     STATISTIC_ACTION = 5,
186     STATISTIC_BLE_AND_ACTION = 6,
187     STATISTIC_BLE_TRIGGER = 7,
188     STATISTIC_RENEGOTIATE = 8,
189     STATISTIC_SPARK_LINK_TRIGGER = 9,
190     STATISTIC_BOOT_LINK_TYPE_NUM = 10,
191 };
192 
193 struct WifiDirectDfxInfo {
194     enum StatisticLinkType linkType;
195     enum StatisticBootLinkType bootLinkType;
196     int renegotiate;
197     int reuse;
198     int costTime;
199     uint16_t challengeCode;
200     int frequency;
201     int staChannel;
202     int hmlChannel;
203     int p2pChannel;
204     int apChannel;
205 };
206 
207 struct WifiDirectConnectInfo {
208     uint32_t requestId;
209     int32_t pid;
210     enum WifiDirectConnectType connectType;
211     bool isStrictProtocol; // for HMLv1 | P2Pv2
212     struct WifiDirectNegotiateChannel negoChannel;
213     bool reuseOnly;
214     uint32_t expectApiRole;
215     bool isStrict;
216     char remoteNetworkId[NETWORK_ID_BUF_LEN];
217     char remoteMac[MAC_ADDR_STR_LEN];
218     bool isNetworkDelegate;
219     bool ratePreference;
220     int32_t bandWidth;
221     enum IpAddrType ipAddrType;
222     struct WifiDirectDfxInfo dfxInfo;
223     bool isVirtualLink;
224 };
225 
226 struct WifiDirectDisconnectInfo {
227     uint32_t requestId;
228     int32_t pid;
229     int32_t linkId;
230     struct WifiDirectNegotiateChannel negoChannel;
231 };
232 
233 struct WifiDirectForceDisconnectInfo {
234     uint32_t requestId;
235     int32_t pid;
236     char remoteUuid[UUID_BUF_LEN];
237     enum WifiDirectLinkType linkType;
238     struct WifiDirectNegotiateChannel negoChannel;
239 };
240 
241 struct WifiDirectConnectCallback {
242     void (*onConnectSuccess)(uint32_t requestId, const struct WifiDirectLink *link);
243     void (*onConnectFailure)(uint32_t requestId, int32_t reason);
244 };
245 
246 struct WifiDirectDisconnectCallback {
247     void (*onDisconnectSuccess)(uint32_t requestId);
248     void (*onDisconnectFailure)(uint32_t requestId, int32_t reason);
249 };
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 #endif