1 /*
2  * Copyright (c) 2022 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 NETMANAGER_BASE_INCLUDE_EVENT_REPORT_H
17 #define NETMANAGER_BASE_INCLUDE_EVENT_REPORT_H
18 
19 #include <string>
20 
21 #include "hisysevent.h"
22 
23 using HiSysEventType = OHOS::HiviewDFX::HiSysEvent::EventType;
24 using HiSysEvent = OHOS::HiviewDFX::HiSysEvent;
25 
26 namespace OHOS {
27 namespace NetManagerStandard {
28 enum class NetConnEventType {
29     UNKNOW = 0,
30     /***********FAULT EVENT**************/
31     NET_CONN_SUPPLER_FAULT,
32     NET_CONN_REQUEST_FAULT,
33     NET_CONN_MONITOR_FAULT,
34     /***********BEHAVIOR EVENT***********/
35     NET_CONN_SUPPLER_STAT,
36     NET_CONN_REQUEST_STAT,
37     NET_CONN_MONITOR_STAT,
38 };
39 
40 enum HiSysEventType {
41     FAULT = 1,     // system fault event
42     STATISTIC = 2, // system statistic event
43     SECURITY = 3,  // system security event
44     BEHAVIOR = 4   // system behavior event
45 };
46 
47 enum NetConnSupplerFault {
48     FAULT_UPDATE_SUPPLIERINFO_INV_PARAM = (-1),
49     FAULT_CREATE_PHYSICAL_NETWORK_FAILED = (-2),
50     FAULT_UPDATE_NETLINK_INFO_INV_PARAM = (-3),
51     FAULT_UPDATE_NETLINK_INFO_FAILED = (-4),
52     FAULT_SET_DEFAULT_NETWORK_FAILED = (-5),
53     FAULT_DELETE_PHYSICAL_NETWORK_FAILED = (-6),
54     FAULT_CLEAR_DEFAULT_NETWORK_FAILED = (-7),
55     FAULT_CREATE_VIRTUAL_NETWORK_FAILED = (-8),
56 };
57 
58 enum NetConnRequestFault { FAULT_INVALID_PARAMETER = (-1) };
59 
60 enum NetConnMonitorFault {
61     FAULT_BIND_SOCKET_FAILED = (-1),
62 };
63 
64 struct EventInfo {
65     int32_t updateSupplierId = 0;
66     std::string supplierInfo;
67     std::string netlinkInfo;
68     int32_t updateNetlinkId = 0;
69     std::string capabilities;
70     int32_t socketFd = 0;
71     int32_t netId = 0;
72     int32_t bearerType = 0;
73     std::string ident;
74     int32_t supplierId = 0;
75     std::string callbackAvailable;
76     std::string supplierIdent;
77     std::string netcaps;
78     int32_t monitorStatus = 0;
79 
80     int32_t errorType = 0;
81     std::string errorMsg;
82 };
83 
84 class EventReport {
85 public:
86     static void SendSupplierFaultEvent(const EventInfo &eventInfo);
87     static void SendSupplierBehaviorEvent(const EventInfo &eventInfo);
88     static void SendRequestFaultEvent(const EventInfo &eventInfo);
89     static void SendRequestBehaviorEvent(const EventInfo &eventInfo);
90     static void SendMonitorFaultEvent(const EventInfo &eventInfo);
91     static void SendMonitorBehaviorEvent(const EventInfo &eventInfo);
92 };
93 } // namespace NetManagerStandard
94 } // namespace OHOS
95 #endif // NETMANAGER_BASE_INCLUDE_EVENT_REPORT_H
96