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 
37 #define DEFAULT_GROUP_TYPE 0
38 #define DEFAULT_MULTI_MEMBER_GROUP_TYPE 1
39 #define DEFAULT_CRED_TYPE 0
40 #define DEFAULT_CALL_RESULT 0
41 #define DEFAULT_APPID NULL
42 
43 #define DEFAULT_EXECUTION_TIME 0
44 #define DEFAULT_REQ_ID 0
45 #define DEFAULT_FAULT_INFO NULL
46 #define DEFAULT_EXT_INFO NULL
47 
48 #include <stdint.h>
49 
50 enum DevAuthReportProcessCode {
51     PROCESS_BIND_V1 = 0x001000,
52     PROCESS_AUTH_V1,
53     PROCESS_BIND_V2,
54     PROCESS_AUTH_V2,
55     PROCESS_CREATE_GROUP,
56     PROCESS_DELETE_GROUP,
57     PROCESS_DELETE_MEMBER_FROM_GROUP,
58     PROCESS_ADD_MULTI_MEMBERS_TO_GROUP,
59     PROCESS_DEL_MULTI_MEMBERS_FROM_GROUP,
60     PROCESS_UPDATE
61 };
62 
63 #define DEFAULT_PNAMEID "device_auth"
64 #define DEFAULT_PVERSIONID "1.0"
65 
66 #ifndef DEV_AUTH_HIVIEW_ENABLE
67 
68 #define DEV_AUTH_REPORT_CALL_EVENT(eventData)
69 #define DEV_AUTH_REPORT_FAULT_EVENT(eventdata)
70 #define DEV_AUTH_REPORT_FAULT_EVENT_WITH_ERR_CODE(funcName, processCode, errorCode)
71 #define DEV_AUTH_REPORT_UE_CALL_EVENT(osAccountId, groupType, appId, funcName)
72 #define DEV_AUTH_REPORT_UE_CALL_EVENT_BY_PARAMS(osAccountId, inParams, appId, funcName)
73 #else
74 
75 #define DEV_AUTH_REPORT_CALL_EVENT(eventData) \
76     DevAuthReportCallEvent(eventData)
77 #define DEV_AUTH_REPORT_FAULT_EVENT(eventdata) \
78     DevAuthReportFaultEvent(eventdata)
79 #define DEV_AUTH_REPORT_FAULT_EVENT_WITH_ERR_CODE(funcName, processCode, errorCode) \
80     DevAuthReportFaultEventWithErrCode(funcName, processCode, errorCode)
81 #define DEV_AUTH_REPORT_UE_CALL_EVENT(osAccountId, groupType, appId, funcName) \
82     DevAuthReportUeCallEvent(osAccountId, groupType, appId, funcName)
83 #define DEV_AUTH_REPORT_UE_CALL_EVENT_BY_PARAMS(osAccountId, inParams, appId, funcName) \
84     DevAuthReportUeCallEventByParams(osAccountId, inParams, appId, funcName)
85 
86 #ifdef __cplusplus
87 extern "C" {
88 #endif
89 
90 typedef struct {
91     const char *funcName;
92     const char *appId;
93     int32_t osAccountId;
94     int32_t callResult;
95     int32_t processCode;
96     uint8_t credType;
97     int32_t groupType;
98     int64_t executionTime;
99     const char *extInfo;
100 } DevAuthCallEvent;
101 
102 typedef struct {
103     const char *appId;
104     int32_t processCode;
105     const char *funcName;
106     int64_t reqId;
107     int32_t errorCode;
108     const char *faultInfo;
109 } DevAuthFaultEvent;
110 
111 void DevAuthReportCallEvent(const DevAuthCallEvent eventData);
112 void DevAuthReportFaultEvent(const DevAuthFaultEvent eventdata);
113 void DevAuthReportFaultEventWithErrCode(const char *funcName, const int32_t processCode, const int32_t errorCode);
114 void DevAuthReportUeCallEvent(int32_t osAccountId, int32_t groupType, const char *appId,
115     const char *funcName);
116 void DevAuthReportUeCallEventByParams(int32_t osAccountId, const char *inParams, const char *appId,
117     const char *funcName);
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif
124 
125 #endif
126