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 NETMGR_EXT_INCLUDE_EVENT_REPORT_H 17 #define NETMGR_EXT_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 struct EventInfo { 29 int32_t sharingType = 0; 30 int32_t operatorType = 0; 31 int32_t sharingCount = 0; 32 33 int32_t errorType = 0; 34 std::string errorMsg; 35 }; 36 37 enum class NetworkShareEventOperator { 38 OPERATION_START_SA = 0, 39 OPERATION_ENABLE_IFACE, 40 OPERATION_TURNON_IP_FORWARD, 41 OPERATION_GET_UPSTREAM, 42 OPERATION_CONFIG_FORWARD, 43 OPERATION_CHECK_SA = 10, 44 OPERATION_DISABLE_IFACE, 45 OPERATION_TURNOFF_IP_FORWARD, 46 OPERATION_CANCEL_FORWARD, 47 }; 48 49 enum class NetworkShareEventErrorType { 50 ERROR_START_SA = -100, 51 ERROR_CHECK_SA = -101, 52 ERROR_ENABLE_IFACE = -110, 53 ERROR_DISABLE_IFACE = -111, 54 ERROR_TURNON_IP_FORWARD = -120, 55 ERROR_TURNOFF_IP_FORWARD = -121, 56 ERROR_CONFIG_FORWARD = -130, 57 ERROR_CANCEL_FORWARD = -131, 58 ERROR_GET_UPSTREAM = -140, 59 }; 60 61 enum class NetworkShareEventType { 62 SETUP_EVENT = 0, 63 CANCEL_EVENT = 1, 64 BEHAVIOR_EVENT = 2, 65 }; 66 67 struct VpnEventInfo { 68 int32_t legacy = 0; 69 int32_t operatorType = 0; 70 int32_t errorType = 0; 71 std::string errorMsg; 72 }; 73 74 enum class VpnEventType { 75 TYPE_UNKNOWN = 0, 76 TYPE_LEGACY, 77 TYPE_EXTENDED, 78 }; 79 80 enum class VpnEventOperator { 81 OPERATION_START_SA = 0, 82 OPERATION_PROTOCOL_NEGOTIATE, 83 OPERATION_CONNECT_SETTING, 84 OPERATION_CONNECT_DESTROY, 85 }; 86 87 enum class VpnEventErrorType { 88 ERROR_UNKNOWN_PROTOCOL_TYPE = -100, 89 ERROR_CREATE_INTERFACE_ERROR = -101, 90 ERROR_REG_NET_SUPPLIER_ERROR = -110, 91 ERROR_UNREG_NET_SUPPLIER_ERROR = -111, 92 ERROR_UPDATE_SUPPLIER_INFO_ERROR = -120, 93 ERROR_UPDATE_NETLINK_INFO_ERROR = -121, 94 ERROR_SET_APP_UID_RULE_ERROR = -130, 95 ERROR_INTERNAL_ERROR = -140, 96 }; 97 98 class NetEventReport { 99 public: 100 static void SendSetupFaultEvent(const EventInfo &eventInfo); 101 static void SendCancleFaultEvent(const EventInfo &eventInfo); 102 static void SendTimeBehaviorEvent(const EventInfo &eventInfo); 103 static void SendVpnConnectEvent(const VpnEventInfo &eventInfo); 104 }; 105 } // namespace NetManagerStandard 106 } // namespace OHOS 107 #endif // NETMGR_EXT_INCLUDE_EVENT_REPORT_H 108