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_RULE_UTILS_H
17 #define SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_RULE_UTILS_H
18 
19 #include "iptables_utils.h"
20 
21 namespace OHOS {
22 namespace EDM {
23 namespace IPTABLES {
24 
25 const char* const SPACE_OPTION = " ";
26 
27 const char* const ACCEPT_TARGET = "ACCEPT";
28 const char* const REJECT_TARGET = "REJECT";
29 const char* const DROP_TARGET = "DROP";
30 
31 const char* const PROTOCOL_ALL = "all";
32 const char* const PROTOCOL_TCP = "tcp";
33 const char* const PROTOCOL_UDP = "udp";
34 const char* const PROTOCOL_ICMP = "icmp";
35 
36 
37 const char* const EDM_DENY_OUTPUT_CHAIN_NAME = "edm_deny_output";
38 const char* const EDM_DENY_INPUT_CHAIN_NAME = "edm_deny_input";
39 const char* const EDM_ALLOW_OUTPUT_CHAIN_NAME = "edm_allow_output";
40 const char* const EDM_ALLOW_INPUT_CHAIN_NAME = "edm_allow_input";
41 const char* const EDM_DEFAULT_DENY_OUTPUT_CHAIN_NAME = "edm_default_deny_output";
42 
43 const char* const EDM_DNS_DENY_OUTPUT_CHAIN_NAME = "edm_dns_deny_output";
44 const char* const EDM_DNS_ALLOW_OUTPUT_CHAIN_NAME = "edm_dns_allow_output";
45 const char* const EDM_DEFAULT_DNS_DENY_OUTPUT_CHAIN_NAME = "edm_default_dns_deny_output";
46 
47 class RuleUtils {
48 public:
49     static std::string EnumToString(Action action);
50     static Action StringToAction(std::string action);
51     static std::string EnumToString(Protocol protocol);
52     static Protocol StringProtocl(std::string protocol);
53 };
54 } // namespace IPTABLES
55 } // namespace EDM
56 } // namespace OHOS
57 #endif // SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_RULE_UTILS_H
58