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_IEXECUTER_H 17 #define SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_IEXECUTER_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "chain_rule.h" 24 #include "edm_errors.h" 25 #include "executer_utils.h" 26 27 namespace OHOS { 28 namespace EDM { 29 namespace IPTABLES { 30 31 class IExecuter { 32 public: 33 explicit IExecuter(std::string chainName); 34 35 virtual ErrCode CreateChain(); 36 virtual ErrCode Init() = 0; 37 virtual ErrCode Add(const std::shared_ptr<ChainRule> &rule); 38 virtual ErrCode Remove(const std::shared_ptr<ChainRule> &rule); 39 virtual ErrCode GetAll(std::vector<std::string> &ruleList); 40 41 private: 42 virtual ErrCode ExecWithOption(std::ostringstream &oss, const std::shared_ptr<ChainRule> &rule); 43 44 protected: 45 IExecuter() = default; 46 47 protected: 48 std::string tableName_; 49 std::string chainName_; 50 }; 51 } // namespace IPTABLES 52 } // namespace EDM 53 } // namespace OHOS 54 #endif // SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_IEXECUTER_H 55