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 CONN_EVENT_FORM_H
17 #define CONN_EVENT_FORM_H
18 
19 #include <stdint.h>
20 
21 #include "event_form_enum.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef enum {
28     EVENT_SCENE_CONNECT = 1,
29     EVENT_SCENE_START_BASE_LISTENER = 2,
30     EVENT_SCENE_STOP_BASE_LISTENER = 3,
31     EVENT_SCENE_SOCKET_CREATE = 4,
32     EVENT_SCENE_SOCKET_LISTEN = 5,
33     EVENT_SCENE_SOCKET_ACCEPT = 6,
34     EVENT_SCENE_SOCKET_CONNECT = 7,
35     EVENT_SCENE_SOCKET_SHUTDOWN = 8,
36     EVENT_SCENE_SOCKET_CLOSE = 9,
37 } ConnEventScene;
38 
39 typedef enum {
40     EVENT_STAGE_CONNECT_START = 1,
41     EVENT_STAGE_CONNECT_INVOKE_PROTOCOL = 2,
42     EVENT_STAGE_CONNECT_END = 3,
43     EVENT_STAGE_CONNECT_SEND_MESSAGE = 10,
44     EVENT_STAGE_CONNECT_CHECK_HML = 11,
45     EVENT_STAGE_CONNECT_CREATE_GROUP = 12,
46     EVENT_STAGE_CONNECT_CONNECT_NOTIFY = 13,
47     EVENT_STAGE_CONNECT_POST_RENEGOTIATE_REQ = 14,
48     EVENT_STAGE_CONNECT_RENEGOTIATE_CONNECT = 15,
49     EVENT_STAGE_CONNECT_SWITCH_NOTIFY = 16,
50     EVENT_STAGE_CONNECT_POST_RENEGOTIATE_RESP = 17,
51     EVENT_STAGE_CONNECT_CONNECT_GROUP = 18,
52     EVENT_STAGE_CONNECT_CONFIG_INFO = 19,
53     EVENT_STAGE_CONNECT_START_LISTENING = 20,
54     EVENT_STAGE_CONNECT_DEVICE = 2101,
55     EVENT_STAGE_CONNECT_DEVICE_DIRECTLY = 2102,
56     EVENT_STAGE_CONNECT_UPDATE_CONNECTION_RC = 2103,
57     EVENT_STAGE_CONNECT_SERVER_ACCEPTED = 2104,
58     EVENT_STAGE_CONNECT_SEND_BASIC_INFO = 2105,
59     EVENT_STAGE_CONNECT_PARSE_BASIC_INFO = 2106,
60 } ConnEventConnectStage;
61 
62 typedef enum {
63     EVENT_STAGE_TCP_COMMON_ONE = 1,
64 } ConnEventTcpCommonStage;
65 
66 typedef struct {
67     int32_t result;             // STAGE_RES
68     int32_t errcode;            // ERROR_CODE
69     int32_t connectionId;       // CONN_ID
70     int32_t requestId;          // CONN_REQ_ID
71     int32_t linkType;           // LINK_TYPE
72     int32_t authType;           // AUTH_TYPE
73     int32_t authId;             // AUTH_ID
74     const char *lnnType;        // LNN_TYPE
75     int32_t expectRole;         // EXPECT_ROLE
76     int32_t costTime;           // TIME_CONSUMING
77     int32_t rssi;               // RSSI
78     int32_t load;               // CHLOAD
79     int32_t frequency;          // FREQ
80     int32_t connProtocol;       // CONN_PROTOCOL
81     int32_t connRole;           // CONN_ROLE
82     int32_t connRcDelta;        // CONN_RC_DELTA
83     int32_t connRc;             // CONN_RC
84     int32_t supportFeature;     // SUPT_FEATURE
85     int32_t moduleId;           // MODULE_ID
86     uint32_t proType;           // PROTOCOL_TYPE
87     int32_t fd;                 // FD
88     int32_t cfd;                // CFD
89     const char *challengeCode;  // CHALLENGE_CODE
90     const char *peerIp;         // PEER_IP
91     const char *peerBrMac;      // PEER_BR_MAC
92     const char *peerBleMac;     // PEER_BLE_MAC
93     const char *peerWifiMac;    // PEER_WIFI_MAC
94     const char *peerPort;       // PEER_PORT
95     const char *peerNetworkId;  // PEER_NET_ID
96     const char *peerUdid;       // PEER_UDID
97     const char *peerDeviceType; // PEER_DEV_TYPE
98     const char *localNetworkId; // LOCAL_NET_ID
99     const char *callerPkg;      // HOST_PKG
100     const char *calleePkg;      // TO_CALL_PKG
101     int32_t bootLinkType;       // BOOT_LINK_TYPE
102     int32_t isRenegotiate;      // IS_RENEGOTIATE
103     int32_t isReuse;            // IS_REUSE
104     uint64_t negotiateTime;     // NEGOTIATE_TIME_COSUMING
105     uint64_t linkTime;          // LINK_TIME_COSUMING
106     int32_t osType;             // OS_TYPE
107     const char *localDeviceType;   // LOCAL_DEVICE_TYPE
108     const char *remoteDeviceType;  //REMOTE_DEVICE_TYPE
109 } ConnEventExtra;
110 
111 typedef enum {
112     ALARM_SCENE_CONN_RESERVED = 1,
113 } ConnAlarmScene;
114 
115 typedef struct {
116     int32_t errcode;
117     int32_t result;
118     int32_t linkType;
119     int32_t duration;
120     int32_t netType;
121 } ConnAlarmExtra;
122 
123 typedef enum {
124     STATS_SCENE_CONN_RESERVED = 1,
125     STATS_SCENE_CONN_BT_POST_FAILED,
126     STATS_SCENE_CONN_BT_RECV_FAILED,
127     STATS_SCENE_CONN_WIFI_CONN_FAILED,
128     STATS_SCENE_CONN_WIFI_SEND_FAILED,
129     STATS_SCENE_CONN_WIFI_POST_FAILED,
130     STATS_SCENE_CONN_WIFI_RECV_FAILED,
131 } ConnStatsScene;
132 
133 typedef enum {
134     CONN_RESULT_OK = 0,
135     CONN_RESULT_DISCONNECTED,
136     CONN_RESULT_REFUSED,
137 } ConnResult;
138 
139 typedef struct {
140     int32_t reserved;
141 } ConnStatsExtra;
142 
143 typedef enum {
144     AUDIT_SCENE_CONN_HML_GROUP_TIMEOUT = 1,
145 } ConnAuditScene;
146 
147 typedef struct {
148     int32_t errcode;             // ERROR_CODE
149     SoftbusAuditType auditType;  // AUDIT_TYPE
150     int32_t connectionId;        // CONN_ID
151     int32_t requestId;           // REQ_ID
152     int32_t linkType;            // LINK_TYPE
153     int32_t expectRole;          // EXPECT_ROLE
154     int32_t costTime;            // COST_TIME
155     int32_t connectTimes;        // CONN_TIMES
156     const char *frequency;       // FREQ
157     const char *challengeCode;   // CHALLENGE_CODE
158     const char *peerBrMac;       // PEER_BR_MAC
159     const char *localBrMac;      // LOCAL_BR_MAC
160     const char *peerBleMac;      // PEER_BLE_MAC
161     const char *localBleMac;     // LOCAL_BLE_MAC
162     const char *peerWifiMac;     // PEER_WIFI_MAC
163     const char *peerDeviceType;  // PEER_DEV_TYPE
164     const char *peerUdid;        // PEER_UDID
165     const char *localUdid;       // LOCAL_UDID
166     const char *connPayload;     // CONN_PAYLOAD
167     const char *localDeviceName; // LOCAL_DEV_NAME
168     const char *peerIp;          // PEER_IP
169     const char *localIp;         // LOCAL_IP
170     const char *extra;           // EXTRA
171     const char *callerPkg;       // HOST_PKG
172     const char *calleePkg;       // TO_CALL_PKG
173     const char *peerPort;        // PEER_PORT
174     const char *localPort;       // LOCAL_PORT
175 } ConnAuditExtra;
176 
177 #ifdef __cplusplus
178 }
179 #endif /* __cplusplus */
180 #endif // CONN_EVENT_FORM_H
181