--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __STC_MANAGER_PLUGIN_MONITOR_H__
+#define __STC_MANAGER_PLUGIN_MONITOR_H__
+
+#define STC_PLUGIN_MONITOR_FILEPATH "/usr/lib/stc-plugin-monitor.so"
+
+#include "stc-plugin-monitor.h"
+
+int stc_plugin_monitor_init(void);
+int stc_plugin_monitor_deinit(void);
+
+int stc_plugin_monitor_add_app(uint32_t classid,
+ const char *app_id,
+ const char *pkg_id,
+ const stc_app_value_s value);
+int stc_plugin_monitor_remove_app(uint32_t classid,
+ const char *app_id);
+int stc_plugin_monitor_lookup_app(uint32_t classid);
+int stc_plugin_monitor_add_rstn(table_restrictions_info *info);
+int stc_plugin_monitor_remove_rstn(table_restrictions_info *info);
+int stc_plugin_monitor_init_connection(stc_s *stc);
+int stc_plugin_monitor_deinit_connection(stc_s *stc);
+int stc_plugin_monitor_add_proc(uint32_t classid,
+ const char *app_id, const stc_proc_value_s value);
+int stc_plugin_monitor_remove_proc(uint32_t classid, pid_t pid);
+int stc_plugin_monitor_move_proc(uint32_t from, uint32_t to);
+int stc_plugin_monitor_update_proc_ground(uint32_t classid,
+ const char *app_id, const stc_proc_value_s value);
+
+#endif /* __STC_MANAGER_PLUGIN_MONITOR_H__ */
#define ret_value_if(expr, val) do { \
if (expr) { \
- STC_LOGE("(%s) -> %s():%d return", #expr, __FUNCTION__, __LINE__); \
return (val); \
} \
} while (0)
#define ret_value_msg_if(expr, val, fmt, arg...) do { \
if (expr) { \
- STC_LOGE(fmt, ##arg); \
+ if (STC_DEBUG_LOG) \
+ STC_LOGE(fmt, ##arg); \
return val; \
} \
} while (0)
Name: stc-manager
Summary: STC(Smart Traffic Control) manager
-Version: 0.0.82
+Version: 0.0.83
Release: 0
Group: Network & Connectivity/Other
License: Apache-2.0
%description plugin-tether
A smart traffic control manager extension for tethering client data usage plugin
+%package plugin-monitor
+Summary: Monitor plugin for data usage of clients
+
+%description plugin-monitor
+A smart traffic control manager extension for monitoring client data usage plugin
+
%prep
%setup -q
chmod 644 %{SOURCE0}
%files plugin-tether
%manifest %{name}.manifest
%attr(500,root,root) %{_libdir}/stc-plugin-tether.so
+
+%files plugin-monitor
+%manifest %{name}.manifest
+%attr(500,root,root) %{_libdir}/stc-plugin-monitor.so
SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
SET(HELPER_SOURCE_DIR ${SOURCE_DIR}/helper)
SET(DATABASE_SOURCE_DIR ${SOURCE_DIR}/database)
-SET(MONITOR_SOURCE_DIR ${SOURCE_DIR}/monitor)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces)
INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR})
INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}/include)
-
ADD_SUBDIRECTORY(appstatus)
ADD_SUBDIRECTORY(exception)
ADD_SUBDIRECTORY(procfs)
ADD_SUBDIRECTORY(pcap)
ADD_SUBDIRECTORY(tether)
+ADD_SUBDIRECTORY(monitor)
else
apptype = STC_APP_TYPE_GUI;
- if (STC_DEBUG_LOG && STC_STAT_LOG) {
+ if (STC_STAT_LOG) {
STC_LOGD("\033[1;34mAPP STATUS\033[0;m: PkgID[\033[0;34m%s\033[0;m] "
"AppID[\033[0;32m%s\033[0;m] PID[\033[1;33m%d\033[0;m] Status[%s] Type[%s]",
pkgid, appid, pid, statstr, pkgtype);
const char *process_name = key;
const char *exe_type = value;
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGI("Process_name[%s] exe_type[%s]",
process_name, exe_type);
}
table_exceptions_foreach(__insert_exception_cb, NULL);
pkginfo_exceptions_foreach(__insert_exception_cb, NULL);
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
__excn_hash_printall();
g_excns_timer_id = g_timeout_add_seconds(EXCNS_TIMER_INTERVAL,
__remove_exception_appall();
pkginfo_exceptions_foreach(__insert_exception_cb, NULL);
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
__excn_hash_printall();
return STC_ERROR_NONE;
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc-plugin-monitor C)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(monitor_plugin REQUIRED
+ dlog
+ gio-2.0
+ gio-unix-2.0
+ glib-2.0
+ vconf
+ openssl
+ )
+
+FOREACH(flag ${monitor_plugin_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/configure/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/tether/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/appstatus/include)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(SRCS_PLUGIN
+ stc-plugin-monitor.c
+ stc-plugin-monitor-proc.c
+ stc-plugin-monitor-connection.c
+ stc-plugin-monitor-rstn.c
+ stc-plugin-monitor-app.c
+ stc-plugin-monitor-ipt.c
+ stc-plugin-monitor-time.c
+ )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN})
+ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${monitor_plugin_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
+
+# install
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
* limitations under the License.
*/
-#ifndef __STC_MONITOR_APP_H__
-#define __STC_MONITOR_APP_H__
+#ifndef __STC_PLUGIN_MONITOR_APP_H__
+#define __STC_PLUGIN_MONITOR_APP_H__
#include <glib.h>
#include "stc-error.h"
#include "stc-manager.h"
-#include "stc-monitor-context.h"
-#include "stc-connection.h"
+#include "stc-plugin-monitor-context.h"
+#include "stc-plugin-monitor-connection.h"
#define MAC_ADDRESS_LEN 18
#define SUBSCRIBERID_NONE "none_subid"
char mac[MAC_ADDRESS_LEN+1]; /**< application mac address */
} stc_app_value_s;
-void stc_monitor_app_update_counter(stc_app_value_s *value,
- classid_bytes_context_s *context);
-
-void stc_monitor_app_update_iface_counter(classid_bytes_context_s *context);
-
-gboolean stc_monitor_app_flush_stats_to_db(gpointer user_data);
-stc_error_e stc_monitor_app_add(uint32_t classid,
+stc_error_e stc_plugin_monitor_app_add(uint32_t classid,
const char *app_id,
const char *pkg_id,
const stc_app_value_s value);
+stc_error_e stc_plugin_monitor_app_remove(uint32_t classid,
+ const char *app_id);
+gboolean stc_plugin_monitor_app_lookup(uint32_t classid);
-void stc_monitor_app_add_by_iface(const char *app_id);
+void stc_monitor_app_update_counter(stc_app_value_s *value,
+ classid_bytes_context_s *context);
+void stc_monitor_app_update_iface_counter(classid_bytes_context_s *context);
+gboolean stc_monitor_app_flush_stats_to_db(gpointer user_data);
+void stc_monitor_app_add_by_iface(const char *app_id);
void stc_monitor_app_add_monitor(gpointer key,
gpointer value, gpointer data);
-
void stc_monitor_app_add_by_connection(stc_connection_s *conn);
-
void stc_monitor_app_add_accept(gpointer key,
gpointer value, gpointer data);
-
-stc_error_e stc_monitor_app_remove(uint32_t classid, const char *app_id);
-
void stc_monitor_app_remove_monitor(gpointer key,
gpointer value, gpointer data);
-
void stc_monitor_app_remove_by_connection(stc_connection_s *conn);
-
void stc_monitor_app_remove_accept(gpointer key,
gpointer value, gpointer data);
-
-gboolean stc_monitor_app_lookup(uint32_t classid);
-
GHashTable *stc_monitor_apps_init(void);
-#endif /* __STC_MONITOR_APP_H__ */
+#endif /* __STC_PLUGIN_MONITOR_APP_H__ */
* limitations under the License.
*/
-#ifndef __STC_CONNECTION_H__
-#define __STC_CONNECTION_H__
+#ifndef __STC_PLUGIN_MONITOR_CONNECTION_H__
+#define __STC_PLUGIN_MONITOR_CONNECTION_H__
#include <glib.h>
#include "stc-error.h"
tether_iface_s tether_iface;
} stc_connection_s;
-stc_error_e stc_connection_monitor_init(stc_s *stc);
-stc_error_e stc_connection_monitor_deinit(stc_s *stc);
+
+stc_error_e stc_plugin_monitor_connection_init(stc_s *stc);
+stc_error_e stc_plugin_monitor_connection_deinit(stc_s *stc);
+
GSList *stc_get_connection_list(void);
-#endif /* __STC_CONNECTION_H__ */
+#endif /* __STC_PLUGIN_MONITOR_CONNECTION_H__ */
* limitations under the License.
*/
-#ifndef __STC_MONITOR_CONTEXT_H__
-#define __STC_MONITOR_CONTEXT_H__
+#ifndef __STC_PLUGIN_MONITOR_CONTEXT_H__
+#define __STC_PLUGIN_MONITOR_CONTEXT_H__
#include "stc-manager.h"
int month_start_date;
} stc_system_s;
-#endif /* __STC_MONITOR_CONTEXT_H__ */
+#endif /* __STC_PLUGIN_MONITOR_CONTEXT_H__ */
* limitations under the License.
*/
-#ifndef __STC_MONITOR_IPT_H__
-#define __STC_MONITOR_IPT_H__
+#ifndef __STC_PLUGIN_MONITOR_IPT_H__
+#define __STC_PLUGIN_MONITOR_IPT_H__
#include "helper-nfacct-rule.h"
stc_error_e stc_monitor_tether_del_out(struct nfacct_rule *counter,
const gchar *ipaddr);
-#endif /* __STC_MONITOR_IPT_H__ */
+#endif /* __STC_PLUGIN_MONITOR_IPT_H__ */
* limitations under the License.
*/
-#ifndef __STC_MONITOR_PROC_H__
-#define __STC_MONITOR_PROC_H__
+#ifndef __STC_PLUGIN_MONITOR_PROC_H__
+#define __STC_PLUGIN_MONITOR_PROC_H__
#include <glib.h>
gboolean entry_removed;
} remove_pid_context_s;
-stc_error_e stc_monitor_proc_update_ground(uint32_t classid,
+stc_error_e stc_plugin_monitor_proc_update_ground(uint32_t classid,
const char *app_id,
const stc_proc_value_s value);
-stc_error_e stc_monitor_proc_add(uint32_t classid,
+stc_error_e stc_plugin_monitor_proc_add(uint32_t classid,
const char *app_id,
const stc_proc_value_s value);
-stc_error_e stc_monitor_proc_remove(uint32_t classid,
- pid_t pid);
+stc_error_e stc_plugin_monitor_proc_remove(uint32_t classid, pid_t pid);
-stc_error_e stc_monitor_proc_move(uint32_t from,
- uint32_t to);
+stc_error_e stc_plugin_monitor_proc_move(uint32_t from, uint32_t to);
-#endif /* __STC_MONITOR_PROC_H__ */
+#endif /* __STC_PLUGIN_MONITOR_PROC_H__ */
* limitations under the License.
*/
-#ifndef __STC_MONITOR_RSTN_H__
-#define __STC_MONITOR_RSTN_H__
+#ifndef __STC_PLUGIN_MONITOR_RSTN_H__
+#define __STC_PLUGIN_MONITOR_RSTN_H__
#include <glib.h>
#include "stc-error.h"
#include "stc-manager.h"
-#include "stc-monitor-context.h"
-#include "stc-connection.h"
+#include "stc-plugin-monitor-context.h"
+#include "stc-plugin-monitor-connection.h"
#include "stc-restriction.h"
#include "table-restrictions.h"
int64_t daily_stat;
} stc_rstn_cumulative_data_s;
-void stc_monitor_rstn_reset_time_counters_if_required(void);
+stc_error_e stc_plugin_monitor_rstn_add(const table_restrictions_info *info);
+stc_error_e stc_plugin_monitor_rstn_remove(const table_restrictions_info *info);
+
+
+void stc_monitor_rstn_reset_time_counters_if_required(void);
void stc_monitor_rstn_update_counter(gpointer data,
gpointer user_data);
-
void stc_monitor_rstn_update_iface_counter(classid_bytes_context_s *context);
-
void stc_monitor_rstn_action_when_limit_exceeded(stc_rstn_limit_type_e limit_type,
stc_rstn_data_s *rstn_data,
classid_bytes_context_s *context);
-
gboolean stc_monitor_rstn_flush_contr_to_db(gpointer user_data);
-
-stc_error_e stc_monitor_rstn_add(const table_restrictions_info *info);
-
void stc_monitor_rstn_add_for_app(uint32_t classid);
-
void stc_monitor_rstn_add_by_connection(stc_connection_s *conn);
-
-stc_error_e stc_monitor_rstn_remove(const table_restrictions_info *info);
-
void stc_monitor_rstn_remove_for_app(uint32_t classid);
-
void stc_monitor_rstn_remove_by_connection(stc_connection_s *conn);
-
void stc_monitor_rstns_load(void);
-
GHashTable *stc_monitor_rstns_init(void);
-#endif /* __STC_MONITOR_RSTN_H__ */
+#endif /* __STC_PLUGIN_MONITOR_RSTN_H__ */
* limitations under the License.
*/
-#ifndef __STC_MANAGER_TIME_H__
-#define __STC_MANAGER_TIME_H__
+#ifndef __STC_PLUGIN_MANAGER_TIME_H__
+#define __STC_PLUGIN_MANAGER_TIME_H__
time_t stc_time_get_day_start(time_t now);
time_t stc_time_get_week_start(time_t now);
time_t stc_time_get_month_start(time_t now, int month_start_date);
-#endif /* __STC_MANAGER_TIME_H__ */
+#endif /* __STC_PLUGIN_MANAGER_TIME_H__ */
* limitations under the License.
*/
-#ifndef __STC_MONITOR_H__
-#define __STC_MONITOR_H__
+#ifndef __STC_PLUGIN_MONITOR_H__
+#define __STC_PLUGIN_MONITOR_H__
#include <glib.h>
#include "stc-error.h"
#include "stc-manager.h"
#include "stc-manager-util.h"
-#include "stc-monitor-context.h"
-#include "stc-monitor-app.h"
-#include "stc-monitor-proc.h"
-#include "stc-monitor-rstn.h"
+#include "stc-plugin-monitor-context.h"
+#include "stc-plugin-monitor-app.h"
+#include "stc-plugin-monitor-proc.h"
+#include "stc-plugin-monitor-rstn.h"
#include "helper-nl.h"
/* 1 seconds */
#define VCONFKEY_SETAPPL_DATA_RESTRICTION_INT "db/setting/data_restriction"
#endif
-/**
- * @brief initializes stc monitor module
- */
-stc_error_e stc_monitor_init(void);
+typedef struct {
+ int (*initialize_plugin) (void);
+ int (*deinitialize_plugin) (void);
-/**
- * @brief deinitializes stc monitor module
- */
-stc_error_e stc_monitor_deinit(void);
+ int (*add_application) (uint32_t classid,
+ const char *app_id,
+ const char *pkg_id,
+ const stc_app_value_s value);
+ int (*remove_application) (uint32_t classid,
+ const char *app_id);
-GHashTable *stc_monitor_get_system_apps(void);
+ int (*add_restriction) (const table_restrictions_info *info);
+ int (*remove_restriction) (const table_restrictions_info *info);
+ int (*lookup_application) (uint32_t classid);
-GHashTable *stc_monitor_get_system_rstns(void);
+ int (*init_connection) (stc_s *stc);
+ int (*deinit_connection) (stc_s *stc);
-int stc_monitor_get_contr_sock(void);
+ int (*add_process) (uint32_t classid,
+ const char *app_id,
+ const stc_proc_value_s value);
+ int (*remove_process) (uint32_t classid, pid_t pid);
+ int (*move_process) (uint32_t from, uint32_t to);
+ int (*update_process_ground) (uint32_t classid,
+ const char *app_id,
+ const stc_proc_value_s value);
-time_t stc_monitor_get_last_month_ts(void);
+ int (*check_excn_by_cmdline) (char *cmdline);
+} stc_plugin_monitor_s;
-void stc_monitor_set_last_month_ts(time_t time);
+stc_error_e stc_plugin_monitor_initialize(void);
+stc_error_e stc_plugin_monitor_deinitialize(void);
+GHashTable *stc_monitor_get_system_apps(void);
+GHashTable *stc_monitor_get_system_rstns(void);
+int stc_monitor_get_contr_sock(void);
+time_t stc_monitor_get_last_month_ts(void);
+void stc_monitor_set_last_month_ts(time_t time);
time_t stc_monitor_get_last_week_ts(void);
-
void stc_monitor_set_last_week_ts(time_t time);
-
time_t stc_monitor_get_last_day_ts(void);
-
void stc_monitor_set_last_day_ts(time_t time);
-
void stc_monitor_set_rstns_updated(gboolean value);
-
gboolean stc_monitor_get_rstns_updated(void);
-
void stc_monitor_set_apps_updated(gboolean value);
-
gboolean stc_monitor_get_apps_updated(void);
-
void stc_monitor_set_background_state(gboolean value);
-
gboolean stc_monitor_get_background_state(void);
-
void stc_monitor_update_by_connection(void *data);
-
void stc_monitor_add_by_connection(void *data);
-
void stc_monitor_remove_by_connection(void *data);
-stc_error_e stc_monitor_check_excn_by_cmdline(char *cmdline);
-
-#endif /* __STC_MONITOR_H__ */
+#endif /* __STC_PLUGIN_MONITOR_H__ */
#include "stc-db.h"
#include "counter.h"
#include "stc-manager.h"
-#include "stc-monitor.h"
-#include "stc-monitor-app.h"
-#include "stc-monitor-rstn.h"
-#include "stc-monitor-proc.h"
-#include "stc-monitor-ipt.h"
+#include "stc-plugin-monitor.h"
+#include "stc-plugin-monitor-app.h"
+#include "stc-plugin-monitor-rstn.h"
+#include "stc-plugin-monitor-proc.h"
+#include "stc-plugin-monitor-ipt.h"
#include "table-statistics.h"
#include "helper-net-cls.h"
#include "stc-manager-plugin-tether.h"
}
}
-void stc_monitor_app_update_counter(stc_app_value_s *value,
- classid_bytes_context_s *context)
-{
- switch (context->counter->iotype) {
- case NFACCT_COUNTER_IN:
- value->data_usage.in_bytes += context->bytes;
- value->counter.in_bytes = context->bytes;
- stc_monitor_set_apps_updated(TRUE);
-
- break;
- case NFACCT_COUNTER_OUT:
- value->data_usage.out_bytes += context->bytes;
- value->counter.out_bytes = context->bytes;
- stc_monitor_set_apps_updated(TRUE);
-
- break;
- default:
- STC_LOGE("Unknown iotype");
- }
-}
-
-void stc_monitor_app_update_iface_counter(classid_bytes_context_s *context)
-{
- switch (context->counter->iftype) {
- case STC_IFACE_DATACALL:
- __app_update_counter(context, STC_TOTAL_DATACALL_CLASSID);
- break;
- case STC_IFACE_WIFI:
- __app_update_counter(context, STC_TOTAL_WIFI_CLASSID);
- __app_update_counter(context, STC_TETHERING_APP_CLASSID);
- break;
- case STC_IFACE_BLUETOOTH:
- __app_update_counter(context, STC_TOTAL_BLUETOOTH_CLASSID);
- __app_update_counter(context, STC_TETHERING_APP_CLASSID);
- break;
- case STC_IFACE_USB:
- __app_update_counter(context, STC_TETHERING_APP_CLASSID);
- break;
- case STC_IFACE_P2P:
- __app_update_counter(context, STC_TETHERING_APP_CLASSID);
- break;
- default:
- break;
- }
-}
-
-gboolean stc_monitor_app_flush_stats_to_db(gpointer user_data)
-{
- time_t current_time = 0;
- stc_s *stc = stc_get_manager();
- GHashTable *apps = stc_monitor_get_system_apps();
- gboolean apps_updated = stc_monitor_get_apps_updated();
-
- if (stc && stc->carg)
- current_time = stc->carg->last_run_time;
-
- if (apps_updated == FALSE)
- return G_SOURCE_REMOVE;
-
- stc_monitor_set_apps_updated(FALSE);
-
- if (apps)
- g_hash_table_foreach(apps,
- __app_update_statistics,
- ¤t_time);
-
- STC_LOGI("Flushed app stats to database");
- return G_SOURCE_REMOVE;
-}
-
-API stc_error_e stc_monitor_app_add(uint32_t classid,
+API stc_error_e stc_plugin_monitor_app_add(uint32_t classid,
const char *app_id,
const char *pkg_id,
const stc_app_value_s value)
lookup_value = g_hash_table_lookup(apps, GUINT_TO_POINTER(classid));
if (lookup_value) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGE("Already exists [\033[1;36m%d\033[0;m:"
"\033[0;32m%s\033[0;m]", classid, app_id);
return STC_ERROR_NONE;
app_value = MALLOC0(stc_app_value_s, 1);
if (!app_value) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGE("Value allocation failed");
return STC_ERROR_OUT_OF_MEMORY;
}
stc_monitor_rstn_add_for_app(classid);
- if (STC_DEBUG_LOG && STC_STAT_LOG) {
+ if (STC_STAT_LOG) {
__print_app(GUINT_TO_POINTER(classid), app_value, NULL);
STC_LOGD("\033[1;32mApplication added\033[0;m "
"[\033[1;36m%d\033[0;m]", classid);
return STC_ERROR_NONE;
}
+API stc_error_e stc_plugin_monitor_app_remove(uint32_t classid,
+ const char *app_id)
+{
+ stc_app_value_s *app_lookup;
+ GHashTable *apps = stc_monitor_get_system_apps();
+ GSList *conn_list = stc_get_connection_list();
+
+ if (!apps)
+ return STC_ERROR_NO_DATA;
+
+ classid = get_classid_by_app_id(app_id, FALSE);
+
+ app_lookup = g_hash_table_lookup(apps, GUINT_TO_POINTER(classid));
+ if (!app_lookup) {
+ if (STC_STAT_LOG)
+ STC_LOGD("Application not found [\033[1;36m%d\033[0;m]", classid);
+ return STC_ERROR_FAIL;
+ }
+
+ for (; conn_list != NULL; conn_list = conn_list->next) {
+ stc_connection_s *conn = conn_list->data;
+ /* remove nfacct rule for this classid */
+ stc_monitor_app_remove_monitor(GUINT_TO_POINTER(classid),
+ app_lookup, conn);
+
+ if (app_lookup->state == STC_APP_STATE_FOREGROUND)
+ stc_monitor_app_remove_accept(GUINT_TO_POINTER(classid),
+ app_lookup, conn);
+ }
+
+ /* remove ristrictions if any */
+ stc_monitor_rstn_remove_for_app(classid);
+
+ if (STC_STAT_LOG)
+ __print_app(GUINT_TO_POINTER(classid), app_lookup, NULL);
+
+ /* remove app_key from the stc-manager */
+ g_hash_table_remove(apps, GUINT_TO_POINTER(classid));
+
+ return STC_ERROR_NONE;
+}
+
+API gboolean stc_plugin_monitor_app_lookup(uint32_t classid)
+{
+ stc_app_value_s *lookup_value;
+
+ GHashTable *apps = stc_monitor_get_system_apps();
+
+ if (!apps)
+ return FALSE;
+
+ if (classid == STC_UNKNOWN_CLASSID)
+ return FALSE;
+
+ lookup_value = g_hash_table_lookup(apps, GUINT_TO_POINTER(classid));
+ if (lookup_value)
+ return TRUE;
+
+ return FALSE;
+}
+
+void stc_monitor_app_update_counter(stc_app_value_s *value,
+ classid_bytes_context_s *context)
+{
+ switch (context->counter->iotype) {
+ case NFACCT_COUNTER_IN:
+ value->data_usage.in_bytes += context->bytes;
+ value->counter.in_bytes = context->bytes;
+ stc_monitor_set_apps_updated(TRUE);
+
+ break;
+ case NFACCT_COUNTER_OUT:
+ value->data_usage.out_bytes += context->bytes;
+ value->counter.out_bytes = context->bytes;
+ stc_monitor_set_apps_updated(TRUE);
+
+ break;
+ default:
+ STC_LOGE("Unknown iotype");
+ }
+}
+
+void stc_monitor_app_update_iface_counter(classid_bytes_context_s *context)
+{
+ switch (context->counter->iftype) {
+ case STC_IFACE_DATACALL:
+ __app_update_counter(context, STC_TOTAL_DATACALL_CLASSID);
+ break;
+ case STC_IFACE_WIFI:
+ __app_update_counter(context, STC_TOTAL_WIFI_CLASSID);
+ __app_update_counter(context, STC_TETHERING_APP_CLASSID);
+ break;
+ case STC_IFACE_BLUETOOTH:
+ __app_update_counter(context, STC_TOTAL_BLUETOOTH_CLASSID);
+ __app_update_counter(context, STC_TETHERING_APP_CLASSID);
+ break;
+ case STC_IFACE_USB:
+ __app_update_counter(context, STC_TETHERING_APP_CLASSID);
+ break;
+ case STC_IFACE_P2P:
+ __app_update_counter(context, STC_TETHERING_APP_CLASSID);
+ break;
+ default:
+ break;
+ }
+}
+
+gboolean stc_monitor_app_flush_stats_to_db(gpointer user_data)
+{
+ time_t current_time = 0;
+ stc_s *stc = stc_get_manager();
+ GHashTable *apps = stc_monitor_get_system_apps();
+ gboolean apps_updated = stc_monitor_get_apps_updated();
+
+ if (stc && stc->carg)
+ current_time = stc->carg->last_run_time;
+
+ if (apps_updated == FALSE)
+ return G_SOURCE_REMOVE;
+
+ stc_monitor_set_apps_updated(FALSE);
+
+ if (apps)
+ g_hash_table_foreach(apps,
+ __app_update_statistics,
+ ¤t_time);
+
+ STC_LOGI("Flushed app stats to database");
+ return G_SOURCE_REMOVE;
+}
+
void stc_monitor_app_add_by_iface(const char *ifname)
{
stc_app_value_s app_value;
app_value.counter.in_bytes = 0;
app_value.counter.out_bytes = 0;
- stc_monitor_app_add(STC_UNKNOWN_CLASSID, ifname, ifname, app_value);
+ stc_plugin_monitor_app_add(STC_UNKNOWN_CLASSID, ifname, ifname, app_value);
}
void stc_monitor_app_add_monitor(gpointer key,
}
}
-API stc_error_e stc_monitor_app_remove(uint32_t classid, const char *app_id)
-{
- stc_app_value_s *app_lookup;
- GHashTable *apps = stc_monitor_get_system_apps();
- GSList *conn_list = stc_get_connection_list();
-
- if (!apps)
- return STC_ERROR_NO_DATA;
-
- classid = get_classid_by_app_id(app_id, FALSE);
-
- app_lookup = g_hash_table_lookup(apps, GUINT_TO_POINTER(classid));
- if (!app_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
- STC_LOGD("Application not found [\033[1;36m%d\033[0;m]", classid);
- return STC_ERROR_FAIL;
- }
-
- for (; conn_list != NULL; conn_list = conn_list->next) {
- stc_connection_s *conn = conn_list->data;
- /* remove nfacct rule for this classid */
- stc_monitor_app_remove_monitor(GUINT_TO_POINTER(classid),
- app_lookup, conn);
-
- if (app_lookup->state == STC_APP_STATE_FOREGROUND)
- stc_monitor_app_remove_accept(GUINT_TO_POINTER(classid),
- app_lookup, conn);
- }
-
- /* remove ristrictions if any */
- stc_monitor_rstn_remove_for_app(classid);
-
- if (STC_DEBUG_LOG && STC_STAT_LOG)
- __print_app(GUINT_TO_POINTER(classid), app_lookup, NULL);
-
- /* remove app_key from the stc-manager */
- g_hash_table_remove(apps, GUINT_TO_POINTER(classid));
-
- return STC_ERROR_NONE;
-}
-
void stc_monitor_app_remove_monitor(gpointer key,
gpointer value, gpointer data)
{
return;
}
-API gboolean stc_monitor_app_lookup(uint32_t classid)
-{
- stc_app_value_s *lookup_value;
-
- GHashTable *apps = stc_monitor_get_system_apps();
-
- if (!apps)
- return FALSE;
-
- if (classid == STC_UNKNOWN_CLASSID)
- return FALSE;
-
- lookup_value = g_hash_table_lookup(apps, GUINT_TO_POINTER(classid));
- if (lookup_value)
- return TRUE;
-
- return FALSE;
-}
-
GHashTable *stc_monitor_apps_init(void)
{
return g_hash_table_new_full(g_direct_hash, g_direct_equal,
#include <vconf/vconf.h>
#include <openssl/sha.h>
-#include "stc-monitor.h"
#include "stc-firewall.h"
#include "stc-manager-gdbus.h"
-#include "stc-connection.h"
+#include "stc-plugin-monitor.h"
+#include "stc-plugin-monitor-connection.h"
/* connman service dbus details */
#define CONNMAN_SERVICE "net.connman"
return;
}
-stc_error_e stc_connection_monitor_init(stc_s *stc)
+stc_error_e stc_plugin_monitor_connection_init(stc_s *stc)
{
int ret;
ret_value_msg_if(stc == NULL, STC_ERROR_INVALID_PARAMETER, "failed to get stc data");
return STC_ERROR_NONE;
}
-stc_error_e stc_connection_monitor_deinit(stc_s *stc)
+stc_error_e stc_plugin_monitor_connection_deinit(stc_s *stc)
{
ret_value_msg_if(stc == NULL, STC_ERROR_INVALID_PARAMETER, "failed to get stc data");
* limitations under the License.
*/
-#include "stc-monitor-ipt.h"
-#include "stc-monitor-context.h"
+#include "stc-plugin-monitor-ipt.h"
+#include "stc-plugin-monitor-context.h"
static nfacct_rule_jump __get_jump_by_intend(struct nfacct_rule *counter)
{
* limitations under the License.
*/
-#include "stc-monitor.h"
-#include "stc-monitor-proc.h"
-#include "stc-connection.h"
+#include "stc-plugin-monitor.h"
+#include "stc-plugin-monitor-proc.h"
+#include "stc-plugin-monitor-connection.h"
#include "helper-net-cls.h"
static void __print_proc(gpointer key, gpointer value,
if (!g_hash_table_remove(app_value->processes, GUINT_TO_POINTER(context->pid)))
return;
- if (STC_DEBUG_LOG && STC_STAT_LOG) {
+ if (STC_STAT_LOG) {
__print_proc_all(app_value->processes);
STC_LOGD("\033[1;31mProcess removed\033[0;m "
"[\033[1;33m%d\033[0;m]", context->pid);
place_pids_to_net_cgroup(to_value->pid, to_app_value->app_id);
}
-API stc_error_e stc_monitor_proc_update_ground(uint32_t classid,
+API stc_error_e stc_plugin_monitor_proc_update_ground(uint32_t classid,
const char *app_id,
const stc_proc_value_s value)
{
app_lookup = g_hash_table_lookup(apps, GUINT_TO_POINTER(classid));
if (!app_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("Application not found [\033[1;36m%d\033[0;m]", classid);
return STC_ERROR_NO_DATA;
}
proc_lookup = g_hash_table_lookup(app_lookup->processes,
GUINT_TO_POINTER(value.pid));
if (!proc_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("Process not found [\033[1;33m%d\033[0;m]", value.pid);
return STC_ERROR_NO_DATA;
}
return ret;
}
-API stc_error_e stc_monitor_proc_add(uint32_t classid,
+API stc_error_e stc_plugin_monitor_proc_add(uint32_t classid,
const char *app_id,
const stc_proc_value_s value)
{
app_lookup = g_hash_table_lookup(apps, GUINT_TO_POINTER(classid));
if (!app_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("Application not found [\033[1;36m%d\033[0;m]", classid);
return STC_ERROR_NO_DATA;
}
proc_lookup = g_hash_table_lookup(app_lookup->processes,
GUINT_TO_POINTER(value.pid));
if (proc_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGE("Already exists [\033[1;36m%d\033[0;m]", value.pid);
return STC_ERROR_NONE;
}
proc_value = MALLOC0(stc_proc_value_s, 1);
if (!proc_value) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGE("Value allocation failed");
return STC_ERROR_OUT_OF_MEMORY;
}
/* add pid to application cgroup */
place_pids_to_net_cgroup(proc_value->pid, app_id);
- if (STC_DEBUG_LOG && STC_STAT_LOG) {
+ if (STC_STAT_LOG) {
__print_proc_all(app_lookup->processes);
STC_LOGD("\033[1;32mProcess added\033[0;m "
"[\033[1;33m%d\033[0;m]", proc_value->pid);
return ret;
}
-API stc_error_e stc_monitor_proc_remove(uint32_t classid,
- pid_t pid)
+API stc_error_e stc_plugin_monitor_proc_remove(uint32_t classid, pid_t pid)
{
stc_error_e ret = STC_ERROR_NONE;
stc_app_value_s *app_lookup = NULL;
app_lookup = context.app_value;
if (!app_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("Process not found [\033[1;33m%d\033[0;m]", pid);
return STC_ERROR_NO_DATA;
}
} else {
app_lookup = g_hash_table_lookup(apps, GUINT_TO_POINTER(classid));
if (!app_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("Application not found [\033[1;36m%d\033[0;m]",
classid);
return STC_ERROR_NO_DATA;
}
if (g_hash_table_remove(app_lookup->processes, GUINT_TO_POINTER(pid))) {
- if (STC_DEBUG_LOG && STC_STAT_LOG) {
+ if (STC_STAT_LOG) {
__print_proc_all(app_lookup->processes);
STC_LOGD("\033[1;31mProcess removed\033[0;m "
"[\033[1;33m%d\033[0;m]", pid);
g_hash_table_remove(apps, GUINT_TO_POINTER(classid));
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("\033[1;31mApplication removed\033[0;m "
"[\033[1;36m%d\033[0;m]", classid);
}
return ret;
}
-API stc_error_e stc_monitor_proc_move(uint32_t from,
- uint32_t to)
+API stc_error_e stc_plugin_monitor_proc_move(uint32_t from, uint32_t to)
{
stc_error_e ret = STC_ERROR_NONE;
stc_app_value_s *from_lookup = NULL;
to != STC_UNKNOWN_CLASSID) {
from_lookup = g_hash_table_lookup(apps, GUINT_TO_POINTER(from));
if (!from_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("Application not found [\033[1;36m%d\033[0;m]", from);
return STC_ERROR_NO_DATA;
}
to_lookup = g_hash_table_lookup(apps, GUINT_TO_POINTER(to));
if (!to_lookup) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("Application not found [\033[1;36m%d\033[0;m]", to);
return STC_ERROR_NO_DATA;
}
g_hash_table_foreach(from_lookup->processes,
__proc_move_pid, to_lookup);
- if (STC_DEBUG_LOG && STC_STAT_LOG) {
+ if (STC_STAT_LOG) {
__print_proc_all(to_lookup->processes);
STC_LOGD("\033[1;34mProcesses moved\033[0;m "
"[\033[1;36m%d\033[0;m] -> [\033[1;36m%d\033[0;m]",
g_hash_table_remove_all(from_lookup->processes);
- if (STC_DEBUG_LOG && STC_STAT_LOG) {
+ if (STC_STAT_LOG) {
__print_proc_all(from_lookup->processes);
STC_LOGD("\033[1;31mProcesses removed\033[0;m "
"[\033[1;36m%d\033[0;m]", from);
g_hash_table_remove(apps, GUINT_TO_POINTER(from));
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("\033[1;31mApplication removed\033[0;m "
"[\033[1;36m%d\033[0;m]", from);
}
#include <vconf-keys.h>
#include "counter.h"
-#include "stc-monitor.h"
-#include "stc-monitor-rstn.h"
-#include "stc-monitor-ipt.h"
-#include "stc-time.h"
+#include "stc-plugin-monitor.h"
+#include "stc-plugin-monitor-rstn.h"
+#include "stc-plugin-monitor-ipt.h"
+#include "stc-plugin-monitor-time.h"
#include "table-counters.h"
#include "table-restrictions.h"
#include "table-statistics.h"
__reset_time_counter_foreach_rstn_data, data);
}
+API stc_error_e stc_plugin_monitor_rstn_add(const table_restrictions_info *info)
+{
+ stc_rstn_data_s data;
+
+ memset(&data, 0, sizeof(stc_rstn_data_s));
+
+ if (info->app_id) {
+ data.classid = get_classid_by_app_id(info->app_id, TRUE);
+ data.app_id = info->app_id;
+ } else
+ data.classid = STC_UNKNOWN_CLASSID;
+
+ if (data.classid == STC_BACKGROUND_APP_CLASSID) {
+ stc_monitor_set_background_state(TRUE);
+ __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, TRUE);
+ }
+
+ data.iftype = info->iftype;
+ data.ifname = info->ifname;
+ data.subscriber_id = info->subscriber_id;
+ data.roaming = info->roaming;
+ data.mac = info->mac;
+
+ data.rstn_type = info->rstn_type;
+ data.rstn_state = STC_RSTN_STATE_UNKNOWN;
+ data.restriction_id = info->restriction_id;
+
+ data.limit[STC_RSTN_LIMIT_TYPE_DATA] = info->data_limit;
+ data.limit[STC_RSTN_LIMIT_TYPE_DATA_WARN] = info->data_warn_limit;
+ data.limit[STC_RSTN_LIMIT_TYPE_MONTHLY] = info->monthly_limit;
+ data.limit[STC_RSTN_LIMIT_TYPE_WEEKLY] = info->weekly_limit;
+ data.limit[STC_RSTN_LIMIT_TYPE_DAILY] = info->daily_limit;
+ data.month_start_date = info->month_start_date;
+ data.month_start_ts = stc_time_get_month_start(time(NULL),
+ info->month_start_date);
+
+ return __rstn_data_add(&data);
+}
+
+API stc_error_e stc_plugin_monitor_rstn_remove(const table_restrictions_info *info)
+{
+ stc_rstn_data_s data;
+
+ memset(&data, 0, sizeof(stc_rstn_data_s));
+
+ data.classid = get_classid_by_app_id(info->app_id, TRUE);
+ data.app_id = info->app_id;
+
+ data.iftype = info->iftype;
+ data.ifname = info->ifname;
+ data.subscriber_id = info->subscriber_id;
+ data.roaming = info->roaming;
+
+ if (g_strcmp0(info->app_id, STC_TOTAL_BACKGROUND) == 0) {
+ stc_monitor_set_background_state(FALSE);
+ __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, FALSE);
+ }
+
+ return __rstn_data_remove(&data);
+}
+
void stc_monitor_rstn_reset_time_counters_if_required(void)
{
reset_time_limits_context_s context;
return G_SOURCE_REMOVE;
}
-stc_error_e stc_monitor_rstn_add(const table_restrictions_info *info)
-{
- stc_rstn_data_s data;
-
- memset(&data, 0, sizeof(stc_rstn_data_s));
-
- if (info->app_id) {
- data.classid = get_classid_by_app_id(info->app_id, TRUE);
- data.app_id = info->app_id;
- } else
- data.classid = STC_UNKNOWN_CLASSID;
-
- if (data.classid == STC_BACKGROUND_APP_CLASSID) {
- stc_monitor_set_background_state(TRUE);
- __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, TRUE);
- }
-
- data.iftype = info->iftype;
- data.ifname = info->ifname;
- data.subscriber_id = info->subscriber_id;
- data.roaming = info->roaming;
- data.mac = info->mac;
-
- data.rstn_type = info->rstn_type;
- data.rstn_state = STC_RSTN_STATE_UNKNOWN;
- data.restriction_id = info->restriction_id;
-
- data.limit[STC_RSTN_LIMIT_TYPE_DATA] = info->data_limit;
- data.limit[STC_RSTN_LIMIT_TYPE_DATA_WARN] = info->data_warn_limit;
- data.limit[STC_RSTN_LIMIT_TYPE_MONTHLY] = info->monthly_limit;
- data.limit[STC_RSTN_LIMIT_TYPE_WEEKLY] = info->weekly_limit;
- data.limit[STC_RSTN_LIMIT_TYPE_DAILY] = info->daily_limit;
- data.month_start_date = info->month_start_date;
- data.month_start_ts = stc_time_get_month_start(time(NULL),
- info->month_start_date);
-
- return __rstn_data_add(&data);
-}
-
void stc_monitor_rstn_add_for_app(uint32_t classid)
{
stc_rstn_value_s *lookup_value;
g_hash_table_foreach(rstns, __rstn_add_by_connection, conn);
}
-stc_error_e stc_monitor_rstn_remove(const table_restrictions_info *info)
-{
- stc_rstn_data_s data;
-
- memset(&data, 0, sizeof(stc_rstn_data_s));
-
- data.classid = get_classid_by_app_id(info->app_id, TRUE);
- data.app_id = info->app_id;
-
- data.iftype = info->iftype;
- data.ifname = info->ifname;
- data.subscriber_id = info->subscriber_id;
- data.roaming = info->roaming;
-
- if (g_strcmp0(info->app_id, STC_TOTAL_BACKGROUND) == 0) {
- stc_monitor_set_background_state(FALSE);
- __vconf_set_int(VCONFKEY_STC_BACKGROUND_STATE, FALSE);
- }
-
- return __rstn_data_remove(&data);
-}
-
void stc_monitor_rstn_remove_for_app(uint32_t classid)
{
stc_rstn_value_s *lookup_value;
struct tm *res;
res = localtime_r(&now, &curr);
+ if (!res)
+ return 0;
curr.tm_sec = 0;
curr.tm_min = 0;
int days;
res = localtime_r(&now, &curr);
+ if (!res)
+ return 0;
curr.tm_sec = 0;
curr.tm_min = 0;
bool is_leap_year;
res = localtime_r(&now, &curr);
+ if (!res)
+ return 0;
curr.tm_sec = 0;
curr.tm_min = 0;
#include <vconf.h>
#include <vconf-keys.h>
-#include "stc-connection.h"
#include "helper-nl.h"
#include "helper-nfacct-rule.h"
#include "helper-net-cls.h"
#include "counter.h"
#include "table-statistics.h"
#include "table-counters.h"
-#include "stc-monitor.h"
+#include "stc-plugin-monitor.h"
+#include "stc-plugin-monitor-connection.h"
+#include "stc-plugin-monitor-rstn.h"
#include "stc-manager-plugin-exception.h"
-#include "stc-manager-plugin-tether.h"
static stc_system_s *g_system = NULL;
stc_plugin_fill_exception_list();
}
-stc_error_e stc_monitor_init(void)
+stc_error_e stc_plugin_monitor_initialize(void)
{
+ __STC_LOG_FUNC_ENTER__;
+
stc_system_s *system = MALLOC0(stc_system_s, 1);
GIOChannel *gio = NULL;
stc_monitor_app_add_by_iface(STC_TOTAL_BLUETOOTH);
stc_monitor_app_add_by_iface(STC_TOTAL_IPV4);
stc_monitor_app_add_by_iface(STC_TOTAL_IPV6);
- /* stc_monitor_app_add_by_iface(STC_TOTAL_TETHERING); */
__update_contr_cb(NULL);
__fill_exceptions_list();
stc_monitor_rstns_load();
+ __STC_LOG_FUNC_EXIT__;
return STC_ERROR_NONE;
}
-stc_error_e stc_monitor_deinit(void)
+stc_error_e stc_plugin_monitor_deinitialize(void)
{
ret_value_msg_if(g_system == NULL, STC_ERROR_FAIL, "stc monitor not initialized!");
}
}
-API stc_error_e stc_monitor_check_excn_by_cmdline(char *cmdline)
-{
- return stc_plugin_check_exception_by_cmdline(cmdline);
-}
+API stc_plugin_monitor_s stc_plugin_monitor = {
+ .initialize_plugin =
+ stc_plugin_monitor_initialize,
+ .deinitialize_plugin =
+ stc_plugin_monitor_deinitialize,
+ .add_application =
+ stc_plugin_monitor_app_add,
+ .remove_application =
+ stc_plugin_monitor_app_remove,
+ .lookup_application =
+ stc_plugin_monitor_app_lookup,
+ .add_restriction =
+ stc_plugin_monitor_rstn_add,
+ .remove_restriction =
+ stc_plugin_monitor_rstn_remove,
+ .init_connection =
+ stc_plugin_monitor_connection_init,
+ .deinit_connection =
+ stc_plugin_monitor_connection_deinit,
+ .add_process =
+ stc_plugin_monitor_proc_add,
+ .remove_process =
+ stc_plugin_monitor_proc_remove,
+ .move_process =
+ stc_plugin_monitor_proc_move,
+ .update_process_ground =
+ stc_plugin_monitor_proc_update_ground
+};
static void __pcap_ntp_time_info(uint32_t s, char *time)
{
- time_t seconds;
+ time_t seconds;
char *curr = NULL;
int len = 0;
uint32_t sec = ntohl(s);
IS_SRC_OR_DST_PORT(PORT_BOOTP_S))
__pcap_bootp_info(packet);
else if (IS_SRC_OR_DST_PORT(PORT_NTP))
- __pcap_ntp_info(packet);
+ __pcap_ntp_info(packet);
}
static const char *__pcap_eth_type_info(u_int16_t type)
g_source_attach(source, context);
g_source_unref(source);
-
+
__STC_LOG_FUNC_EXIT__;
return NULL;
}
int stc_plugin_pcap_lookup_dev(void)
{
- __STC_LOG_FUNC_ENTER__;
-
char *dev = NULL;
char errbuf[PCAP_ERRBUF_SIZE];
dev = pcap_lookupdev(errbuf);
if (dev == NULL) {
STC_LOGE("Failed to look up dev [%s]", errbuf);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_FAIL;
}
STC_LOGD("Dev [%s]", dev);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_NONE;
}
int stc_plugin_pcap_lookup_net(void)
{
- __STC_LOG_FUNC_ENTER__;
-
char *dev = NULL;
char net[BUFF_SIZE_IP];
char mask[BUFF_SIZE_IP];
dev = pcap_lookupdev(errbuf);
if (dev == NULL) {
STC_LOGE("Failed to look up dev [%s]", errbuf);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_FAIL;
}
ret = pcap_lookupnet(dev, &netp, &maskp, errbuf);
if (ret == -1) {
STC_LOGE("Failed to look up net [%s]", errbuf);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_FAIL;
}
inet_ntop(AF_INET, &maskp, mask, BUFF_SIZE_IP);
STC_LOGD("Mask [%s]", mask);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_NONE;
}
int stc_plugin_pcap_find_alldevs(void)
{
- __STC_LOG_FUNC_ENTER__;
-
char net[BUFF_SIZE_IP];
char mask[BUFF_SIZE_IP];
char errbuf[PCAP_ERRBUF_SIZE];
if (pcap_findalldevs(&alldevs, errbuf) < 0 ||
alldevs == NULL) {
STC_LOGE("Failed to find all devs [%s]", errbuf);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_FAIL;
}
pcap_freealldevs(alldevs);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_NONE;
}
int stc_plugin_pcap_register_loop_pcap(const char *ifname,
int group)
{
- __STC_LOG_FUNC_ENTER__;
-
stc_pcap_data_s *data;
stc_pcap_data_s *lookup;
char buf[MAX_IFACE_LENGTH];
lookup = g_hash_table_lookup(g_pcap_tables, buf);
if (lookup) {
STC_LOGD("pcap loop already present");
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_ALREADY_DATA;
}
data = MALLOC0(stc_pcap_data_s, 1);
if (!data) {
STC_LOGE("data allocation failed");
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_OUT_OF_MEMORY;
}
g_hash_table_insert(g_pcap_tables, g_strdup(buf), data);
STC_LOGD("Successfully added pcap loop [%s]", buf);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_NONE;
}
int stc_plugin_pcap_unregister_loop_pcap(const char *ifname,
int group)
{
- __STC_LOG_FUNC_ENTER__;
-
stc_pcap_data_s *lookup;
char buf[MAX_IFACE_LENGTH];
pcap_breakloop(lookup->handle);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_NONE;
}
ENDFOREACH(flag)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception/include)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
#include <glib.h>
#include "stc-error.h"
#include "stc-manager.h"
-#include "stc-monitor.h"
typedef struct {
int (*initialize_plugin) (void);
#include <glib.h>
#include "stc-plugin-procfs.h"
-#include "stc-monitor.h"
#include "helper-net-cls.h"
#include "helper-procfs.h"
+#include "stc-manager-plugin-monitor.h"
+#include "stc-manager-plugin-exception.h"
//LCOV_EXCL_START
typedef struct {
parent = lookup;
} while (lookup);
- if (STC_DEBUG_LOG && STC_STAT_LOG) {
+ if (STC_STAT_LOG) {
if (parent != NULL)
STC_LOGD("\033[0;35mPARENT\033[0;m: tgid[\033[1;33m%s\033[0;m] "
"pid[%s] ppid[%s] cmdline[\033[0;34m%s\033[0;m] name[%s]",
}
if (key == NULL || value == NULL) {
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGE("invalid parameters");
return;
}
if (cmdline[0] == '(')
return TRUE;
- ret = stc_monitor_check_excn_by_cmdline(cmdline);
+ ret = stc_plugin_check_exception_by_cmdline(cmdline);
if (ret == STC_ERROR_UNINITIALIZED ||
ret == STC_ERROR_NO_DATA)
return FALSE;
g_strlcpy(value.status[i], status[i], sizeof(value.status[i]));
g_strlcpy(value.cmdline, cmdline, sizeof(value.cmdline));
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("\033[1;32mFORK\033[0;m: tgid[\033[1;33m%d\033[0;m] "
"ppid=[%s] cmdline[\033[0;34m%s\033[0;m] pid[%d]",
tgid, status[PROC_STATUS_PPID], cmdline, pid);
sizeof(value.status[i]));
g_strlcpy(value.cmdline, cmdline, sizeof(value.cmdline));
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("\033[1;32mEXEC\033[0;m: tgid[\033[1;33m%d\033[0;m] "
"ppid[%s] cmdline[\033[0;34m%s\033[0;m] pid[%d]",
tgid, status[PROC_STATUS_PPID], cmdline, pid);
if (lookup == NULL) /* unmonitored process */
return;
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("\033[1;31mEXIT\033[0;m: tgid[\033[1;33m%d\033[0;m] "
"cmdline[\033[0;34m%s\033[0;m] pid[%d] exitcode[%d]",
tgid, lookup->cmdline, pid, exit_code);
{
stc_error_e ret = STC_ERROR_NONE;
- if ((pkg_id && app_id) && STC_DEBUG_LOG && STC_STAT_LOG)
+ if ((pkg_id && app_id) && STC_STAT_LOG)
STC_LOGD("cmd[%d] pkgid[%s] appid[%s] pid[%d] type[%d]",
cmd, pkg_id, app_id, pid, app_type);
bg_classid = get_classid_by_app_id(bg_app_id, FALSE);
fg_classid = get_classid_by_app_id(app_id, TRUE);
- stc_monitor_app_add(fg_classid, app_id, pkg_id, app_value);
+ stc_plugin_monitor_add_app(fg_classid, app_id, pkg_id, app_value);
- stc_monitor_proc_move(bg_classid, fg_classid);
+ stc_plugin_monitor_move_proc(bg_classid, fg_classid);
- stc_monitor_proc_add(fg_classid, app_id, proc_value);
- stc_monitor_proc_update_ground(fg_classid, app_id, proc_value);
+ stc_plugin_monitor_add_proc(fg_classid, app_id, proc_value);
+ stc_plugin_monitor_update_proc_ground(fg_classid, app_id, proc_value);
FREE(bg_app_id);
break;
fg_classid = get_classid_by_app_id(app_id, FALSE);
bg_classid = get_classid_by_app_id(bg_app_id, TRUE);
- stc_monitor_app_add(bg_classid, bg_app_id, pkg_id, app_value);
+ stc_plugin_monitor_add_app(bg_classid, bg_app_id, pkg_id, app_value);
- stc_monitor_proc_move(fg_classid, bg_classid);
+ stc_plugin_monitor_move_proc(fg_classid, bg_classid);
- stc_monitor_proc_add(bg_classid, bg_app_id, proc_value);
- stc_monitor_proc_update_ground(bg_classid, bg_app_id, proc_value);
+ stc_plugin_monitor_add_proc(bg_classid, bg_app_id, proc_value);
+ stc_plugin_monitor_update_proc_ground(bg_classid, bg_app_id, proc_value);
FREE(bg_app_id);
break;
memset(&proc_value, 0, sizeof(stc_proc_value_s));
classid = get_classid_by_app_id(app_id, FALSE);
- is_exist = stc_monitor_app_lookup(classid);
+ is_exist = stc_plugin_monitor_lookup_app(classid);
if (is_exist) {
app_value.type = app_type;
app_value.state = STC_APP_STATE_FOREGROUND;
proc_value.pid = pid;
proc_value.ground = STC_APP_STATE_FOREGROUND;
- stc_monitor_app_add(classid, app_id, pkg_id, app_value);
- stc_monitor_proc_add(classid, app_id, proc_value);
+ stc_plugin_monitor_add_app(classid, app_id, pkg_id, app_value);
+ stc_plugin_monitor_add_proc(classid, app_id, proc_value);
} else {
bg_app_id = g_strconcat(app_id, STC_BACKGROUND_APP_SUFFIX, NULL);
classid = get_classid_by_app_id(bg_app_id, TRUE);
proc_value.pid = pid;
proc_value.ground = STC_APP_STATE_BACKGROUND;
- stc_monitor_app_add(classid, bg_app_id, pkg_id, app_value);
- stc_monitor_proc_add(classid, bg_app_id, proc_value);
+ stc_plugin_monitor_add_app(classid, bg_app_id, pkg_id, app_value);
+ stc_plugin_monitor_add_proc(classid, bg_app_id, proc_value);
FREE(bg_app_id);
}
if (classid == STC_UNKNOWN_CLASSID)
classid = get_classid_by_app_id(app_id, FALSE);
- stc_monitor_proc_remove(classid, pid);
+ stc_plugin_monitor_remove_proc(classid, pid);
FREE(bg_app_id);
break;
ENDFOREACH(flag)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor/include)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
#include <errno.h>
#include <glib.h>
-#include "stc-monitor.h"
#include "stc-plugin-tether.h"
+#include "stc-manager-plugin-monitor.h"
static GSList *station_list = NULL;
static GDBusConnection *connection = NULL;
app_value.processes = NULL;
g_strlcpy(app_value.mac, mac, STATION_MAC_STR_LEN);
- ret = stc_monitor_app_add(STC_UNKNOWN_CLASSID, app_id, pkg_id, app_value);
+ ret = stc_plugin_monitor_add_app(STC_UNKNOWN_CLASSID, app_id, pkg_id, app_value);
FREE(app_value.pkg_id);
FREE(app_value.app_id);
return ret;
sta_app_id = g_strconcat(app_id, STC_TETHERING_APP_SUFFIX, NULL);
- ret = stc_monitor_app_remove(STC_UNKNOWN_CLASSID, sta_app_id);
+ ret = stc_plugin_monitor_remove_app(STC_UNKNOWN_CLASSID, sta_app_id);
FREE(sta_app_id);
return ret;
_mobileap_signal_cb,
NULL, NULL);
- STC_LOGI("tether plugin initialised");
+ STC_LOGI("tether plugin initialized");
return 0;
}
SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
SET(HELPER_SOURCE_DIR ${SOURCE_DIR}/helper)
SET(DATABASE_SOURCE_DIR ${SOURCE_DIR}/database)
-SET(MONITOR_SOURCE_DIR ${SOURCE_DIR}/monitor)
SET(CONFIGURE_SOURCE_DIR ${SOURCE_DIR}/configure)
SET(LIMITATION_SOURCE_DIR ${SOURCE_DIR}/limitation)
SET(PLUGIN_DIR ${CMAKE_SOURCE_DIR}/plugin)
SET(PROCFS_SOURCE_DIR ${PLUGIN_DIR}/procfs)
SET(PCAP_SOURCE_DIR ${PLUGIN_DIR}/pcap)
SET(TETHER_SOURCE_DIR ${PLUGIN_DIR}/tether)
+SET(MONITOR_SOURCE_DIR ${PLUGIN_DIR}/monitor)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces)
INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR})
INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}/include)
-
INCLUDE_DIRECTORIES(${CONFIGURE_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CONFIGURE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${PROCFS_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${PCAP_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${TETHER_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}/include)
FILE(GLOB SOURCE_SRCS ${SOURCE_DIR}/*.c)
FILE(GLOB HELPER_SRCS ${HELPER_SOURCE_DIR}/*.c)
-FILE(GLOB MONITOR_SRCS ${MONITOR_SOURCE_DIR}/*.c)
FILE(GLOB CONFIGURE_SRCS ${CONFIGURE_SOURCE_DIR}/*.c)
FILE(GLOB LIMITATION_SRCS ${LIMITATION_SOURCE_DIR}/*.c)
-SET(SRCS ${SRCS} ${SOURCE_SRCS} ${HELPER_SRCS} ${MONITOR_SRCS} ${CONFIGURE_SRCS} ${LIMITATION_SRCS})
+SET(SRCS ${SRCS} ${SOURCE_SRCS} ${HELPER_SRCS} ${CONFIGURE_SRCS} ${LIMITATION_SRCS})
IF("${ENABLE_DATABASE}" STREQUAL "YES")
FILE(GLOB DATABASE_SRCS ${DATABASE_SOURCE_DIR}/*.c)
stc_db_initialize_once();
-#ifndef TIZEN_TV_EXT
EXEC(STC_ERROR_NONE, table_statistics_prepare(database));
EXEC(STC_ERROR_NONE, table_restrictions_prepare(database));
EXEC(STC_ERROR_NONE, table_counters_prepare(database));
-#endif
EXEC(STC_ERROR_NONE, table_firewall_prepare(database));
EXEC(STC_ERROR_NONE, stc_init_db_guard());
return TRUE; //LCOV_EXCL_LINE
}
-#ifndef TIZEN_TV_EXT
table_statistics_finalize();
table_restrictions_finalize();
table_counters_finalize();
-#endif
table_firewall_finalize();
sqlite3_close(database);
return ret;
}
-stc_error_e table_counters_get(uint64_t restriction_id,
+API stc_error_e table_counters_get(uint64_t restriction_id,
table_counters_info *info)
{
stc_error_e error_code = STC_ERROR_NONE;
}
//LCOV_EXCL_START
-stc_error_e table_counters_update_counters(const table_counters_info *info)
+API stc_error_e table_counters_update_counters(const table_counters_info *info)
{
stc_error_e error_code = STC_ERROR_NONE;
sqlite3_stmt *stmt = update_counter;
}
//LCOV_EXCL_STOP
-stc_error_e table_counters_get_timestamps(uint64_t restriction_id,
+API stc_error_e table_counters_get_timestamps(uint64_t restriction_id,
table_counters_info *info)
{
stc_error_e error_code = STC_ERROR_NONE;
}
//LCOV_EXCL_START
-stc_error_e table_counters_update_timestamps(const table_counters_info *info)
+API stc_error_e table_counters_update_timestamps(const table_counters_info *info)
{
stc_error_e error_code = STC_ERROR_NONE;
sqlite3_stmt *stmt = update_timestamp;
//LCOV_EXCL_STOP
-stc_error_e table_counters_delete(uint64_t restriction_id)
+API stc_error_e table_counters_delete(uint64_t restriction_id)
{
stc_error_e error_code = STC_ERROR_NONE;
sqlite3_stmt *stmt = delete_counter;
return error_code;
}
-stc_error_e table_restrictions_foreach(const table_restrictions_info_cb restriction_cb,
+API stc_error_e table_restrictions_foreach(const table_restrictions_info_cb restriction_cb,
void *user_data)
{
__STC_LOG_FUNC_ENTER__;
return error_code;
}
-stc_error_e table_statistics_per_app(const char *app_id,
+API stc_error_e table_statistics_per_app(const char *app_id,
table_statistics_select_rule *rule,
table_statistics_info_cb info_cb,
void *user_data)
return error_code;
}
-stc_error_e table_statistics_insert(stc_db_classid_iftype_key *stat_key,
+API stc_error_e table_statistics_insert(stc_db_classid_iftype_key *stat_key,
stc_db_app_stats *stat,
time_t last_touch_time)
{
goto handle_error; //LCOV_EXCL_LINE
}
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("App stat recorded [\033[0;34m%s\033[0;m] "
"rcv[%lld] snd[%lld]", stat->app_id, rcv, snd);
char buf[MAX_PATH_LENGTH];
snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("cgroup_buf %s, value %d\n", buf, value); //LCOV_EXCL_LINE
return fwrite_uint(buf, value);
char buf[MAX_PATH_LENGTH];
snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("cgroup_buf %s, string %s\n", buf, string); //LCOV_EXCL_LINE
return fwrite_str(buf, string);
snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
ret = fread_uint(buf, value);
- if (STC_DEBUG_LOG && STC_STAT_LOG)
+ if (STC_STAT_LOG)
STC_LOGD("cgroup_buf %s, value %d\n", buf, *value); //LCOV_EXCL_LINE
return ret;
return cgroup_write_node_str(buf, NOTIFY_ON_RELEASE, "1");
}
-void cgroup_init(void)
+API void cgroup_init(void)
{
/* create stc cgroup directory */
cgroup_make_subdir(CGROUP_NETWORK, STC_CGROUP_NAME, NULL);
assert(str);
t = realpath(path, NULL);
- ret_value_errno_msg_if(!t, -errno,
- "Fail to get realpath %s", path);
+ ret_value_if(!t, -errno);
free(t);
f = fopen(path, "w");
- ret_value_errno_msg_if(!f, -errno,
- "Fail to open file %s", path);
+ ret_value_if(!f, -errno);
ret = fputs(str, f);
- ret_value_errno_msg_if(ret == EOF, errno ? -errno : -EIO,
- "Fail to write file");
+ ret_value_if(ret == EOF, errno ? -errno : -EIO);
return STC_ERROR_NONE;
}
int ret;
ret = asprintf(&digit_buf, "%d", number);
- ret_value_errno_msg_if(ret < 0, -ENOMEM,
- "sprintf failed\n");
+ ret_value_if(ret < 0, -ENOMEM);
return fwrite_str(path, digit_buf);
}
int ret;
f = fopen(path, "r");
- ret_value_errno_msg_if(!f, -errno,
- "Fail to open %s file.", path);
+ ret_value_if(!f, -errno);
ret = fscanf(f, "%u", number);
- ret_value_errno_msg_if(ret == EOF, -errno,
- "Fail to read file\n");
+ ret_value_if(ret == EOF, -errno);
return STC_ERROR_NONE;
}
return ret;
}
-stc_error_e iptables_flush_chains(void)
+API stc_error_e iptables_flush_chains(void)
{
stc_error_e ret = STC_ERROR_NONE;
stc_s *stc = stc_get_manager();
goto done; //LCOV_EXCL_LINE
}
+ ret = __ip6tables_add_chain(stc->connection, STC_TETHER_CHAIN);
+ if (ret != STC_ERROR_NONE) {
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ goto done; //LCOV_EXCL_LINE
+ }
+
ret = _iptables_add_in_chain_jump_rule();
if (ret != STC_ERROR_NONE) {
__STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
return STC_ERROR_NONE;
}
-stc_error_e init_current_classid(void)
+API stc_error_e init_current_classid(void)
{
int ret = 0;
struct stat stat_buf;
return classid;
handle_error:
-
- STC_LOGE("error_code: [%d]", ret); //LCOV_EXCL_LINE
+ if (STC_DEBUG_LOG)
+ STC_LOGE("error_code: [%d]", ret); //LCOV_EXCL_LINE
return STC_UNKNOWN_CLASSID; //LCOV_EXCL_LINE
}
-stc_error_e place_pids_to_net_cgroup(const int pid, const char *app_id)
+API stc_error_e place_pids_to_net_cgroup(const int pid, const char *app_id)
{
char child_buf[21 + MAX_DEC_SIZE(int) + MAX_DEC_SIZE(int) + 1];
const char *path_to_net_cgroup_dir = NULL;
NFACCT_F_QUOTA_BYTES);
}
-stc_error_e nfacct_send_get_all(struct counter_arg *carg)
+API stc_error_e nfacct_send_get_all(struct counter_arg *carg)
{
/* get and reset everything, used when quiting */
return internal_nfacct_send_get(carg, NFNL_MSG_ACCT_GET_CTRZERO, NULL,
type > STC_IFACE_UNKNOWN) ? type : STC_IFACE_UNKNOWN;
}
-bool recreate_counter_by_name(char *cnt_name, nfacct_rule_s *cnt)
+API bool recreate_counter_by_name(char *cnt_name, nfacct_rule_s *cnt)
{
char *iftype_part;
char *classid_part;
params->post_eval_attr(carg);
}
-netlink_serialization_command *
+API netlink_serialization_command *
netlink_create_command(struct netlink_serialization_params *params)
{
static netlink_serialization_command command = {0,};
return STC_ERROR_NONE;
}
-stc_error_e produce_net_rule(nfacct_rule_s *rule)
+API stc_error_e produce_net_rule(nfacct_rule_s *rule)
{
stc_error_e ret = STC_ERROR_NONE;
/* read netlink message from socket
* return opaque pointer to genl structure
*/
-int read_netlink(int sock, void *buf, size_t len)
+API int read_netlink(int sock, void *buf, size_t len)
{
ssize_t ret;
struct sockaddr_nl addr;
void stc_firewall_init(void)
{
+ __STC_LOG_FUNC_ENTER__;
+
int ret = STC_ERROR_NONE;
g_firewalls = g_hash_table_new_full(g_str_hash,
table_firewall_foreach_chain(__fw_table_chain_info_cb, NULL);
table_firewall_foreach_rule(__fw_table_rule_info_cb, NULL);
+
+ __STC_LOG_FUNC_EXIT__;
}
-void stc_firewall_update(void)
+API void stc_firewall_update(void)
{
+ __STC_LOG_FUNC_ENTER__;
+
__fw_chain_foreach(__fw_foreach_to_add_chain, NULL);
__fw_chain_foreach(__fw_foreach_to_set_rule_to_chain, NULL);
__fw_chain_foreach(__fw_foreach_to_set_chain, NULL);
+
+ __STC_LOG_FUNC_EXIT__;
}
void stc_firewall_deinit(void)
{
+ __STC_LOG_FUNC_ENTER__;
+
if (g_firewalls) {
g_hash_table_destroy(g_firewalls);
g_firewalls = NULL;
}
+
+ __STC_LOG_FUNC_EXIT__;
}
gboolean handle_firewall_lock(StcFirewall *object,
#include "stc-restriction.h"
#include "stc-firewall.h"
#include "stc-pcap.h"
-#include "stc-connection.h"
#include "stc-manager-util.h"
#include "stc-manager-plugin-appstatus.h"
#include "stc-manager-plugin-procfs.h"
+#include "stc-manager-plugin-monitor.h"
#include "helper-iptables.h"
#define MANAGER_DBUS_ERROR_NAME "net.stc.manager.Error.Failed"
stc->connection);
iptables_init();
-#ifndef TIZEN_TV_EXT
- stc_connection_monitor_init(stc);
+ stc_firewall_update();
+ stc_plugin_monitor_init_connection(stc);
stc_plugin_appstatus_register_state_changed_cb(stc,
stc_plugin_procfs_app_status_changed, NULL);
-#endif
__STC_LOG_FUNC_EXIT__;
}
stc_s *stc = (stc_s *)stc_data;
stc_plugin_appstatus_deregister_state_changed_cb(stc);
- stc_connection_monitor_deinit(stc);
+ stc_plugin_monitor_deinit_connection(stc);
g_bus_unown_name(stc->gdbus_owner_id);
__STC_LOG_FUNC_EXIT__;
}
-GVariant *stc_manager_gdbus_call_sync(GDBusConnection *connection,
+API GVariant *stc_manager_gdbus_call_sync(GDBusConnection *connection,
const char *dest, const char *path,
const char *interface_name,
const char *method, GVariant *params)
return reply;
}
-guint stc_manager_gdbus_subscribe_signal(GDBusConnection *connection,
+API guint stc_manager_gdbus_subscribe_signal(GDBusConnection *connection,
const gchar *sender,
const gchar *interface_name,
const gchar *member,
user_data_free_func);
}
-void stc_manager_gdbus_unsubscribe_signal(GDBusConnection *connection,
+API void stc_manager_gdbus_unsubscribe_signal(GDBusConnection *connection,
guint subscription_id)
{
if (connection == NULL) {
__STC_LOG_FUNC_EXIT__;
}
-gboolean stc_manager_dbus_emit_signal(GDBusConnection *connection,
+API gboolean stc_manager_dbus_emit_signal(GDBusConnection *connection,
const gchar *object_path,
const gchar *interface_name,
const gchar *signal_name,
return STC_ERROR_NONE;
}
-int stc_plugin_appstatus_send_message(const char *content,
+API int stc_plugin_appstatus_send_message(const char *content,
const char *type, const char *app_id, const char *iftype, const char *limit)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->send_message_to_net_popup(content,
type, app_id, iftype, limit);
}
int stc_plugin_appstatus_register_state_changed_cb(stc_s *stc,
stc_plugin_app_state_changed_cb cb, void *data)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->register_state_changed_cb(stc, cb, data);
}
int stc_plugin_appstatus_deregister_state_changed_cb(stc_s *stc)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->deregister_state_changed_cb(stc);
}
//LCOV_EXCL_STOP
static stc_plugin_exception_s *stc_plugin;
//LCOV_EXCL_START
-int stc_plugin_exception_init(void)
+API int stc_plugin_exception_init(void)
{
__STC_LOG_FUNC_ENTER__;
return STC_ERROR_NONE;
}
-int stc_plugin_exception_deinit(void)
+API int stc_plugin_exception_deinit(void)
{
__STC_LOG_FUNC_ENTER__;
return STC_ERROR_NONE;
}
-int stc_plugin_fill_exception_list(void)
+API int stc_plugin_fill_exception_list(void)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->fill_exception_list();
}
-int stc_plugin_update_exception_list(void)
+API int stc_plugin_update_exception_list(void)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->update_exception_list();
}
-int stc_plugin_check_exception_by_cmdline(char *cmdline)
+API int stc_plugin_check_exception_by_cmdline(char *cmdline)
{
if (!stc_plugin_enabled)
return STC_ERROR_UNINITIALIZED;
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+
+#include "stc-manager.h"
+#include "stc-manager-plugin-monitor.h"
+
+static gboolean stc_plugin_enabled = FALSE;
+static void *handle_plugin;
+static stc_plugin_monitor_s *stc_plugin;
+
+//LCOV_EXCL_START
+API int stc_plugin_monitor_init(void)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ handle_plugin = dlopen(STC_PLUGIN_MONITOR_FILEPATH, RTLD_NOW);
+ if (!handle_plugin) {
+ STC_LOGE("Can't load %s: %s", STC_PLUGIN_MONITOR_FILEPATH, dlerror());
+ __STC_LOG_FUNC_EXIT__;
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ stc_plugin = dlsym(handle_plugin, "stc_plugin_monitor");
+ if (!stc_plugin) {
+ STC_LOGE("Can't load symbol: %s", dlerror());
+ dlclose(handle_plugin);
+ __STC_LOG_FUNC_EXIT__;
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ stc_plugin->initialize_plugin();
+ stc_plugin_enabled = TRUE;
+
+ __STC_LOG_FUNC_EXIT__;
+ return STC_ERROR_NONE;
+}
+
+API int stc_plugin_monitor_deinit(void)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ if (!stc_plugin_enabled)
+ return STC_ERROR_UNINITIALIZED;
+
+ stc_plugin->deinitialize_plugin();
+ stc_plugin_enabled = FALSE;
+ dlclose(handle_plugin);
+
+ __STC_LOG_FUNC_EXIT__;
+ return STC_ERROR_NONE;
+}
+
+API int stc_plugin_monitor_add_app(uint32_t classid,
+ const char *app_id,
+ const char *pkg_id,
+ const stc_app_value_s value)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->add_application(classid, app_id, pkg_id, value);
+}
+
+API int stc_plugin_monitor_remove_app(uint32_t classid,
+ const char *app_id)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->remove_application(classid, app_id);
+}
+
+API int stc_plugin_monitor_lookup_app(uint32_t classid)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->lookup_application(classid);
+}
+
+API int stc_plugin_monitor_add_rstn(table_restrictions_info *info)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->add_restriction(info);
+}
+
+API int stc_plugin_monitor_remove_rstn(table_restrictions_info *info)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->remove_restriction(info);
+}
+
+API int stc_plugin_monitor_init_connection(stc_s *stc)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->init_connection(stc);
+}
+
+API int stc_plugin_monitor_deinit_connection(stc_s *stc)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->deinit_connection(stc);
+}
+
+API int stc_plugin_monitor_add_proc(uint32_t classid,
+ const char *app_id, const stc_proc_value_s value)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->add_process(classid, app_id, value);
+}
+
+API int stc_plugin_monitor_remove_proc(uint32_t classid, pid_t pid)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->remove_process(classid, pid);
+}
+
+API int stc_plugin_monitor_move_proc(uint32_t from, uint32_t to)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->move_process(from, to);
+}
+
+API int stc_plugin_monitor_update_proc_ground(uint32_t classid,
+ const char *app_id, const stc_proc_value_s value)
+{
+ if (!stc_plugin_enabled) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ if (!stc_plugin) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
+ return STC_ERROR_UNINITIALIZED;
+ }
+
+ return stc_plugin->update_process_ground(classid, app_id, value);
+}
+//LCOV_EXCL_STOP
int stc_plugin_pcap_lookup_dev(void)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->lookup_dev();
}
int stc_plugin_pcap_lookup_net(void)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->lookup_net();
}
int stc_plugin_pcap_find_alldevs(void)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->find_alldevs();
}
int stc_plugin_pcap_register_loop_pcap(const char *ifname,
int group)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->register_loop_pcap(ifname, group);
}
int stc_plugin_pcap_unregister_loop_pcap(const char *ifname,
int group)
{
- __STC_LOG_FUNC_ENTER__;
-
if (!stc_plugin_enabled) {
- STC_LOGE("Plugin wasn't enabled");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't enabled");
return STC_ERROR_UNINITIALIZED;
}
if (!stc_plugin) {
- STC_LOGE("Plugin wasn't loaded");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("Plugin wasn't loaded");
return STC_ERROR_UNINITIALIZED;
}
- __STC_LOG_FUNC_EXIT__;
return stc_plugin->unregister_loop_pcap(ifname, group);
}
//LCOV_EXCL_STOP
return STC_ERROR_NONE;
}
-int stc_plugin_tether_get_station_ip(const char *mac, char **ipaddr)
+API int stc_plugin_tether_get_station_ip(const char *mac, char **ipaddr)
{
- __STC_LOG_FUNC_ENTER__;
char ip[INET_ADDRSTRLEN+1];
if (!stc_tether_plugin_enabled ||
- mac == NULL || ipaddr == NULL) {
- STC_LOGE("invalid args");
- __STC_LOG_FUNC_EXIT__;
+ mac == NULL || ipaddr == NULL) {
+ if (STC_DEBUG_LOG)
+ STC_LOGE("invalid args");
return STC_ERROR_INVALID_PARAMETER;
}
*ipaddr = g_strdup(ip);
STC_LOGI("station ip(%s)", *ipaddr);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_NONE;
}
-int stc_plugin_tether_get_station_by_classid(const int classid, char **mac)
+API int stc_plugin_tether_get_station_by_classid(const int classid, char **mac)
{
__STC_LOG_FUNC_ENTER__;
char mac_addr[STATION_MAC_STR_LEN+1];
if (!stc_tether_plugin_enabled || mac == NULL) {
- STC_LOGE("invalid args");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("invalid args");
return STC_ERROR_INVALID_PARAMETER;
}
*mac = g_strdup(mac_addr);
STC_LOGI("station mac(%s)", *mac);
- __STC_LOG_FUNC_EXIT__;
return STC_ERROR_NONE;
}
-int stc_plugin_tether_set_station_classid(const char *mac, int classid)
+API int stc_plugin_tether_set_station_classid(const char *mac, int classid)
{
__STC_LOG_FUNC_ENTER__;
if (!stc_tether_plugin_enabled || mac == NULL) {
- STC_LOGE("invalid args");
- __STC_LOG_FUNC_EXIT__;
+ if (STC_DEBUG_LOG)
+ STC_LOGE("invalid args");
return STC_ERROR_INVALID_PARAMETER;
}
STC_LOGI("classid(%d) for station mac(%s) is set successfully",
classid, mac);
- __STC_LOG_FUNC_EXIT__;
+
return STC_ERROR_NONE;
}
#include "helper-nfacct-rule.h"
#include "helper-iptables.h"
#include "helper-inotify.h"
-#include "stc-monitor.h"
#include "stc-firewall.h"
#include "stc-manager-plugin-appstatus.h"
#include "stc-manager-plugin-exception.h"
#include "stc-manager-plugin-procfs.h"
#include "stc-manager-plugin-tether.h"
#include "stc-manager-plugin-pcap.h"
+#include "stc-manager-plugin-monitor.h"
#define BUF_SIZE_FOR_ERR 100
return;
}
- stc_monitor_deinit();
+ stc_plugin_monitor_deinit();
stc_deinit_db_guard();
stc_db_deinitialize();
inotify_initialize();
inotify_register(INFO_STORAGE_DIR, __stc_inotify_handler);
-#ifndef TIZEN_TV_EXT
cgroup_set_release_agent(NET_CLS_SUBSYS, NET_RELEASE_AGENT);
-#endif
err = stc_db_initialize();
if (err != STC_ERROR_NONE) {
return NULL; //LCOV_EXCL_LINE
}
-#ifndef TIZEN_TV_EXT
stc_plugin_appstatus_init();
stc_plugin_exception_init();
stc_plugin_procfs_init();
stc_plugin_tether_init();
stc_plugin_pcap_init();
-#endif
+ stc_plugin_monitor_init();
stc_firewall_init();
-#ifndef TIZEN_TV_EXT
- err = stc_monitor_init();
- if (err != STC_ERROR_NONE) {
- STC_LOGD("Failed to initialize stc manager"); //LCOV_EXCL_LINE
- return NULL; //LCOV_EXCL_LINE
- }
-
stc_plugin_procfs_load_pid();
-#endif
stc_manager_gdbus_init((gpointer)stc);
return stc;
}
-stc_s *stc_get_manager(void)
+API stc_s *stc_get_manager(void)
{
return g_stc;
}
#include "table-restrictions.h"
#include "stc-restriction.h"
#include "stc-manager-gdbus.h"
-#include "stc-monitor.h"
+#include "stc-manager-plugin-monitor.h"
#define RESTRICTION_DBUS_ERROR_NAME "net.stc.restriction.Error.Failed"
return TRUE;
}
- stc_monitor_rstn_add(&rule);
+ stc_plugin_monitor_add_rstn(&rule);
STC_DBUS_REPLY_ERROR_NONE(invocation);
__STC_LOG_FUNC_EXIT__;
return TRUE;
return TRUE;
}
- stc_monitor_rstn_remove(&rule);
+ stc_plugin_monitor_remove_rstn(&rule);
STC_DBUS_REPLY_ERROR_NONE(invocation);
__STC_LOG_FUNC_EXIT__;
return TRUE;