Separate monitoring function plugin
[platform/core/connectivity/stc-manager.git] / plugin / monitor / include / stc-plugin-monitor-app.h
1 /*
2  * Copyright (c) 2017 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_PLUGIN_MONITOR_APP_H__
18 #define __STC_PLUGIN_MONITOR_APP_H__
19
20 #include <glib.h>
21
22 #include "stc-error.h"
23 #include "stc-manager.h"
24 #include "stc-plugin-monitor-context.h"
25 #include "stc-plugin-monitor-connection.h"
26
27 #define MAC_ADDRESS_LEN 18
28 #define SUBSCRIBERID_NONE "none_subid"
29
30 typedef struct {
31         uint32_t classid;  /**< classid for a package */
32         gchar *pkg_id;  /**< package id */
33         gchar *app_id;  /**< application id */
34         stc_app_type_e type;  /**< type of application */
35         stc_app_state_e state;
36         stc_data_counter_s data_usage;
37         stc_data_counter_s counter;
38         GHashTable *processes;  /**< applications instances */
39         char mac[MAC_ADDRESS_LEN+1]; /**< application mac address */
40 } stc_app_value_s;
41
42
43 stc_error_e stc_plugin_monitor_app_add(uint32_t classid,
44                                 const char *app_id,
45                                 const char *pkg_id,
46                                 const stc_app_value_s value);
47 stc_error_e stc_plugin_monitor_app_remove(uint32_t classid,
48                                 const char *app_id);
49 gboolean stc_plugin_monitor_app_lookup(uint32_t classid);
50
51
52 void stc_monitor_app_update_counter(stc_app_value_s *value,
53                                  classid_bytes_context_s *context);
54 void stc_monitor_app_update_iface_counter(classid_bytes_context_s *context);
55 gboolean stc_monitor_app_flush_stats_to_db(gpointer user_data);
56 void stc_monitor_app_add_by_iface(const char *app_id);
57 void stc_monitor_app_add_monitor(gpointer key,
58                                 gpointer value, gpointer data);
59 void stc_monitor_app_add_by_connection(stc_connection_s *conn);
60 void stc_monitor_app_add_accept(gpointer key,
61                                 gpointer value, gpointer data);
62 void stc_monitor_app_remove_monitor(gpointer key,
63                                 gpointer value, gpointer data);
64 void stc_monitor_app_remove_by_connection(stc_connection_s *conn);
65 void stc_monitor_app_remove_accept(gpointer key,
66                                 gpointer value, gpointer data);
67 GHashTable *stc_monitor_apps_init(void);
68
69 #endif /* __STC_PLUGIN_MONITOR_APP_H__ */