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 std::string apOpenErrorMsg; 36 std::string apCloseErrorMsg; 37 }; 38 39 enum class NetworkShareEventOperator { 40 OPERATION_START_SA = 0, 41 OPERATION_ENABLE_IFACE, 42 OPERATION_TURNON_IP_FORWARD, 43 OPERATION_GET_UPSTREAM, 44 OPERATION_CONFIG_FORWARD, 45 OPERATION_CHECK_SA = 10, 46 OPERATION_DISABLE_IFACE, 47 OPERATION_TURNOFF_IP_FORWARD, 48 OPERATION_CANCEL_FORWARD, 49 }; 50 51 enum class NetworkShareEventErrorType { 52 ERROR_START_SA = -100, 53 ERROR_CHECK_SA = -101, 54 ERROR_ENABLE_IFACE = -110, 55 ERROR_DISABLE_IFACE = -111, 56 ERROR_TURNON_IP_FORWARD = -120, 57 ERROR_TURNOFF_IP_FORWARD = -121, 58 ERROR_CONFIG_FORWARD = -130, 59 ERROR_CANCEL_FORWARD = -131, 60 ERROR_GET_UPSTREAM = -140, 61 }; 62 63 enum class NetworkShareEventType { 64 SETUP_EVENT = 0, 65 CANCEL_EVENT = 1, 66 BEHAVIOR_EVENT = 2, 67 }; 68 69 struct VpnEventInfo { 70 int32_t legacy = 0; 71 int32_t operatorType = 0; 72 int32_t errorType = 0; 73 std::string errorMsg; 74 }; 75 76 enum class VpnEventType { 77 TYPE_UNKNOWN = 0, 78 TYPE_LEGACY, 79 TYPE_EXTENDED, 80 }; 81 82 enum class VpnEventOperator { 83 OPERATION_START_SA = 0, 84 OPERATION_PROTOCOL_NEGOTIATE, 85 OPERATION_CONNECT_SETTING, 86 OPERATION_CONNECT_DESTROY, 87 }; 88 89 enum class VpnEventErrorType { 90 ERROR_UNKNOWN_PROTOCOL_TYPE = -100, 91 ERROR_CREATE_INTERFACE_ERROR = -101, 92 ERROR_REG_NET_SUPPLIER_ERROR = -110, 93 ERROR_UNREG_NET_SUPPLIER_ERROR = -111, 94 ERROR_UPDATE_SUPPLIER_INFO_ERROR = -120, 95 ERROR_UPDATE_NETLINK_INFO_ERROR = -121, 96 ERROR_SET_APP_UID_RULE_ERROR = -130, 97 ERROR_INTERNAL_ERROR = -140, 98 }; 99 100 struct MultiVpnEvent { 101 bool isMainUser = true; 102 int32_t operatorType = 0; 103 int32_t errorCode = 0; 104 int32_t vpnType = 0; 105 std::string bundleName; 106 }; 107 108 enum class VpnOperatorType { 109 OPERATION_SETUP_VPN = 0, 110 OPERATION_ADD_VPN, 111 OPERATION_DELETE_VPN, 112 OPERATION_DESTROY_VPN, 113 }; 114 115 enum class VpnOperatorErrorType { 116 ERROR_PEER_NO_RESPONSE = -100, 117 ERROR_IKEV2_KEY_INCORRECT = -101, 118 ERROR_CA_INCORRECT = -102, 119 ERROR_PASSWORD_INCORRECT = -103, 120 ERROR_IKEV1_KEY_INCORRECT = -104, 121 ERROR_CFG_INCORRECT = -105, 122 }; 123 124 class NetEventReport { 125 public: 126 static int32_t SendSetupFaultEvent(const EventInfo &eventInfo); 127 static int32_t SendCancleFaultEvent(const EventInfo &eventInfo); 128 static int32_t SendTimeBehaviorEvent(const EventInfo &eventInfo); 129 static int32_t SendVpnConnectEvent(const VpnEventInfo &eventInfo); 130 static int32_t SendWifiSoftapEvent(const EventInfo &eventInfo); 131 static int32_t SendVpnFault(const MultiVpnEvent &eventInfo); 132 static int32_t SendVpnBehavior(const MultiVpnEvent &eventInfo); 133 }; 134 } // namespace NetManagerStandard 135 } // namespace OHOS 136 #endif // NETMGR_EXT_INCLUDE_EVENT_REPORT_H 137