2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __STC_MANAGER_H__
18 #define __STC_MANAGER_H__
20 #include "stc-error.h"
21 #include "stc-manager-util.h"
23 #define NET_RELEASE_AGENT "/usr/bin/net-cls-release"
24 #define NET_CLS_SUBSYS "net_cls"
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 #define STC_TOTAL_TETHERING "TOTAL_TETHERING"
35 #define STC_IPTABLES "/usr/sbin/iptables"
36 #define STC_IP6TABLES "/usr/sbin/ip6tables"
38 #define STC_CMD_SIZE 256
40 #define STC_DEBUG_LOG (stc_util_get_debuglog())
43 STC_CANCEL = 0, /**< cancel */
44 STC_CONTINUE = 1, /**< continue */
51 STC_CMD_SET_APP_LAUNCHED,
52 STC_CMD_SET_SERVICE_LAUNCHED,
53 STC_CMD_SET_TERMINATED,
58 STC_FW_DIRECTION_NONE,
67 } stc_fw_family_type_e;
92 } stc_fw_protocol_type_e;
95 STC_FW_CHAIN_TARGET_NONE,
96 STC_FW_CHAIN_TARGET_INPUT,
97 STC_FW_CHAIN_TARGET_OUTPUT
98 } stc_fw_chain_target_e;
101 STC_FW_RULE_TARGET_NONE,
102 STC_FW_RULE_TARGET_ACCEPT,
103 STC_FW_RULE_TARGET_DROP,
104 STC_FW_RULE_TARGET_LOG,
105 } stc_fw_rule_target_e;
108 * @brief Monitored application types
114 STC_APP_TYPE_SERVICE,
122 * @brief State of the statisticsed process
125 STC_APP_STATE_UNKNOWN,
126 STC_APP_STATE_FOREGROUND, /** < foreground state */
127 STC_APP_STATE_BACKGROUND, /** < background state */
128 STC_APP_STATE_LAST_ELEM
132 * @brief Network restriction states
135 STC_RSTN_STATE_UNKNOWN,
136 STC_RSTN_STATE_ACTIVATED,
137 STC_RSTN_STATE_DEACTIVATED,
138 STC_RSTN_STATE_LAST_ELEM
142 * @brief Network restriction types
145 STC_RSTN_TYPE_UNKNOWN,
146 STC_RSTN_TYPE_ACCEPT,
148 STC_RSTN_TYPE_LAST_ELEM
152 * @brief Network interface types
155 STC_IFACE_UNKNOWN, /**< undefined iface */
156 STC_IFACE_DATACALL, /**< mobile data */
157 STC_IFACE_WIFI, /**< wifi data */
158 STC_IFACE_WIRED, /**< wired interface */
159 STC_IFACE_BLUETOOTH, /**< bluetooth interface */
160 STC_IFACE_IPV4, /**< ipv4 interface */
161 STC_IFACE_IPV6, /**< ipv6 interface */
162 STC_IFACE_USB, /**< usb interface */
163 STC_IFACE_P2P, /**< p2p interface */
164 STC_IFACE_ALL, /**< enumerate all network interface types */
169 * @brief Network roaming type
172 STC_ROAMING_UNKNOWN, /**< can't define roaming - roaming unknown */
173 STC_ROAMING_ENABLE, /**< in roaming */
174 STC_ROAMING_DISABLE, /**< not in roaming */
175 STC_ROAMING_LAST_ELEM,
176 } stc_roaming_type_e;
179 * @brief Hardware network protocol types
182 STC_PROTOCOL_UNKNOWN, /**< Network unknown */
183 STC_PROTOCOL_DATACALL_NOSVC, /**< Network no service */
184 STC_PROTOCOL_DATACALL_EMERGENCY, /**< Network emergency */
185 STC_PROTOCOL_DATACALL_SEARCH, /**< Network search 1900 */
186 STC_PROTOCOL_DATACALL_2G, /**< Network 2G */
187 STC_PROTOCOL_DATACALL_2_5G, /**< Network 2.5G */
188 STC_PROTOCOL_DATACALL_2_5G_EDGE, /**< Network EDGE */
189 STC_PROTOCOL_DATACALL_3G, /**< Network UMTS */
190 STC_PROTOCOL_DATACALL_HSDPA, /**< Network HSDPA */
191 STC_PROTOCOL_DATACALL_LTE, /**< Network LTE */
192 STC_PROTOCOL_MAX_ELEM
193 } stc_hw_net_protocol_type_e;
196 * @desc Description of the boolean option for enabling/disabling
197 * network interfaces and enabling/disabling some behaviar
201 STC_DB_OPTION_ENABLE,
202 STC_DB_OPTION_DISABLE
203 } stc_option_state_e;
206 * @desc Set of the options.
207 * wifi - enable/disable wifi, STC_DB_OPTION_UNDEF to leave option as is
208 * datacall - enable/disable datacall, STC_DB_OPTION_UNDEF to leave option as is
209 * datausage_timer - set period of the updating data from the kernel,
210 * 0 to leave option as is
211 * datacall_logging - enable/disable datacall_logging,
212 * STC_DB_OPTION_UNDEF to leave option as is
215 stc_option_state_e wifi;
216 stc_option_state_e datacall;
217 time_t datausage_timer;
218 stc_option_state_e datacall_logging;
222 * @brief datausage in bytes
225 int64_t in_bytes; /**< incoming bytes */
226 int64_t out_bytes; /**< outgoing bytes */
227 } stc_data_counter_s;
230 GMainLoop *main_loop;
232 gpointer statistics_obj;
233 gpointer restriction_obj;
234 gpointer firewall_obj;
235 gpointer manager_obj;
237 GDBusObjectManagerServer *obj_mgr;
238 GDBusConnection *connection;
239 guint gdbus_owner_id;
241 void *system; /* stc_system_s */
242 struct counter_arg *carg;
245 stc_s *stc_get_manager(void);
246 void stc_stop_manager(void);
247 int stc_commit_iptables(char *cmd, int *err_num, char **err_str);
249 #endif /* __STC_MANAGER__ */