• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FORWARD_CHAIN_NAME = "edm_deny_forward";
39 const char* const EDM_DENY_INPUT_CHAIN_NAME = "edm_deny_input";
40 const char* const EDM_ALLOW_OUTPUT_CHAIN_NAME = "edm_allow_output";
41 const char* const EDM_ALLOW_FORWARD_CHAIN_NAME = "edm_allow_forward";
42 const char* const EDM_ALLOW_INPUT_CHAIN_NAME = "edm_allow_input";
43 const char* const EDM_REJECT_OUTPUT_CHAIN_NAME = "edm_reject_output";
44 const char* const EDM_REJECT_FORWARD_CHAIN_NAME = "edm_reject_forward";
45 const char* const EDM_REJECT_INPUT_CHAIN_NAME = "edm_reject_input";
46 const char* const EDM_DEFAULT_DENY_OUTPUT_CHAIN_NAME = "edm_default_deny_output";
47 const char* const EDM_DEFAULT_DENY_FORWARD_CHAIN_NAME = "edm_default_deny_forward";
48 
49 const char* const EDM_DNS_DENY_OUTPUT_CHAIN_NAME = "edm_dns_deny_output";
50 const char* const EDM_DNS_DENY_FORWARD_CHAIN_NAME = "edm_dns_deny_forward";
51 const char* const EDM_DNS_ALLOW_OUTPUT_CHAIN_NAME = "edm_dns_allow_output";
52 const char* const EDM_DNS_ALLOW_FORWARD_CHAIN_NAME = "edm_dns_allow_forward";
53 const char* const EDM_DNS_REJECT_OUTPUT_CHAIN_NAME = "edm_dns_reject_output";
54 const char* const EDM_DNS_REJECT_FORWARD_CHAIN_NAME = "edm_dns_reject_forward";
55 const char* const EDM_DEFAULT_DNS_DENY_OUTPUT_CHAIN_NAME = "edm_default_dns_deny_output";
56 const char* const EDM_DEFAULT_DNS_DENY_FORWARD_CHAIN_NAME = "edm_default_dns_deny_forward";
57 
58 class RuleUtils {
59 public:
60     static std::string EnumToString(Action action);
61     static Action StringToAction(const std::string &action);
62     static std::string EnumToString(Protocol protocol);
63     static Protocol StringProtocol(const std::string &protocol);
64 };
65 } // namespace IPTABLES
66 } // namespace EDM
67 } // namespace OHOS
68 #endif // SERVICES_EDM_PLUGIN_INCLUDE_IPTABLES_RULE_UTILS_H
69