1 /* 2 * Copyright (c) 2023 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 SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_DOMAIN_CHAIN_RULE_H 17 #define SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_DOMAIN_CHAIN_RULE_H 18 19 #include "domain_filter_rule.h" 20 #include "chain_rule.h" 21 22 namespace OHOS { 23 namespace EDM { 24 namespace IPTABLES { 25 26 class DomainChainRule final: public ChainRule { 27 public: 28 explicit DomainChainRule(DomainFilterRule domainFilterRule); 29 explicit DomainChainRule(const std::string& rule); 30 DomainFilterRule ToFilterRule(); 31 [[nodiscard]] std::string Parameter() const override; 32 33 private: 34 static std::string DomainToFormatData(const std::string& domainName); 35 static std::string FormatDataToDomain(const std::string& formatData); 36 static uint8_t CharToHex(const char& first, const char& second); 37 static uint8_t CharToHex(const char& hexChar); 38 39 private: 40 std::string appUid_; 41 std::string domainName_; 42 }; 43 } // namespace IPTABLES 44 } // namespace EDM 45 } // namespace OHOS 46 #endif // SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_DOMAIN_CHAIN_RULE_H 47