1 /*
2  * Copyright (c) 2022-2024 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 SOFTBUS_ADAPTER_HISYSEVENT_H
17 #define SOFTBUS_ADAPTER_HISYSEVENT_H
18 #include <stdbool.h>
19 #include <stdint.h>
20 #include <stdlib.h>
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 #define SOFTBUS_HISYSEVT_NAME_LEN                65
29 #define SOFTBUS_HISYSEVT_PARAM_LEN               65
30 #define SOFTBUS_HISYSEVT_PARAM_UINT32_ARRAY_SIZE 52
31 
32 typedef enum {
33     SOFTBUS_EVT_PARAM_ZERO = 0,
34     SOFTBUS_EVT_PARAM_ONE = 1,
35     SOFTBUS_EVT_PARAM_TWO = 2,
36     SOFTBUS_EVT_PARAM_THREE = 3,
37     SOFTBUS_EVT_PARAM_FOUR = 4,
38     SOFTBUS_EVT_PARAM_FIVE = 5,
39     SOFTBUS_EVT_PARAM_SIX = 6,
40     SOFTBUS_EVT_PARAM_SEVEN = 7,
41     SOFTBUS_EVT_PARAM_EIGHT = 8,
42     SOFTBUS_EVT_PARAM_NINE = 9,
43     SOFTBUS_EVT_PARAM_TEN = 10,
44     SOFTBUS_EVT_PARAM_ELEVEN = 11,
45     SOFTBUS_EVT_PARAM_TWELVE = 12,
46     SOFTBUS_EVT_PARAM_THIRTEEN = 13,
47     SOFTBUS_EVT_PARAM_FOURTEEN = 14,
48     SOFTBUS_EVT_PARAM_FIFTEEN = 15,
49     SOFTBUS_EVT_PARAM_SIXTEEN = 16,
50     SOFTBUS_EVT_PARAM_SEVENTEEN = 17,
51     SOFTBUS_EVT_PARAM_EIGHTEEN = 18,
52     SOFTBUS_EVT_PARAM_NINETEEN = 19,
53     SOFTBUS_EVT_PARAM_TWENTY = 20,
54     SOFTBUS_EVT_PARAM_TWENTY_ONE = 21,
55     SOFTBUS_EVT_PARAM_BUTT,
56 } SoftBusEvtParamNum;
57 
58 typedef enum {
59     SOFTBUS_EVT_TYPE_FAULT = 1,
60     SOFTBUS_EVT_TYPE_STATISTIC = 2,
61     SOFTBUS_EVT_TYPE_SECURITY = 3,
62     SOFTBUS_EVT_TYPE_BEHAVIOR = 4,
63 
64     SOFTBUS_EVT_TYPE_BUTT
65 } SoftBusEvtType;
66 
67 typedef enum {
68     SOFTBUS_EVT_LEVEL_CRITICAL,
69     SOFTBUS_EVT_LEVEL_MINOR,
70 } SoftBusEvtLevel;
71 
72 typedef enum {
73     SOFTBUS_EVT_PARAMTYPE_BOOL,
74     SOFTBUS_EVT_PARAMTYPE_UINT8,
75     SOFTBUS_EVT_PARAMTYPE_UINT16,
76     SOFTBUS_EVT_PARAMTYPE_INT32,
77     SOFTBUS_EVT_PARAMTYPE_UINT32,
78     SOFTBUS_EVT_PARAMTYPE_INT64,
79     SOFTBUS_EVT_PARAMTYPE_UINT64,
80     SOFTBUS_EVT_PARAMTYPE_FLOAT,
81     SOFTBUS_EVT_PARAMTYPE_DOUBLE,
82     SOFTBUS_EVT_PARAMTYPE_STRING,
83     SOFTBUS_EVT_PARAMTYPE_UINT32_ARRAY,
84 
85     SOFTBUS_EVT_PARAMTYPE_BUTT
86 } SoftBusEvtParamType;
87 
88 typedef union {
89     bool b;
90     uint8_t u8v;
91     uint16_t u16v;
92     int32_t i32v;
93     uint32_t u32v;
94     int64_t i64v;
95     uint64_t u64v;
96     float f;
97     double d;
98     char str[SOFTBUS_HISYSEVT_PARAM_LEN];
99     uint32_t u32a[SOFTBUS_HISYSEVT_PARAM_UINT32_ARRAY_SIZE];
100 } SoftbusEvtParamValue;
101 
102 typedef struct {
103     SoftBusEvtParamType paramType;
104     char paramName[SOFTBUS_HISYSEVT_NAME_LEN];
105     SoftbusEvtParamValue paramValue;
106 } SoftBusEvtParam;
107 
108 typedef struct {
109     char evtName[SOFTBUS_HISYSEVT_NAME_LEN];
110     SoftBusEvtType evtType;
111     uint32_t paramNum;
112     SoftBusEvtParam *paramArray;
113 } SoftBusEvtReportMsg;
114 
115 int32_t SoftbusWriteHisEvt(SoftBusEvtReportMsg *reportMsg);
116 
117 SoftBusEvtReportMsg *SoftbusCreateEvtReportMsg(int32_t paramNum);
118 
119 void SoftbusFreeEvtReportMsg(SoftBusEvtReportMsg *msg);
120 
121 #ifdef __cplusplus
122 #if __cplusplus
123 }
124 #endif /* __cplusplus */
125 #endif /* __cplusplus */
126 
127 #endif /* SOFTBUS_ADAPTER_HISYSEVENT_H */