8a1dbeafb469acc540b0b4c4db609cb26e086351
[platform/core/connectivity/stc-manager.git] / src / helper / helper-firewall.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __STC_HELPER_FIREWALL_H__
18 #define __STC_HELPER_FIREWALL_H__
19
20 #include <arpa/inet.h>
21
22 #include "stc-manager.h"
23 #include "stc-error.h"
24
25 #define FIREWALL_CHAIN_TARGET_IN     "STC_IN"
26 #define FIREWALL_CHAIN_TARGET_OUT    "STC_OUT"
27
28 #define FIREWALL_RULE_TARGET_ACCEPT  "ACCEPT"
29 #define FIREWALL_RULE_TARGET_DROP    "DROP"
30 #define FIREWALL_RULE_TARGET_LOG     "LOG"
31
32 typedef enum {
33         FIREWALL_UNKONWN,
34         FIREWALL_UNLOCKED,
35         FIREWALL_LOCKED
36 } firewall_lock_e;
37
38 typedef union {
39         struct in_addr Ipv4;
40         struct in6_addr Ipv6;
41 } ip_addr_u;
42
43 typedef struct {
44         char *chain;
45         stc_fw_chain_target_e target;
46         guint priority;
47 } firewall_chain_s;
48
49 typedef struct {
50         guint key;
51         char *chain;
52         stc_fw_direction_e direction;
53         stc_fw_ip_type_e s_ip_type;
54         stc_fw_ip_type_e d_ip_type;
55         stc_fw_port_type_e s_port_type;
56         stc_fw_port_type_e d_port_type;
57         stc_fw_protocol_type_e protocol;
58         stc_fw_family_type_e family;
59         ip_addr_u s_ip1;
60         ip_addr_u s_ip2;
61         ip_addr_u d_ip1;
62         ip_addr_u d_ip2;
63         guint s_port1;
64         guint s_port2;
65         guint d_port1;
66         guint d_port2;
67         char *ifname;
68         stc_fw_rule_target_e target;
69         char *target_str;
70         char *identifier;
71 } firewall_rule_s;
72
73 stc_error_e firewall_chain_add(firewall_chain_s *chain);
74 stc_error_e firewall_chain_remove(firewall_chain_s *chain);
75 stc_error_e firewall_chain_flush(firewall_chain_s *chain);
76 stc_error_e firewall_chain_set(firewall_chain_s *chain);
77 stc_error_e firewall_chain_unset(firewall_chain_s *chain);
78
79 stc_error_e firewall_rule_add(firewall_rule_s *rule);
80 stc_error_e firewall_rule_remove(firewall_rule_s *rule);
81
82 #endif  /*__STC_HELPER_FIREWALL_H__*/