2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Manage ip6tables rule using libip6tc
21 #ifndef __STC_HELPER_IP6TABLES_H__
22 #define __STC_HELPER_IP6TABLES_H__
24 #include <libiptc/libip6tc.h>
29 IP6TABLES_CHAIN_INPUT,
30 IP6TABLES_CHAIN_OUTPUT
34 IP6TABLES_DIRECTION_NONE,
35 IP6TABLES_DIRECTION_IN,
36 IP6TABLES_DIRECTION_OUT
37 } ip6tables_direction_e;
44 } ip6tables_ip_type_e;
48 IP6TABLES_PORT_SINGLE,
50 } ip6tables_port_type_e;
53 IP6TABLES_PROTOCOL_NONE,
54 IP6TABLES_PROTOCOL_TCP,
55 IP6TABLES_PROTOCOL_UDP,
56 IP6TABLES_PROTOCOL_ICMP,
57 IP6TABLES_PROTOCOL_ESP,
58 IP6TABLES_PROTOCOL_AH,
59 IP6TABLES_PROTOCOL_SCTP,
60 IP6TABLES_PROTOCOL_MH,
61 IP6TABLES_PROTOCOL_ALL,
62 } ip6tables_protocol_type_e;
65 IP6TABLES_ACTION_NONE,
66 IP6TABLES_ACTION_ACCEPT,
67 IP6TABLES_ACTION_DROP,
69 IP6TABLES_ACTION_NFLOG,
70 } ip6tables_target_action_e;
74 ip6tables_direction_e direction;
75 ip6tables_ip_type_e s_ip_type;
76 ip6tables_ip_type_e d_ip_type;
77 ip6tables_port_type_e s_port_type;
78 ip6tables_port_type_e d_port_type;
79 ip6tables_protocol_type_e protocol;
80 struct in6_addr s_ip1;
81 struct in6_addr s_ip2;
82 struct in6_addr d_ip1;
83 struct in6_addr d_ip2;
92 ip6tables_target_action_e target_type;
93 unsigned char log_level;
95 unsigned int nflog_group;
97 unsigned int nflog_range;
98 unsigned int nflog_threshold;
102 * @desc This function adds a new ip6tables rule.
103 * @return 0 on success and negative value if error.
105 int ip6tables_add_rule(ip6tables_rule_s *rule);
106 int ip6tables_add_rule_list(GSList *rule_list);;
109 * @desc This function inserts a new ip6tables rule.
110 * @return 0 on success and negative value if error.
112 int ip6tables_insert_rule(ip6tables_rule_s *rule);
115 * @desc This function removes already set ip6tables rule.
116 * @return 0 on success and negative value if error.
118 int ip6tables_remove_rule(ip6tables_rule_s *rule);
119 int ip6tables_remove_rule_list(GSList *rule_list);
122 * @desc This function adds a new ip6tables chain.
123 * @return 0 on success and negative value if error.
125 int ip6tables_add_chain(const char *chain);
128 * @desc This function removes already set ip6tables chain.
129 * @return 0 on success and negative value if error.
131 int ip6tables_remove_chain(const char *chain);
134 * @desc This function flushes all ip6tables rules in chain.
135 * @return 0 on success and negative value if error.
137 int ip6tables_flush_chain(const char *chain);
139 #endif /*__STC_HELPER_IP6TABLES_H__*/