Merge "Added firewall feature" into tizen
[platform/core/connectivity/stc-manager.git] / include / stc-manager.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_MANAGER_H__
18 #define __STC_MANAGER_H__
19
20 #include "stc-error.h"
21 #include "stc-manager-util.h"
22
23 #define NET_RELEASE_AGENT "/usr/bin/net-cls-release"
24 #define NET_CLS_SUBSYS "net_cls"
25
26 #define STC_BACKGROUND_APP_SUFFIX "_BACKGROUND"
27 #define STC_BACKGROUND_APP_ID "BACKGROUND"
28 #define STC_TOTAL_DATACALL "TOTAL_DATACALL"
29 #define STC_TOTAL_WIFI "TOTAL_WIFI"
30 #define STC_TOTAL_BLUETOOTH "TOTAL_BLUETOOTH"
31 #define STC_TOTAL_IPV4 "TOTAL_IPV4"
32 #define STC_TOTAL_IPV6 "TOTAL_IPV6"
33
34 #define STC_DEBUG_LOG (stc_util_get_debuglog())
35
36 typedef enum {
37         STC_CANCEL = 0,    /**< cancel */
38         STC_CONTINUE = 1,  /**< continue */
39 } stc_cb_ret_e;
40
41 typedef enum {
42         STC_CMD_NONE,
43         STC_CMD_SET_FOREGRD,
44         STC_CMD_SET_BACKGRD,
45         STC_CMD_SET_APP_LAUNCHED,
46         STC_CMD_SET_SERVICE_LAUNCHED,
47         STC_CMD_SET_TERMINATED,
48         STC_CMD_MAX_ELEM
49 } stc_cmd_type_e;
50
51 typedef enum {
52         STC_FW_DIRECTION_NONE,
53         STC_FW_DIRECTION_IN,
54         STC_FW_DIRECTION_OUT
55 } stc_fw_direction_e;
56
57 typedef enum {
58         STC_FW_FAMILY_NONE,
59         STC_FW_FAMILY_V4,
60         STC_FW_FAMILY_V6
61 } stc_fw_family_type_e;
62
63 typedef enum {
64         STC_FW_IP_NONE,
65         STC_FW_IP_SINGLE,
66         STC_FW_IP_MASK,
67         STC_FW_IP_RANGE
68 } stc_fw_ip_type_e;
69
70 typedef enum {
71         STC_FW_PORT_NONE,
72         STC_FW_PORT_SINGLE,
73         STC_FW_PORT_RANGE
74 } stc_fw_port_type_e;
75
76 typedef enum {
77         STC_FW_PROTOCOL_NONE,
78         STC_FW_PROTOCOL_TCP,
79         STC_FW_PROTOCOL_UDP,
80         STC_FW_PROTOCOL_ICMP,
81         STC_FW_PROTOCOL_ESP,
82         STC_FW_PROTOCOL_AH,
83         STC_FW_PROTOCOL_SCTP,
84         STC_FW_PROTOCOL_MH,
85         STC_FW_PROTOCOL_ALL,
86 } stc_fw_protocol_type_e;
87
88 typedef enum {
89         STC_FW_CHAIN_TARGET_NONE,
90         STC_FW_CHAIN_TARGET_INPUT,
91         STC_FW_CHAIN_TARGET_OUTPUT
92 } stc_fw_chain_target_e;
93
94 typedef enum {
95         STC_FW_RULE_TARGET_NONE,
96         STC_FW_RULE_TARGET_ACCEPT,
97         STC_FW_RULE_TARGET_DROP,
98         STC_FW_RULE_TARGET_LOG,
99 } stc_fw_rule_target_e;
100
101 /**
102  * @brief Monitored application types
103  */
104 typedef enum {
105         STC_APP_TYPE_NONE,
106         STC_APP_TYPE_READY,
107         STC_APP_TYPE_GUI,
108         STC_APP_TYPE_SERVICE,
109         STC_APP_TYPE_GROUP,
110         STC_APP_TYPE_WATCH,
111         STC_APP_TYPE_WIDGET,
112         STC_APP_TYPE_MAX,
113 } stc_app_type_e;
114
115 /**
116  * @brief State of the statisticsed process
117  */
118 typedef enum {
119         STC_APP_STATE_UNKNOWN = 0,
120         STC_APP_STATE_FOREGROUND = 1 << 1,  /** < foreground state */
121         STC_APP_STATE_BACKGROUND = 1 << 2,  /** < background state */
122         STC_APP_STATE_LAST_ELEM = 1 << 3
123 } stc_app_state_e;
124
125 /**
126  * @brief Network restriction states
127  */
128 typedef enum {
129         STC_RESTRICTION_UNKNOWN,
130         STC_RESTRICTION_ACTIVATED,  /**< restriction has been activated */
131         STC_RESTRICTION_DEACTIVATED,  /**< restriction has been deactivated */
132         STC_RESTRICTION_LAST_ELEM
133 } stc_restriction_state_e;
134
135 /**
136  * @brief Network restriction types
137  */
138 typedef enum {
139         STC_RSTN_TYPE_UNKNOWN,
140         STC_RSTN_TYPE_EXCLUDED,  /**< exclusion */
141         STC_RSTN_TYPE_BLOCKED,    /**< block */
142         STC_RSTN_TYPE_LAST_ELEM
143 } stc_rstn_type_e;
144
145 /**
146  * @brief Network interface types
147  */
148 typedef enum {
149         STC_IFACE_UNKNOWN,    /**< undefined iface */
150         STC_IFACE_DATACALL,   /**< mobile data */
151         STC_IFACE_WIFI,       /**< wifi data */
152         STC_IFACE_WIRED,      /**< wired interface */
153         STC_IFACE_BLUETOOTH,  /**< bluetooth interface */
154         STC_IFACE_IPV4,       /**< ipv4 interface */
155         STC_IFACE_IPV6,       /**< ipv6 interface */
156         STC_IFACE_ALL,        /**< enumerate all network interface types */
157         STC_IFACE_LAST_ELEM
158 } stc_iface_type_e;
159
160 /**
161  * @brief Network roaming type
162  */
163 typedef enum {
164         STC_ROAMING_UNKNOWN,   /**< can't define roaming - roaming unknown */
165         STC_ROAMING_ENABLE,    /**< in roaming */
166         STC_ROAMING_DISABLE,   /**< not in roaming */
167         STC_ROAMING_LAST_ELEM,
168 } stc_roaming_type_e;
169
170 /**
171  * @brief Hardware network protocol types
172  */
173 typedef enum {
174         STC_PROTOCOL_UNKNOWN,             /**< Network unknown */
175         STC_PROTOCOL_DATACALL_NOSVC,      /**< Network no service */
176         STC_PROTOCOL_DATACALL_EMERGENCY,  /**< Network emergency */
177         STC_PROTOCOL_DATACALL_SEARCH,     /**< Network search 1900 */
178         STC_PROTOCOL_DATACALL_2G,         /**< Network 2G */
179         STC_PROTOCOL_DATACALL_2_5G,       /**< Network 2.5G */
180         STC_PROTOCOL_DATACALL_2_5G_EDGE,  /**< Network EDGE */
181         STC_PROTOCOL_DATACALL_3G,         /**< Network UMTS */
182         STC_PROTOCOL_DATACALL_HSDPA,      /**< Network HSDPA */
183         STC_PROTOCOL_DATACALL_LTE,        /**< Network LTE */
184         STC_PROTOCOL_MAX_ELEM
185 } stc_hw_net_protocol_type_e;
186
187 /**
188  * @desc Description of the boolean option for enabling/disabling
189  *     network interfaces and enabling/disabling some behaviar
190  */
191 typedef enum {
192         STC_DB_OPTION_UNDEF,
193         STC_DB_OPTION_ENABLE,
194         STC_DB_OPTION_DISABLE
195 } stc_option_state_e;
196
197 /**
198  * @desc Set of the options.
199  * wifi - enable/disable wifi, STC_DB_OPTION_UNDEF to leave option as is
200  * datacall - enable/disable datacall, STC_DB_OPTION_UNDEF to leave option as is
201  * datausage_timer - set period of the updating data from the kernel,
202  *     0 to leave option as is
203  * datacall_logging - enable/disable datacall_logging,
204  *     STC_DB_OPTION_UNDEF to leave option as is
205  */
206 typedef struct {
207         stc_option_state_e wifi;
208         stc_option_state_e datacall;
209         time_t datausage_timer;
210         stc_option_state_e datacall_logging;
211 } stc_options_s;
212
213 /**
214  * @brief datausage in bytes
215  */
216 typedef struct {
217         int64_t in_bytes;  /**< incoming bytes */
218         int64_t out_bytes;  /**< outgoing bytes */
219 } stc_data_counter_s;
220
221 typedef struct {
222         GMainLoop *main_loop;
223
224         gpointer statistics_obj;
225         gpointer restriction_obj;
226         gpointer firewall_obj;
227         gpointer manager_obj;
228
229         GDBusObjectManagerServer *obj_mgr;
230         GDBusConnection *connection;
231         guint gdbus_owner_id;
232
233         void *system; /* stc_system_s */
234         struct counter_arg *carg;
235 } stc_s;
236
237 stc_s *stc_get_manager(void);
238 void stc_stop_manager(void);
239
240 #endif /* __STC_MANAGER__ */