• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 HISYSEVENT_ADAPTER_H
17 #define HISYSEVENT_ADAPTER_H
18 
19 #include <stddef.h>
20 
21 #define CREATE_GROUP_EVENT "CreateGroup"
22 #define DELETE_GROUP_EVENT "DeleteGroup"
23 #define ADD_MEMBER_EVENT "AddMember"
24 #define DEL_MEMBER_EVENT "DelMember"
25 #define ADD_MULTI_MEMBER_EVENT "AddMultiMember"
26 #define DEL_MULTI_MEMBER_EVENT "DelMultiMember"
27 #define AUTH_DEV_EVENT "AuthDevice"
28 
29 #define CANCEL_REQUEST_EVENT "CancelRequest"
30 #define GET_REGISTER_INFO_EVENT "GetRegisterInfo"
31 #define GET_PK_INFO_LIST_EVENT "GetPkInfoList"
32 
33 #define ADD_MEMBER_WITH_LITE_COMPATIBILITY "AddMemberWithLiteCompatibility"
34 #define ADD_MEMBER_WITH_LITE_STANDARD "AddMemberWithLiteStandard"
35 #define UPGRADE_DATA_EVENT "UpgradeData"
36 #define BIND_CONSUME_EVENT "BindConsume"
37 #define AUTH_CONSUME_EVENT "AuthConsume"
38 #define ADD_MEMBER_TO_CALL_PKG_NAME "dsoftbus"
39 #define ADD_MEMBER_HOST_PKG_NAME "deviceManager"
40 #define AUTH_DEVICE_HOST_PKG_NAME "dsoftbus"
41 
42 #define ANONYMOUS_UDID_LEN 12
43 
44 #define DEFAULT_GROUP_TYPE 0
45 #define DEFAULT_MULTI_MEMBER_GROUP_TYPE 1
46 #define DEFAULT_CRED_TYPE 0
47 #define DEFAULT_CALL_RESULT 0
48 #define DEFAULT_APPID NULL
49 
50 #define DEFAULT_EXECUTION_TIME 0
51 #define DEFAULT_REQ_ID 0
52 #define DEFAULT_FAULT_INFO NULL
53 #define DEFAULT_EXT_INFO NULL
54 
55 #include <stdint.h>
56 
57 enum DevAuthReportProcessCode {
58     PROCESS_BIND_V1 = 0x001000,
59     PROCESS_AUTH_V1,
60     PROCESS_BIND_V2,
61     PROCESS_AUTH_V2,
62     PROCESS_CREATE_GROUP,
63     PROCESS_DELETE_GROUP,
64     PROCESS_DELETE_MEMBER_FROM_GROUP,
65     PROCESS_ADD_MULTI_MEMBERS_TO_GROUP,
66     PROCESS_DEL_MULTI_MEMBERS_FROM_GROUP,
67     PROCESS_UPDATE
68 };
69 
70 #define DEFAULT_PNAMEID "device_auth"
71 #define DEFAULT_PVERSIONID "1.0"
72 
73 #ifndef DEV_AUTH_HIVIEW_ENABLE
74 
75 #define DEV_AUTH_REPORT_CALL_EVENT(eventData)
76 #define DEV_AUTH_REPORT_FAULT_EVENT(eventdata)
77 #define DEV_AUTH_REPORT_FAULT_EVENT_WITH_ERR_CODE(funcName, processCode, errorCode)
78 #define DEV_AUTH_REPORT_UE_CALL_EVENT(osAccountId, groupType, appId, funcName)
79 #define DEV_AUTH_REPORT_UE_CALL_EVENT_BY_PARAMS(osAccountId, inParams, appId, funcName)
80 #else
81 
82 #define DEV_AUTH_REPORT_CALL_EVENT(eventData) \
83     DevAuthReportCallEvent(eventData)
84 #define DEV_AUTH_REPORT_FAULT_EVENT(eventdata) \
85     DevAuthReportFaultEvent(eventdata)
86 #define DEV_AUTH_REPORT_FAULT_EVENT_WITH_ERR_CODE(funcName, processCode, errorCode) \
87     DevAuthReportFaultEventWithErrCode(funcName, processCode, errorCode)
88 #define DEV_AUTH_REPORT_UE_CALL_EVENT(osAccountId, groupType, appId, funcName) \
89     DevAuthReportUeCallEvent(osAccountId, groupType, appId, funcName)
90 #define DEV_AUTH_REPORT_UE_CALL_EVENT_BY_PARAMS(osAccountId, inParams, appId, funcName) \
91     DevAuthReportUeCallEventByParams(osAccountId, inParams, appId, funcName)
92 
93 #ifdef __cplusplus
94 extern "C" {
95 #endif
96 
97 typedef struct {
98     const char *funcName;
99     const char *appId;
100     int32_t osAccountId;
101     int32_t callResult;
102     int32_t processCode;
103     uint8_t credType;
104     int32_t groupType;
105     int64_t executionTime;
106     const char *extInfo;
107 } DevAuthCallEvent;
108 
109 typedef struct {
110     const char *orgPkg;
111     const char *funcName;
112     int32_t bizScene;
113     int32_t bizState;
114     int32_t bizStage;
115     int32_t stageRes;
116     int32_t errorCode;
117     const char *toCallPkg;
118     const char *hostPkg;
119     const char *localUdid;
120     const char *peerUdid;
121     const char *concurrentId;
122 } DevAuthBehaviorEvent;
123 
124 typedef struct {
125     const char *appId;
126     int32_t processCode;
127     const char *funcName;
128     int64_t reqId;
129     int32_t errorCode;
130     const char *faultInfo;
131 } DevAuthFaultEvent;
132 
133 typedef enum {
134     BIZ_SCENE_ADD_MEMBER_CLIENT = 1,
135     BIZ_SCENE_ADD_MEMBER_SERVER,
136     BIZ_SCENE_AUTH_DEVICE_CLIENT,
137     BIZ_SCENE_AUTH_DEVICE_SERVER
138 } DevAuthBizScene;
139 
140 typedef enum {
141     BIZ_STATE_PROCESS = 0,
142     BIZ_STATE_BEGIN,
143     BIZ_STATE_END
144 } DevAuthBizState;
145 
146 typedef enum {
147     BIZ_STAGE_BEGIN = 1,
148     BIZ_STAGE_PROCESS
149 } DevAuthBizStage;
150 
151 typedef enum {
152     STAGE_RES_IDLE = 0,
153     STAGE_RES_SUCCESS,
154     STAGE_RES_FAILED
155 } DevAuthStageRes;
156 
157 void DevAuthReportCallEvent(const DevAuthCallEvent eventData);
158 void DevAuthReportBehaviorEvent(const DevAuthBehaviorEvent *eventData);
159 void BuildBehaviorEventData(DevAuthBehaviorEvent *eventData, const char *funcName, int32_t bizScene, int32_t bizState,
160     int32_t bizStage);
161 void DevAuthReportFaultEvent(const DevAuthFaultEvent eventdata);
162 void DevAuthReportFaultEventWithErrCode(const char *funcName, const int32_t processCode, const int32_t errorCode);
163 void DevAuthReportUeCallEvent(int32_t osAccountId, int32_t groupType, const char *appId,
164     const char *funcName);
165 void DevAuthReportUeCallEventByParams(int32_t osAccountId, const char *inParams, const char *appId,
166     const char *funcName);
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 #endif
173 
174 #endif
175