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 #ifndef NET_FIREWALL_RULE_PARSE_H 16 #define NET_FIREWALL_RULE_PARSE_H 17 18 #include <napi/native_api.h> 19 20 #include "netfirewall_common.h" 21 22 namespace OHOS { 23 namespace NetManagerStandard { 24 class NetFirewallRuleParse { 25 public: 26 // Parsing firewall rule input parameters 27 static void ParseRuleParams(napi_env env, napi_value object, const sptr<NetFirewallRule> &rule); 28 29 // Set firewall parameters 30 static void SetRuleParams(napi_env env, napi_value object, const NetFirewallRule &rule); 31 32 // Parsing Paging Information Parameters 33 static int32_t ParsePageParam(napi_env env, napi_value object, const sptr<RequestParam> ¶m, bool isRule); 34 35 private: 36 // Parse IP list 37 static void ParseIpList(napi_env env, napi_value params, std::vector<NetFirewallIpParam> &list); 38 39 // Parse port list 40 static void ParsePortList(napi_env env, napi_value params, std::vector<NetFirewallPortParam> &list); 41 42 static void ParseDomainList(napi_env env, napi_value params, std::vector<NetFirewallDomainParam> &list); 43 44 static void SetIpList(napi_env env, napi_value object, const std::string &propertyName, 45 const std::vector<NetFirewallIpParam> &list); 46 47 static void SetPortList(napi_env env, napi_value object, const std::string &propertyName, 48 const std::vector<NetFirewallPortParam> &list); 49 50 // Set domain name list 51 static void SetDomainList(napi_env env, napi_value object, const std::string &propertyName, 52 const std::vector<NetFirewallDomainParam> &list); 53 }; 54 } // namespace NetManagerStandard 55 } // namespace OHOS 56 #endif // NET_FIREWALL_RULE_PARSE_H 57