Added additional test cases for stc-manager firewall dbus methods
[platform/core/connectivity/stc-manager.git] / unittest / firewall.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __STC_MGR_FIREWALL_H__
17 #define __STC_MGR_FIREWALL_H__
18
19 #include <glib.h>
20 #include <gio/gio.h>
21
22 #include "stcmgr.h"
23 #include "gdbus.h"
24
25 #define FIREWALL_RULE_CHAIN      "chain"
26 #define FIREWALL_RULE_DIRECTION  "direction"
27 #define FIREWALL_RULE_IFNAME     "ifname"
28 #define FIREWALL_RULE_PROTOCOL   "protocol"
29 #define FIREWALL_RULE_TARGET     "target"
30 #define FIREWALL_RULE_TARGETTYPE "target_type"
31
32 #define FIREWALL_RULE_FAMILY     "family"
33 #define FIREWALL_RULE_SIPTYPE    "s_ip_type"
34 #define FIREWALL_RULE_SIP1       "s_ip1"
35 #define FIREWALL_RULE_SIP2       "s_ip2"
36 #define FIREWALL_RULE_DIPTYPE    "d_ip_type"
37 #define FIREWALL_RULE_DIP1       "d_ip1"
38 #define FIREWALL_RULE_DIP2       "d_ip2"
39 #define FIREWALL_RULE_SPORTTYPE  "s_port_type"
40 #define FIREWALL_RULE_SPORT1     "s_port1"
41 #define FIREWALL_RULE_SPORT2     "s_port2"
42 #define FIREWALL_RULE_DPORTTYPE  "d_port_type"
43 #define FIREWALL_RULE_DPORT1     "d_port1"
44 #define FIREWALL_RULE_DPORT2     "d_port2"
45
46 #define FIREWALL_RULE_LOG_LEVEL       "log_level"
47 #define FIREWALL_RULE_LOG_PREFIX      "log_prefix"
48 #define FIREWALL_RULE_NFLOG_GROUP     "nflog_group"
49 #define FIREWALL_RULE_NFLOG_PREFIX    "nflog_prefix"
50 #define FIREWALL_RULE_NFLOG_RANGE     "nflog_range"
51 #define FIREWALL_RULE_NFLOG_THRESHOLD "nflog_threshold"
52
53 #define CHAIN_LEN 256
54 #define IFACE_LEN 256
55 #define IP_LEN 16
56
57 class FRule {
58 private:
59 public:
60         char chain[CHAIN_LEN];
61         guint16 direction;
62         guint16 siptype;
63         guint16 diptype;
64         guint16 sporttype;
65         guint16 dporttype;
66         guint16 protocol;
67         guint16 family;
68         char sip1[IP_LEN];
69         char dip1[IP_LEN];
70         char sip2[IP_LEN];
71         char dip2[IP_LEN];
72         guint32 dport1;
73         guint32 dport2;
74         guint32 sport1;
75         guint32 sport2;
76         char iface[IFACE_LEN];
77         guint16 target;
78
79         FRule();
80         ~FRule();
81 };
82
83 class Firewall : public GDbus {
84 private:
85         FRule m_Rule;
86 public:
87         Firewall();
88         ~Firewall();
89         error_e SetRule(const char *app_id, const char *iface_name,
90                 const char *subscriber_id, iface_type_e iface_type,
91                 int64_t data_limit, int64_t data_warn_limit,
92                 roaming_type_e roaming_type, const char *mac);
93         void MakeRuleParams(GVariant **params);
94         void MakeGetParams(GVariant **params);
95         void MakeStatusParams(GVariant **params);
96         error_e Lock(void);
97         error_e Unlock(void);
98         error_e GetLock(int *state);
99         error_e AddChain(const char * chain);
100         error_e RemoveChain(const char * chain);
101         error_e FlushChain(const char * chain);
102         error_e GetAllChain();
103         error_e SetChain(const char *chain, unsigned int target);
104         error_e UnsetChain(const char *chain);
105         error_e SetRule(const char *chain, guint16 direction,
106                         guint16 siptype, guint16 diptype, guint16 sporttype,
107                         guint16 dporttype, guint16 protocol, guint16 family,
108                         const char *sip1, const char *dip1, const char *sip2,
109                         const char *dip2, guint32 dport1, guint32 dport2,
110                         guint32 sport1, guint32 sport2, const char *iface,
111                         guint16 target);
112         error_e AddRule();
113         error_e RemoveRule();
114         error_e UpdateRule();
115         error_e GetAllRule();
116 };
117
118 #endif /* __STC_MGR_FIREWALL_H__ */