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 #define DESTROY_DEVICE_AUTH_SERVICE_EVENT "DestroyDeviceAuthService"
29 #define INIT_DEVICE_AUTH_SERVICE_EVENT "InitDeviceAuthService"
30 
31 #define CANCEL_REQUEST_EVENT "CancelRequest"
32 #define GET_REAL_INFO_EVENT "GetRealInfo"
33 #define GET_PSEUDONYM_ID_EVENT "GetPseudonymId"
34 #define REG_CALLBACK_EVENT "RegCallback"
35 #define UN_REG_GROUP_MANAGER_CALLBACK_EVENT "UnRegGroupManagerCallback"
36 #define REG_LISTENER_EVENT "RegListener"
37 #define UN_REG_LISTENER_EVENT "UnRegListener"
38 #define GET_REGISTER_INFO_EVENT "GetRegisterInfo"
39 #define CHECK_ACCESS_TO_GROUP_EVENT "CheckAccessToGroup"
40 #define GET_ACCESSIBLE_GROUP_INFO_BY_ID_EVENT "GetAccessibleGroupInfoById"
41 #define GET_ACCESSIBLE_GROUP_INFO_EVENT "GetAccessibleGroupInfo"
42 #define GET_ACCESSIBLE_JOINED_GROUPS_EVENT "GetAccessibleJoinedGroups"
43 #define GET_ACCESSIBLE_RELATED_GROUPS_EVENT "GetAccessibleRelatedGroups"
44 #define GET_ACCESSIBLE_DEVICE_INFO_BY_ID_EVENT "GetAccessibleDeviceInfoById"
45 #define GET_ACCESSIBLE_TRUSTED_DEVICES_EVENT "GetAccessibleTrustedDevices"
46 #define IS_DEVICE_IN_ACCESSIBLE_GROUP_EVENT "IsDeviceInAccessibleGroup"
47 #define GET_PK_INFO_LIST_EVENT "GetPkInfoList"
48 #define DESTROY_INFO_EVENT "DestroyInfo"
49 
50 #define ADD_MEMBER_WITH_LITE_COMPATIBILITY "AddMemberWithLiteCompatibility"
51 #define ADD_MEMBER_WITH_LITE_STANDARD "AddMemberWithLiteStandard"
52 #define UPGRADE_DATA_EVENT "UpgradeData"
53 #define BIND_CONSUME_EVENT "BindConsume"
54 #define AUTH_CONSUME_EVENT "AuthConsume"
55 
56 #define DEFAULT_GROUP_TYPE 256
57 #define DEFAULT_CRED_TYPE 0
58 #define DEFAULT_APPID NULL
59 
60 #define DEFAULT_EXECUTION_TIME 0
61 #define DEFAULT_REQ_ID 0
62 #define DEFAULT_FAULT_INFO NULL
63 #define DEFAULT_EXT_INFO NULL
64 
65 #include <stdint.h>
66 
67 enum DevAuthReportProcessCode {
68     PROCESS_ADD_MEMBER_TO_GROUP = 0x001000,
69     PROCESS_AUTH_DEVICE,
70     PROCESS_UPDATE_DATA_BY_INPUT_INDEX,
71     PROCESS_REQUEST_CREATE_GROUP,
72     PROCESS_REQUEST_DELETE_GROUP,
73     PROCESS_REQUEST_DELETE_MEMBER_FROM_GROUP,
74     PREOCESS_REQUEST_ADD_MULTI_MEMBERS_TO_GROUP,
75     PROCESS_REQUEST_DEL_MULTI_MEMBERS_FROM_GROUP,
76     PROCESS_FAULT_REPORT_WITH_TYPE,
77     PROCESS_HANDLE_RESTORE_CALL,
78     PROCESS_FAULT_REPORT_WITH_OP_CODE
79 };
80 
81 #define DEFAULT_PNAMEID "device_auth"
82 #define DEFAULT_PVERSIONID "1.0"
83 
84 #ifndef DEV_AUTH_HIVIEW_ENABLE
85 
86 #define DEV_AUTH_REPORT_CALL_EVENT(eventData)
87 #define DEV_AUTH_REPORT_CALL_EVENT_WITH_RESULT(appId, funcName, osAccountId, callResult, processCode)
88 #define DEV_AUTH_REPORT_FAULT_EVENT(eventdata)
89 #define DEV_AUTH_REPORT_FAULT_EVENT_WITH_ERR_CODE(funcName, processCode, errorCode)
90 #define DEV_AUTH_REPORT_UE_CALL_EVENT(osAccountId, groupType, appId, funcName)
91 #define DEV_AUTH_REPORT_UE_CALL_EVENT_BY_PARAMS(osAccountId, inParams, appId, funcName)
92 #else
93 
94 #define DEV_AUTH_REPORT_CALL_EVENT(eventData) \
95     DevAuthReportCallEvent(eventData)
96 #define DEV_AUTH_REPORT_CALL_EVENT_WITH_RESULT(appId, funcName, osAccountId, callResult, processCode) \
97     DevAuthReportCallEventWithResult(appId, funcName, osAccountId, callResult, processCode)
98 #define DEV_AUTH_REPORT_FAULT_EVENT(eventdata) \
99     DevAuthReportFaultEvent(eventdata)
100 #define DEV_AUTH_REPORT_FAULT_EVENT_WITH_ERR_CODE(funcName, processCode, errorCode) \
101     DevAuthReportFaultEventWithErrCode(funcName, processCode, errorCode)
102 #define DEV_AUTH_REPORT_UE_CALL_EVENT(osAccountId, groupType, appId, funcName) \
103     DevAuthReportUeCallEvent(osAccountId, groupType, appId, funcName)
104 #define DEV_AUTH_REPORT_UE_CALL_EVENT_BY_PARAMS(osAccountId, inParams, appId, funcName) \
105     DevAuthReportUeCallEventByParams(osAccountId, inParams, appId, funcName)
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
111 typedef struct {
112     const char *appId;
113     const char *funcName;
114     int32_t osAccountId;
115     int32_t callResult;
116     int32_t processCode;
117     uint8_t credType;
118     int32_t groupType;
119     int64_t executionTime;
120     const char *extInfo;
121 } DevAuthCallEvent;
122 
123 typedef struct {
124     const char *appId;
125     int32_t processCode;
126     const char *funcName;
127     int64_t reqId;
128     int32_t errorCode;
129     const char *faultInfo;
130 } DevAuthFaultEvent;
131 
132 void DevAuthReportCallEvent(const DevAuthCallEvent eventData);
133 void DevAuthReportFaultEvent(const DevAuthFaultEvent eventdata);
134 void DevAuthReportCallEventWithResult(const char *appId, const char *funcName, const int32_t osAccountId,
135     const int32_t callResult, const int32_t processCode);
136 void DevAuthReportFaultEventWithErrCode(const char *funcName, const int32_t processCode, const int32_t errorCode);
137 void DevAuthReportUeCallEvent(int32_t osAccountId, int32_t groupType, const char *appId,
138     const char *funcName);
139 void DevAuthReportUeCallEventByParams(int32_t osAccountId, const char *inParams, const char *appId,
140     const char *funcName);
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif
147 
148 #endif
149