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_ERROR_CODE_H
17 #define WIFI_DIRECT_ERROR_CODE_H
18
19 #ifdef __cplusplus
20 #include <cstdlib>
21 #else
22 #include <stdlib.h>
23 #endif
24 #include "softbus_error_code.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 enum WifiDirectErrorCode {
31 /* Error code representing OK */
32 OK = 0,
33
34 /* Error code representing start position of V1 errors. */
35 V1_ERROR_START = -401000,
36
37 /* Indicating cannot build a p2p link because the device is already connected with a mismatch role. */
38 V1_ERROR_CONNECTED_WITH_MISMATCHED_ROLE = V1_ERROR_START - 1,
39
40 /* Indicating cannot build a p2p link because this device is already be GC. */
41 V1_ERROR_GC_CONNECTED_TO_ANOTHER_DEVICE = V1_ERROR_START - 2,
42
43 /* Indicating cannot build a p2p link because this device cannot be connected with the specified role. */
44 V1_ERROR_AVAILABLE_WITH_MISMATCHED_ROLE = V1_ERROR_START - 3,
45
46 /* Indicating cannot build a p2p link because the remote device is already be GC. */
47 V1_ERROR_PEER_GC_CONNECTED_TO_ANOTHER_DEVICE = V1_ERROR_START - 4,
48
49 /* Indicating cannot build a p2p link because both the devices are GO. */
50 V1_ERROR_BOTH_GO = V1_ERROR_START - 5,
51
52 /* Indicating that two devices initiate a connection to peer device at the same time. */
53 V1_ERROR_TWO_WAY_SIMULTANEOUS_CONNECTION = V1_ERROR_START - 6,
54
55 /* Indicating that this connect request has timed out. */
56 V1_ERROR_CONNECT_TIMEOUT = V1_ERROR_START - 7,
57
58 /* Indicating that failure occurred when reusing p2p link. */
59 V1_ERROR_REUSE_FAILED = V1_ERROR_START - 8,
60
61 /* Indicating that p2p link is used by another service. */
62 V1_ERROR_LINK_USED_BY_ANOTHER_SERVICE = V1_ERROR_START - 9,
63
64 /* Indicating that GOInfo is wrong. */
65 V1_ERROR_WRONG_GO_INFO = V1_ERROR_START - 10,
66
67 /* Indicating that GCInfo is wrong. */
68 V1_ERROR_WRONG_GC_INFO = V1_ERROR_START - 11,
69
70 /* Indicating that post message to remote device via AuthConnection has failed. */
71 V1_ERROR_POST_MESSAGE_FAILED = V1_ERROR_START - 12,
72
73 /* Indicating that cannot build a p2p link because current device is busy. */
74 V1_ERROR_BUSY = V1_ERROR_START - 15,
75
76 /* Indicating that peer device is not a trusted device. */
77 V1_ERROR_NOT_TRUSTED_DEVICE = V1_ERROR_START - 17,
78
79 /* Indicating that connect group failed. */
80 V1_ERROR_CONNECT_GROUP_FAILED = V1_ERROR_START - 18,
81
82 /* Indicating that create group failed. */
83 V1_ERROR_CREATE_GROUP_FAILED = V1_ERROR_START - 19,
84
85 /* Indicating that connect group timeout. */
86 V1_ERROR_PEER_CONNECT_GROUP_FAILED = V1_ERROR_START - 20,
87
88 /* Indicating that create group timeout. */
89 V1_ERROR_PEER_CREATE_GROUP_FAILED = V1_ERROR_START - 21,
90
91 /* Indicating that create group timeout. */
92 V1_ERROR_RPT_ENABLED = V1_ERROR_START - 22,
93
94 /* Indicating that create group timeout. */
95 V1_ERROR_PEER_RPT_ENABLED = V1_ERROR_START - 23,
96
97 /* Indicating unknown reason. */
98 V1_ERROR_UNKNOWN = V1_ERROR_START - 24,
99
100 /* Indicating p2p interface is not available */
101 V1_ERROR_IF_NOT_AVAILABLE = V1_ERROR_START - 25,
102
103 /* Error code representing end position of v1 errors. */
104 V1_ERROR_END = V1_ERROR_START - 30,
105
106 /* Base error code */
107 ERROR_BASE = -200000,
108
109 /* Error code representing invalid input parameters */
110 ERROR_INVALID_INPUT_PARAMETERS = ERROR_BASE - 1,
111
112 /* Error code representing not context */
113 ERROR_NO_CONTEXT = ERROR_BASE - 2,
114
115 /* Error code representing entity is busy */
116 ERROR_ENTITY_BUSY = ERROR_BASE - 3,
117
118 /* Error code representing fail to generate a command */
119 ERROR_GENERATE_COMMAND_FAILED = ERROR_BASE - 4,
120
121 /* Error code representing fail to post data */
122 ERROR_POST_DATA_FAILED = ERROR_BASE - 5,
123
124 /* Error code representing wait link state change timeout */
125 ERROR_WAIT_LINK_CHANGE_TIMEOUT = ERROR_BASE - 6,
126
127 /* Error code representing reuse link fail */
128 ERROR_SINK_REUSE_LINK_FAILED = ERROR_BASE - 7,
129
130 /* Error code representing remove link fail */
131 ERROR_REMOVE_LINK_FAILED = ERROR_BASE - 8,
132
133 /* Error code representing fail to config Ip */
134 ERROR_CONFIG_IP_FAIL = ERROR_BASE - 9,
135
136 /* Error code representing no interface info on sink end */
137 ERROR_SINK_NO_INTERFACE_INFO = ERROR_BASE - 10,
138
139 /* Error code representing fail to reuse link on source end */
140 ERROR_SOURCE_REUSE_LINK_FAILED = ERROR_BASE - 11,
141
142 /* Error code representing no interface info on source end */
143 ERROR_SOURCE_NO_INTERFACE_INFO = ERROR_BASE - 12,
144
145 /* Error code representing no link on source end */
146 ERROR_SOURCE_NO_LINK = ERROR_BASE - 13,
147
148 /* Error code representing no link on sink end */
149 ERROR_SINK_NO_LINK = ERROR_BASE - 14,
150
151 /* Error code representing manager is busy */
152 ERROR_MANAGER_BUSY = ERROR_BASE - 15,
153
154 /* Error code representing information on auth connection is wrong */
155 ERROR_WRONG_AUTH_CONNECTION_INFO = ERROR_BASE - 16,
156
157 /* Error code representing start position of wifi direct errors */
158 ERROR_WIFI_DIRECT_START = ERROR_BASE - 4000,
159
160 /* Error code representing no suitable wifi direct processor */
161 ERROR_WIFI_DIRECT_NO_SUITABLE_PROCESSOR = ERROR_BASE - 4001,
162
163 /* Error code representing failed to process wifi direct command */
164 ERROR_WIFI_DIRECT_PROCESS_FAILED = ERROR_BASE - 4002,
165
166 /* Error code representing wrong wifi direct negotiation msg */
167 ERROR_WIFI_DIRECT_WRONG_NEGOTIATION_MSG = ERROR_BASE - 4003,
168
169 /* Error code representing wifi if off */
170 ERROR_WIFI_OFF = ERROR_BASE - 4004,
171
172 /* Error code representing rpt is enabled */
173 ERROR_RPT_ENABLED = ERROR_BASE - 4005,
174
175 /* Error code representing no suitable protocol */
176 ERROR_WIFI_DIRECT_NO_SUITABLE_PROTOCOL = ERROR_BASE - 4006,
177
178 /* Error code representing fail to pack data */
179 ERROR_WIFI_DIRECT_PACK_DATA_FAILED = ERROR_BASE - 4007,
180
181 /* Error code representing wait negotiation message timeout */
182 ERROR_WIFI_DIRECT_WAIT_NEGOTIATION_MSG_TIMEOUT = ERROR_BASE - 4008,
183
184 /* Error code representing wait connect request timeout */
185 ERROR_WIFI_DIRECT_WAIT_CONNECT_REQUEST_TIMEOUT = ERROR_BASE - 4009,
186
187 /* Error code representing wait connect response timeout */
188 ERROR_WIFI_DIRECT_WAIT_CONNECT_RESPONSE_TIMEOUT = ERROR_BASE - 4010,
189
190 /* Error code representing fail to get LinkInfo on sink end */
191 ERROR_WIFI_DIRECT_SINK_GET_LINK_INFO_FAILED = ERROR_BASE - 4011,
192
193 /* Error code representing fail to get remote wifi config info */
194 ERROR_WIFI_DIRECT_GET_REMOTE_WIFI_CFG_INFO_FAILED = ERROR_BASE - 4012,
195
196 /* Error code representing fail to get local wifi config info */
197 ERROR_WIFI_DIRECT_SINK_GET_LOCAL_WIFI_CFG_INFO_FAILED = ERROR_BASE - 4013,
198
199 /* Error code representing fail to get LinkInfo on source end */
200 ERROR_WIFI_DIRECT_SOURCE_GET_LINK_INFO_FAILED = ERROR_BASE - 4014,
201
202 /* Error code representing fail to set connect notify */
203 ERROR_WIFI_DIRECT_SET_CONNECT_NOTIFY_FAILED = ERROR_BASE - 4015,
204
205 /* Error code representing local link is not connected, but remote link is still connected */
206 ERROR_WIFI_DIRECT_LOCAL_DISCONNECTED_REMOTE_CONNECTED = ERROR_BASE - 4016,
207
208 /* Error code representing local link is connected, but remote link is not connected */
209 ERROR_WIFI_DIRECT_LOCAL_CONNECTED_REMOTE_DISCONNECTED = ERROR_BASE - 4017,
210
211 /* Error code representing two devices initiate a connection or a disconnection to peer device simultaneously */
212 ERROR_WIFI_DIRECT_BIDIRECTIONAL_SIMULTANEOUS_REQ = ERROR_BASE - 4018,
213
214 /* Error code representing there exists no available interface */
215 ERROR_WIFI_DIRECT_NO_AVAILABLE_INTERFACE = ERROR_BASE - 4019,
216
217 /* Error code representing remote device is not trusted */
218 ERROR_WIFI_DIRECT_NOT_TRUSTED_DEVICE = ERROR_BASE - 4020,
219
220 /* Error code representing remote device is not trusted */
221 ERROR_WIFI_DIRECT_UNPACK_DATA_FAILED = ERROR_BASE - 4021,
222
223 /* Error code representing command wait timeout */
224 ERROR_WIFI_DIRECT_COMMAND_WAIT_TIMEOUT = ERROR_BASE - 4022,
225
226 /* Error code representing wait connect reuse response timeout */
227 ERROR_WIFI_DIRECT_WAIT_REUSE_RESPONSE_TIMEOUT = ERROR_BASE - 4023,
228
229 /* Error code representing p2p link is used by another service */
230 ERROR_P2P_LINK_USED_BY_ANOTHER_SERVICE = ERROR_BASE - 5000,
231
232 /* Error code representing mismatch role */
233 ERROR_P2P_GC_AVAILABLE_WITH_MISMATCHED_ROLE = ERROR_BASE - 5001,
234
235 /* Error code representing current GC device has connected to another device */
236 ERROR_P2P_GC_CONNECTED_TO_ANOTHER_DEVICE = ERROR_BASE - 5002,
237
238 /* Error code representing the GO is not a trusted device */
239 ERROR_P2P_GO_NOT_TRUSTED = ERROR_BASE - 5003,
240
241 /* Error code representing fail to apply GC ip address */
242 ERROR_P2P_APPLY_GC_IP_FAIL = ERROR_BASE - 5004,
243
244 /* Error code representing p2p server has already destroyed */
245 ERROR_P2P_SERVER_ALREADY_DESTROYED = ERROR_BASE - 5005,
246
247 /* Error code representing two devices are both GO */
248 ERROR_P2P_BOTH_GO = ERROR_BASE - 5006,
249
250 /* Error code representing remote GC device has connected to another GO */
251 ERROR_P2P_PEER_GC_CONNECTED_TO_ANOTHER_DEVICE = ERROR_BASE - 5007,
252
253 /* Error code representing GO available with mismatched role */
254 ERROR_P2P_GO_AVAILABLE_WITH_MISMATCHED_ROLE = ERROR_BASE - 5008,
255
256 /* Error code representing fail to remove link */
257 ERROR_P2P_SHARE_LINK_REMOVE_FAILED = ERROR_BASE - 5009,
258
259 /* Error code representing fail to reuse link */
260 ERROR_P2P_SHARE_LINK_REUSE_FAILED = ERROR_BASE - 5010,
261
262 /* Error code representing handling an expired request */
263 ERROR_P2P_EXPIRED_REQ = ERROR_BASE - 5011,
264
265 /* Error code representing handling an expired response */
266 ERROR_P2P_EXPIRED_RESP = ERROR_BASE - 5012,
267
268 /* Error code representing fail to connect group */
269 ERROR_P2P_CONNECT_GROUP_FAILED = ERROR_BASE - 5200,
270
271 /* Error code representing p2p client already exists */
272 ERROR_P2P_CLIENT_EXISTS = ERROR_BASE - 5201,
273
274 /* Error code representing fail to create p2p group */
275 ERROR_P2P_CREATE_GROUP_FAILED = ERROR_BASE - 5600,
276
277 /* Error code representing p2p server already exists */
278 ERROR_P2P_SERVER_EXISTS = ERROR_BASE - 5601,
279
280 /* Error code representing fail disconnect hml */
281 ERROR_HML_DISCONNECT_FAIL = ERROR_BASE - 6000,
282
283 /* Error code representing config ip fail */
284 ERROR_HML_CONFIG_IP_FAIL = ERROR_BASE - 6001,
285
286 /* Error code representing apply ip fail */
287 ERROR_HML_APPLY_IP_FAIL = ERROR_BASE - 6002,
288
289 /* Error code representing fail to connect hml group */
290 ERROR_HML_CONNECT_GROUP_FAIL = ERROR_BASE - 6200,
291
292 /* Error code representing fail to create hml group */
293 ERROR_HML_CREATE_GROUP_FAIL = ERROR_BASE - 6600,
294
295 /* Error code representing fail to destroy hml group */
296 ERROR_HML_DESTROY_FAIL = ERROR_BASE - 6601,
297
298 /* Error code representing fail to notify connect */
299 ERROR_HML_CONNECT_NOTIFY_FAIL = ERROR_BASE - 6602,
300
301 /* Error code representing 3 vap conflict */
302 ERROR_LOCAL_THREE_VAP_CONFLICT = ERROR_BASE - 6603,
303
304 /* Error code representing Peer device 3 vap conflict */
305 ERROR_PEER_THREE_VAP_CONFLICT = ERROR_BASE - 6604,
306
307 /* Error code representing Local device 3 vap dbac conflict */
308 ERROR_LOCAL_THREE_VAP_DBAC_CONFLICT = ERROR_BASE - 6605,
309
310 /* Error code representing Peer device 3 vap dbac conflict */
311 ERROR_PEER_THREE_VAP_DBAC_CONFLICT = ERROR_BASE - 6606,
312
313 /* Error code representing Entity is unavailable */
314 ERROR_ENTITY_UNAVAILABLE = ERROR_BASE - 6607,
315
316 /* Error code representing remote client join failed */
317 ERROR_HML_CLIENT_JOIN_FAIL = ERROR_BASE - 6608,
318
319 /* Error code representing switch notify failed */
320 ERROR_HML_SWITCH_NOTIFY_FAIL = ERROR_BASE - 6609,
321
322 /* Error code representing switch notify failed */
323 ERROR_HML_RENEGO_TO_P2P = ERROR_BASE - 6610,
324
325 /* Error code representing waiting hand shake timeout */
326 ERROR_HML_WAITING_HANDSHAKE_TIMEOUT = ERROR_BASE - 6611,
327
328 /* Error code wait HML_CREATE_GROUP timeout */
329 ERROR_HML_CREATE_GROUP_TIMEOUT = ERROR_BASE - 6612,
330
331 /* Error code wait HML_DESTROY_GROUP timeout */
332 ERROR_HML_DESTROY_GROUP_TIMEOUT = ERROR_BASE - 6613,
333
334 /* Error code wait HML_CONN_NOTIFY timeout */
335 ERROR_HML_CONN_NOTIFY_TIMEOUT = ERROR_BASE - 6614,
336
337 /* Error code wait HML_CONNECT_GROUP timeout */
338 ERROR_HML_CONNECT_GROUP_TIMEOUT = ERROR_BASE - 6615,
339
340 /* Error code wait HML_DISCONNECT_GROUP timeout */
341 ERROR_HML_DISCONNECT_GROUP_TIMEOUT = ERROR_BASE - 6616,
342
343 /* Error code auth start listen failed */
344 ERROR_HML_AUTH_START_LISTEN_FAIL = ERROR_BASE - 6617,
345
346 /* Error code auth open connection failed */
347 ERROR_HML_AUTH_OPEN_CONNECTION_FAIL = ERROR_BASE - 6618,
348
349 /* Error code switch notify timeout */
350 ERROR_HML_SWITCH_NOTIFY_TIMEOUT = ERROR_BASE - 6619,
351
352 /* Error code need renegotiate */
353 ERROR_HML_NEED_RENEGOTIATE = ERROR_BASE - 6620,
354
355 /* Error code need renegotiate */
356 ERROR_HML_PRE_ASSIGN_PORT_FAILED = ERROR_BASE - 6621,
357
358 /* Error code no negotiate channel */
359 ERROR_NO_NEGO_CHANNEL = ERROR_BASE - 6622,
360
361 /* Error code parallelism conflict */
362 ERROR_PARALLELISM_CONFLICT = ERROR_BASE - 6623,
363
364 /* Error code retry for avoid block */
365 ERROR_RETRY_FOR_AVOID_BLOCK = ERROR_BASE - 6624,
366
367 /* Error code no wifi config info */
368 ERROR_NO_WIFI_CONFIG_INFO = ERROR_BASE - 6625,
369
370 /* Error code start action listen failed */
371 ERROR_START_ACTION_LISTEN_FAILED = ERROR_BASE - 6626,
372
373 /* Error code trigger message not handled */
374 ERROR_TRIGGER_MSG_NOT_HANDLED = ERROR_BASE - 6627,
375
376 /* Error code representing end position of wifi direct errors */
377 ERROR_WIFI_DIRECT_END = ERROR_BASE - 6999,
378 };
379
ToSoftBusErrorCode(int32_t errorCode)380 static inline int32_t ToSoftBusErrorCode(int32_t errorCode)
381 {
382 return SOFTBUS_ERRNO(SHORT_DISTANCE_MAPPING_MODULE_CODE) + abs(errorCode);
383 }
384 #ifdef __cplusplus
385 }
386 #endif
387 #endif
388