• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_INVALID = -1,
37     WIFI_DIRECT_CONNECT_TYPE_WIFI_DIRECT = 0,
38     WIFI_DIRECT_CONNECT_TYPE_P2P = 1,
39     WIFI_DIRECT_CONNECT_TYPE_HML = 2,
40     WIFI_DIRECT_CONNECT_TYPE_MAX,
41 };
42 
43 enum WifiDirectRole {
44     WIFI_DIRECT_ROLE_AUTO = 1,
45     WIFI_DIRECT_ROLE_GO = 2,
46     WIFI_DIRECT_ROLE_GC = 3,
47     WIFI_DIRECT_ROLE_BRIDGE_GC = 4,
48     WIFI_DIRECT_ROLE_NONE = 5,
49     WIFI_DIRECT_ROLE_HML = 6,
50     WIFI_DIRECT_ROLE_INVALID = 7,
51 };
52 
53 enum WifiDirectApiRole {
54     WIFI_DIRECT_API_ROLE_NONE = 0,
55     WIFI_DIRECT_API_ROLE_STA = 1,
56     WIFI_DIRECT_API_ROLE_AP = 2,
57     WIFI_DIRECT_API_ROLE_GO = 4,
58     WIFI_DIRECT_API_ROLE_GC = 8,
59     WIFI_DIRECT_API_ROLE_HML = 16,
60 };
61 
62 enum WifiDirectP2pContentType {
63     P2P_CONTENT_TYPE_INVALID = -1,
64     P2P_CONTENT_TYPE_GO_INFO = 1,
65     P2P_CONTENT_TYPE_GC_INFO = 2,
66     P2P_CONTENT_TYPE_RESULT = 3,
67 };
68 
69 enum WifiDirectNegotiateCmdType {
70     CMD_INVALID = -1,
71     /* v1 cmd */
72     CMD_DISCONNECT_V1_REQ = 5,
73     CMD_CONN_V1_REQ = 8,
74     CMD_CONN_V1_RESP = 9,
75     CMD_REUSE_REQ = 12,
76     CMD_CTRL_CHL_HANDSHAKE = 13,
77     CMD_REUSE_RESP = 19,
78 
79     /* v2 cmd */
80     CMD_CONN_V2_REQ_1 = 21,
81     CMD_CONN_V2_REQ_2 = 22,
82     CMD_CONN_V2_REQ_3 = 23,
83     CMD_CONN_V2_RESP_1 = 24,
84     CMD_CONN_V2_RESP_2 = 25,
85     CMD_CONN_V2_RESP_3 = 26,
86     CMD_DISCONNECT_V2_REQ = 27,
87     CMD_DISCONNECT_V2_RESP = 28,
88     CMD_CLIENT_JOIN_FAIL_NOTIFY = 29,
89 
90     CMD_PC_GET_INTERFACE_INFO_REQ = 30,
91     CMD_PC_GET_INTERFACE_INFO_RESP = 31,
92 };
93 
94 enum WifiDirectEntityType {
95     ENTITY_TYPE_P2P = 0,
96     ENTITY_TYPE_HML = 1,
97     ENTITY_TYPE_MAX,
98 };
99 
100 enum P2pGroupConfigIndex {
101     P2P_GROUP_CONFIG_INDEX_SSID = 0,
102     P2P_GROUP_CONFIG_INDEX_BSSID = 1,
103     P2P_GROUP_CONFIG_INDEX_SHARE_KEY = 2,
104     P2P_GROUP_CONFIG_INDEX_FREQ = 3,
105     P2P_GROUP_CONFIG_INDEX_MODE = 4,
106     P2P_GROUP_CONFIG_INDEX_MAX,
107 };
108 
109 struct WifiDirectLink {
110     int32_t linkId;
111     char localIp[IP_ADDR_STR_LEN];
112     char remoteIp[IP_ADDR_STR_LEN];
113     enum WifiDirectConnectType connectType;
114 };
115 
116 struct WifiDirectNegotiateChannel;
117 struct WifiDirectConnectInfo {
118     int32_t requestId;
119     int32_t pid;
120     enum WifiDirectConnectType connectType;
121     struct WifiDirectNegotiateChannel *negoChannel;
122     enum WifiDirectRole expectRole;
123     char remoteMac[MAC_ADDR_STR_LEN];
124     bool isNetworkDelegate;
125     int32_t linkId;
126 };
127 
128 struct WifiDirectConnectCallback {
129     void (*onConnectSuccess)(int32_t requestId, const struct WifiDirectLink *link);
130     void (*onConnectFailure)(int32_t requestId, enum WifiDirectErrorCode reason);
131     void (*onDisconnectSuccess)(int32_t requestId);
132     void (*onDisconnectFailure)(int32_t requestId, enum WifiDirectErrorCode reason);
133 };
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 #endif