1 /* 2 * Copyright (c) 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 NETFIREWALL_HISYSEVENT_H 17 #define NETFIREWALL_HISYSEVENT_H 18 19 #include <string> 20 21 #include "netfirewall_parcel.h" 22 #include "net_event_report.h" 23 #include "net_manager_ext_constants.h" 24 25 namespace OHOS { 26 namespace NetManagerStandard { 27 struct NetFirewallEvent { 28 int32_t userId = 100; 29 int32_t errorType = 0; 30 std::string errorMsg; 31 }; 32 33 class NetFirewallHisysEvent { 34 public: 35 ~NetFirewallHisysEvent() = default; 36 37 static NetFirewallHisysEvent &GetInstance(); 38 39 /** 40 * Send firewall configuration management information 41 * 42 * @param userId User id 43 * @param errorCode 44 */ 45 static void SendFirewallConfigReport(int32_t userId, int32_t &errorCode); 46 47 /** 48 * Send and obtain firewall management information 49 * 50 * @param userId User id 51 * @param errorCode Errorcode such as FIREWALL_SUCCESS = 0, 52 * FIREWALL_ERR_PERMISSION_DENIED = 201 and so on 53 */ 54 static void SendFirewallRequestReport(const int32_t userId, int32_t &errorCode); 55 56 /** 57 * Sending and obtaining interception records and tracking information 58 * 59 * @param userId User id 60 * @param errorCode Errorcode such as FIREWALL_SUCCESS = 0, 61 * FIREWALL_ERR_PERMISSION_DENIED = 201 and so on 62 */ 63 static void SendRecordRequestReport(const int32_t userId, int32_t &errorCode); 64 65 /** 66 * Send initialization default rule information 67 * 68 * @param userId User id 69 * @param errorCode Errorcode such as FIREWALL_SUCCESS = 0, 70 * FIREWALL_ERR_PERMISSION_DENIED = 201 and so on 71 */ 72 static void SendInitDefaultRequestReport(const int32_t userId, int32_t &errorCode); 73 74 private: 75 NetFirewallHisysEvent() = default; 76 77 void SendNetFirewallRuleFault(const NetFirewallEvent &event, const std::string &eventName); 78 79 void SendNetFirewallRuleBehavior(const int32_t userId, const std::string &eventName); 80 81 void SendNetFirewallFault(const NetFirewallEvent &event, const std::string &eventName); 82 83 void SendNetFirewallBehavior(const int32_t userId, const std::string &eventName); 84 }; 85 } // namespace NetManagerStandard 86 } // namespace OHOS 87 #endif // NETFIREWALL_HISYSEVENT_H