Monitoring system wide IPv4 and IPv6 data usage.
[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 typedef enum {
35         STC_CANCEL = 0,    /**< cancel */
36         STC_CONTINUE = 1,  /**< continue */
37 } stc_cb_ret_e;
38
39 /**
40  * @brief Monitored application types
41  */
42 typedef enum {
43         STC_APP_TYPE_NONE,
44         STC_APP_TYPE_READY,
45         STC_APP_TYPE_GUI,
46         STC_APP_TYPE_SERVICE,
47         STC_APP_TYPE_GROUP,
48         STC_APP_TYPE_WATCH,
49         STC_APP_TYPE_WIDGET,
50         STC_APP_TYPE_MAX,
51 } stc_app_type_e;
52
53 /**
54  * @brief State of the statisticsed process
55  */
56 typedef enum {
57         STC_APP_STATE_UNKNOWN = 0,
58         STC_APP_STATE_FOREGROUND = 1 << 1,  /** < foreground state */
59         STC_APP_STATE_BACKGROUND = 1 << 2,  /** < background state */
60         STC_APP_STATE_LAST_ELEM = 1 << 3
61 } stc_app_state_e;
62
63 /**
64  * @brief Network restriction states
65  */
66 typedef enum {
67         STC_RESTRICTION_UNKNOWN,
68         STC_RESTRICTION_ACTIVATED,  /** < restriction has been activated */
69         STC_RESTRICTION_REMOVED,    /** < restriction has been removed */
70         STC_RESTRICTION_EXCLUDED,   /** < restriction has been excluded */
71         STC_RESTRICTION_LAST_ELEM
72 } stc_restriction_state_e;
73
74 /**
75  * @brief Network interface types
76  */
77 typedef enum {
78         STC_IFACE_UNKNOWN,    /**< undefined iface */
79         STC_IFACE_DATACALL,   /**< mobile data */
80         STC_IFACE_WIFI,       /**< wifi data */
81         STC_IFACE_WIRED,      /**< wired interface */
82         STC_IFACE_BLUETOOTH,  /**< bluetooth interface */
83         STC_IFACE_IPV4,       /**< ipv4 interface */
84         STC_IFACE_IPV6,       /**< ipv6 interface */
85         STC_IFACE_ALL,        /**< enumerate all network interface types */
86         STC_IFACE_LAST_ELEM
87 } stc_iface_type_e;
88
89 /**
90  * @brief Network roaming type
91  */
92 typedef enum {
93         STC_ROAMING_UNKNOWN,   /**< can't define roaming - roaming unknown */
94         STC_ROAMING_ENABLE,    /**< in roaming */
95         STC_ROAMING_DISABLE,   /**< not in roaming */
96         STC_ROAMING_LAST_ELEM,
97 } stc_roaming_type_e;
98
99 /**
100  * @brief Hardware network protocol types
101  */
102 typedef enum {
103         STC_PROTOCOL_NONE,                /**< Network unknown */
104         STC_PROTOCOL_DATACALL_NOSVC,      /**< Network no service */
105         STC_PROTOCOL_DATACALL_EMERGENCY,  /**< Network emergency */
106         STC_PROTOCOL_DATACALL_SEARCH,     /**< Network search 1900 */
107         STC_PROTOCOL_DATACALL_2G,         /**< Network 2G */
108         STC_PROTOCOL_DATACALL_2_5G,       /**< Network 2.5G */
109         STC_PROTOCOL_DATACALL_2_5G_EDGE,  /**< Network EDGE */
110         STC_PROTOCOL_DATACALL_3G,         /**< Network UMTS */
111         STC_PROTOCOL_DATACALL_HSDPA,      /**< Network HSDPA */
112         STC_PROTOCOL_DATACALL_LTE,        /**< Network LTE */
113         STC_PROTOCOL_MAX_ELEM
114 } stc_hw_net_protocol_type_e;
115
116 /**
117  * @desc Description of the boolean option for enabling/disabling
118  *     network interfaces and enabling/disabling some behaviar
119  */
120 typedef enum {
121         STC_DB_OPTION_UNDEF,
122         STC_DB_OPTION_ENABLE,
123         STC_DB_OPTION_DISABLE
124 } stc_option_state_e;
125
126 /**
127  * @desc Set of the options.
128  * version - contains structure version
129  * wifi - enable/disable wifi, STC_DB_OPTION_UNDEF to leave option as is
130  * datacall - enable/disable datacall, STC_DB_OPTION_UNDEF to leave option as is
131  * datausage_timer - set period of the updating data from the kernel,
132  *     0 to leave option as is
133  * datacall_logging - enable/disable datacall_logging,
134  *     STC_DB_OPTION_UNDEF to leave option as is
135  */
136 typedef struct {
137         unsigned char version;
138         stc_option_state_e wifi;
139         stc_option_state_e datacall;
140         time_t datausage_timer;
141         stc_option_state_e datacall_logging;
142 } stc_options_s;
143
144 /**
145  * @brief datausage in bytes
146  */
147 typedef struct {
148         int64_t in_bytes;  /**< incoming bytes */
149         int64_t out_bytes;  /**< outgoing bytes */
150 } stc_data_counter_s;
151
152 typedef struct {
153         GMainLoop *main_loop;
154
155         gpointer statistics_obj;
156         gpointer restriction_obj;
157
158         GDBusObjectManagerServer *obj_mgr;
159         GDBusConnection *connection;
160         guint gdbus_owner_id;
161
162         void *system; /* stc_system_s */
163         struct counter_arg *carg;
164 } stc_s;
165
166 stc_s *stc_get_manager(void);
167
168 #endif /* __STC_MANAGER__ */