From fa0667b02fc4cbb72344d5ea3c6d591115d98218 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Tue, 21 Apr 2020 21:45:14 +0900 Subject: [PATCH 01/16] [fix] Rename dbus auto-activation service file Naming rule for dbus auto-activation service file : well-known name + ".service" https://bugs.freedesktop.org/show_bug.cgi?id=99874 Change-Id: I2ad7c6d4c9673a7bc50fed93e23a61429c1ff403 --- packaging/stc-manager.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 6a86074..79eb620 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -149,7 +149,7 @@ mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -cp resources/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc-manager.service +cp resources/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service #OS Upgrade mkdir -p %{buildroot}%{upgrade_script_path} -- 2.7.4 From 73ab8e313957e16854708bc16a717d822f8f4a88 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Fri, 29 May 2020 19:06:24 +0900 Subject: [PATCH 02/16] Fix to init g_system as NULL in error case Change-Id: I2a70043afafb76f1594313899a16f01679e82586 Signed-off-by: Semun Lee --- plugin/monitor/stc-plugin-monitor.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c index fc71c8c..1f08dc3 100755 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stc-plugin-monitor.c @@ -68,6 +68,17 @@ static gboolean __process_contr_reply(GIOChannel *source, GIOCondition condition, gpointer user_data); +static void __free_system(stc_system_s *system) +{ + /* destroy monitored application tree */ + if (system->apps) + g_hash_table_destroy(system->apps); + /* destroy restriction rules tree */ + if (system->rstns) + g_hash_table_destroy(system->rstns); + FREE(system); +} + static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system) { GIOChannel *gio = NULL; @@ -88,7 +99,8 @@ static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system) system->contr_sock = create_netlink(NETLINK_NETFILTER, 0); if (system->contr_sock < 0) { STC_LOGE("failed to open socket"); - FREE(system); + __free_system(system); + g_system = NULL; return STC_ERROR_FAIL; } @@ -349,7 +361,7 @@ stc_error_e stc_plugin_monitor_initialize(void) system->contr_sock = create_netlink(NETLINK_NETFILTER, 0); if (system->contr_sock < 0) { STC_LOGE("failed to open socket"); - FREE(system); + __free_system(system); return STC_ERROR_FAIL; } @@ -403,15 +415,8 @@ stc_error_e stc_plugin_monitor_deinitialize(void) g_system->contr_timer_id = 0; } - /* destroy monitored application tree */ - g_hash_table_destroy(g_system->apps); - g_system->apps = NULL; - - /* destroy restriction rules tree */ - g_hash_table_destroy(g_system->rstns); - g_system->rstns = NULL; - - FREE(g_system); + __free_system(g_system); + g_system = NULL; return STC_ERROR_NONE; } -- 2.7.4 From 713f5536e99bdc86ed59dec477a2b0b83cad723a Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 11 Jun 2020 18:13:40 +0530 Subject: [PATCH 03/16] Add retry mechanism for netlink socket creation Change-Id: Ic0512f1bc680a68a9209c097b7ef4a2fb1a8548c Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- src/helper/helper-nl.c | 35 +++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 79eb620..a418017 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.0.99 +Version: 0.1.0 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/helper/helper-nl.c b/src/helper/helper-nl.c index ff9d1af..6d54e8f 100755 --- a/src/helper/helper-nl.c +++ b/src/helper/helper-nl.c @@ -20,35 +20,54 @@ #include #include #include +#include -/** - * create_netlink(): Create netlink socket and returns it. - * Returns: Created socket on success and -1 on failure. - */ -API int create_netlink(int protocol, uint32_t groups) +#define NETLINK_SOCK_RETRY_COUNT 3 + +int __create_netlink(int protocol, uint32_t groups, int retry) { /** * TODO it's one socket, in future make set of sockets * unique for protocol and groups */ int sock; - sock = socket(PF_NETLINK, SOCK_RAW, protocol); - if (sock < 0) + + if (retry <= 0) return -EINVAL; //LCOV_EXCL_LINE + errno = 0; + sock = socket(PF_NETLINK, SOCK_RAW, protocol); + if (sock < 0) { + STC_LOGE("failed to open socket errno [%d], retry [%d]", + errno, NETLINK_SOCK_RETRY_COUNT - retry); //LCOV_EXCL_LINE + return __create_netlink(protocol, groups, --retry); //LCOV_EXCL_LINE + } + struct sockaddr_nl src_addr = { 0, }; src_addr.nl_family = AF_NETLINK; src_addr.nl_groups = groups; + errno = 0; if (bind(sock, (struct sockaddr *)&src_addr, sizeof(src_addr)) < 0) { + STC_LOGE("failed to bind socket errno [%d], retry [%d]", + errno, NETLINK_SOCK_RETRY_COUNT - retry); //LCOV_EXCL_LINE close(sock); //LCOV_EXCL_LINE - return -1; //LCOV_EXCL_LINE + return __create_netlink(protocol, groups, --retry); //LCOV_EXCL_LINE } return sock; } +/** + * create_netlink(): Create netlink socket and returns it. + * Returns: Created socket on success and -1 on failure. + */ +API int create_netlink(int protocol, uint32_t groups) +{ + return __create_netlink(protocol, groups, NETLINK_SOCK_RETRY_COUNT); +} + void fill_attribute_list(struct rtattr **atb, const int max_len, struct rtattr *rt_na, int rt_len) { -- 2.7.4 From 15af46f1287673a3bdb9d34be47da459a4c75cc7 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 11 Jun 2020 20:34:55 +0530 Subject: [PATCH 04/16] Add callback in monitor plugin to stop stc-manager Change-Id: I88c9d9275620ee1ee32ee62e853e88c46c535a3f Signed-off-by: Nishant Chaprana --- include/stc-manager-plugin-monitor.h | 2 +- packaging/stc-manager.spec | 2 +- plugin/monitor/include/stc-plugin-monitor.h | 6 ++++-- plugin/monitor/stc-plugin-monitor.c | 11 ++++++++++- src/stc-manager-plugin-monitor.c | 4 ++-- src/stc-manager.c | 18 +++++++++++++++++- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/stc-manager-plugin-monitor.h b/include/stc-manager-plugin-monitor.h index 3830608..76a65bd 100755 --- a/include/stc-manager-plugin-monitor.h +++ b/include/stc-manager-plugin-monitor.h @@ -21,7 +21,7 @@ #include "stc-plugin-monitor.h" -int stc_plugin_monitor_init(void); +int stc_plugin_monitor_init(stc_manager_stop_cb stop_cb); int stc_plugin_monitor_deinit(void); int stc_plugin_monitor_add_app(uint32_t classid, diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index a418017..f8690c2 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.0 +Version: 0.1.1 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/plugin/monitor/include/stc-plugin-monitor.h b/plugin/monitor/include/stc-plugin-monitor.h index 35509c8..0cc8c42 100755 --- a/plugin/monitor/include/stc-plugin-monitor.h +++ b/plugin/monitor/include/stc-plugin-monitor.h @@ -38,8 +38,10 @@ #define VCONFKEY_SETAPPL_DATA_RESTRICTION_INT "db/setting/data_restriction" #endif +typedef void (*stc_manager_stop_cb)(void); + typedef struct { - int (*initialize_plugin) (void); + int (*initialize_plugin) (stc_manager_stop_cb stop_cb); int (*deinitialize_plugin) (void); int (*add_application) (uint32_t classid, @@ -68,7 +70,7 @@ typedef struct { int (*check_excn_by_cmdline) (char *cmdline); } stc_plugin_monitor_s; -stc_error_e stc_plugin_monitor_initialize(void); +stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb); stc_error_e stc_plugin_monitor_deinitialize(void); GHashTable *stc_monitor_get_system_apps(void); diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c index 1f08dc3..ab06816 100755 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stc-plugin-monitor.c @@ -32,6 +32,7 @@ #include "stc-manager-plugin-exception.h" static stc_system_s *g_system = NULL; +static stc_manager_stop_cb g_stop_cb = NULL; static int __vconf_get_int(const char *key, int *value) { @@ -101,6 +102,7 @@ static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system) STC_LOGE("failed to open socket"); __free_system(system); g_system = NULL; + g_stop_cb(); return STC_ERROR_FAIL; } @@ -337,7 +339,7 @@ static void __fill_exceptions_list(void) stc_plugin_fill_exception_list(); } -stc_error_e stc_plugin_monitor_initialize(void) +stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb) { __STC_LOG_FUNC_ENTER__; @@ -347,6 +349,11 @@ stc_error_e stc_plugin_monitor_initialize(void) ret_value_msg_if(system == NULL, STC_ERROR_OUT_OF_MEMORY, "stc_system_s malloc fail!"); + ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER, + "stop_cb callback is NULL"); + + g_stop_cb = stop_cb; + /* initializing current classid */ init_current_classid(); @@ -362,6 +369,7 @@ stc_error_e stc_plugin_monitor_initialize(void) if (system->contr_sock < 0) { STC_LOGE("failed to open socket"); __free_system(system); + g_stop_cb(); return STC_ERROR_FAIL; } @@ -417,6 +425,7 @@ stc_error_e stc_plugin_monitor_deinitialize(void) __free_system(g_system); g_system = NULL; + g_stop_cb = NULL; return STC_ERROR_NONE; } diff --git a/src/stc-manager-plugin-monitor.c b/src/stc-manager-plugin-monitor.c index 209b1a1..efdf759 100755 --- a/src/stc-manager-plugin-monitor.c +++ b/src/stc-manager-plugin-monitor.c @@ -24,7 +24,7 @@ static void *handle_plugin; static stc_plugin_monitor_s *stc_plugin; //LCOV_EXCL_START -API int stc_plugin_monitor_init(void) +API int stc_plugin_monitor_init(stc_manager_stop_cb stop_cb) { __STC_LOG_FUNC_ENTER__; @@ -43,7 +43,7 @@ API int stc_plugin_monitor_init(void) return STC_ERROR_UNINITIALIZED; } - stc_plugin->initialize_plugin(); + stc_plugin->initialize_plugin(stop_cb); stc_plugin_enabled = TRUE; __STC_LOG_FUNC_EXIT__; diff --git a/src/stc-manager.c b/src/stc-manager.c index a376e7f..0011c97 100755 --- a/src/stc-manager.c +++ b/src/stc-manager.c @@ -38,6 +38,7 @@ #define BUF_SIZE_FOR_ERR 100 static stc_s *g_stc = NULL; +static gboolean g_is_fail_exit = FALSE; static gboolean __validate_ident(const char *ident) { @@ -100,6 +101,15 @@ static void __stc_manager_deinit(void) __STC_LOG_FUNC_EXIT__; } +void __stc_manager_stop_with_fail(void) +{ + STC_LOGI("plugin needs stc-manager to exit"); + + g_is_fail_exit = TRUE; + + stc_stop_manager(); +} + static stc_s *__stc_manager_init(void) { __STC_LOG_FUNC_ENTER__; @@ -134,7 +144,7 @@ static stc_s *__stc_manager_init(void) stc_plugin_tether_init(); if (stc_plugin_pcap_init() == STC_ERROR_NONE) g_stc->ondemand_mode = FALSE; - if (stc_plugin_monitor_init() == STC_ERROR_NONE) + if (stc_plugin_monitor_init(__stc_manager_stop_with_fail) == STC_ERROR_NONE) g_stc->ondemand_mode = FALSE; stc_plugin_firewall_init(); @@ -265,6 +275,9 @@ gint32 main(gint32 argc, gchar *argv[]) if (!g_stc) goto fail; + if (g_is_fail_exit == TRUE) + goto fail; + /* Crate the GLIB main loop */ main_loop = g_main_loop_new(NULL, FALSE); g_stc->main_loop = main_loop; @@ -283,5 +296,8 @@ fail: if (main_loop) g_main_loop_unref(main_loop); + if (g_is_fail_exit == TRUE) + exit(-1); + return 0; } -- 2.7.4 From a0acdcb8da80127d74553c56844117fde085b100 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 11 Jun 2020 22:09:52 +0530 Subject: [PATCH 05/16] Restart stc-manager at non-zero exit code after 5 seconds Change-Id: I56bf9171a996846606c40b019d4694af837269ac Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- resources/systemd/stc-manager.service | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index f8690c2..b6c1b12 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.1 +Version: 0.1.2 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/resources/systemd/stc-manager.service b/resources/systemd/stc-manager.service index e20402f..899db52 100644 --- a/resources/systemd/stc-manager.service +++ b/resources/systemd/stc-manager.service @@ -6,6 +6,8 @@ Type=dbus BusName=net.stc SmackProcessLabel=System ExecStart=/usr/bin/stc-manager +Restart=on-failure +RestartSec=5 [Install] WantedBy=multi-user.target -- 2.7.4 From acfe9db1a6d1e7d8d9f5a8f90c5f9db323bdd821 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Wed, 10 Jun 2020 15:50:51 +0900 Subject: [PATCH 06/16] Modify to add/remove rule list by connection Change-Id: I97dd168f82a457968672e2a7dafa9b83444aaa5d Signed-off-by: hyunuk.tak --- plugin/monitor/include/stc-plugin-monitor-ipt.h | 3 + plugin/monitor/stc-plugin-monitor-app.c | 150 +++++++++++++++++++++++- plugin/monitor/stc-plugin-monitor-connection.c | 9 +- plugin/monitor/stc-plugin-monitor-ipt.c | 16 +++ plugin/monitor/stc-plugin-monitor.c | 3 - src/helper/helper-iptables.c | 137 ++++++++++++++++++++++ src/helper/helper-iptables.h | 2 + src/helper/helper-nfacct-rule.c | 82 +++++++++++++ src/helper/helper-nfacct-rule.h | 2 + 9 files changed, 393 insertions(+), 11 deletions(-) mode change 100644 => 100755 src/helper/helper-iptables.h diff --git a/plugin/monitor/include/stc-plugin-monitor-ipt.h b/plugin/monitor/include/stc-plugin-monitor-ipt.h index a104c10..ab7286d 100755 --- a/plugin/monitor/include/stc-plugin-monitor-ipt.h +++ b/plugin/monitor/include/stc-plugin-monitor-ipt.h @@ -29,6 +29,9 @@ stc_error_e stc_monitor_ip6t_add_out(struct nfacct_rule *counter); stc_error_e stc_monitor_ip6t_del_in(struct nfacct_rule *counter); stc_error_e stc_monitor_ip6t_del_out(struct nfacct_rule *counter); +stc_error_e stc_monitor_ipt_add_list(GSList *counter_list, nfacct_rule_iptype iptype); +stc_error_e stc_monitor_ipt_del_list(GSList *counter_list, nfacct_rule_iptype iptype); + stc_error_e stc_monitor_tether_add_in(struct nfacct_rule *counter, const gchar *ipaddr); stc_error_e stc_monitor_tether_add_out(struct nfacct_rule *counter, diff --git a/plugin/monitor/stc-plugin-monitor-app.c b/plugin/monitor/stc-plugin-monitor-app.c index a5804da..6bc410a 100755 --- a/plugin/monitor/stc-plugin-monitor-app.c +++ b/plugin/monitor/stc-plugin-monitor-app.c @@ -558,15 +558,135 @@ void stc_monitor_app_add_monitor(gpointer key, } } +typedef struct { + GSList *counter_v4_list; + GSList *counter_v6_list; + stc_connection_s *connection; + nfacct_rule_action action; + nfacct_rule_intend intend; +} counter_list_data; + +static void __make_counter(stc_app_value_s *app_value, + nfacct_rule_direction iotype, nfacct_rule_iptype iptype, + counter_list_data *list_data) +{ + stc_s *stc = stc_get_manager(); + struct nfacct_rule *counter; + + if (!stc || !list_data->connection || !list_data->connection->ifname) + return; + + if (!stc->carg) { + stc->carg = MALLOC0(counter_arg_s, 1); + if (stc->carg == NULL) + return; + + stc->carg->sock = stc_monitor_get_contr_sock(); + } + + counter = MALLOC0(struct nfacct_rule, 1); + if (counter == NULL) + return; + + counter->carg = stc->carg; + counter->classid = app_value->classid; + counter->app_state = app_value->state; + counter->intend = list_data->intend; + counter->action = list_data->action; + counter->iotype = iotype; + counter->iftype = list_data->connection->type; + g_strlcpy(counter->ifname, list_data->connection->ifname, MAX_IFACE_LENGTH); + switch (counter->intend) { + case NFACCT_BLOCK: + case NFACCT_TETH_BLOCK: + counter->jump = NFACCT_JUMP_REJECT; + break; + case NFACCT_WARN: + case NFACCT_ALLOW: + case NFACCT_TETH_ALLOW: + counter->jump = NFACCT_JUMP_ACCEPT; + break; + default: + counter->jump = NFACCT_JUMP_UNKNOWN; + } + counter->send_limit = 0; + counter->rcv_limit = 0; + + if (iptype == NFACCT_TYPE_IPV4) + list_data->counter_v4_list = g_slist_append(list_data->counter_v4_list, counter); + else if (iptype == NFACCT_TYPE_IPV6) + list_data->counter_v6_list = g_slist_append(list_data->counter_v6_list, counter); +} + +static void __make_counter_list(stc_app_value_s *app_value, counter_list_data *list_data) +{ + switch (app_value->classid) { + case STC_TOTAL_IPV4_CLASSID: + __make_counter(app_value, NFACCT_COUNTER_IN, NFACCT_TYPE_IPV4, list_data); + __make_counter(app_value, NFACCT_COUNTER_OUT, NFACCT_TYPE_IPV4, list_data); + break; + case STC_TOTAL_IPV6_CLASSID: + __make_counter(app_value, NFACCT_COUNTER_IN, NFACCT_TYPE_IPV6, list_data); + __make_counter(app_value, NFACCT_COUNTER_OUT, NFACCT_TYPE_IPV6, list_data); + break; + default: + __make_counter(app_value, NFACCT_COUNTER_IN, NFACCT_TYPE_IPV4, list_data); + __make_counter(app_value, NFACCT_COUNTER_OUT, NFACCT_TYPE_IPV4, list_data); + __make_counter(app_value, NFACCT_COUNTER_IN, NFACCT_TYPE_IPV6, list_data); + __make_counter(app_value, NFACCT_COUNTER_OUT, NFACCT_TYPE_IPV6, list_data); + } +} + +static void __foreach_app_table(gpointer key, gpointer value, gpointer data) +{ + stc_app_value_s *app_value = (stc_app_value_s *)value; + counter_list_data *list_data = (counter_list_data *)data; + + if (app_value->classid == STC_TOTAL_DATACALL_CLASSID || + app_value->classid == STC_TOTAL_WIFI_CLASSID || + app_value->classid == STC_TOTAL_BLUETOOTH_CLASSID) + return; + + list_data->intend = NFACCT_COUNTER; + __make_counter_list(app_value, list_data); + + if (app_value->state == STC_APP_STATE_FOREGROUND) { + list_data->intend = NFACCT_ALLOW; + __make_counter_list(app_value, list_data); + } +} + void stc_monitor_app_add_by_connection(stc_connection_s *conn) { GHashTable *apps = stc_monitor_get_system_apps(); + counter_list_data list_data = { 0, }; + struct timespec start, end; + time_t sec; + long int nsec; if (!apps) return; - g_hash_table_foreach(apps, stc_monitor_app_add_monitor, conn); - g_hash_table_foreach(apps, stc_monitor_app_add_accept, conn); + list_data.connection = conn; + list_data.action = NFACCT_ACTION_INSERT; + + g_hash_table_foreach(apps, __foreach_app_table, &list_data); + + clock_gettime(CLOCK_MONOTONIC, &start); + + stc_monitor_ipt_add_list(list_data.counter_v4_list, NFACCT_TYPE_IPV4); + stc_monitor_ipt_add_list(list_data.counter_v6_list, NFACCT_TYPE_IPV6); + + g_slist_free_full(list_data.counter_v4_list, g_free); + g_slist_free_full(list_data.counter_v6_list, g_free); + + clock_gettime(CLOCK_MONOTONIC, &end); + + sec = end.tv_sec - start.tv_sec; + nsec = end.tv_nsec - start.tv_nsec; + if (nsec < 0) + nsec += 1000000000; + STC_LOGD("Added by [%s] connection [%3ld.%09ld]s", conn->ifname, sec, nsec); } void stc_monitor_app_add_accept(gpointer key, @@ -679,12 +799,34 @@ void stc_monitor_app_remove_monitor(gpointer key, void stc_monitor_app_remove_by_connection(stc_connection_s *conn) { GHashTable *apps = stc_monitor_get_system_apps(); + counter_list_data list_data = { 0, }; + struct timespec start, end; + time_t sec; + long int nsec; if (!apps) return; - g_hash_table_foreach(apps, stc_monitor_app_remove_monitor, conn); - g_hash_table_foreach(apps, stc_monitor_app_remove_accept, conn); + list_data.connection = conn; + list_data.action = NFACCT_ACTION_DELETE; + + g_hash_table_foreach(apps, __foreach_app_table, &list_data); + + clock_gettime(CLOCK_MONOTONIC, &start); + + stc_monitor_ipt_del_list(list_data.counter_v4_list, NFACCT_TYPE_IPV4); + stc_monitor_ipt_del_list(list_data.counter_v6_list, NFACCT_TYPE_IPV6); + + g_slist_free_full(list_data.counter_v4_list, g_free); + g_slist_free_full(list_data.counter_v6_list, g_free); + + clock_gettime(CLOCK_MONOTONIC, &end); + + sec = end.tv_sec - start.tv_sec; + nsec = end.tv_nsec - start.tv_nsec; + if (nsec < 0) + nsec += 1000000000; + STC_LOGD("Removed by [%s] connection [%3ld.%09ld]s", conn->ifname, sec, nsec); } void stc_monitor_app_remove_accept(gpointer key, diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stc-plugin-monitor-connection.c index a305002..2ed2161 100755 --- a/plugin/monitor/stc-plugin-monitor-connection.c +++ b/plugin/monitor/stc-plugin-monitor-connection.c @@ -212,7 +212,7 @@ static void __telephony_update_default_modem_subscriber_id(GDBusConnection *conn return; } -static void __print_connection_info(stc_connection_s *conn) +static void __print_connection_info(stc_connection_s *conn, const char *state) { STC_LOGI("============= connection info ============"); STC_LOGI("path [%s]", conn->path); @@ -221,6 +221,7 @@ static void __print_connection_info(stc_connection_s *conn) STC_LOGI("roaming [%u]", conn->roaming ? TRUE : FALSE); if (conn->type == STC_IFACE_DATACALL) STC_LOGI("sub_id [%s]", conn->subscriber_id); + STC_LOGI("state [%s]", state); STC_LOGI("=================================================="); } @@ -437,7 +438,7 @@ static stc_error_e __get_connected_profiles(GDBusConnection *connection) } __get_connection_info(connection, conn, conn->path); - __print_connection_info(conn); + __print_connection_info(conn, "connected"); if (default_conn == TRUE) { g_default_connection = conn; @@ -525,7 +526,7 @@ static void __append_connected_profile(GDBusConnection *connection, } __get_connection_info(connection, conn, conn->path); - __print_connection_info(conn); + __print_connection_info(conn, "connected"); g_connection_list = g_slist_append(g_connection_list, conn); @@ -538,7 +539,7 @@ static void __append_connected_profile(GDBusConnection *connection, static void __remove_disconnected_profile(GDBusConnection *connection, stc_connection_s *conn) { - __print_connection_info(conn); + __print_connection_info(conn, "disconnected"); stc_monitor_remove_by_connection(conn); diff --git a/plugin/monitor/stc-plugin-monitor-ipt.c b/plugin/monitor/stc-plugin-monitor-ipt.c index c8fa882..f9df3fb 100755 --- a/plugin/monitor/stc-plugin-monitor-ipt.c +++ b/plugin/monitor/stc-plugin-monitor-ipt.c @@ -153,6 +153,22 @@ stc_error_e stc_monitor_ip6t_del_out(struct nfacct_rule *counter) return produce_net_rule(counter); } +stc_error_e stc_monitor_ipt_add_list(GSList *counter_list, nfacct_rule_iptype iptype) +{ + if (counter_list == NULL) + return STC_ERROR_INVALID_PARAMETER; + + return produce_net_list(counter_list, iptype, NFACCT_ACTION_INSERT); +} + +stc_error_e stc_monitor_ipt_del_list(GSList *counter_list, nfacct_rule_iptype iptype) +{ + if (counter_list == NULL) + return STC_ERROR_INVALID_PARAMETER; + + return produce_net_list(counter_list, iptype, NFACCT_ACTION_DELETE); +} + stc_error_e stc_monitor_tether_add_in(struct nfacct_rule *counter, const gchar *ipaddr) { diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c index 1f08dc3..8bf1c30 100755 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stc-plugin-monitor.c @@ -546,9 +546,6 @@ void stc_monitor_update_by_connection(void *data) stc_connection_s *connection = (stc_connection_s *)data; if (connection != NULL && connection->path != NULL) { - stc_monitor_app_remove_by_connection(connection); - stc_monitor_rstn_remove_by_connection(connection); - iptables_flush_chains(); stc_monitor_app_add_by_connection(connection); diff --git a/src/helper/helper-iptables.c b/src/helper/helper-iptables.c index 519d898..ffffd21 100755 --- a/src/helper/helper-iptables.c +++ b/src/helper/helper-iptables.c @@ -32,6 +32,10 @@ #define STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_RULE "IptRemoveRule" #define STC_IPTABLES_DBUS_METHOD_IP6T_ADD_RULE "Ip6tAddRule" #define STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_RULE "Ip6tRemoveRule" +#define STC_IPTABLES_DBUS_METHOD_IPT_ADD_LIST "IptAddList" +#define STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_LIST "IptRemoveList" +#define STC_IPTABLES_DBUS_METHOD_IP6T_ADD_LIST "Ip6tAddList" +#define STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_LIST "Ip6tRemoveList" #define RULE_CHAIN "chain" #define RULE_DIRECTION "direction" @@ -141,6 +145,43 @@ static void __remove_rule_reply( g_free(nfacct_name); } +static void __add_list_info_to_builder(GVariantBuilder *builder, + GSList *iptables_list) +{ + GSList *list; + GVariantBuilder sub_builder; + + for (list = iptables_list; list; list = list->next) { + iptables_rule_s *rule = list->data; + + g_variant_builder_init(&sub_builder, G_VARIANT_TYPE("a{sv}")); + + g_variant_builder_add(&sub_builder, "{sv}", RULE_CHAIN, + g_variant_new_string(rule->chain)); + + g_variant_builder_add(&sub_builder, "{sv}", RULE_DIRECTION, + g_variant_new_uint16(rule->direction)); + + if (rule->ifname) + g_variant_builder_add(&sub_builder, "{sv}", RULE_IFNAME, + g_variant_new_string(rule->ifname)); + + if (rule->classid > 0) + g_variant_builder_add(&sub_builder, "{sv}", RULE_CGROUP, + g_variant_new_uint32(rule->classid)); + + if (rule->nfacct_name) + g_variant_builder_add(&sub_builder, "{sv}", RULE_NFACCT, + g_variant_new_string(rule->nfacct_name)); + + if (rule->target) + g_variant_builder_add(&sub_builder, "{sv}", RULE_TARGET, + g_variant_new_string(rule->target)); + + g_variant_builder_add_value(builder, g_variant_builder_end(&sub_builder)); + } +} + static int __iptables_rule_add(GDBusConnection *connection, iptables_rule_s *rule) { @@ -269,6 +310,82 @@ static int __ip6tables_rule_remove(GDBusConnection *connection, return result; } +static int __iptables_list_add(GDBusConnection *connection, + GSList *iptables_list, iptables_ip_type_e iptype) +{ + stc_error_e result = STC_ERROR_NONE; + GVariantBuilder *builder = NULL; + GVariant *params = NULL; + GVariant *message = NULL; + const char *method = (iptype == IP_TYPE_IPV4) ? + STC_IPTABLES_DBUS_METHOD_IPT_ADD_LIST : + STC_IPTABLES_DBUS_METHOD_IP6T_ADD_LIST; + + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); + __add_list_info_to_builder(builder, iptables_list); + params = g_variant_new("(aa{sv})", builder); + g_variant_builder_unref(builder); + + message = stc_manager_gdbus_call_sync(connection, + STC_IPTABLES_DBUS_SERVICE, + STC_IPTABLES_DBUS_RULE_PATH, + STC_IPTABLES_DBUS_RULE_INTERFACE, + method, + params); + + if (message == NULL) { + STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE + return STC_ERROR_FAIL; //LCOV_EXCL_LINE + } + + g_variant_get(message, "(i)", &result); + + STC_LOGD("%s to add list [%s:%d]", + result == STC_ERROR_NONE ? "Successed" : "Failed", + iptype == IP_TYPE_IPV4 ? "IPv4" : "IPv6", result); + + g_variant_unref(message); + return result; +} + +static int __iptables_list_remove(GDBusConnection *connection, + GSList *iptables_list, iptables_ip_type_e iptype) +{ + int result = 0; + GVariantBuilder *builder = NULL; + GVariant *params = NULL; + GVariant *message = NULL; + const char *method = (iptype == IP_TYPE_IPV4) ? + STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_LIST : + STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_LIST; + + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); + __add_list_info_to_builder(builder, iptables_list); + params = g_variant_new("(aa{sv})", builder); + g_variant_builder_unref(builder); + + message = stc_manager_gdbus_call_sync(connection, + STC_IPTABLES_DBUS_SERVICE, + STC_IPTABLES_DBUS_RULE_PATH, + STC_IPTABLES_DBUS_RULE_INTERFACE, + method, + params); + + if (message == NULL) { + STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE + return STC_ERROR_FAIL; //LCOV_EXCL_LINE + } + + g_variant_get(message, "(i)", &result); + + STC_LOGD("%s to add list [%s:%d]", + result == STC_ERROR_NONE ? "Successed" : "Failed", + iptype == IP_TYPE_IPV4 ? "IPv4" : "IPv6", result); + + g_variant_unref(message); + return STC_ERROR_NONE; +} + static int __iptables_add_chain(GDBusConnection *connection, const char *chain) { @@ -931,6 +1048,26 @@ done: return ret; } +stc_error_e iptables_add_list(GSList *iptables_list, iptables_ip_type_e iptype) +{ + stc_s *stc = stc_get_manager(); + + if (!stc || !stc->connection) + return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + + return __iptables_list_add(stc->connection, iptables_list, iptype); +} + +stc_error_e iptables_remove_list(GSList *iptables_list, iptables_ip_type_e iptype) +{ + stc_s *stc = stc_get_manager(); + + if (!stc || !stc->connection) + return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + + return __iptables_list_remove(stc->connection, iptables_list, iptype); +} + API stc_error_e iptables_flush_chains(void) { stc_error_e ret = STC_ERROR_NONE; diff --git a/src/helper/helper-iptables.h b/src/helper/helper-iptables.h old mode 100644 new mode 100755 index 6fa7908..f9f069a --- a/src/helper/helper-iptables.h +++ b/src/helper/helper-iptables.h @@ -76,6 +76,8 @@ typedef struct { stc_error_e iptables_add(iptables_rule_s *rule, iptables_ip_type_e iptype); stc_error_e iptables_remove(iptables_rule_s *rule, iptables_ip_type_e iptype); +stc_error_e iptables_add_list(GSList *iptables_list, iptables_ip_type_e iptype); +stc_error_e iptables_remove_list(GSList *iptables_list, iptables_ip_type_e iptype); stc_error_e iptables_flush_chains(void); stc_error_e iptables_init(void); stc_error_e iptables_deinit(void); diff --git a/src/helper/helper-nfacct-rule.c b/src/helper/helper-nfacct-rule.c index 070052b..ff703d3 100755 --- a/src/helper/helper-nfacct-rule.c +++ b/src/helper/helper-nfacct-rule.c @@ -850,6 +850,88 @@ API stc_error_e produce_net_rule(nfacct_rule_s *rule) return ret; } +static stc_error_e append_iptables_cmd(GSList **iptables_list, nfacct_rule_s *rule) +{ + iptables_rule_s *iptables_rule = NULL; + + iptables_rule = MALLOC0(iptables_rule_s, 1); + if (!iptables_rule) + return STC_ERROR_OUT_OF_MEMORY; + + iptables_rule->nfacct_name = g_strdup(rule->name); + iptables_rule->ifname = g_strdup(rule->ifname); + iptables_rule->target = g_strdup(get_iptables_jump(rule->jump)); + iptables_rule->chain = g_strdup(get_iptables_chain(rule->classid, + rule->iotype, rule->app_state, rule->intend)); + if (rule->classid < STC_RESERVED_CLASSID_MAX) + iptables_rule->classid = STC_UNKNOWN_CLASSID; + else + iptables_rule->classid = rule->classid; + iptables_rule->direction = (rule->iotype & NFACCT_COUNTER_IN) ? + IPTABLES_DIRECTION_IN : IPTABLES_DIRECTION_OUT; + + *iptables_list = g_slist_append(*iptables_list, iptables_rule); + + return STC_ERROR_NONE; +} + +static void iptables_list_free(gpointer value) +{ + iptables_rule_s *iptables_rule = (iptables_rule_s *)value; + + g_free(iptables_rule->chain); + g_free(iptables_rule->nfacct_name); + g_free(iptables_rule->ifname); + g_free(iptables_rule->target); + g_free(iptables_rule); +} + +API stc_error_e produce_net_list(GSList *rule_list, + nfacct_rule_iptype iptype, nfacct_rule_action action) +{ + GSList *list = NULL; + GSList *iptables_list = NULL; + stc_error_e ret = STC_ERROR_NONE; + + for (list = rule_list; list; list = list->next) { + nfacct_rule_s *rule = list->data; + + if (rule->action == NFACCT_ACTION_APPEND && + rule->intend == NFACCT_WARN && + !rule->send_limit && !rule->rcv_limit) + continue; + + generate_counter_name(rule); + if (rule->action != NFACCT_ACTION_DELETE) { + ret = nfacct_send_del(rule); + if (ret != STC_ERROR_NONE) + continue; + + ret = nfacct_send_new(rule); + if (ret != STC_ERROR_NONE) + continue; + } + + append_iptables_cmd(&iptables_list, rule); + } + + if (action == NFACCT_ACTION_INSERT || + action == NFACCT_ACTION_APPEND) + ret = iptables_add_list(iptables_list, iptype); + else if (action == NFACCT_ACTION_DELETE) + ret = iptables_remove_list(iptables_list, iptype); + + for (list = rule_list; list; list = list->next) { + nfacct_rule_s *rule = list->data; + + if (rule->action == NFACCT_ACTION_DELETE) + nfacct_send_del(rule); + } + + g_slist_free_full(iptables_list, iptables_list_free); + return ret; +} + void generate_counter_name(nfacct_rule_s *counter) { char warn_symbol = 'c'; diff --git a/src/helper/helper-nfacct-rule.h b/src/helper/helper-nfacct-rule.h index 80b9f83..f313849 100755 --- a/src/helper/helper-nfacct-rule.h +++ b/src/helper/helper-nfacct-rule.h @@ -134,6 +134,8 @@ bool recreate_counter_by_name(char *cnt_name, nfacct_rule_s *counter); stc_error_e nfacct_send_get_all(struct counter_arg *carg); stc_error_e produce_net_rule(nfacct_rule_s *rule); +stc_error_e produce_net_list(GSList *rule_list, + nfacct_rule_iptype iptype, nfacct_rule_action action); netlink_serialization_command * netlink_create_command(struct netlink_serialization_params *params); -- 2.7.4 From ee2840c9abe00ab42f19e32024c19c7809d4e30c Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 22 Jun 2020 15:34:16 +0900 Subject: [PATCH 07/16] Fix memory leak in stc_plugin_monitor_initialize Variable system going out of scope leaks the memory it points to. Change-Id: I9d2c5dc3cc3b951954e793cf3864f270810d846c Signed-off-by: Jaehyun Kim --- plugin/monitor/stc-plugin-monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c index a26749f..7922b88 100755 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stc-plugin-monitor.c @@ -343,15 +343,15 @@ stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb) { __STC_LOG_FUNC_ENTER__; + ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER, + "stop_cb callback is NULL"); + stc_system_s *system = MALLOC0(stc_system_s, 1); GIOChannel *gio = NULL; ret_value_msg_if(system == NULL, STC_ERROR_OUT_OF_MEMORY, "stc_system_s malloc fail!"); - ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER, - "stop_cb callback is NULL"); - g_stop_cb = stop_cb; /* initializing current classid */ -- 2.7.4 From fd15fe5dda52af31a84ccb4c67da58714c7d9eaa Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Wed, 24 Jun 2020 15:42:03 +0900 Subject: [PATCH 08/16] Change the service file path for 64bit build Change-Id: Ib65165167a09f007f61192dd81bdd5df3084b8ac Signed-off-by: Jaehyun Kim --- packaging/stc-manager.spec | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index b6c1b12..2f2b56c 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -138,11 +138,11 @@ mkdir -p %{buildroot}/%{_localstatedir}/lib/stc cp data/exceptions %{buildroot}/%{_localstatedir}/lib/stc/exceptions #Systemd service file -mkdir -p %{buildroot}%{_libdir}/systemd/system/ -cp resources/systemd/stc-manager.service %{buildroot}%{_libdir}/systemd/system/stc-manager.service +mkdir -p %{buildroot}%{_unitdir} +cp resources/systemd/stc-manager.service %{buildroot}%{_unitdir}/stc-manager.service -mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/ -ln -s ../stc-manager.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/stc-manager.service +mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/ +ln -s ../stc-manager.service %{buildroot}%{_unitdir}/multi-user.target.wants/stc-manager.service #DBus DAC (stc-manager.manifest enables DBus SMACK) mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d @@ -161,8 +161,8 @@ cp -f scripts/%{upgrade_script_filename} %{buildroot}%{upgrade_script_path} %defattr(-,root,root,-) %attr(500,root,root) %{_bindir}/* -%attr(644,root,root) %{_libdir}/systemd/system/stc-manager.service -%attr(644,root,root) %{_libdir}/systemd/system/multi-user.target.wants/stc-manager.service +%attr(644,root,root) %{_unitdir}/stc-manager.service +%attr(644,root,root) %{_unitdir}/multi-user.target.wants/stc-manager.service %attr(755,network_fw,network_fw) /%{_localstatedir}/lib/stc %attr(600,root,root) /%{_localstatedir}/lib/stc/exceptions -- 2.7.4 From 5fe6aec4480cf8ae8062df2faa5f8add6cb24b62 Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Thu, 25 Jun 2020 18:38:43 +0900 Subject: [PATCH 09/16] Free all the unpacked values if breaking out of g_variant_iter_loop Change-Id: Ib5e67dfa852f38431f19ed66a540275165073724 --- plugin/monitor/stc-plugin-monitor-connection.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stc-plugin-monitor-connection.c index 2ed2161..1f03737 100755 --- a/plugin/monitor/stc-plugin-monitor-connection.c +++ b/plugin/monitor/stc-plugin-monitor-connection.c @@ -490,6 +490,8 @@ static stc_error_e __get_default_connection(GDBusConnection *connection) if (comp && comp->data) g_default_connection = comp->data; + g_free(object_path); + g_variant_iter_free(next); break; } } -- 2.7.4 From 040cfa48a4c49ef8566246cc66898efa5c938d4d Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Thu, 25 Jun 2020 18:42:14 +0900 Subject: [PATCH 10/16] Free before return Change-Id: I951213a634605c561d9061c45134c6d7ef924d67 --- src/stc-manager-util.c | 1 + src/stc-pcap.c | 6 ++++++ src/stc-restriction.c | 20 ++++++++++++++++++++ src/stc-statistics.c | 2 ++ 4 files changed, 29 insertions(+) diff --git a/src/stc-manager-util.c b/src/stc-manager-util.c index 1f25927..3e77610 100755 --- a/src/stc-manager-util.c +++ b/src/stc-manager-util.c @@ -182,4 +182,5 @@ void stc_util_initialize_config(void) } __save_key_file(keyfile, path); + g_key_file_free(keyfile); } diff --git a/src/stc-pcap.c b/src/stc-pcap.c index 3faa7ec..29f5037 100755 --- a/src/stc-pcap.c +++ b/src/stc-pcap.c @@ -106,6 +106,7 @@ gboolean handle_pcap_start(StcPcap *object, if (__validate_pcap(&pcap) == FALSE) { STC_PCAP_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_INVALID_PARAMETER); + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -113,11 +114,13 @@ gboolean handle_pcap_start(StcPcap *object, ret = stc_plugin_pcap_register_loop(pcap.ifname, pcap.nflog_group); if (ret != STC_ERROR_NONE) { STC_PCAP_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } STC_DBUS_REPLY_ERROR_NONE(invocation); + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; return TRUE; } @@ -147,6 +150,7 @@ gboolean handle_pcap_stop(StcPcap *object, if (__validate_pcap(&pcap) == FALSE) { STC_PCAP_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_INVALID_PARAMETER); + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -154,11 +158,13 @@ gboolean handle_pcap_stop(StcPcap *object, ret = stc_plugin_pcap_unregister_loop(pcap.ifname, pcap.nflog_group); if (ret != STC_ERROR_NONE) { STC_PCAP_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } STC_DBUS_REPLY_ERROR_NONE(invocation); + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; return TRUE; } diff --git a/src/stc-restriction.c b/src/stc-restriction.c index d47aaf0..47bfee8 100755 --- a/src/stc-restriction.c +++ b/src/stc-restriction.c @@ -259,6 +259,14 @@ static void __stc_extract_restriction_rule(const char *key, GVariant *value, } } +static void __stc_free_restriction_rule_members(table_restrictions_info *rule) +{ + FREE(rule->app_id); + FREE(rule->ifname); + FREE(rule->subscriber_id); + FREE(rule->mac); +} + gboolean handle_restriction_set(StcRestriction *object, GDBusMethodInvocation *invocation, GVariant *parameters, @@ -285,6 +293,7 @@ gboolean handle_restriction_set(StcRestriction *object, if (__validate_rstn_rule(&rule) == FALSE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_INVALID_PARAMETER); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -293,12 +302,14 @@ gboolean handle_restriction_set(StcRestriction *object, if (ret != STC_ERROR_NONE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_DB_FAILED); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } stc_plugin_monitor_add_rstn(&rule); STC_DBUS_REPLY_ERROR_NONE(invocation); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; return TRUE; } @@ -329,6 +340,7 @@ gboolean handle_restriction_unset(StcRestriction *object, if (__validate_rstn_rule(&rule) == FALSE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_INVALID_PARAMETER); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -338,12 +350,14 @@ gboolean handle_restriction_unset(StcRestriction *object, if (ret != STC_ERROR_NONE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_DB_FAILED); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } stc_plugin_monitor_remove_rstn(&rule); STC_DBUS_REPLY_ERROR_NONE(invocation); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; return TRUE; } @@ -376,6 +390,7 @@ gboolean handle_restriction_set_list(StcRestriction *object, STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE g_variant_iter_free(iter_row); g_variant_iter_free(iter); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -385,11 +400,13 @@ gboolean handle_restriction_set_list(StcRestriction *object, STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE g_variant_iter_free(iter_row); g_variant_iter_free(iter); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } } + __stc_free_restriction_rule_members(&rule); g_variant_iter_free(iter_row); } g_variant_iter_free(iter); @@ -428,6 +445,7 @@ gboolean handle_restriction_unset_list(StcRestriction *object, STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE g_variant_iter_free(iter_row); g_variant_iter_free(iter); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -437,11 +455,13 @@ gboolean handle_restriction_unset_list(StcRestriction *object, STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE g_variant_iter_free(iter_row); g_variant_iter_free(iter); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } } + __stc_free_restriction_rule_members(&rule); g_variant_iter_free(iter_row); } g_variant_iter_free(iter); diff --git a/src/stc-statistics.c b/src/stc-statistics.c index 0e26464..ee61443 100755 --- a/src/stc-statistics.c +++ b/src/stc-statistics.c @@ -345,6 +345,7 @@ gboolean handle_statistics_get(StcStatistics *object, if (ret < STC_ERROR_NONE) { g_variant_builder_unref(builder); //LCOV_EXCL_LINE STC_STATISTICS_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE + g_free(rule.app_id); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; //LCOV_EXCL_LINE } @@ -355,6 +356,7 @@ gboolean handle_statistics_get(StcStatistics *object, DEBUG_GDBUS_VARIANT("Return parameters: ", return_parameters); STC_DBUS_REPLY(invocation, return_parameters); + g_free(rule.app_id); __STC_LOG_FUNC_EXIT__; return TRUE; } -- 2.7.4 From 7ed139f064240de4485f1342f037e9a05e2ada0d Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 2 Jul 2020 12:14:59 +0530 Subject: [PATCH 11/16] Fix build when using gcov and gtests build flags [ 75s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/firewall.cpp: In member function 'error_e Firewall::GetLock(int*)': [ 75s] /usr/include/dlog/dlog-internal.h:72:31: error: format '%d' expects argument of type 'int', but argument 8 has type 'int*' [-Werror=format=] [ 75s] 72 | __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##__VA_ARGS__); \ [ 75s] /usr/include/dlog/dlog-internal.h:166:27: note: in expansion of macro 'LOG_' [ 75s] 166 | #define LOGD(format, ...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##__VA_ARGS__) [ 75s] | ^~~~ [ 75s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/stcmgr.h:30:32: note: in expansion of macro 'LOGD' [ 75s] 30 | #define GLOGD(format, args...) LOGD(format, ##args) [ 75s] | ^~~~ [ 75s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/firewall.cpp:484:2: note: in expansion of macro 'GLOGD' [ 75s] 484 | GLOGD("Succeeded to get lock state[%d]", state); [ 75s] | ^~~~~ [ 75s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/firewall.cpp:484:38: note: format string is defined here [ 75s] 484 | GLOGD("Succeeded to get lock state[%d]", state); [ 75s] | ~^ [ 75s] | | [ 75s] | int [ 75s] | %n [ 78s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/statistics.cpp: In member function 'error_e Statistics::ResetStatistics()': [ 78s] /usr/include/dlog/dlog-internal.h:72:31: error: too many arguments for format [-Werror=format-extra-args] [ 78s] 72 | __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##__VA_ARGS__); \ [ 78s] /usr/include/dlog/dlog-internal.h:166:27: note: in expansion of macro 'LOG_' [ 78s] 166 | #define LOGD(format, ...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##__VA_ARGS__) [ 78s] | ^~~~ [ 78s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/stcmgr.h:30:32: note: in expansion of macro 'LOGD' [ 78s] 30 | #define GLOGD(format, args...) LOGD(format, ##args) [ 78s] | ^~~~ [ 78s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/statistics.cpp:292:2: note: in expansion of macro 'GLOGD' [ 78s] 292 | GLOGD("Succeeded to reset statistics", result); [ 78s] | ^~~~~ Change-Id: I5a23d18e3e8b3d510cacac834506ec22fa2bd193 Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- unittest/firewall.cpp | 4 ++-- unittest/statistics.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 2f2b56c..cff6b78 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.2 +Version: 0.1.3 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/unittest/firewall.cpp b/unittest/firewall.cpp index 44bcfe5..0cf9521 100644 --- a/unittest/firewall.cpp +++ b/unittest/firewall.cpp @@ -480,8 +480,8 @@ error_e Firewall::GetLock(int *state) return error; } - g_variant_get(message, "(i)", &state); - GLOGD("Succeeded to get lock state[%d]", state); + g_variant_get(message, "(i)", state); + GLOGD("Succeeded to get lock state[%d]", *state); g_variant_unref(message); return ERROR_NONE; diff --git a/unittest/statistics.cpp b/unittest/statistics.cpp index 7c816cc..6c80db1 100644 --- a/unittest/statistics.cpp +++ b/unittest/statistics.cpp @@ -289,7 +289,7 @@ error_e Statistics::ResetStatistics(void) } g_variant_get(message, "(i)", &result); - GLOGD("Succeeded to reset statistics", result); + GLOGD("Succeeded to reset statistics [%d]", result); g_variant_unref(message); return ERROR_NONE; -- 2.7.4 From cf268a5d8be0a4064fcd9cbeffa012080466279c Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Tue, 7 Jul 2020 09:50:29 +0900 Subject: [PATCH 12/16] Fix a coverity for 1142644 Change-Id: I2865c692003f0ae45a73918e84ad7810864903fc Signed-off-by: hyunuk.tak --- plugin/monitor/stc-plugin-monitor-app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/monitor/stc-plugin-monitor-app.c b/plugin/monitor/stc-plugin-monitor-app.c index 6bc410a..4b5703b 100755 --- a/plugin/monitor/stc-plugin-monitor-app.c +++ b/plugin/monitor/stc-plugin-monitor-app.c @@ -614,7 +614,7 @@ static void __make_counter(stc_app_value_s *app_value, if (iptype == NFACCT_TYPE_IPV4) list_data->counter_v4_list = g_slist_append(list_data->counter_v4_list, counter); - else if (iptype == NFACCT_TYPE_IPV6) + else list_data->counter_v6_list = g_slist_append(list_data->counter_v6_list, counter); } -- 2.7.4 From a93ae15925a8ee955c3f20c687a7f7e40cd4ed88 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Fri, 3 Jul 2020 11:21:46 +0530 Subject: [PATCH 13/16] Add test cases for removing rule post warn and restriction limit are crossed Change-Id: I47486ce363fb157b77824dd140052262c1b43495 Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- unittest/unittest.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index cff6b78..0690fde 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.3 +Version: 0.1.4 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp index 8b467f7..41d57c4 100644 --- a/unittest/unittest.cpp +++ b/unittest/unittest.cpp @@ -328,6 +328,84 @@ TEST(StcManager_Statistics, Reset_p) EXPECT_EQ(ERROR_NONE, ret); } +TEST(StcManager_Restriction, RemoveRulePostWarnLimitCrossed_p) +{ + error_e ret = ERROR_NONE; + int sys_ret; + Restriction rest; + + ret = rest.SetRule("TOTAL_WIFI", + "wlan0", + NULL, + IFACE_WIFI, + -1, + 1, + ROAMING_UNKNOWN, + GTEST_MAC); + EXPECT_EQ(ERROR_NONE, ret); + + ret = rest.SetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); + + sys_ret = system("toybox ping -c 5 www.tizen.org"); + EXPECT_EQ(0, sys_ret); + + ret = rest.UnsetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); +} + +TEST(StcManager_Restriction, RemoveRulePostRestrictionLimitCrossed_p) +{ + error_e ret = ERROR_NONE; + int sys_ret; + Restriction rest; + + ret = rest.SetRule("TOTAL_WIFI", + "wlan0", + NULL, + IFACE_WIFI, + 2, + -1, + ROAMING_UNKNOWN, + GTEST_MAC); + EXPECT_EQ(ERROR_NONE, ret); + + ret = rest.SetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); + + sys_ret = system("toybox ping -c 5 www.tizen.org"); + EXPECT_NE(0, sys_ret); + + ret = rest.UnsetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); +} + +TEST(StcManager_Restriction, RemoveRulePostBothLimitCrossed_p) +{ + error_e ret = ERROR_NONE; + int sys_ret; + Restriction rest; + + ret = rest.SetRule("TOTAL_WIFI", + "wlan0", + NULL, + IFACE_WIFI, + 2, + 1, + ROAMING_UNKNOWN, + GTEST_MAC); + EXPECT_EQ(ERROR_NONE, ret); + + ret = rest.SetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); + + sys_ret = system("toybox ping -c 5 www.tizen.org"); + EXPECT_NE(0, sys_ret); + + ret = rest.UnsetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); +} + TEST(StcManager_Firewall, Lock_p) { error_e ret = ERROR_NONE; -- 2.7.4 From 5b8edd8d8ca57403e6775811d195134d644f7634 Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Thu, 20 Aug 2020 17:35:39 +0900 Subject: [PATCH 14/16] [cleanup] change file location and mode Change-Id: I1f74ff9259a5c02a161bb75d4dd2ea15b0c6de6f --- CMakeLists.txt | 11 ++++--- LICENSE => LICENSE.APLv2 | 0 {interfaces => dbus-interface}/CMakeLists.txt | 0 .../stcmanager-iface-firewall.xml | 0 .../stcmanager-iface-manager.xml | 0 .../stcmanager-iface-pcap.xml | 0 .../stcmanager-iface-restriction.xml | 0 .../stcmanager-iface-statistics.xml | 0 {src/configure/include => include}/counter.h | 0 .../include => include/db}/table-counters.h | 0 .../include => include/db}/table-firewall.h | 0 .../include => include/db}/table-restrictions.h | 0 .../include => include/db}/table-statistics.h | 0 {src/database/include => include}/stc-db.h | 0 include/stc-error.h | 0 include/stc-firewall.h | 0 include/stc-manager-gdbus.h | 0 include/stc-manager-plugin-appstatus.h | 0 include/stc-manager-plugin-exception.h | 0 include/stc-manager-plugin-firewall.h | 0 include/stc-manager-plugin-monitor.h | 0 include/stc-manager-plugin-pcap.h | 0 include/stc-manager-plugin-procfs.h | 0 include/stc-manager-plugin-tether.h | 0 include/stc-manager-util.h | 0 include/stc-manager.h | 0 include/stc-pcap.h | 0 include/stc-restriction.h | 0 include/stc-statistics.h | 0 include/transmission.h | 0 {src => manager}/CMakeLists.txt | 38 ++++++++-------------- {src => manager}/database/db-common.c | 0 {src => manager}/database/db-guard.c | 0 .../include => manager/database}/db-internal.h | 0 .../tables => manager/database}/table-counters.c | 0 .../tables => manager/database}/table-firewall.c | 0 .../database}/table-restrictions.c | 0 .../tables => manager/database}/table-statistics.c | 0 .../include => manager/helper}/configure_stub.h | 0 {src => manager}/helper/helper-cgroup.c | 0 {src => manager}/helper/helper-cgroup.h | 0 {src => manager}/helper/helper-file.c | 0 {src => manager}/helper/helper-file.h | 0 {src => manager}/helper/helper-firewall.c | 0 {src => manager}/helper/helper-firewall.h | 0 {src => manager}/helper/helper-inotify.c | 0 {src => manager}/helper/helper-inotify.h | 0 {src => manager}/helper/helper-iptables.c | 0 {src => manager}/helper/helper-iptables.h | 0 {src => manager}/helper/helper-net-cls.c | 0 {src => manager}/helper/helper-net-cls.h | 0 {src => manager}/helper/helper-nfacct-rule.c | 1 - {src => manager}/helper/helper-nfacct-rule.h | 1 - {src => manager}/helper/helper-nl.c | 0 {src => manager}/helper/helper-nl.h | 0 {src => manager}/helper/helper-procfs.c | 0 {src => manager}/helper/helper-procfs.h | 0 {src => manager}/stc-firewall.c | 0 {src => manager}/stc-manager-gdbus.c | 0 {src => manager}/stc-manager-plugin-appstatus.c | 0 {src => manager}/stc-manager-plugin-exception.c | 0 {src => manager}/stc-manager-plugin-firewall.c | 0 {src => manager}/stc-manager-plugin-monitor.c | 0 {src => manager}/stc-manager-plugin-pcap.c | 0 {src => manager}/stc-manager-plugin-procfs.c | 0 {src => manager}/stc-manager-plugin-tether.c | 0 {src => manager}/stc-manager.c | 0 {src => manager}/stc-pcap.c | 0 {src => manager}/stc-restriction.c | 0 {src => manager}/stc-statistics.c | 0 {src => manager/util}/stc-manager-util.c | 0 {src/utils => misc}/CMakeLists.txt | 0 {src/utils => misc}/net-cls-release.c | 0 .../stc-manager.manifest | 1 - packaging/stc-manager.spec | 15 +++++---- plugin/CMakeLists.txt | 7 ++-- plugin/appstatus/CMakeLists.txt | 2 -- plugin/appstatus/stc-plugin-appstatus.c | 0 .../appstatus/{include => }/stc-plugin-appstatus.h | 0 plugin/exception/CMakeLists.txt | 2 -- plugin/exception/stc-plugin-exception.c | 0 .../exception/{include => }/stc-plugin-exception.h | 0 plugin/firewall/CMakeLists.txt | 2 -- plugin/firewall/stc-plugin-firewall.c | 0 .../firewall/{include => }/stc-plugin-firewall.h | 0 plugin/monitor/CMakeLists.txt | 10 +++--- plugin/monitor/stc-plugin-monitor-app.c | 0 .../monitor/{include => }/stc-plugin-monitor-app.h | 0 plugin/monitor/stc-plugin-monitor-connection.c | 0 .../{include => }/stc-plugin-monitor-connection.h | 0 .../{include => }/stc-plugin-monitor-context.h | 0 plugin/monitor/stc-plugin-monitor-ipt.c | 0 .../monitor/{include => }/stc-plugin-monitor-ipt.h | 0 plugin/monitor/stc-plugin-monitor-proc.c | 0 .../{include => }/stc-plugin-monitor-proc.h | 0 plugin/monitor/stc-plugin-monitor-rstn.c | 0 .../{include => }/stc-plugin-monitor-rstn.h | 0 plugin/monitor/stc-plugin-monitor-time.c | 0 .../{include => }/stc-plugin-monitor-time.h | 0 plugin/monitor/stc-plugin-monitor.c | 0 plugin/monitor/{include => }/stc-plugin-monitor.h | 0 plugin/pcap/CMakeLists.txt | 2 -- .../pcap/{include => }/stc-plugin-pcap-internal.h | 0 plugin/pcap/stc-plugin-pcap.c | 0 plugin/pcap/{include => }/stc-plugin-pcap.h | 0 plugin/procfs/CMakeLists.txt | 5 ++- plugin/procfs/stc-plugin-procfs.c | 0 plugin/procfs/{include => }/stc-plugin-procfs.h | 0 plugin/tether/CMakeLists.txt | 3 +- plugin/tether/stc-plugin-tether.c | 0 plugin/tether/{include => }/stc-plugin-tether.h | 0 {scripts => res}/500.stc-manager_upgrade.sh | 0 {resources => res}/dbus/net.stc-manager.service | 0 {resources => res}/dbus/stc-manager.conf | 0 {data => res}/exceptions | 0 {data => res}/firewall_db.sql | 0 {resources => res}/systemd/stc-manager.service | 0 {data => res}/traffic_db.sql | 0 {unittest => tests}/CMakeLists.txt | 0 {unittest => tests}/common.cpp | 1 - {unittest => tests}/common.h | 0 {unittest => tests}/firewall.cpp | 1 - {unittest => tests}/firewall.h | 0 {unittest => tests}/gdbus.cpp | 0 {unittest => tests}/gdbus.h | 0 {unittest => tests}/manager.cpp | 0 {unittest => tests}/manager.h | 0 {unittest => tests}/restriction.cpp | 0 {unittest => tests}/restriction.h | 0 {unittest => tests}/statistics.cpp | 2 +- {unittest => tests}/statistics.h | 0 {unittest => tests}/stcmgr.cpp | 0 {unittest => tests}/stcmgr.h | 0 {unittest => tests}/unittest.cpp | 0 {unittest => tests}/unittest.h | 0 135 files changed, 38 insertions(+), 66 deletions(-) rename LICENSE => LICENSE.APLv2 (100%) rename {interfaces => dbus-interface}/CMakeLists.txt (100%) rename {interfaces => dbus-interface}/stcmanager-iface-firewall.xml (100%) rename {interfaces => dbus-interface}/stcmanager-iface-manager.xml (100%) rename {interfaces => dbus-interface}/stcmanager-iface-pcap.xml (100%) rename {interfaces => dbus-interface}/stcmanager-iface-restriction.xml (100%) rename {interfaces => dbus-interface}/stcmanager-iface-statistics.xml (100%) rename {src/configure/include => include}/counter.h (100%) rename {src/database/include => include/db}/table-counters.h (100%) mode change 100755 => 100644 rename {src/database/include => include/db}/table-firewall.h (100%) mode change 100755 => 100644 rename {src/database/include => include/db}/table-restrictions.h (100%) mode change 100755 => 100644 rename {src/database/include => include/db}/table-statistics.h (100%) mode change 100755 => 100644 rename {src/database/include => include}/stc-db.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 include/stc-error.h mode change 100755 => 100644 include/stc-firewall.h mode change 100755 => 100644 include/stc-manager-gdbus.h mode change 100755 => 100644 include/stc-manager-plugin-appstatus.h mode change 100755 => 100644 include/stc-manager-plugin-exception.h mode change 100755 => 100644 include/stc-manager-plugin-firewall.h mode change 100755 => 100644 include/stc-manager-plugin-monitor.h mode change 100755 => 100644 include/stc-manager-plugin-pcap.h mode change 100755 => 100644 include/stc-manager-plugin-procfs.h mode change 100755 => 100644 include/stc-manager-plugin-tether.h mode change 100755 => 100644 include/stc-manager-util.h mode change 100755 => 100644 include/stc-manager.h mode change 100755 => 100644 include/stc-pcap.h mode change 100755 => 100644 include/stc-restriction.h mode change 100755 => 100644 include/stc-statistics.h mode change 100755 => 100644 include/transmission.h rename {src => manager}/CMakeLists.txt (68%) rename {src => manager}/database/db-common.c (100%) mode change 100755 => 100644 rename {src => manager}/database/db-guard.c (100%) rename {src/database/include => manager/database}/db-internal.h (100%) mode change 100755 => 100644 rename {src/database/tables => manager/database}/table-counters.c (100%) mode change 100755 => 100644 rename {src/database/tables => manager/database}/table-firewall.c (100%) mode change 100755 => 100644 rename {src/database/tables => manager/database}/table-restrictions.c (100%) mode change 100755 => 100644 rename {src/database/tables => manager/database}/table-statistics.c (100%) mode change 100755 => 100644 rename {src/configure/include => manager/helper}/configure_stub.h (100%) rename {src => manager}/helper/helper-cgroup.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-cgroup.h (100%) rename {src => manager}/helper/helper-file.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-file.h (100%) rename {src => manager}/helper/helper-firewall.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-firewall.h (100%) rename {src => manager}/helper/helper-inotify.c (100%) rename {src => manager}/helper/helper-inotify.h (100%) rename {src => manager}/helper/helper-iptables.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-iptables.h (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-net-cls.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-net-cls.h (100%) rename {src => manager}/helper/helper-nfacct-rule.c (99%) mode change 100755 => 100644 rename {src => manager}/helper/helper-nfacct-rule.h (99%) mode change 100755 => 100644 rename {src => manager}/helper/helper-nl.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-nl.h (100%) rename {src => manager}/helper/helper-procfs.c (100%) rename {src => manager}/helper/helper-procfs.h (100%) rename {src => manager}/stc-firewall.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-gdbus.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-appstatus.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-exception.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-firewall.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-monitor.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-pcap.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-procfs.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-tether.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-pcap.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-restriction.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-statistics.c (100%) mode change 100755 => 100644 rename {src => manager/util}/stc-manager-util.c (100%) mode change 100755 => 100644 rename {src/utils => misc}/CMakeLists.txt (100%) rename {src/utils => misc}/net-cls-release.c (100%) rename stc-manager.manifest => packaging/stc-manager.manifest (98%) mode change 100755 => 100644 plugin/appstatus/stc-plugin-appstatus.c rename plugin/appstatus/{include => }/stc-plugin-appstatus.h (100%) mode change 100755 => 100644 plugin/exception/stc-plugin-exception.c rename plugin/exception/{include => }/stc-plugin-exception.h (100%) mode change 100755 => 100644 plugin/firewall/stc-plugin-firewall.c rename plugin/firewall/{include => }/stc-plugin-firewall.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-app.c rename plugin/monitor/{include => }/stc-plugin-monitor-app.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-connection.c rename plugin/monitor/{include => }/stc-plugin-monitor-connection.h (100%) mode change 100755 => 100644 rename plugin/monitor/{include => }/stc-plugin-monitor-context.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-ipt.c rename plugin/monitor/{include => }/stc-plugin-monitor-ipt.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-proc.c rename plugin/monitor/{include => }/stc-plugin-monitor-proc.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-rstn.c rename plugin/monitor/{include => }/stc-plugin-monitor-rstn.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-time.c rename plugin/monitor/{include => }/stc-plugin-monitor-time.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor.c rename plugin/monitor/{include => }/stc-plugin-monitor.h (100%) mode change 100755 => 100644 rename plugin/pcap/{include => }/stc-plugin-pcap-internal.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/pcap/stc-plugin-pcap.c rename plugin/pcap/{include => }/stc-plugin-pcap.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/procfs/stc-plugin-procfs.c rename plugin/procfs/{include => }/stc-plugin-procfs.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/tether/stc-plugin-tether.c rename plugin/tether/{include => }/stc-plugin-tether.h (100%) rename {scripts => res}/500.stc-manager_upgrade.sh (100%) mode change 100644 => 100755 rename {resources => res}/dbus/net.stc-manager.service (100%) mode change 100755 => 100644 rename {resources => res}/dbus/stc-manager.conf (100%) mode change 100755 => 100644 rename {data => res}/exceptions (100%) rename {data => res}/firewall_db.sql (100%) rename {resources => res}/systemd/stc-manager.service (100%) rename {data => res}/traffic_db.sql (100%) rename {unittest => tests}/CMakeLists.txt (100%) rename {unittest => tests}/common.cpp (99%) rename {unittest => tests}/common.h (100%) rename {unittest => tests}/firewall.cpp (99%) rename {unittest => tests}/firewall.h (100%) rename {unittest => tests}/gdbus.cpp (100%) rename {unittest => tests}/gdbus.h (100%) rename {unittest => tests}/manager.cpp (100%) rename {unittest => tests}/manager.h (100%) rename {unittest => tests}/restriction.cpp (100%) rename {unittest => tests}/restriction.h (100%) rename {unittest => tests}/statistics.cpp (99%) rename {unittest => tests}/statistics.h (100%) rename {unittest => tests}/stcmgr.cpp (100%) rename {unittest => tests}/stcmgr.h (100%) rename {unittest => tests}/unittest.cpp (100%) rename {unittest => tests}/unittest.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3386c69..011c4bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(stc-manager C CXX) SET(PACKAGE ${PROJECT_NAME}) -SET(INTERFACES "${CMAKE_SOURCE_DIR}/interfaces") +SET(INTERFACES "${CMAKE_SOURCE_DIR}/dbus-interface") SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(LIBDIR ${PREFIX}/${LIB_PATH}) -SET(DATA_DIR ${CMAKE_SOURCE_DIR}/data) +SET(DATA_DIR ${CMAKE_SOURCE_DIR}/res) -ADD_SUBDIRECTORY(interfaces) -ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(dbus-interface) +ADD_SUBDIRECTORY(manager) ADD_SUBDIRECTORY(plugin) +ADD_SUBDIRECTORY(misc) IF(BUILD_GTESTS) - ADD_SUBDIRECTORY(unittest) + ADD_SUBDIRECTORY(tests) ENDIF(BUILD_GTESTS) diff --git a/LICENSE b/LICENSE.APLv2 similarity index 100% rename from LICENSE rename to LICENSE.APLv2 diff --git a/interfaces/CMakeLists.txt b/dbus-interface/CMakeLists.txt similarity index 100% rename from interfaces/CMakeLists.txt rename to dbus-interface/CMakeLists.txt diff --git a/interfaces/stcmanager-iface-firewall.xml b/dbus-interface/stcmanager-iface-firewall.xml similarity index 100% rename from interfaces/stcmanager-iface-firewall.xml rename to dbus-interface/stcmanager-iface-firewall.xml diff --git a/interfaces/stcmanager-iface-manager.xml b/dbus-interface/stcmanager-iface-manager.xml similarity index 100% rename from interfaces/stcmanager-iface-manager.xml rename to dbus-interface/stcmanager-iface-manager.xml diff --git a/interfaces/stcmanager-iface-pcap.xml b/dbus-interface/stcmanager-iface-pcap.xml similarity index 100% rename from interfaces/stcmanager-iface-pcap.xml rename to dbus-interface/stcmanager-iface-pcap.xml diff --git a/interfaces/stcmanager-iface-restriction.xml b/dbus-interface/stcmanager-iface-restriction.xml similarity index 100% rename from interfaces/stcmanager-iface-restriction.xml rename to dbus-interface/stcmanager-iface-restriction.xml diff --git a/interfaces/stcmanager-iface-statistics.xml b/dbus-interface/stcmanager-iface-statistics.xml similarity index 100% rename from interfaces/stcmanager-iface-statistics.xml rename to dbus-interface/stcmanager-iface-statistics.xml diff --git a/src/configure/include/counter.h b/include/counter.h similarity index 100% rename from src/configure/include/counter.h rename to include/counter.h diff --git a/src/database/include/table-counters.h b/include/db/table-counters.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/table-counters.h rename to include/db/table-counters.h diff --git a/src/database/include/table-firewall.h b/include/db/table-firewall.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/table-firewall.h rename to include/db/table-firewall.h diff --git a/src/database/include/table-restrictions.h b/include/db/table-restrictions.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/table-restrictions.h rename to include/db/table-restrictions.h diff --git a/src/database/include/table-statistics.h b/include/db/table-statistics.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/table-statistics.h rename to include/db/table-statistics.h diff --git a/src/database/include/stc-db.h b/include/stc-db.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/stc-db.h rename to include/stc-db.h diff --git a/include/stc-error.h b/include/stc-error.h old mode 100755 new mode 100644 diff --git a/include/stc-firewall.h b/include/stc-firewall.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-gdbus.h b/include/stc-manager-gdbus.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-appstatus.h b/include/stc-manager-plugin-appstatus.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-exception.h b/include/stc-manager-plugin-exception.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-firewall.h b/include/stc-manager-plugin-firewall.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-monitor.h b/include/stc-manager-plugin-monitor.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-pcap.h b/include/stc-manager-plugin-pcap.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-procfs.h b/include/stc-manager-plugin-procfs.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-tether.h b/include/stc-manager-plugin-tether.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-util.h b/include/stc-manager-util.h old mode 100755 new mode 100644 diff --git a/include/stc-manager.h b/include/stc-manager.h old mode 100755 new mode 100644 diff --git a/include/stc-pcap.h b/include/stc-pcap.h old mode 100755 new mode 100644 diff --git a/include/stc-restriction.h b/include/stc-restriction.h old mode 100755 new mode 100644 diff --git a/include/stc-statistics.h b/include/stc-statistics.h old mode 100755 new mode 100644 diff --git a/include/transmission.h b/include/transmission.h old mode 100755 new mode 100644 diff --git a/src/CMakeLists.txt b/manager/CMakeLists.txt similarity index 68% rename from src/CMakeLists.txt rename to manager/CMakeLists.txt index 9883098..3c0d1b7 100644 --- a/src/CMakeLists.txt +++ b/manager/CMakeLists.txt @@ -21,10 +21,9 @@ FOREACH(flag ${stc_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src) +SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/manager) SET(HELPER_SOURCE_DIR ${SOURCE_DIR}/helper) SET(DATABASE_SOURCE_DIR ${SOURCE_DIR}/database) -SET(CONFIGURE_SOURCE_DIR ${SOURCE_DIR}/configure) SET(LIMITATION_SOURCE_DIR ${SOURCE_DIR}/limitation) SET(PLUGIN_DIR ${CMAKE_SOURCE_DIR}/plugin) SET(APPSTATUS_SOURCE_DIR ${PLUGIN_DIR}/appstatus) @@ -36,40 +35,31 @@ SET(MONITOR_SOURCE_DIR ${PLUGIN_DIR}/monitor) SET(FIREWALL_SOURCE_DIR ${PLUGIN_DIR}/firewall) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbus-interface) INCLUDE_DIRECTORIES(${SOURCE_DIR}) INCLUDE_DIRECTORIES(${HELPER_SOURCE_DIR}) INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/db) -INCLUDE_DIRECTORIES(${CONFIGURE_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CONFIGURE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${APPSTATUS_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${EXCEPTION_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${PROCFS_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${PCAP_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${TETHER_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${FIREWALL_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${LIMITATION_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${LIMITATION_SOURCE_DIR}/include) - -INCLUDE_DIRECTORIES(${APPSTATUS_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${EXCEPTION_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) -INCLUDE_DIRECTORIES(${FIREWALL_SOURCE_DIR}/include) - -FILE(GLOB SOURCE_SRCS ${SOURCE_DIR}/*.c) +FILE(GLOB SOURCE_SRCS ${SOURCE_DIR}/*.c util/*.c) FILE(GLOB HELPER_SRCS ${HELPER_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} ${CONFIGURE_SRCS} ${LIMITATION_SRCS}) +SET(SRCS ${SRCS} ${SOURCE_SRCS} ${HELPER_SRCS}) IF("${ENABLE_DATABASE}" STREQUAL "YES") FILE(GLOB DATABASE_SRCS ${DATABASE_SOURCE_DIR}/*.c) - FILE(GLOB DATABASE_TABLES_SRCS ${DATABASE_SOURCE_DIR}/tables/*.c) - SET(SRCS ${SRCS} ${DATABASE_SRCS} ${DATABASE_TABLES_SRCS}) + SET(SRCS ${SRCS} ${DATABASE_SRCS}) INSTALL(FILES ${DATA_DIR}/traffic_db.sql DESTINATION /usr/share) INSTALL(FILES ${DATA_DIR}/firewall_db.sql DESTINATION /usr/share) @@ -99,5 +89,3 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${stc_pkgs_LDFLAGS} -ldl) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR}) ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE) - -ADD_SUBDIRECTORY(utils) diff --git a/src/database/db-common.c b/manager/database/db-common.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/db-common.c rename to manager/database/db-common.c diff --git a/src/database/db-guard.c b/manager/database/db-guard.c similarity index 100% rename from src/database/db-guard.c rename to manager/database/db-guard.c diff --git a/src/database/include/db-internal.h b/manager/database/db-internal.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/db-internal.h rename to manager/database/db-internal.h diff --git a/src/database/tables/table-counters.c b/manager/database/table-counters.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/tables/table-counters.c rename to manager/database/table-counters.c diff --git a/src/database/tables/table-firewall.c b/manager/database/table-firewall.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/tables/table-firewall.c rename to manager/database/table-firewall.c diff --git a/src/database/tables/table-restrictions.c b/manager/database/table-restrictions.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/tables/table-restrictions.c rename to manager/database/table-restrictions.c diff --git a/src/database/tables/table-statistics.c b/manager/database/table-statistics.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/tables/table-statistics.c rename to manager/database/table-statistics.c diff --git a/src/configure/include/configure_stub.h b/manager/helper/configure_stub.h similarity index 100% rename from src/configure/include/configure_stub.h rename to manager/helper/configure_stub.h diff --git a/src/helper/helper-cgroup.c b/manager/helper/helper-cgroup.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-cgroup.c rename to manager/helper/helper-cgroup.c diff --git a/src/helper/helper-cgroup.h b/manager/helper/helper-cgroup.h similarity index 100% rename from src/helper/helper-cgroup.h rename to manager/helper/helper-cgroup.h diff --git a/src/helper/helper-file.c b/manager/helper/helper-file.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-file.c rename to manager/helper/helper-file.c diff --git a/src/helper/helper-file.h b/manager/helper/helper-file.h similarity index 100% rename from src/helper/helper-file.h rename to manager/helper/helper-file.h diff --git a/src/helper/helper-firewall.c b/manager/helper/helper-firewall.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-firewall.c rename to manager/helper/helper-firewall.c diff --git a/src/helper/helper-firewall.h b/manager/helper/helper-firewall.h similarity index 100% rename from src/helper/helper-firewall.h rename to manager/helper/helper-firewall.h diff --git a/src/helper/helper-inotify.c b/manager/helper/helper-inotify.c similarity index 100% rename from src/helper/helper-inotify.c rename to manager/helper/helper-inotify.c diff --git a/src/helper/helper-inotify.h b/manager/helper/helper-inotify.h similarity index 100% rename from src/helper/helper-inotify.h rename to manager/helper/helper-inotify.h diff --git a/src/helper/helper-iptables.c b/manager/helper/helper-iptables.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-iptables.c rename to manager/helper/helper-iptables.c diff --git a/src/helper/helper-iptables.h b/manager/helper/helper-iptables.h old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-iptables.h rename to manager/helper/helper-iptables.h diff --git a/src/helper/helper-net-cls.c b/manager/helper/helper-net-cls.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-net-cls.c rename to manager/helper/helper-net-cls.c diff --git a/src/helper/helper-net-cls.h b/manager/helper/helper-net-cls.h similarity index 100% rename from src/helper/helper-net-cls.h rename to manager/helper/helper-net-cls.h diff --git a/src/helper/helper-nfacct-rule.c b/manager/helper/helper-nfacct-rule.c old mode 100755 new mode 100644 similarity index 99% rename from src/helper/helper-nfacct-rule.c rename to manager/helper/helper-nfacct-rule.c index ff703d3..5694d14 --- a/src/helper/helper-nfacct-rule.c +++ b/manager/helper/helper-nfacct-rule.c @@ -959,4 +959,3 @@ void generate_counter_name(nfacct_rule_s *counter) warn_symbol, counter->iotype, counter->iftype, counter->classid, counter->ifname); } - diff --git a/src/helper/helper-nfacct-rule.h b/manager/helper/helper-nfacct-rule.h old mode 100755 new mode 100644 similarity index 99% rename from src/helper/helper-nfacct-rule.h rename to manager/helper/helper-nfacct-rule.h index f313849..5e09471 --- a/src/helper/helper-nfacct-rule.h +++ b/manager/helper/helper-nfacct-rule.h @@ -141,4 +141,3 @@ netlink_serialization_command * netlink_create_command(struct netlink_serialization_params *params); #endif /* __STC_NFACCT_RULE_H__ */ - diff --git a/src/helper/helper-nl.c b/manager/helper/helper-nl.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-nl.c rename to manager/helper/helper-nl.c diff --git a/src/helper/helper-nl.h b/manager/helper/helper-nl.h similarity index 100% rename from src/helper/helper-nl.h rename to manager/helper/helper-nl.h diff --git a/src/helper/helper-procfs.c b/manager/helper/helper-procfs.c similarity index 100% rename from src/helper/helper-procfs.c rename to manager/helper/helper-procfs.c diff --git a/src/helper/helper-procfs.h b/manager/helper/helper-procfs.h similarity index 100% rename from src/helper/helper-procfs.h rename to manager/helper/helper-procfs.h diff --git a/src/stc-firewall.c b/manager/stc-firewall.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-firewall.c rename to manager/stc-firewall.c diff --git a/src/stc-manager-gdbus.c b/manager/stc-manager-gdbus.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-gdbus.c rename to manager/stc-manager-gdbus.c diff --git a/src/stc-manager-plugin-appstatus.c b/manager/stc-manager-plugin-appstatus.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-appstatus.c rename to manager/stc-manager-plugin-appstatus.c diff --git a/src/stc-manager-plugin-exception.c b/manager/stc-manager-plugin-exception.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-exception.c rename to manager/stc-manager-plugin-exception.c diff --git a/src/stc-manager-plugin-firewall.c b/manager/stc-manager-plugin-firewall.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-firewall.c rename to manager/stc-manager-plugin-firewall.c diff --git a/src/stc-manager-plugin-monitor.c b/manager/stc-manager-plugin-monitor.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-monitor.c rename to manager/stc-manager-plugin-monitor.c diff --git a/src/stc-manager-plugin-pcap.c b/manager/stc-manager-plugin-pcap.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-pcap.c rename to manager/stc-manager-plugin-pcap.c diff --git a/src/stc-manager-plugin-procfs.c b/manager/stc-manager-plugin-procfs.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-procfs.c rename to manager/stc-manager-plugin-procfs.c diff --git a/src/stc-manager-plugin-tether.c b/manager/stc-manager-plugin-tether.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-tether.c rename to manager/stc-manager-plugin-tether.c diff --git a/src/stc-manager.c b/manager/stc-manager.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager.c rename to manager/stc-manager.c diff --git a/src/stc-pcap.c b/manager/stc-pcap.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-pcap.c rename to manager/stc-pcap.c diff --git a/src/stc-restriction.c b/manager/stc-restriction.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-restriction.c rename to manager/stc-restriction.c diff --git a/src/stc-statistics.c b/manager/stc-statistics.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-statistics.c rename to manager/stc-statistics.c diff --git a/src/stc-manager-util.c b/manager/util/stc-manager-util.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-util.c rename to manager/util/stc-manager-util.c diff --git a/src/utils/CMakeLists.txt b/misc/CMakeLists.txt similarity index 100% rename from src/utils/CMakeLists.txt rename to misc/CMakeLists.txt diff --git a/src/utils/net-cls-release.c b/misc/net-cls-release.c similarity index 100% rename from src/utils/net-cls-release.c rename to misc/net-cls-release.c diff --git a/stc-manager.manifest b/packaging/stc-manager.manifest similarity index 98% rename from stc-manager.manifest rename to packaging/stc-manager.manifest index 81ace0c..97e8c31 100644 --- a/stc-manager.manifest +++ b/packaging/stc-manager.manifest @@ -3,4 +3,3 @@ - diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 0690fde..c19c312 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -5,6 +5,7 @@ Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 Source0: %{name}-%{version}.tar.gz +Source1001: %{name}.manifest %define enable_database YES %define enable_statistics YES @@ -93,7 +94,7 @@ A smart traffic control manager extension for firewall plugin %prep %setup -q -chmod 644 %{SOURCE0} +cp %{SOURCE1001} ./%{name}.manifest %build @@ -135,29 +136,29 @@ rm -rf %{buildroot} #Exceptions file mkdir -p %{buildroot}/%{_localstatedir}/lib/stc -cp data/exceptions %{buildroot}/%{_localstatedir}/lib/stc/exceptions +cp res/exceptions %{buildroot}/%{_localstatedir}/lib/stc/exceptions #Systemd service file mkdir -p %{buildroot}%{_unitdir} -cp resources/systemd/stc-manager.service %{buildroot}%{_unitdir}/stc-manager.service +cp res/systemd/stc-manager.service %{buildroot}%{_unitdir}/stc-manager.service mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/ ln -s ../stc-manager.service %{buildroot}%{_unitdir}/multi-user.target.wants/stc-manager.service #DBus DAC (stc-manager.manifest enables DBus SMACK) mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d -cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf +cp res/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -cp resources/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service +cp res/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service #OS Upgrade mkdir -p %{buildroot}%{upgrade_script_path} -cp -f scripts/%{upgrade_script_filename} %{buildroot}%{upgrade_script_path} +cp -f res/%{upgrade_script_filename} %{buildroot}%{upgrade_script_path} %files %manifest %{name}.manifest -%license LICENSE +%license LICENSE.APLv2 %defattr(-,root,root,-) %attr(500,root,root) %{_bindir}/* diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 98f28b7..d1777f2 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -1,15 +1,14 @@ -SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src) +SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/manager) SET(HELPER_SOURCE_DIR ${SOURCE_DIR}/helper) SET(DATABASE_SOURCE_DIR ${SOURCE_DIR}/database) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbus-interface) INCLUDE_DIRECTORIES(${SOURCE_DIR}) INCLUDE_DIRECTORIES(${HELPER_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/db) ADD_SUBDIRECTORY(appstatus) ADD_SUBDIRECTORY(exception) diff --git a/plugin/appstatus/CMakeLists.txt b/plugin/appstatus/CMakeLists.txt index d4d7428..0a3acf7 100644 --- a/plugin/appstatus/CMakeLists.txt +++ b/plugin/appstatus/CMakeLists.txt @@ -16,8 +16,6 @@ FOREACH(flag ${appstatus_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/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") diff --git a/plugin/appstatus/stc-plugin-appstatus.c b/plugin/appstatus/stc-plugin-appstatus.c old mode 100755 new mode 100644 diff --git a/plugin/appstatus/include/stc-plugin-appstatus.h b/plugin/appstatus/stc-plugin-appstatus.h similarity index 100% rename from plugin/appstatus/include/stc-plugin-appstatus.h rename to plugin/appstatus/stc-plugin-appstatus.h diff --git a/plugin/exception/CMakeLists.txt b/plugin/exception/CMakeLists.txt index 1ccf391..06b6d93 100644 --- a/plugin/exception/CMakeLists.txt +++ b/plugin/exception/CMakeLists.txt @@ -15,8 +15,6 @@ FOREACH(flag ${exception_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/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") diff --git a/plugin/exception/stc-plugin-exception.c b/plugin/exception/stc-plugin-exception.c old mode 100755 new mode 100644 diff --git a/plugin/exception/include/stc-plugin-exception.h b/plugin/exception/stc-plugin-exception.h similarity index 100% rename from plugin/exception/include/stc-plugin-exception.h rename to plugin/exception/stc-plugin-exception.h diff --git a/plugin/firewall/CMakeLists.txt b/plugin/firewall/CMakeLists.txt index 05c4d90..2576f2d 100644 --- a/plugin/firewall/CMakeLists.txt +++ b/plugin/firewall/CMakeLists.txt @@ -14,8 +14,6 @@ FOREACH(flag ${firewall_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/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") diff --git a/plugin/firewall/stc-plugin-firewall.c b/plugin/firewall/stc-plugin-firewall.c old mode 100755 new mode 100644 diff --git a/plugin/firewall/include/stc-plugin-firewall.h b/plugin/firewall/stc-plugin-firewall.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/firewall/include/stc-plugin-firewall.h rename to plugin/firewall/stc-plugin-firewall.h diff --git a/plugin/monitor/CMakeLists.txt b/plugin/monitor/CMakeLists.txt index e1e0048..c05a448 100644 --- a/plugin/monitor/CMakeLists.txt +++ b/plugin/monitor/CMakeLists.txt @@ -18,12 +18,10 @@ 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) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/firewall/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/tether) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/appstatus) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/firewall) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/plugin/monitor/stc-plugin-monitor-app.c b/plugin/monitor/stc-plugin-monitor-app.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-app.h b/plugin/monitor/stc-plugin-monitor-app.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-app.h rename to plugin/monitor/stc-plugin-monitor-app.h diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stc-plugin-monitor-connection.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-connection.h b/plugin/monitor/stc-plugin-monitor-connection.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-connection.h rename to plugin/monitor/stc-plugin-monitor-connection.h diff --git a/plugin/monitor/include/stc-plugin-monitor-context.h b/plugin/monitor/stc-plugin-monitor-context.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-context.h rename to plugin/monitor/stc-plugin-monitor-context.h diff --git a/plugin/monitor/stc-plugin-monitor-ipt.c b/plugin/monitor/stc-plugin-monitor-ipt.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-ipt.h b/plugin/monitor/stc-plugin-monitor-ipt.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-ipt.h rename to plugin/monitor/stc-plugin-monitor-ipt.h diff --git a/plugin/monitor/stc-plugin-monitor-proc.c b/plugin/monitor/stc-plugin-monitor-proc.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-proc.h b/plugin/monitor/stc-plugin-monitor-proc.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-proc.h rename to plugin/monitor/stc-plugin-monitor-proc.h diff --git a/plugin/monitor/stc-plugin-monitor-rstn.c b/plugin/monitor/stc-plugin-monitor-rstn.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-rstn.h b/plugin/monitor/stc-plugin-monitor-rstn.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-rstn.h rename to plugin/monitor/stc-plugin-monitor-rstn.h diff --git a/plugin/monitor/stc-plugin-monitor-time.c b/plugin/monitor/stc-plugin-monitor-time.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-time.h b/plugin/monitor/stc-plugin-monitor-time.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-time.h rename to plugin/monitor/stc-plugin-monitor-time.h diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor.h b/plugin/monitor/stc-plugin-monitor.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor.h rename to plugin/monitor/stc-plugin-monitor.h diff --git a/plugin/pcap/CMakeLists.txt b/plugin/pcap/CMakeLists.txt index be4b022..48c7dae 100644 --- a/plugin/pcap/CMakeLists.txt +++ b/plugin/pcap/CMakeLists.txt @@ -14,8 +14,6 @@ FOREACH(flag ${pcap_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/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") diff --git a/plugin/pcap/include/stc-plugin-pcap-internal.h b/plugin/pcap/stc-plugin-pcap-internal.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/pcap/include/stc-plugin-pcap-internal.h rename to plugin/pcap/stc-plugin-pcap-internal.h diff --git a/plugin/pcap/stc-plugin-pcap.c b/plugin/pcap/stc-plugin-pcap.c old mode 100755 new mode 100644 diff --git a/plugin/pcap/include/stc-plugin-pcap.h b/plugin/pcap/stc-plugin-pcap.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/pcap/include/stc-plugin-pcap.h rename to plugin/pcap/stc-plugin-pcap.h diff --git a/plugin/procfs/CMakeLists.txt b/plugin/procfs/CMakeLists.txt index 17ab7f2..6e529c1 100644 --- a/plugin/procfs/CMakeLists.txt +++ b/plugin/procfs/CMakeLists.txt @@ -14,9 +14,8 @@ FOREACH(flag ${procfs_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") 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) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/plugin/procfs/stc-plugin-procfs.c b/plugin/procfs/stc-plugin-procfs.c old mode 100755 new mode 100644 diff --git a/plugin/procfs/include/stc-plugin-procfs.h b/plugin/procfs/stc-plugin-procfs.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/procfs/include/stc-plugin-procfs.h rename to plugin/procfs/stc-plugin-procfs.h diff --git a/plugin/tether/CMakeLists.txt b/plugin/tether/CMakeLists.txt index b64cfbd..7918d2e 100644 --- a/plugin/tether/CMakeLists.txt +++ b/plugin/tether/CMakeLists.txt @@ -14,8 +14,7 @@ FOREACH(flag ${tether_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/plugin/tether/stc-plugin-tether.c b/plugin/tether/stc-plugin-tether.c old mode 100755 new mode 100644 diff --git a/plugin/tether/include/stc-plugin-tether.h b/plugin/tether/stc-plugin-tether.h similarity index 100% rename from plugin/tether/include/stc-plugin-tether.h rename to plugin/tether/stc-plugin-tether.h diff --git a/scripts/500.stc-manager_upgrade.sh b/res/500.stc-manager_upgrade.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/500.stc-manager_upgrade.sh rename to res/500.stc-manager_upgrade.sh diff --git a/resources/dbus/net.stc-manager.service b/res/dbus/net.stc-manager.service old mode 100755 new mode 100644 similarity index 100% rename from resources/dbus/net.stc-manager.service rename to res/dbus/net.stc-manager.service diff --git a/resources/dbus/stc-manager.conf b/res/dbus/stc-manager.conf old mode 100755 new mode 100644 similarity index 100% rename from resources/dbus/stc-manager.conf rename to res/dbus/stc-manager.conf diff --git a/data/exceptions b/res/exceptions similarity index 100% rename from data/exceptions rename to res/exceptions diff --git a/data/firewall_db.sql b/res/firewall_db.sql similarity index 100% rename from data/firewall_db.sql rename to res/firewall_db.sql diff --git a/resources/systemd/stc-manager.service b/res/systemd/stc-manager.service similarity index 100% rename from resources/systemd/stc-manager.service rename to res/systemd/stc-manager.service diff --git a/data/traffic_db.sql b/res/traffic_db.sql similarity index 100% rename from data/traffic_db.sql rename to res/traffic_db.sql diff --git a/unittest/CMakeLists.txt b/tests/CMakeLists.txt similarity index 100% rename from unittest/CMakeLists.txt rename to tests/CMakeLists.txt diff --git a/unittest/common.cpp b/tests/common.cpp similarity index 99% rename from unittest/common.cpp rename to tests/common.cpp index 3fbaf8d..0f2b8d4 100644 --- a/unittest/common.cpp +++ b/tests/common.cpp @@ -63,4 +63,3 @@ void MainLoop::quit(void) { timeoutCb(NULL); } - diff --git a/unittest/common.h b/tests/common.h similarity index 100% rename from unittest/common.h rename to tests/common.h diff --git a/unittest/firewall.cpp b/tests/firewall.cpp similarity index 99% rename from unittest/firewall.cpp rename to tests/firewall.cpp index 0cf9521..43f32e2 100644 --- a/unittest/firewall.cpp +++ b/tests/firewall.cpp @@ -536,4 +536,3 @@ error_e Firewall::Lock() return ERROR_NONE; } - diff --git a/unittest/firewall.h b/tests/firewall.h similarity index 100% rename from unittest/firewall.h rename to tests/firewall.h diff --git a/unittest/gdbus.cpp b/tests/gdbus.cpp similarity index 100% rename from unittest/gdbus.cpp rename to tests/gdbus.cpp diff --git a/unittest/gdbus.h b/tests/gdbus.h similarity index 100% rename from unittest/gdbus.h rename to tests/gdbus.h diff --git a/unittest/manager.cpp b/tests/manager.cpp similarity index 100% rename from unittest/manager.cpp rename to tests/manager.cpp diff --git a/unittest/manager.h b/tests/manager.h similarity index 100% rename from unittest/manager.h rename to tests/manager.h diff --git a/unittest/restriction.cpp b/tests/restriction.cpp similarity index 100% rename from unittest/restriction.cpp rename to tests/restriction.cpp diff --git a/unittest/restriction.h b/tests/restriction.h similarity index 100% rename from unittest/restriction.h rename to tests/restriction.h diff --git a/unittest/statistics.cpp b/tests/statistics.cpp similarity index 99% rename from unittest/statistics.cpp rename to tests/statistics.cpp index 6c80db1..de870c4 100644 --- a/unittest/statistics.cpp +++ b/tests/statistics.cpp @@ -153,7 +153,7 @@ void Statistics::MakeRuleParams(GVariant **params, int mode) break; case 3: /* get all */ default: - *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder)); + *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder)); break; } diff --git a/unittest/statistics.h b/tests/statistics.h similarity index 100% rename from unittest/statistics.h rename to tests/statistics.h diff --git a/unittest/stcmgr.cpp b/tests/stcmgr.cpp similarity index 100% rename from unittest/stcmgr.cpp rename to tests/stcmgr.cpp diff --git a/unittest/stcmgr.h b/tests/stcmgr.h similarity index 100% rename from unittest/stcmgr.h rename to tests/stcmgr.h diff --git a/unittest/unittest.cpp b/tests/unittest.cpp similarity index 100% rename from unittest/unittest.cpp rename to tests/unittest.cpp diff --git a/unittest/unittest.h b/tests/unittest.h similarity index 100% rename from unittest/unittest.h rename to tests/unittest.h -- 2.7.4 From 4117c287e43330c1dea89b7298a0bbf58f87046a Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Fri, 21 Aug 2020 09:42:58 +0900 Subject: [PATCH 15/16] [cleanup] chanage file names for readability Change-Id: I90f348ca5c9f5e51e1cf32ba261b099358eb759b --- include/db/table-counters.h | 4 ++++ include/db/table-firewall.h | 2 ++ include/db/table-restrictions.h | 2 ++ include/db/table-statistics.h | 3 +++ include/{counter.h => stc-counter.h} | 0 include/stc-db.h | 2 +- include/stc-firewall.h | 4 ++-- include/{stc-manager-gdbus.h => stc-gdbus.h} | 2 +- include/stc-pcap.h | 4 ++-- ...r-plugin-appstatus.h => stc-plugin-appstatus.h} | 2 +- ...r-plugin-exception.h => stc-plugin-exception.h} | 2 +- ...ger-plugin-firewall.h => stc-plugin-firewall.h} | 2 +- .../stc-plugin-iface-appstatus.h | 3 +-- .../stc-plugin-iface-exception.h | 3 +-- .../stc-plugin-iface-firewall.h | 5 ++-- .../stc-plugin-iface-monitor.h | 28 ++++++++++++++++------ .../stc-plugin-iface-pcap.h | 0 .../stc-plugin-iface-procfs.h | 3 +-- .../stc-plugin-iface-tether.h | 3 +-- ...nager-plugin-monitor.h => stc-plugin-monitor.h} | 3 ++- ...stc-manager-plugin-pcap.h => stc-plugin-pcap.h} | 2 +- ...manager-plugin-procfs.h => stc-plugin-procfs.h} | 2 +- ...manager-plugin-tether.h => stc-plugin-tether.h} | 2 +- include/stc-restriction.h | 8 +++---- include/stc-statistics.h | 4 ++-- include/{transmission.h => stc-transmission.h} | 0 .../helper-inotify.h => include/stc-util-inotify.h | 0 include/{stc-manager-util.h => stc-util.h} | 0 include/{stc-manager.h => stc.h} | 2 +- manager/database/db-common.c | 8 +++---- manager/database/db-guard.c | 2 +- manager/database/table-counters.c | 2 +- manager/database/table-firewall.c | 2 +- manager/database/table-restrictions.c | 2 +- manager/database/table-statistics.c | 3 ++- manager/helper/helper-cgroup.h | 2 +- manager/helper/helper-file.h | 2 +- manager/helper/helper-firewall.c | 2 +- manager/helper/helper-firewall.h | 3 +-- manager/helper/helper-iptables.c | 2 +- manager/helper/helper-iptables.h | 3 +-- manager/helper/helper-net-cls.c | 2 +- manager/helper/helper-net-cls.h | 2 +- manager/helper/helper-nfacct-rule.c | 2 +- manager/helper/helper-nl.h | 2 +- manager/helper/helper-procfs.c | 3 +-- manager/{stc-firewall.c => stcmgr-firewall.c} | 8 +++---- manager/{stc-manager-gdbus.c => stcmgr-gdbus.c} | 15 ++++++------ manager/{stc-pcap.c => stcmgr-pcap.c} | 2 +- ...lugin-appstatus.c => stcmgr-plugin-appstatus.c} | 4 ++-- ...lugin-exception.c => stcmgr-plugin-exception.c} | 4 ++-- ...-plugin-firewall.c => stcmgr-plugin-firewall.c} | 4 ++-- ...er-plugin-monitor.c => stcmgr-plugin-monitor.c} | 4 ++-- ...-manager-plugin-pcap.c => stcmgr-plugin-pcap.c} | 4 ++-- ...ager-plugin-procfs.c => stcmgr-plugin-procfs.c} | 4 ++-- ...ager-plugin-tether.c => stcmgr-plugin-tether.c} | 4 ++-- .../{stc-restriction.c => stcmgr-restriction.c} | 6 ++--- manager/{stc-statistics.c => stcmgr-statistics.c} | 4 ++-- manager/{stc-manager.c => stcmgr.c} | 24 +++++++++---------- .../helper-inotify.c => util/stcutil-inotify.c} | 4 ++-- manager/util/{stc-manager-util.c => stcutil.c} | 2 +- packaging/stc-manager.spec | 2 +- plugin/appstatus/CMakeLists.txt | 2 +- ...tc-plugin-appstatus.c => stcplugin-appstatus.c} | 2 +- plugin/exception/CMakeLists.txt | 2 +- ...tc-plugin-exception.c => stcplugin-exception.c} | 3 ++- plugin/firewall/CMakeLists.txt | 2 +- ...{stc-plugin-firewall.c => stcplugin-firewall.c} | 6 ++--- plugin/monitor/CMakeLists.txt | 14 +++++------ ...lugin-monitor-app.c => stcplugin-monitor-app.c} | 18 +++++++------- ...lugin-monitor-app.h => stcplugin-monitor-app.h} | 21 ++++------------ ...connection.c => stcplugin-monitor-connection.c} | 6 ++--- ...connection.h => stcplugin-monitor-connection.h} | 4 +--- ...nitor-context.h => stcplugin-monitor-context.h} | 2 +- ...lugin-monitor-ipt.c => stcplugin-monitor-ipt.c} | 4 ++-- ...lugin-monitor-ipt.h => stcplugin-monitor-ipt.h} | 0 ...gin-monitor-proc.c => stcplugin-monitor-proc.c} | 9 ++++--- ...gin-monitor-proc.h => stcplugin-monitor-proc.h} | 9 ++----- ...gin-monitor-rstn.c => stcplugin-monitor-rstn.c} | 18 +++++++------- ...gin-monitor-rstn.h => stcplugin-monitor-rstn.h} | 9 ++++--- ...gin-monitor-time.c => stcplugin-monitor-time.c} | 0 ...gin-monitor-time.h => stcplugin-monitor-time.h} | 0 .../{stc-plugin-monitor.c => stcplugin-monitor.c} | 26 +++++++++++--------- plugin/pcap/CMakeLists.txt | 2 +- .../pcap/{stc-plugin-pcap.c => stcplugin-pcap.c} | 4 ++-- ...stc-plugin-pcap-internal.h => stcplugin-pcap.h} | 3 +-- plugin/procfs/CMakeLists.txt | 2 +- .../{stc-plugin-procfs.c => stcplugin-procfs.c} | 6 ++--- plugin/tether/CMakeLists.txt | 2 +- .../{stc-plugin-tether.c => stcplugin-tether.c} | 6 ++--- .../{net.stc-manager.service => net.stc.service} | 0 tests/stcmgr.cpp | 17 ------------- tests/{common.cpp => stctest-common.cpp} | 3 +-- tests/{common.h => stctest-common.h} | 0 tests/{firewall.cpp => stctest-firewall.cpp} | 5 ++-- tests/{firewall.h => stctest-firewall.h} | 4 ++-- tests/{gdbus.cpp => stctest-gdbus.cpp} | 3 +-- tests/{gdbus.h => stctest-gdbus.h} | 2 +- tests/{unittest.cpp => stctest-main.cpp} | 13 +++++----- tests/{unittest.h => stctest-main.h} | 0 tests/{manager.cpp => stctest-manager.cpp} | 3 +-- tests/{manager.h => stctest-manager.h} | 4 ++-- tests/{restriction.cpp => stctest-restriction.cpp} | 5 ++-- tests/{restriction.h => stctest-restriction.h} | 4 ++-- tests/{statistics.cpp => stctest-statistics.cpp} | 4 ++-- tests/{statistics.h => stctest-statistics.h} | 4 ++-- tests/{stcmgr.h => stctest.h} | 0 107 files changed, 235 insertions(+), 254 deletions(-) rename include/{counter.h => stc-counter.h} (100%) rename include/{stc-manager-gdbus.h => stc-gdbus.h} (99%) rename include/{stc-manager-plugin-appstatus.h => stc-plugin-appstatus.h} (96%) rename include/{stc-manager-plugin-exception.h => stc-plugin-exception.h} (96%) rename include/{stc-manager-plugin-firewall.h => stc-plugin-firewall.h} (97%) rename plugin/appstatus/stc-plugin-appstatus.h => include/stc-plugin-iface-appstatus.h (97%) rename plugin/exception/stc-plugin-exception.h => include/stc-plugin-iface-exception.h (96%) rename plugin/firewall/stc-plugin-firewall.h => include/stc-plugin-iface-firewall.h (95%) rename plugin/monitor/stc-plugin-monitor.h => include/stc-plugin-iface-monitor.h (84%) rename plugin/pcap/stc-plugin-pcap.h => include/stc-plugin-iface-pcap.h (100%) rename plugin/procfs/stc-plugin-procfs.h => include/stc-plugin-iface-procfs.h (96%) rename plugin/tether/stc-plugin-tether.h => include/stc-plugin-iface-tether.h (97%) rename include/{stc-manager-plugin-monitor.h => stc-plugin-monitor.h} (96%) rename include/{stc-manager-plugin-pcap.h => stc-plugin-pcap.h} (97%) rename include/{stc-manager-plugin-procfs.h => stc-plugin-procfs.h} (96%) rename include/{stc-manager-plugin-tether.h => stc-plugin-tether.h} (96%) rename include/{transmission.h => stc-transmission.h} (100%) rename manager/helper/helper-inotify.h => include/stc-util-inotify.h (100%) rename include/{stc-manager-util.h => stc-util.h} (100%) rename include/{stc-manager.h => stc.h} (99%) rename manager/{stc-firewall.c => stcmgr-firewall.c} (98%) rename manager/{stc-manager-gdbus.c => stcmgr-gdbus.c} (98%) rename manager/{stc-pcap.c => stcmgr-pcap.c} (99%) rename manager/{stc-manager-plugin-appstatus.c => stcmgr-plugin-appstatus.c} (97%) rename manager/{stc-manager-plugin-exception.c => stcmgr-plugin-exception.c} (97%) rename manager/{stc-manager-plugin-firewall.c => stcmgr-plugin-firewall.c} (98%) rename manager/{stc-manager-plugin-monitor.c => stcmgr-plugin-monitor.c} (98%) rename manager/{stc-manager-plugin-pcap.c => stcmgr-plugin-pcap.c} (98%) rename manager/{stc-manager-plugin-procfs.c => stcmgr-plugin-procfs.c} (97%) rename manager/{stc-manager-plugin-tether.c => stcmgr-plugin-tether.c} (97%) rename manager/{stc-restriction.c => stcmgr-restriction.c} (99%) rename manager/{stc-statistics.c => stcmgr-statistics.c} (99%) rename manager/{stc-manager.c => stcmgr.c} (93%) rename manager/{helper/helper-inotify.c => util/stcutil-inotify.c} (98%) rename manager/util/{stc-manager-util.c => stcutil.c} (99%) rename plugin/appstatus/{stc-plugin-appstatus.c => stcplugin-appstatus.c} (99%) rename plugin/exception/{stc-plugin-exception.c => stcplugin-exception.c} (99%) rename plugin/firewall/{stc-plugin-firewall.c => stcplugin-firewall.c} (99%) rename plugin/monitor/{stc-plugin-monitor-app.c => stcplugin-monitor-app.c} (98%) rename plugin/monitor/{stc-plugin-monitor-app.h => stcplugin-monitor-app.h} (76%) rename plugin/monitor/{stc-plugin-monitor-connection.c => stcplugin-monitor-connection.c} (99%) rename plugin/monitor/{stc-plugin-monitor-connection.h => stcplugin-monitor-connection.h} (95%) rename plugin/monitor/{stc-plugin-monitor-context.h => stcplugin-monitor-context.h} (98%) rename plugin/monitor/{stc-plugin-monitor-ipt.c => stcplugin-monitor-ipt.c} (98%) rename plugin/monitor/{stc-plugin-monitor-ipt.h => stcplugin-monitor-ipt.h} (100%) rename plugin/monitor/{stc-plugin-monitor-proc.c => stcplugin-monitor-proc.c} (97%) rename plugin/monitor/{stc-plugin-monitor-proc.h => stcplugin-monitor-proc.h} (91%) rename plugin/monitor/{stc-plugin-monitor-rstn.c => stcplugin-monitor-rstn.c} (99%) rename plugin/monitor/{stc-plugin-monitor-rstn.h => stcplugin-monitor-rstn.h} (94%) rename plugin/monitor/{stc-plugin-monitor-time.c => stcplugin-monitor-time.c} (100%) rename plugin/monitor/{stc-plugin-monitor-time.h => stcplugin-monitor-time.h} (100%) rename plugin/monitor/{stc-plugin-monitor.c => stcplugin-monitor.c} (96%) rename plugin/pcap/{stc-plugin-pcap.c => stcplugin-pcap.c} (99%) rename plugin/pcap/{stc-plugin-pcap-internal.h => stcplugin-pcap.h} (99%) rename plugin/procfs/{stc-plugin-procfs.c => stcplugin-procfs.c} (99%) rename plugin/tether/{stc-plugin-tether.c => stcplugin-tether.c} (98%) rename res/dbus/{net.stc-manager.service => net.stc.service} (100%) delete mode 100644 tests/stcmgr.cpp rename tests/{common.cpp => stctest-common.cpp} (98%) rename tests/{common.h => stctest-common.h} (100%) rename tests/{firewall.cpp => stctest-firewall.cpp} (99%) rename tests/{firewall.h => stctest-firewall.h} (98%) rename tests/{gdbus.cpp => stctest-gdbus.cpp} (99%) rename tests/{gdbus.h => stctest-gdbus.h} (99%) rename tests/{unittest.cpp => stctest-main.cpp} (98%) rename tests/{unittest.h => stctest-main.h} (100%) rename tests/{manager.cpp => stctest-manager.cpp} (97%) rename tests/{manager.h => stctest-manager.h} (94%) rename tests/{restriction.cpp => stctest-restriction.cpp} (99%) rename tests/{restriction.h => stctest-restriction.h} (97%) rename tests/{statistics.cpp => stctest-statistics.cpp} (99%) rename tests/{statistics.h => stctest-statistics.h} (97%) rename tests/{stcmgr.h => stctest.h} (100%) diff --git a/include/db/table-counters.h b/include/db/table-counters.h index 41febcb..1faed2d 100644 --- a/include/db/table-counters.h +++ b/include/db/table-counters.h @@ -17,6 +17,10 @@ #ifndef __TABLE_COUNTERS_H__ #define __TABLE_COUNTERS_H__ +#include +#include +#include "stc.h" + typedef struct { long long int restriction_id; long long int data_counter; diff --git a/include/db/table-firewall.h b/include/db/table-firewall.h index 70adca4..735320a 100644 --- a/include/db/table-firewall.h +++ b/include/db/table-firewall.h @@ -18,6 +18,8 @@ #define __TABLE_FIREWALL_H__ #include +#include +#include "stc-firewall.h" #include "helper-firewall.h" typedef stc_cb_ret_e diff --git a/include/db/table-restrictions.h b/include/db/table-restrictions.h index 4f4528a..27493b7 100644 --- a/include/db/table-restrictions.h +++ b/include/db/table-restrictions.h @@ -17,6 +17,8 @@ #ifndef __TABLE_RESTRICTIONS_H__ #define __TABLE_RESTRICTIONS_H__ +#include + typedef struct { char *app_id; char *ifname; diff --git a/include/db/table-statistics.h b/include/db/table-statistics.h index a510f32..a5b6c0a 100644 --- a/include/db/table-statistics.h +++ b/include/db/table-statistics.h @@ -17,6 +17,9 @@ #ifndef __TABLE_STATISTICS_H__ #define __TABLE_STATISTICS_H__ +#include "stc-db.h" +#include + typedef struct { char *app_id; char *ifname; diff --git a/include/counter.h b/include/stc-counter.h similarity index 100% rename from include/counter.h rename to include/stc-counter.h diff --git a/include/stc-db.h b/include/stc-db.h index e648d21..45c0610 100644 --- a/include/stc-db.h +++ b/include/stc-db.h @@ -17,7 +17,7 @@ #ifndef __STC_DB_H__ #define __STC_DB_H__ -#include "stc-manager.h" +#include "stc.h" #define MAX_DB_RETRY_COUNT 5 #define MAX_USLEEP_TIMEOUT 500000 diff --git a/include/stc-firewall.h b/include/stc-firewall.h index 861dede..ee40f27 100644 --- a/include/stc-firewall.h +++ b/include/stc-firewall.h @@ -18,8 +18,8 @@ #define __STC_FIREWALL_H__ #include -#include "stc-manager.h" -#include "stc-manager-gdbus.h" +#include "stc.h" +#include "stc-gdbus.h" #include "table-firewall.h" /***************************************************************************** diff --git a/include/stc-manager-gdbus.h b/include/stc-gdbus.h similarity index 99% rename from include/stc-manager-gdbus.h rename to include/stc-gdbus.h index b535ed2..141742c 100644 --- a/include/stc-manager-gdbus.h +++ b/include/stc-gdbus.h @@ -17,7 +17,7 @@ #ifndef __STC_MANAGER_GDBUS_H__ #define __STC_MANAGER_GDBUS_H__ -#include "stc-manager.h" +#include "stc.h" #include "generated-code.h" #define STC_DBUS_SERVICE "net.stc" diff --git a/include/stc-pcap.h b/include/stc-pcap.h index 1bd3d7e..c250181 100644 --- a/include/stc-pcap.h +++ b/include/stc-pcap.h @@ -18,8 +18,8 @@ #define __STC_PCAP_H__ #include -#include "stc-manager.h" -#include "stc-manager-gdbus.h" +#include "stc.h" +#include "stc-gdbus.h" /***************************************************************************** * Macros and Typedefs diff --git a/include/stc-manager-plugin-appstatus.h b/include/stc-plugin-appstatus.h similarity index 96% rename from include/stc-manager-plugin-appstatus.h rename to include/stc-plugin-appstatus.h index 1140199..84753fc 100644 --- a/include/stc-manager-plugin-appstatus.h +++ b/include/stc-plugin-appstatus.h @@ -19,7 +19,7 @@ #define STC_PLUGIN_APPSTATUS_FILEPATH "/usr/lib/stc-plugin-appstatus.so" -#include "stc-plugin-appstatus.h" +#include "stc-plugin-iface-appstatus.h" int stc_plugin_appstatus_init(void); int stc_plugin_appstatus_deinit(void); diff --git a/include/stc-manager-plugin-exception.h b/include/stc-plugin-exception.h similarity index 96% rename from include/stc-manager-plugin-exception.h rename to include/stc-plugin-exception.h index d826e3c..028c030 100644 --- a/include/stc-manager-plugin-exception.h +++ b/include/stc-plugin-exception.h @@ -19,7 +19,7 @@ #define STC_PLUGIN_EXCEPTION_FILEPATH "/usr/lib/stc-plugin-exception.so" -#include "stc-plugin-exception.h" +#include "stc-plugin-iface-exception.h" int stc_plugin_exception_init(void); int stc_plugin_exception_deinit(void); diff --git a/include/stc-manager-plugin-firewall.h b/include/stc-plugin-firewall.h similarity index 97% rename from include/stc-manager-plugin-firewall.h rename to include/stc-plugin-firewall.h index 258abc5..b73e98a 100644 --- a/include/stc-manager-plugin-firewall.h +++ b/include/stc-plugin-firewall.h @@ -19,7 +19,7 @@ #define STC_PLUGIN_FIREWALL_FILEPATH "/usr/lib/stc-plugin-firewall.so" -#include "stc-plugin-firewall.h" +#include "stc-plugin-iface-firewall.h" int stc_plugin_firewall_init(void); int stc_plugin_firewall_deinit(void); diff --git a/plugin/appstatus/stc-plugin-appstatus.h b/include/stc-plugin-iface-appstatus.h similarity index 97% rename from plugin/appstatus/stc-plugin-appstatus.h rename to include/stc-plugin-iface-appstatus.h index 45025be..2d8703b 100644 --- a/plugin/appstatus/stc-plugin-appstatus.h +++ b/include/stc-plugin-iface-appstatus.h @@ -18,8 +18,7 @@ #define __STC_PLUGIN_APPSTATUS_H__ #include -#include "stc-error.h" -#include "stc-manager.h" +#include "stc.h" typedef stc_error_e (*stc_plugin_app_state_changed_cb)(stc_cmd_type_e cmd, pid_t pid, diff --git a/plugin/exception/stc-plugin-exception.h b/include/stc-plugin-iface-exception.h similarity index 96% rename from plugin/exception/stc-plugin-exception.h rename to include/stc-plugin-iface-exception.h index 70e38e0..9bd0b27 100644 --- a/plugin/exception/stc-plugin-exception.h +++ b/include/stc-plugin-iface-exception.h @@ -18,8 +18,7 @@ #define __STC_PLUGIN_EXCEPTION_H__ #include -#include "stc-error.h" -#include "stc-manager.h" +#include "stc.h" typedef struct { int (*initialize_plugin) (void); diff --git a/plugin/firewall/stc-plugin-firewall.h b/include/stc-plugin-iface-firewall.h similarity index 95% rename from plugin/firewall/stc-plugin-firewall.h rename to include/stc-plugin-iface-firewall.h index d9f9dc4..b7740e6 100644 --- a/plugin/firewall/stc-plugin-firewall.h +++ b/include/stc-plugin-iface-firewall.h @@ -26,9 +26,8 @@ #include #include -#include "stc-error.h" -#include "stc-manager.h" -#include "stc-manager-gdbus.h" +#include "stc.h" +#include "stc-gdbus.h" typedef struct { stc_fw_chain_target_e target; diff --git a/plugin/monitor/stc-plugin-monitor.h b/include/stc-plugin-iface-monitor.h similarity index 84% rename from plugin/monitor/stc-plugin-monitor.h rename to include/stc-plugin-iface-monitor.h index 0cc8c42..98cc8d5 100644 --- a/plugin/monitor/stc-plugin-monitor.h +++ b/include/stc-plugin-iface-monitor.h @@ -18,14 +18,9 @@ #define __STC_PLUGIN_MONITOR_H__ #include -#include "stc-error.h" -#include "stc-manager.h" -#include "stc-manager-util.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 "stc.h" #include "helper-nl.h" +#include "db/table-restrictions.h" /* 1 seconds */ #define CONTR_TIMER_INTERVAL 1 @@ -38,9 +33,28 @@ #define VCONFKEY_SETAPPL_DATA_RESTRICTION_INT "db/setting/data_restriction" #endif +#define MAC_ADDRESS_LEN 18 + typedef void (*stc_manager_stop_cb)(void); typedef struct { + uint32_t classid; /**< classid for a package */ + gchar *pkg_id; /**< package id */ + gchar *app_id; /**< application id */ + stc_app_type_e type; /**< type of application */ + stc_app_state_e state; + stc_data_counter_s data_usage; + stc_data_counter_s counter; + GHashTable *processes; /**< applications instances */ + char mac[MAC_ADDRESS_LEN + 1]; /**< application mac address */ +} stc_app_value_s; + +typedef struct { + pid_t pid; + stc_app_state_e ground; +} stc_proc_value_s; + +typedef struct { int (*initialize_plugin) (stc_manager_stop_cb stop_cb); int (*deinitialize_plugin) (void); diff --git a/plugin/pcap/stc-plugin-pcap.h b/include/stc-plugin-iface-pcap.h similarity index 100% rename from plugin/pcap/stc-plugin-pcap.h rename to include/stc-plugin-iface-pcap.h diff --git a/plugin/procfs/stc-plugin-procfs.h b/include/stc-plugin-iface-procfs.h similarity index 96% rename from plugin/procfs/stc-plugin-procfs.h rename to include/stc-plugin-iface-procfs.h index 53635ca..0dc7f4b 100644 --- a/plugin/procfs/stc-plugin-procfs.h +++ b/include/stc-plugin-iface-procfs.h @@ -18,8 +18,7 @@ #define __STC_PLUGIN_PROCFS_H__ #include -#include "stc-error.h" -#include "stc-manager.h" +#include "stc.h" typedef struct { int (*initialize_plugin) (void); diff --git a/plugin/tether/stc-plugin-tether.h b/include/stc-plugin-iface-tether.h similarity index 97% rename from plugin/tether/stc-plugin-tether.h rename to include/stc-plugin-iface-tether.h index f021516..d4dbcad 100644 --- a/plugin/tether/stc-plugin-tether.h +++ b/include/stc-plugin-iface-tether.h @@ -19,8 +19,7 @@ #include #include -#include "stc-error.h" -#include "stc-manager.h" +#include "stc.h" #define TETHERING_SERVICE_INTERFACE "org.tizen.tethering" #define SIGNAL_NAME_DHCP_STATUS "dhcp_status" diff --git a/include/stc-manager-plugin-monitor.h b/include/stc-plugin-monitor.h similarity index 96% rename from include/stc-manager-plugin-monitor.h rename to include/stc-plugin-monitor.h index 76a65bd..cb9257e 100644 --- a/include/stc-manager-plugin-monitor.h +++ b/include/stc-plugin-monitor.h @@ -19,7 +19,8 @@ #define STC_PLUGIN_MONITOR_FILEPATH "/usr/lib/stc-plugin-monitor.so" -#include "stc-plugin-monitor.h" +#include "db/table-restrictions.h" +#include "stc-plugin-iface-monitor.h" int stc_plugin_monitor_init(stc_manager_stop_cb stop_cb); int stc_plugin_monitor_deinit(void); diff --git a/include/stc-manager-plugin-pcap.h b/include/stc-plugin-pcap.h similarity index 97% rename from include/stc-manager-plugin-pcap.h rename to include/stc-plugin-pcap.h index 7c8fe7e..85ad9d6 100644 --- a/include/stc-manager-plugin-pcap.h +++ b/include/stc-plugin-pcap.h @@ -19,7 +19,7 @@ #define STC_PLUGIN_PCAP_FILEPATH "/usr/lib/stc-plugin-pcap.so" -#include "stc-plugin-pcap.h" +#include "stc-plugin-iface-pcap.h" int stc_plugin_pcap_init(void); int stc_plugin_pcap_deinit(void); diff --git a/include/stc-manager-plugin-procfs.h b/include/stc-plugin-procfs.h similarity index 96% rename from include/stc-manager-plugin-procfs.h rename to include/stc-plugin-procfs.h index 9e7b565..8320852 100644 --- a/include/stc-manager-plugin-procfs.h +++ b/include/stc-plugin-procfs.h @@ -19,7 +19,7 @@ #define STC_PLUGIN_PROCFS_FILEPATH "/usr/lib/stc-plugin-procfs.so" -#include "stc-plugin-procfs.h" +#include "stc-plugin-iface-procfs.h" int stc_plugin_procfs_init(void); int stc_plugin_procfs_deinit(void); diff --git a/include/stc-manager-plugin-tether.h b/include/stc-plugin-tether.h similarity index 96% rename from include/stc-manager-plugin-tether.h rename to include/stc-plugin-tether.h index 8fd874b..14bfb8c 100644 --- a/include/stc-manager-plugin-tether.h +++ b/include/stc-plugin-tether.h @@ -19,7 +19,7 @@ #define STC_PLUGIN_TETHER_FILEPATH "/usr/lib/stc-plugin-tether.so" -#include "stc-plugin-tether.h" +#include "stc-plugin-iface-tether.h" int stc_plugin_tether_init(void); int stc_plugin_tether_deinit(void); diff --git a/include/stc-restriction.h b/include/stc-restriction.h index 1ee0255..63de665 100644 --- a/include/stc-restriction.h +++ b/include/stc-restriction.h @@ -18,10 +18,10 @@ #define __STC_RESTRICTION_H__ #include -#include "stc-manager.h" -#include "stc-manager-gdbus.h" -#include "table-restrictions.h" -#include "transmission.h" +#include "stc.h" +#include "stc-gdbus.h" +#include "db/table-restrictions.h" +#include "stc-transmission.h" /***************************************************************************** * Macros and Typedefs diff --git a/include/stc-statistics.h b/include/stc-statistics.h index a76607e..d619faa 100644 --- a/include/stc-statistics.h +++ b/include/stc-statistics.h @@ -18,8 +18,8 @@ #define __STC_STATISTICS_H__ #include -#include "stc-manager.h" -#include "stc-manager-gdbus.h" +#include "stc.h" +#include "stc-gdbus.h" /***************************************************************************** * Macros and Typedefs diff --git a/include/transmission.h b/include/stc-transmission.h similarity index 100% rename from include/transmission.h rename to include/stc-transmission.h diff --git a/manager/helper/helper-inotify.h b/include/stc-util-inotify.h similarity index 100% rename from manager/helper/helper-inotify.h rename to include/stc-util-inotify.h diff --git a/include/stc-manager-util.h b/include/stc-util.h similarity index 100% rename from include/stc-manager-util.h rename to include/stc-util.h diff --git a/include/stc-manager.h b/include/stc.h similarity index 99% rename from include/stc-manager.h rename to include/stc.h index cfa2404..7d03d58 100644 --- a/include/stc-manager.h +++ b/include/stc.h @@ -18,7 +18,7 @@ #define __STC_MANAGER_H__ #include "stc-error.h" -#include "stc-manager-util.h" +#include "stc-util.h" #define NET_RELEASE_AGENT "/usr/bin/net-cls-release" #define NET_CLS_SUBSYS "net_cls" diff --git a/manager/database/db-common.c b/manager/database/db-common.c index 3519710..f8c217d 100644 --- a/manager/database/db-common.c +++ b/manager/database/db-common.c @@ -18,11 +18,11 @@ #include #include "stc-db.h" +#include "db/table-statistics.h" +#include "db/table-restrictions.h" +#include "db/table-counters.h" +#include "db/table-firewall.h" #include "db-internal.h" -#include "table-statistics.h" -#include "table-restrictions.h" -#include "table-counters.h" -#include "table-firewall.h" #define SQLITE_BUSY_TIMEOUT 500000 diff --git a/manager/database/db-guard.c b/manager/database/db-guard.c index 54b7fc5..43a4297 100644 --- a/manager/database/db-guard.c +++ b/manager/database/db-guard.c @@ -18,7 +18,7 @@ #include #include "stc-db.h" -#include "table-statistics.h" +#include "db/table-statistics.h" #define VCONF_KEY_DB_ENTRIES_COUNT "db/stc-manager/datausage_timer" #define ENTRY_SIZE 128 diff --git a/manager/database/table-counters.c b/manager/database/table-counters.c index c4c0db1..e95fa68 100644 --- a/manager/database/table-counters.c +++ b/manager/database/table-counters.c @@ -21,8 +21,8 @@ */ #include "stc-db.h" +#include "db/table-counters.h" #include "db-internal.h" -#include "table-counters.h" #define DELETE_COUNTER "DELETE FROM counters WHERE restriction_id=?" diff --git a/manager/database/table-firewall.c b/manager/database/table-firewall.c index 995e8cd..1d82e2f 100644 --- a/manager/database/table-firewall.c +++ b/manager/database/table-firewall.c @@ -21,8 +21,8 @@ */ #include "stc-db.h" +#include "db/table-firewall.h" #include "db-internal.h" -#include "table-firewall.h" #define BUF_SIZE_FOR_IP 64 diff --git a/manager/database/table-restrictions.c b/manager/database/table-restrictions.c index 1466a65..dd71443 100644 --- a/manager/database/table-restrictions.c +++ b/manager/database/table-restrictions.c @@ -21,8 +21,8 @@ */ #include "stc-db.h" +#include "db/table-restrictions.h" #include "db-internal.h" -#include "table-restrictions.h" /* DELETE statements */ #define DELETE_RESTRICTIONS "DELETE FROM restrictions " \ diff --git a/manager/database/table-statistics.c b/manager/database/table-statistics.c index 2bfff70..ab565d2 100644 --- a/manager/database/table-statistics.c +++ b/manager/database/table-statistics.c @@ -20,8 +20,9 @@ * @file table-statistics.c */ +#include "stc.h" #include "stc-db.h" -#include "table-statistics.h" +#include "db/table-statistics.h" #include "db-internal.h" /* DELETE statements */ diff --git a/manager/helper/helper-cgroup.h b/manager/helper/helper-cgroup.h index 73abd40..94030a8 100644 --- a/manager/helper/helper-cgroup.h +++ b/manager/helper/helper-cgroup.h @@ -25,7 +25,7 @@ #include #include -#include "stc-manager.h" +#include "stc.h" #include "helper-file.h" #define DEFAULT_CGROUP "/sys/fs/cgroup" diff --git a/manager/helper/helper-file.h b/manager/helper/helper-file.h index b45a668..5a329dc 100644 --- a/manager/helper/helper-file.h +++ b/manager/helper/helper-file.h @@ -23,7 +23,7 @@ #include #include -#include "stc-manager.h" +#include "stc.h" /** * @desc write string to the file diff --git a/manager/helper/helper-firewall.c b/manager/helper/helper-firewall.c index a9b0817..dc26e9e 100644 --- a/manager/helper/helper-firewall.c +++ b/manager/helper/helper-firewall.c @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "stc-manager-gdbus.h" +#include "stc-gdbus.h" #include "helper-firewall.h" #define STC_FIREWALL_DBUS_SERVICE "net.stc.iptables" diff --git a/manager/helper/helper-firewall.h b/manager/helper/helper-firewall.h index 4966769..1c6b3e0 100644 --- a/manager/helper/helper-firewall.h +++ b/manager/helper/helper-firewall.h @@ -19,8 +19,7 @@ #include -#include "stc-manager.h" -#include "stc-error.h" +#include "stc.h" #define FIREWALL_CHAIN_TARGET_IN "INPUT" #define FIREWALL_CHAIN_TARGET_OUT "OUTPUT" diff --git a/manager/helper/helper-iptables.c b/manager/helper/helper-iptables.c index ffffd21..feaf9b3 100644 --- a/manager/helper/helper-iptables.c +++ b/manager/helper/helper-iptables.c @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "stc-manager-gdbus.h" +#include "stc-gdbus.h" #include "helper-iptables.h" #define STC_IPTABLES_DBUS_SERVICE "net.stc.iptables" diff --git a/manager/helper/helper-iptables.h b/manager/helper/helper-iptables.h index f9f069a..b4bdb59 100644 --- a/manager/helper/helper-iptables.h +++ b/manager/helper/helper-iptables.h @@ -18,8 +18,7 @@ #define __STC_HELPER_IPTABLES_H__ #include -#include "stc-manager.h" -#include "stc-error.h" +#include "stc.h" #define STC_IN_CHAIN "STC_IN" #define STC_OUT_CHAIN "STC_OUT" diff --git a/manager/helper/helper-net-cls.c b/manager/helper/helper-net-cls.c index 88041cc..6ae6bac 100644 --- a/manager/helper/helper-net-cls.c +++ b/manager/helper/helper-net-cls.c @@ -21,7 +21,7 @@ #include #include "helper-cgroup.h" -#include "counter.h" +#include "stc-counter.h" #include "stc-db.h" #include "helper-file.h" #include "helper-net-cls.h" diff --git a/manager/helper/helper-net-cls.h b/manager/helper/helper-net-cls.h index d27a5b2..58d3cfd 100644 --- a/manager/helper/helper-net-cls.h +++ b/manager/helper/helper-net-cls.h @@ -21,7 +21,7 @@ #include #include -#include "stc-manager.h" +#include "stc.h" #define PATH_TO_NET_CGROUP_DIR CGROUP_NETWORK diff --git a/manager/helper/helper-nfacct-rule.c b/manager/helper/helper-nfacct-rule.c index 5694d14..109e385 100644 --- a/manager/helper/helper-nfacct-rule.c +++ b/manager/helper/helper-nfacct-rule.c @@ -24,7 +24,7 @@ #include #include -#include "counter.h" +#include "stc-counter.h" #include "helper-nfacct-rule.h" #include "helper-iptables.h" diff --git a/manager/helper/helper-nl.h b/manager/helper/helper-nl.h index 3df7da1..a34a589 100644 --- a/manager/helper/helper-nl.h +++ b/manager/helper/helper-nl.h @@ -26,7 +26,7 @@ #include #include -#include "stc-manager.h" +#include "stc.h" #define NLA_BUF_MAX 65560 /*(65 * 1024) - used in tc_common, we'll do the same */ diff --git a/manager/helper/helper-procfs.c b/manager/helper/helper-procfs.c index a0d9f0e..837e1d9 100644 --- a/manager/helper/helper-procfs.c +++ b/manager/helper/helper-procfs.c @@ -34,8 +34,7 @@ #include #include -#include "stc-error.h" -#include "stc-manager-util.h" +#include "stc.h" #include "helper-procfs.h" #define USRAPPS "/usr/apps/" diff --git a/manager/stc-firewall.c b/manager/stcmgr-firewall.c similarity index 98% rename from manager/stc-firewall.c rename to manager/stcmgr-firewall.c index c13d406..a29e17c 100644 --- a/manager/stc-firewall.c +++ b/manager/stcmgr-firewall.c @@ -15,11 +15,11 @@ */ #include "stc-db.h" -#include "table-firewall.h" -#include "helper-firewall.h" #include "stc-firewall.h" -#include "stc-manager-gdbus.h" -#include "stc-manager-plugin-firewall.h" +#include "db/table-firewall.h" +#include "helper-firewall.h" +#include "stc-gdbus.h" +#include "stc-plugin-firewall.h" #define FIREWALL_DBUS_ERROR_NAME "net.stc.firewall.Error.Failed" diff --git a/manager/stc-manager-gdbus.c b/manager/stcmgr-gdbus.c similarity index 98% rename from manager/stc-manager-gdbus.c rename to manager/stcmgr-gdbus.c index a5cb068..c564073 100644 --- a/manager/stc-manager-gdbus.c +++ b/manager/stcmgr-gdbus.c @@ -14,18 +14,17 @@ * limitations under the License. */ -#include "stc-manager-gdbus.h" -#include "stc-manager.h" +#include "stc.h" +#include "stc-gdbus.h" +#include "helper-iptables.h" #include "stc-statistics.h" #include "stc-restriction.h" #include "stc-firewall.h" #include "stc-pcap.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 "stc-manager-plugin-firewall.h" -#include "helper-iptables.h" +#include "stc-plugin-appstatus.h" +#include "stc-plugin-procfs.h" +#include "stc-plugin-monitor.h" +#include "stc-plugin-firewall.h" #define MANAGER_DBUS_ERROR_NAME "net.stc.manager.Error.Failed" diff --git a/manager/stc-pcap.c b/manager/stcmgr-pcap.c similarity index 99% rename from manager/stc-pcap.c rename to manager/stcmgr-pcap.c index 29f5037..44de950 100644 --- a/manager/stc-pcap.c +++ b/manager/stcmgr-pcap.c @@ -16,7 +16,7 @@ #include "stc-db.h" #include "stc-pcap.h" -#include "stc-manager-plugin-pcap.h" +#include "stc-plugin-pcap.h" #define PCAP_DBUS_ERROR_NAME "net.stc.pcap.Error.Failed" diff --git a/manager/stc-manager-plugin-appstatus.c b/manager/stcmgr-plugin-appstatus.c similarity index 97% rename from manager/stc-manager-plugin-appstatus.c rename to manager/stcmgr-plugin-appstatus.c index a79bc93..48ac87a 100644 --- a/manager/stc-manager-plugin-appstatus.c +++ b/manager/stcmgr-plugin-appstatus.c @@ -16,8 +16,8 @@ #include -#include "stc-manager.h" -#include "stc-manager-plugin-appstatus.h" +#include "stc.h" +#include "stc-plugin-appstatus.h" static gboolean stc_plugin_enabled = FALSE; static void *handle_plugin; diff --git a/manager/stc-manager-plugin-exception.c b/manager/stcmgr-plugin-exception.c similarity index 97% rename from manager/stc-manager-plugin-exception.c rename to manager/stcmgr-plugin-exception.c index ad1c092..3f8e3e1 100644 --- a/manager/stc-manager-plugin-exception.c +++ b/manager/stcmgr-plugin-exception.c @@ -16,8 +16,8 @@ #include -#include "stc-manager.h" -#include "stc-manager-plugin-exception.h" +#include "stc.h" +#include "stc-plugin-exception.h" static gboolean stc_plugin_enabled = FALSE; static void *handle_plugin; diff --git a/manager/stc-manager-plugin-firewall.c b/manager/stcmgr-plugin-firewall.c similarity index 98% rename from manager/stc-manager-plugin-firewall.c rename to manager/stcmgr-plugin-firewall.c index adb87fb..026529e 100644 --- a/manager/stc-manager-plugin-firewall.c +++ b/manager/stcmgr-plugin-firewall.c @@ -16,8 +16,8 @@ #include -#include "stc-manager.h" -#include "stc-manager-plugin-firewall.h" +#include "stc.h" +#include "stc-plugin-firewall.h" static gboolean stc_plugin_enabled = FALSE; static void *handle_plugin; diff --git a/manager/stc-manager-plugin-monitor.c b/manager/stcmgr-plugin-monitor.c similarity index 98% rename from manager/stc-manager-plugin-monitor.c rename to manager/stcmgr-plugin-monitor.c index efdf759..0ca5f48 100644 --- a/manager/stc-manager-plugin-monitor.c +++ b/manager/stcmgr-plugin-monitor.c @@ -16,8 +16,8 @@ #include -#include "stc-manager.h" -#include "stc-manager-plugin-monitor.h" +#include "stc.h" +#include "stc-plugin-monitor.h" static gboolean stc_plugin_enabled = FALSE; static void *handle_plugin; diff --git a/manager/stc-manager-plugin-pcap.c b/manager/stcmgr-plugin-pcap.c similarity index 98% rename from manager/stc-manager-plugin-pcap.c rename to manager/stcmgr-plugin-pcap.c index 8134391..9c69c00 100644 --- a/manager/stc-manager-plugin-pcap.c +++ b/manager/stcmgr-plugin-pcap.c @@ -16,8 +16,8 @@ #include -#include "stc-manager.h" -#include "stc-manager-plugin-pcap.h" +#include "stc.h" +#include "stc-plugin-pcap.h" static gboolean stc_plugin_enabled = FALSE; static void *handle_plugin; diff --git a/manager/stc-manager-plugin-procfs.c b/manager/stcmgr-plugin-procfs.c similarity index 97% rename from manager/stc-manager-plugin-procfs.c rename to manager/stcmgr-plugin-procfs.c index 1067f5e..0fab8bb 100644 --- a/manager/stc-manager-plugin-procfs.c +++ b/manager/stcmgr-plugin-procfs.c @@ -16,8 +16,8 @@ #include -#include "stc-manager.h" -#include "stc-manager-plugin-procfs.h" +#include "stc.h" +#include "stc-plugin-procfs.h" static gboolean stc_plugin_enabled = FALSE; static void *handle_plugin; diff --git a/manager/stc-manager-plugin-tether.c b/manager/stcmgr-plugin-tether.c similarity index 97% rename from manager/stc-manager-plugin-tether.c rename to manager/stcmgr-plugin-tether.c index 4c5e528..48d0609 100644 --- a/manager/stc-manager-plugin-tether.c +++ b/manager/stcmgr-plugin-tether.c @@ -16,8 +16,8 @@ #include -#include "stc-manager.h" -#include "stc-manager-plugin-tether.h" +#include "stc.h" +#include "stc-plugin-tether.h" static gboolean stc_tether_plugin_enabled = FALSE; static void *tether_plugin_handle; diff --git a/manager/stc-restriction.c b/manager/stcmgr-restriction.c similarity index 99% rename from manager/stc-restriction.c rename to manager/stcmgr-restriction.c index 47bfee8..c8e8249 100644 --- a/manager/stc-restriction.c +++ b/manager/stcmgr-restriction.c @@ -15,10 +15,10 @@ */ #include "stc-db.h" -#include "table-restrictions.h" #include "stc-restriction.h" -#include "stc-manager-gdbus.h" -#include "stc-manager-plugin-monitor.h" +#include "db/table-restrictions.h" +#include "stc-gdbus.h" +#include "stc-plugin-monitor.h" #define RESTRICTION_DBUS_ERROR_NAME "net.stc.restriction.Error.Failed" diff --git a/manager/stc-statistics.c b/manager/stcmgr-statistics.c similarity index 99% rename from manager/stc-statistics.c rename to manager/stcmgr-statistics.c index ee61443..7ebdda5 100644 --- a/manager/stc-statistics.c +++ b/manager/stcmgr-statistics.c @@ -15,9 +15,9 @@ */ #include "stc-db.h" -#include "table-statistics.h" #include "stc-statistics.h" -#include "stc-manager-gdbus.h" +#include "db/table-statistics.h" +#include "stc-gdbus.h" #define STATISTICS_DBUS_ERROR_NAME "net.stc.statistics.Error.Failed" diff --git a/manager/stc-manager.c b/manager/stcmgr.c similarity index 93% rename from manager/stc-manager.c rename to manager/stcmgr.c index 0011c97..66bb119 100644 --- a/manager/stc-manager.c +++ b/manager/stcmgr.c @@ -17,23 +17,23 @@ #include #include #include -#include "stc-manager.h" -#include "stc-manager-gdbus.h" +#include "stc.h" +#include "stc-gdbus.h" #include "stc-db.h" -#include "counter.h" -#include "table-restrictions.h" +#include "stc-counter.h" +#include "stc-util-inotify.h" +#include "db/table-restrictions.h" #include "helper-cgroup.h" #include "helper-nfacct-rule.h" #include "helper-iptables.h" -#include "helper-inotify.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" -#include "stc-manager-plugin-firewall.h" +#include "stc-plugin-appstatus.h" +#include "stc-plugin-exception.h" +#include "stc-plugin-procfs.h" +#include "stc-plugin-tether.h" +#include "stc-plugin-pcap.h" +#include "stc-plugin-monitor.h" +#include "stc-plugin-firewall.h" #define BUF_SIZE_FOR_ERR 100 diff --git a/manager/helper/helper-inotify.c b/manager/util/stcutil-inotify.c similarity index 98% rename from manager/helper/helper-inotify.c rename to manager/util/stcutil-inotify.c index 1283cc6..d2a6d32 100644 --- a/manager/helper/helper-inotify.c +++ b/manager/util/stcutil-inotify.c @@ -16,8 +16,8 @@ #include -#include "helper-inotify.h" -#include "stc-manager-util.h" +#include "stc-util.h" +#include "stc-util-inotify.h" typedef struct { GIOChannel *channel; diff --git a/manager/util/stc-manager-util.c b/manager/util/stcutil.c similarity index 99% rename from manager/util/stc-manager-util.c rename to manager/util/stcutil.c index 3e77610..1f608b2 100644 --- a/manager/util/stc-manager-util.c +++ b/manager/util/stcutil.c @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "stc-manager-util.h" +#include "stc-util.h" typedef struct { int state; diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index c19c312..5763874 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -150,7 +150,7 @@ mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d cp res/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -cp res/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service +cp res/dbus/net.stc.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service #OS Upgrade mkdir -p %{buildroot}%{upgrade_script_path} diff --git a/plugin/appstatus/CMakeLists.txt b/plugin/appstatus/CMakeLists.txt index 0a3acf7..30b45f3 100644 --- a/plugin/appstatus/CMakeLists.txt +++ b/plugin/appstatus/CMakeLists.txt @@ -23,7 +23,7 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2") ADD_DEFINITIONS("-DUSE_DLOG") SET(SRCS_PLUGIN - stc-plugin-appstatus.c + stcplugin-appstatus.c ) # library build diff --git a/plugin/appstatus/stc-plugin-appstatus.c b/plugin/appstatus/stcplugin-appstatus.c similarity index 99% rename from plugin/appstatus/stc-plugin-appstatus.c rename to plugin/appstatus/stcplugin-appstatus.c index 7036271..7aa77b2 100644 --- a/plugin/appstatus/stc-plugin-appstatus.c +++ b/plugin/appstatus/stcplugin-appstatus.c @@ -24,7 +24,7 @@ #include #include -#include "stc-plugin-appstatus.h" +#include "stc-plugin-iface-appstatus.h" //LCOV_EXCL_START #define AUL_APP_STATUS_DBUS_PATH "/Org/Tizen/Aul/AppStatus" diff --git a/plugin/exception/CMakeLists.txt b/plugin/exception/CMakeLists.txt index 06b6d93..734f587 100644 --- a/plugin/exception/CMakeLists.txt +++ b/plugin/exception/CMakeLists.txt @@ -22,7 +22,7 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2") ADD_DEFINITIONS("-DUSE_DLOG") SET(SRCS_PLUGIN - stc-plugin-exception.c + stcplugin-exception.c ) # library build diff --git a/plugin/exception/stc-plugin-exception.c b/plugin/exception/stcplugin-exception.c similarity index 99% rename from plugin/exception/stc-plugin-exception.c rename to plugin/exception/stcplugin-exception.c index ec4e2fd..578cfa7 100644 --- a/plugin/exception/stc-plugin-exception.c +++ b/plugin/exception/stcplugin-exception.c @@ -25,7 +25,8 @@ #include #include -#include "stc-plugin-exception.h" +#include "stc.h" +#include "stc-plugin-iface-exception.h" //LCOV_EXCL_START #define EXE_TYPE_APPLICATION "app" diff --git a/plugin/firewall/CMakeLists.txt b/plugin/firewall/CMakeLists.txt index 2576f2d..d09e512 100644 --- a/plugin/firewall/CMakeLists.txt +++ b/plugin/firewall/CMakeLists.txt @@ -21,7 +21,7 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2") ADD_DEFINITIONS("-DUSE_DLOG") SET(SRCS_PLUGIN - stc-plugin-firewall.c + stcplugin-firewall.c ) # library build diff --git a/plugin/firewall/stc-plugin-firewall.c b/plugin/firewall/stcplugin-firewall.c similarity index 99% rename from plugin/firewall/stc-plugin-firewall.c rename to plugin/firewall/stcplugin-firewall.c index 6a497cc..a108a76 100644 --- a/plugin/firewall/stc-plugin-firewall.c +++ b/plugin/firewall/stcplugin-firewall.c @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "stc-plugin-firewall.h" -#include "table-firewall.h" +#include "stc.h" +#include "stc-plugin-iface-firewall.h" +#include "db/table-firewall.h" #include "helper-firewall.h" #define LOCK_NAME "admin" diff --git a/plugin/monitor/CMakeLists.txt b/plugin/monitor/CMakeLists.txt index c05a448..ce792eb 100644 --- a/plugin/monitor/CMakeLists.txt +++ b/plugin/monitor/CMakeLists.txt @@ -30,13 +30,13 @@ 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 + stcplugin-monitor.c + stcplugin-monitor-proc.c + stcplugin-monitor-connection.c + stcplugin-monitor-rstn.c + stcplugin-monitor-app.c + stcplugin-monitor-ipt.c + stcplugin-monitor-time.c ) # library build diff --git a/plugin/monitor/stc-plugin-monitor-app.c b/plugin/monitor/stcplugin-monitor-app.c similarity index 98% rename from plugin/monitor/stc-plugin-monitor-app.c rename to plugin/monitor/stcplugin-monitor-app.c index 4b5703b..1c4d997 100644 --- a/plugin/monitor/stc-plugin-monitor-app.c +++ b/plugin/monitor/stcplugin-monitor-app.c @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "stcplugin-monitor-app.h" +#include "stc.h" #include "stc-db.h" -#include "counter.h" -#include "stc-manager.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 "stc-counter.h" +#include "stc-plugin-tether.h" +#include "db/table-statistics.h" #include "helper-net-cls.h" -#include "stc-manager-plugin-tether.h" +#include "stc-plugin-iface-monitor.h" +#include "stcplugin-monitor-rstn.h" +#include "stcplugin-monitor-proc.h" +#include "stcplugin-monitor-ipt.h" static void __print_app(gpointer key, gpointer value, gpointer data) diff --git a/plugin/monitor/stc-plugin-monitor-app.h b/plugin/monitor/stcplugin-monitor-app.h similarity index 76% rename from plugin/monitor/stc-plugin-monitor-app.h rename to plugin/monitor/stcplugin-monitor-app.h index cfd623f..81ac9b1 100644 --- a/plugin/monitor/stc-plugin-monitor-app.h +++ b/plugin/monitor/stcplugin-monitor-app.h @@ -19,26 +19,13 @@ #include -#include "stc-error.h" -#include "stc-manager.h" -#include "stc-plugin-monitor-context.h" -#include "stc-plugin-monitor-connection.h" +#include "stc.h" +#include "stc-plugin-iface-monitor.h" +#include "stcplugin-monitor-context.h" +#include "stcplugin-monitor-connection.h" -#define MAC_ADDRESS_LEN 18 #define SUBSCRIBERID_NONE "none_subid" -typedef struct { - uint32_t classid; /**< classid for a package */ - gchar *pkg_id; /**< package id */ - gchar *app_id; /**< application id */ - stc_app_type_e type; /**< type of application */ - stc_app_state_e state; - stc_data_counter_s data_usage; - stc_data_counter_s counter; - GHashTable *processes; /**< applications instances */ - char mac[MAC_ADDRESS_LEN+1]; /**< application mac address */ -} stc_app_value_s; - stc_error_e stc_plugin_monitor_app_add(uint32_t classid, const char *app_id, diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stcplugin-monitor-connection.c similarity index 99% rename from plugin/monitor/stc-plugin-monitor-connection.c rename to plugin/monitor/stcplugin-monitor-connection.c index 1f03737..7dc4eb5 100644 --- a/plugin/monitor/stc-plugin-monitor-connection.c +++ b/plugin/monitor/stcplugin-monitor-connection.c @@ -17,11 +17,11 @@ #include #include +#include "stc-gdbus.h" #include "stc-firewall.h" -#include "stc-manager-gdbus.h" +#include "stc-plugin-firewall.h" #include "stc-plugin-monitor.h" -#include "stc-plugin-monitor-connection.h" -#include "stc-manager-plugin-firewall.h" +#include "stcplugin-monitor-connection.h" /* connman service dbus details */ #define CONNMAN_SERVICE "net.connman" diff --git a/plugin/monitor/stc-plugin-monitor-connection.h b/plugin/monitor/stcplugin-monitor-connection.h similarity index 95% rename from plugin/monitor/stc-plugin-monitor-connection.h rename to plugin/monitor/stcplugin-monitor-connection.h index 6454b2d..e8e812b 100644 --- a/plugin/monitor/stc-plugin-monitor-connection.h +++ b/plugin/monitor/stcplugin-monitor-connection.h @@ -18,9 +18,7 @@ #define __STC_PLUGIN_MONITOR_CONNECTION_H__ #include -#include "stc-error.h" -#include "stc-manager.h" -#include "stc-manager-util.h" +#include "stc.h" #define IMSI_LENGTH 16 #define SHA256_DIGEST_LENGTH 32 diff --git a/plugin/monitor/stc-plugin-monitor-context.h b/plugin/monitor/stcplugin-monitor-context.h similarity index 98% rename from plugin/monitor/stc-plugin-monitor-context.h rename to plugin/monitor/stcplugin-monitor-context.h index 3e8f324..76c8f04 100644 --- a/plugin/monitor/stc-plugin-monitor-context.h +++ b/plugin/monitor/stcplugin-monitor-context.h @@ -17,7 +17,7 @@ #ifndef __STC_PLUGIN_MONITOR_CONTEXT_H__ #define __STC_PLUGIN_MONITOR_CONTEXT_H__ -#include "stc-manager.h" +#include "stc.h" typedef struct { time_t now; diff --git a/plugin/monitor/stc-plugin-monitor-ipt.c b/plugin/monitor/stcplugin-monitor-ipt.c similarity index 98% rename from plugin/monitor/stc-plugin-monitor-ipt.c rename to plugin/monitor/stcplugin-monitor-ipt.c index f9df3fb..d846ce7 100644 --- a/plugin/monitor/stc-plugin-monitor-ipt.c +++ b/plugin/monitor/stcplugin-monitor-ipt.c @@ -14,8 +14,8 @@ * limitations under the License. */ -#include "stc-plugin-monitor-ipt.h" -#include "stc-plugin-monitor-context.h" +#include "stcplugin-monitor-ipt.h" +#include "stcplugin-monitor-context.h" static nfacct_rule_jump __get_jump_by_intend(struct nfacct_rule *counter) { diff --git a/plugin/monitor/stc-plugin-monitor-ipt.h b/plugin/monitor/stcplugin-monitor-ipt.h similarity index 100% rename from plugin/monitor/stc-plugin-monitor-ipt.h rename to plugin/monitor/stcplugin-monitor-ipt.h diff --git a/plugin/monitor/stc-plugin-monitor-proc.c b/plugin/monitor/stcplugin-monitor-proc.c similarity index 97% rename from plugin/monitor/stc-plugin-monitor-proc.c rename to plugin/monitor/stcplugin-monitor-proc.c index b4564c0..7545c48 100644 --- a/plugin/monitor/stc-plugin-monitor-proc.c +++ b/plugin/monitor/stcplugin-monitor-proc.c @@ -14,10 +14,13 @@ * limitations under the License. */ -#include "stc-plugin-monitor.h" -#include "stc-plugin-monitor-proc.h" -#include "stc-plugin-monitor-connection.h" #include "helper-net-cls.h" +#include "db/table-restrictions.h" +#include "stc-plugin-iface-monitor.h" +#include "stcplugin-monitor-proc.h" +#include "stcplugin-monitor-app.h" +#include "stcplugin-monitor-rstn.h" +#include "stcplugin-monitor-connection.h" static void __print_proc(gpointer key, gpointer value, gpointer data) diff --git a/plugin/monitor/stc-plugin-monitor-proc.h b/plugin/monitor/stcplugin-monitor-proc.h similarity index 91% rename from plugin/monitor/stc-plugin-monitor-proc.h rename to plugin/monitor/stcplugin-monitor-proc.h index 22bb06a..8ce67e6 100644 --- a/plugin/monitor/stc-plugin-monitor-proc.h +++ b/plugin/monitor/stcplugin-monitor-proc.h @@ -19,13 +19,8 @@ #include -#include "stc-error.h" -#include "stc-manager.h" - -typedef struct { - pid_t pid; - stc_app_state_e ground; -} stc_proc_value_s; +#include "stc.h" +#include "stc-plugin-iface-monitor.h" typedef struct { pid_t pid; diff --git a/plugin/monitor/stc-plugin-monitor-rstn.c b/plugin/monitor/stcplugin-monitor-rstn.c similarity index 99% rename from plugin/monitor/stc-plugin-monitor-rstn.c rename to plugin/monitor/stcplugin-monitor-rstn.c index 5398c1d..a5092c6 100644 --- a/plugin/monitor/stc-plugin-monitor-rstn.c +++ b/plugin/monitor/stcplugin-monitor-rstn.c @@ -20,16 +20,16 @@ #include #include -#include "counter.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" +#include "stc-counter.h" +#include "stc-plugin-tether.h" +#include "db/table-counters.h" +#include "db/table-restrictions.h" +#include "db/table-statistics.h" #include "helper-net-cls.h" -#include "stc-manager-plugin-tether.h" +#include "stc-plugin-iface-monitor.h" +#include "stcplugin-monitor-rstn.h" +#include "stcplugin-monitor-ipt.h" +#include "stcplugin-monitor-time.h" static void __print_rstn(stc_rstn_data_s *rstn_data) { diff --git a/plugin/monitor/stc-plugin-monitor-rstn.h b/plugin/monitor/stcplugin-monitor-rstn.h similarity index 94% rename from plugin/monitor/stc-plugin-monitor-rstn.h rename to plugin/monitor/stcplugin-monitor-rstn.h index 41b1e80..24f41a6 100644 --- a/plugin/monitor/stc-plugin-monitor-rstn.h +++ b/plugin/monitor/stcplugin-monitor-rstn.h @@ -19,12 +19,11 @@ #include -#include "stc-error.h" -#include "stc-manager.h" -#include "stc-plugin-monitor-context.h" -#include "stc-plugin-monitor-connection.h" +#include "stc.h" #include "stc-restriction.h" -#include "table-restrictions.h" +#include "db/table-restrictions.h" +#include "stcplugin-monitor-context.h" +#include "stcplugin-monitor-connection.h" #define GRANULARITY 10 diff --git a/plugin/monitor/stc-plugin-monitor-time.c b/plugin/monitor/stcplugin-monitor-time.c similarity index 100% rename from plugin/monitor/stc-plugin-monitor-time.c rename to plugin/monitor/stcplugin-monitor-time.c diff --git a/plugin/monitor/stc-plugin-monitor-time.h b/plugin/monitor/stcplugin-monitor-time.h similarity index 100% rename from plugin/monitor/stc-plugin-monitor-time.h rename to plugin/monitor/stcplugin-monitor-time.h diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stcplugin-monitor.c similarity index 96% rename from plugin/monitor/stc-plugin-monitor.c rename to plugin/monitor/stcplugin-monitor.c index 7922b88..c301683 100644 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stcplugin-monitor.c @@ -18,18 +18,22 @@ #include #include +#include "stc-counter.h" #include "helper-nl.h" #include "helper-nfacct-rule.h" #include "helper-net-cls.h" #include "helper-cgroup.h" #include "helper-iptables.h" -#include "counter.h" -#include "table-statistics.h" -#include "table-counters.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 "db/table-statistics.h" +#include "db/table-counters.h" +#include "stc-plugin-exception.h" +#include "stc-plugin-iface-monitor.h" +#include "stcplugin-monitor-connection.h" +#include "stcplugin-monitor-rstn.h" +#include "stcplugin-monitor-context.h" +#include "stcplugin-monitor-app.h" +#include "stcplugin-monitor-proc.h" + static stc_system_s *g_system = NULL; static stc_manager_stop_cb g_stop_cb = NULL; @@ -589,10 +593,10 @@ API stc_plugin_monitor_s stc_plugin_monitor = { 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, + .remove_application = + stc_plugin_monitor_app_remove, + .lookup_application = + stc_plugin_monitor_app_lookup, .add_restriction = stc_plugin_monitor_rstn_add, .remove_restriction = diff --git a/plugin/pcap/CMakeLists.txt b/plugin/pcap/CMakeLists.txt index 48c7dae..d388170 100644 --- a/plugin/pcap/CMakeLists.txt +++ b/plugin/pcap/CMakeLists.txt @@ -21,7 +21,7 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2") ADD_DEFINITIONS("-DUSE_DLOG") SET(SRCS_PLUGIN - stc-plugin-pcap.c + stcplugin-pcap.c ) # library build diff --git a/plugin/pcap/stc-plugin-pcap.c b/plugin/pcap/stcplugin-pcap.c similarity index 99% rename from plugin/pcap/stc-plugin-pcap.c rename to plugin/pcap/stcplugin-pcap.c index 018254c..13f5941 100644 --- a/plugin/pcap/stc-plugin-pcap.c +++ b/plugin/pcap/stcplugin-pcap.c @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "stcplugin-pcap.h" -#include "stc-plugin-pcap.h" -#include "stc-plugin-pcap-internal.h" +#include "stc-plugin-iface-pcap.h" #define ENCAPTYPE_ETHERNET 1 #define ENCAPTYPE_NFLOG 141 diff --git a/plugin/pcap/stc-plugin-pcap-internal.h b/plugin/pcap/stcplugin-pcap.h similarity index 99% rename from plugin/pcap/stc-plugin-pcap-internal.h rename to plugin/pcap/stcplugin-pcap.h index 2817613..0742b61 100644 --- a/plugin/pcap/stc-plugin-pcap-internal.h +++ b/plugin/pcap/stcplugin-pcap.h @@ -37,8 +37,7 @@ #include #include -#include "stc-error.h" -#include "stc-manager.h" +#include "stc.h" #define BUFF_SIZE_IP 16 #define BUFF_SIZE_IP6 46 diff --git a/plugin/procfs/CMakeLists.txt b/plugin/procfs/CMakeLists.txt index 6e529c1..c61b895 100644 --- a/plugin/procfs/CMakeLists.txt +++ b/plugin/procfs/CMakeLists.txt @@ -24,7 +24,7 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2") ADD_DEFINITIONS("-DUSE_DLOG") SET(SRCS_PLUGIN - stc-plugin-procfs.c + stcplugin-procfs.c ) # library build diff --git a/plugin/procfs/stc-plugin-procfs.c b/plugin/procfs/stcplugin-procfs.c similarity index 99% rename from plugin/procfs/stc-plugin-procfs.c rename to plugin/procfs/stcplugin-procfs.c index f54794a..f1255d0 100644 --- a/plugin/procfs/stc-plugin-procfs.c +++ b/plugin/procfs/stcplugin-procfs.c @@ -27,11 +27,11 @@ #include #include -#include "stc-plugin-procfs.h" +#include "stc-plugin-iface-procfs.h" #include "helper-net-cls.h" #include "helper-procfs.h" -#include "stc-manager-plugin-monitor.h" -#include "stc-manager-plugin-exception.h" +#include "stc-plugin-monitor.h" +#include "stc-plugin-exception.h" //LCOV_EXCL_START typedef struct { diff --git a/plugin/tether/CMakeLists.txt b/plugin/tether/CMakeLists.txt index 7918d2e..52d8970 100644 --- a/plugin/tether/CMakeLists.txt +++ b/plugin/tether/CMakeLists.txt @@ -23,7 +23,7 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2") ADD_DEFINITIONS("-DUSE_DLOG") SET(SRCS_PLUGIN - stc-plugin-tether.c + stcplugin-tether.c ) # library build diff --git a/plugin/tether/stc-plugin-tether.c b/plugin/tether/stcplugin-tether.c similarity index 98% rename from plugin/tether/stc-plugin-tether.c rename to plugin/tether/stcplugin-tether.c index 4b1e0b8..87e35c1 100644 --- a/plugin/tether/stc-plugin-tether.c +++ b/plugin/tether/stcplugin-tether.c @@ -14,7 +14,6 @@ * limitations under the License. */ -#include #include #include #include @@ -23,8 +22,9 @@ #include #include -#include "stc-plugin-tether.h" -#include "stc-manager-plugin-monitor.h" +#include "stc.h" +#include "stc-plugin-monitor.h" +#include "stc-plugin-iface-tether.h" static GSList *station_list = NULL; static GDBusConnection *connection = NULL; diff --git a/res/dbus/net.stc-manager.service b/res/dbus/net.stc.service similarity index 100% rename from res/dbus/net.stc-manager.service rename to res/dbus/net.stc.service diff --git a/tests/stcmgr.cpp b/tests/stcmgr.cpp deleted file mode 100644 index c3f401f..0000000 --- a/tests/stcmgr.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "stcmgr.h" diff --git a/tests/common.cpp b/tests/stctest-common.cpp similarity index 98% rename from tests/common.cpp rename to tests/stctest-common.cpp index 0f2b8d4..a663897 100644 --- a/tests/common.cpp +++ b/tests/stctest-common.cpp @@ -13,8 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "common.h" +#include "stctest-common.h" GMainLoop *MainLoop::m_mainLoop = NULL; guint MainLoop::m_timerId = 0; diff --git a/tests/common.h b/tests/stctest-common.h similarity index 100% rename from tests/common.h rename to tests/stctest-common.h diff --git a/tests/firewall.cpp b/tests/stctest-firewall.cpp similarity index 99% rename from tests/firewall.cpp rename to tests/stctest-firewall.cpp index 43f32e2..f99f86a 100644 --- a/tests/firewall.cpp +++ b/tests/stctest-firewall.cpp @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "stctest-firewall.h" #include #include #include #include #include - -#include "firewall.h" -#include "common.h" +#include "stctest-common.h" static void AsyncReadyCallback(GObject *source_object, GAsyncResult *res, gpointer user_data) diff --git a/tests/firewall.h b/tests/stctest-firewall.h similarity index 98% rename from tests/firewall.h rename to tests/stctest-firewall.h index f52e10b..b1e8fe2 100644 --- a/tests/firewall.h +++ b/tests/stctest-firewall.h @@ -19,8 +19,8 @@ #include #include -#include "stcmgr.h" -#include "gdbus.h" +#include "stctest.h" +#include "stctest-gdbus.h" #define FIREWALL_RULE_CHAIN "chain" #define FIREWALL_RULE_DIRECTION "direction" diff --git a/tests/gdbus.cpp b/tests/stctest-gdbus.cpp similarity index 99% rename from tests/gdbus.cpp rename to tests/stctest-gdbus.cpp index e882fea..05f6620 100644 --- a/tests/gdbus.cpp +++ b/tests/stctest-gdbus.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "stctest-gdbus.h" #include #include @@ -20,8 +21,6 @@ #include #include -#include "gdbus.h" - GDbus::GDbus() { this->m_pConnection = NULL; diff --git a/tests/gdbus.h b/tests/stctest-gdbus.h similarity index 99% rename from tests/gdbus.h rename to tests/stctest-gdbus.h index f545629..f0089a0 100644 --- a/tests/gdbus.h +++ b/tests/stctest-gdbus.h @@ -19,7 +19,7 @@ #include #include -#include "stcmgr.h" +#include "stctest.h" #define GMAINTIMEOUT 10000 #define DBUS_REPLY_TIMEOUT (120 * 1000) diff --git a/tests/unittest.cpp b/tests/stctest-main.cpp similarity index 98% rename from tests/unittest.cpp rename to tests/stctest-main.cpp index 41d57c4..c713126 100644 --- a/tests/unittest.cpp +++ b/tests/stctest-main.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "stctest-main.h" #include #include @@ -20,13 +21,11 @@ #include #include #include - -#include "unittest.h" -#include "restriction.h" -#include "statistics.h" -#include "manager.h" -#include "stc-manager.h" -#include "firewall.h" +#include "stc.h" +#include "stctest-restriction.h" +#include "stctest-statistics.h" +#include "stctest-manager.h" +#include "stctest-firewall.h" #define GTEST_MAC "1:c:e:b:00:da" diff --git a/tests/unittest.h b/tests/stctest-main.h similarity index 100% rename from tests/unittest.h rename to tests/stctest-main.h diff --git a/tests/manager.cpp b/tests/stctest-manager.cpp similarity index 97% rename from tests/manager.cpp rename to tests/stctest-manager.cpp index a99149c..69fda53 100644 --- a/tests/manager.cpp +++ b/tests/stctest-manager.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "stctest-manager.h" #include #include @@ -20,8 +21,6 @@ #include #include -#include "manager.h" - Manager::Manager() { Create(); diff --git a/tests/manager.h b/tests/stctest-manager.h similarity index 94% rename from tests/manager.h rename to tests/stctest-manager.h index 61b31ca..02eb323 100644 --- a/tests/manager.h +++ b/tests/stctest-manager.h @@ -16,8 +16,8 @@ #ifndef __STC_MGR_MANAGER_H__ #define __STC_MGR_MANAGER_H__ -#include "stcmgr.h" -#include "gdbus.h" +#include "stctest.h" +#include "stctest-gdbus.h" class Manager : public GDbus { private: diff --git a/tests/restriction.cpp b/tests/stctest-restriction.cpp similarity index 99% rename from tests/restriction.cpp rename to tests/stctest-restriction.cpp index 9a3bb4b..aee684f 100644 --- a/tests/restriction.cpp +++ b/tests/stctest-restriction.cpp @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "stctest-restriction.h" #include #include #include #include #include - -#include "restriction.h" -#include "common.h" +#include "stctest-common.h" static void AsyncReadyCallback(GObject *source_object, GAsyncResult *res, gpointer user_data) diff --git a/tests/restriction.h b/tests/stctest-restriction.h similarity index 97% rename from tests/restriction.h rename to tests/stctest-restriction.h index 06cbf2c..0adc768 100644 --- a/tests/restriction.h +++ b/tests/stctest-restriction.h @@ -19,8 +19,8 @@ #include #include -#include "stcmgr.h" -#include "gdbus.h" +#include "stctest.h" +#include "stctest-gdbus.h" #define RESTRICTION_RULE_APP_ID "app_id" #define RESTRICTION_RULE_IFNAME "ifname" diff --git a/tests/statistics.cpp b/tests/stctest-statistics.cpp similarity index 99% rename from tests/statistics.cpp rename to tests/stctest-statistics.cpp index de870c4..41bd95c 100644 --- a/tests/statistics.cpp +++ b/tests/stctest-statistics.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "stctest-statistics.h" #include #include @@ -20,8 +21,7 @@ #include #include -#include "statistics.h" -#include "common.h" +#include "stctest-common.h" static void AsyncReadyCallback(GObject *source_object, GAsyncResult *res, gpointer user_data) diff --git a/tests/statistics.h b/tests/stctest-statistics.h similarity index 97% rename from tests/statistics.h rename to tests/stctest-statistics.h index 5f3ebcc..42f34a3 100644 --- a/tests/statistics.h +++ b/tests/stctest-statistics.h @@ -16,8 +16,8 @@ #ifndef __STC_MGR_STATISTICS_H__ #define __STC_MGR_STATISTICS_H__ -#include "stcmgr.h" -#include "gdbus.h" +#include "stctest.h" +#include "stctest-gdbus.h" #define STATISTICS_RULE_APP_ID "app_id" #define STATISTICS_RULE_INTERVAL_FROM "from" diff --git a/tests/stcmgr.h b/tests/stctest.h similarity index 100% rename from tests/stcmgr.h rename to tests/stctest.h -- 2.7.4 From f3953221237a3ccdd494e0faf7aa4697fcc268ea Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Fri, 21 Aug 2020 10:51:40 +0900 Subject: [PATCH 16/16] revise build scripts and packaging Change-Id: Id248941a4291a67d34b539ec04a4ecab39fc48cc --- CMakeLists.txt | 30 +++++--- LICENSE.APLv2 | 1 + dbus-interface/CMakeLists.txt | 23 +++--- include/stc-firewall.h | 2 +- include/stc-gdbus.h | 2 +- manager/CMakeLists.txt | 101 +++++--------------------- manager/database/CMakeLists.txt | 8 +++ manager/helper/helper-cgroup.c | 2 +- manager/helper/helper-file.c | 2 +- manager/stcmgr.c | 2 +- misc/CMakeLists.txt | 8 +-- packaging/stc-manager.spec | 156 ++++++++++++++++++---------------------- plugin/CMakeLists.txt | 14 +--- plugin/appstatus/CMakeLists.txt | 43 +++-------- plugin/exception/CMakeLists.txt | 40 +++-------- plugin/firewall/CMakeLists.txt | 40 +++-------- plugin/monitor/CMakeLists.txt | 57 +++------------ plugin/pcap/CMakeLists.txt | 38 ++-------- plugin/procfs/CMakeLists.txt | 42 +++-------- plugin/tether/CMakeLists.txt | 40 ++--------- res/CMakeLists.txt | 9 +++ tests/CMakeLists.txt | 37 +++------- 22 files changed, 222 insertions(+), 475 deletions(-) create mode 100644 manager/database/CMakeLists.txt create mode 100644 res/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 011c4bc..15da9ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,31 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(stc-manager C CXX) -SET(PACKAGE ${PROJECT_NAME}) -SET(INTERFACES "${CMAKE_SOURCE_DIR}/dbus-interface") -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(LIBDIR ${PREFIX}/${LIB_PATH}) +CMAKE_MINIMUM_REQUIRED(VERSION 3.9) +PROJECT(stc-manager) -SET(DATA_DIR ${CMAKE_SOURCE_DIR}/res) +INCLUDE(FindPkgConfig) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbus-interface) + +INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/manager/helper") + +SET(EXTRA_FLAGS "-Wall -Werror -fvisibility=hidden") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS} -std=c++11") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") + +SET(DBUS_IFACE "${CMAKE_SOURCE_DIR}/dbus-interface") +SET(DATA_DIR ${CMAKE_SOURCE_DIR}/res) +SET(DB_OBJ "STC_DB") + +ADD_DEFINITIONS("-DUSE_DLOG") +IF(BUILD_GCOV) + ADD_DEFINITIONS("-DTIZEN_TEST_GCOV") +ENDIF(BUILD_GCOV) ADD_SUBDIRECTORY(dbus-interface) ADD_SUBDIRECTORY(manager) ADD_SUBDIRECTORY(plugin) ADD_SUBDIRECTORY(misc) - +ADD_SUBDIRECTORY(res) IF(BUILD_GTESTS) ADD_SUBDIRECTORY(tests) ENDIF(BUILD_GTESTS) diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 index d645695..8221aa1 100644 --- a/LICENSE.APLv2 +++ b/LICENSE.APLv2 @@ -1,3 +1,4 @@ +Copyright (c) 2016-2020 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 diff --git a/dbus-interface/CMakeLists.txt b/dbus-interface/CMakeLists.txt index dc26fa1..d1e4135 100644 --- a/dbus-interface/CMakeLists.txt +++ b/dbus-interface/CMakeLists.txt @@ -1,16 +1,17 @@ +FILE(GLOB DBUS_FILES *.xml) + +FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen) + ADD_CUSTOM_COMMAND( - WORKING_DIRECTORY - OUTPUT dbus - COMMAND gdbus-codegen --interface-prefix net.stc. - --generate-c-code generated-code + OUTPUT stc-generated-dbus.c + COMMAND ${GDBUS_CODEGEN} --interface-prefix net.stc. + --generate-c-code stc-generated-dbus --c-namespace Stc --c-generate-object-manager --generate-docbook generated-code-docs - ${INTERFACES}/stcmanager-iface-manager.xml - ${INTERFACES}/stcmanager-iface-restriction.xml - ${INTERFACES}/stcmanager-iface-statistics.xml - ${INTERFACES}/stcmanager-iface-firewall.xml - ${INTERFACES}/stcmanager-iface-pcap.xml - COMMENT "Generating GDBus .c/.h") + ${DBUS_FILES} + DEPENDS ${DBUS_FILES} + COMMENT "Generating GDBus .c/.h" +) -ADD_CUSTOM_TARGET(GENERATED_DBUS_CODE DEPENDS dbus) +ADD_CUSTOM_TARGET(GENERATED_DBUS_CODE DEPENDS stc-generated-dbus.c) diff --git a/include/stc-firewall.h b/include/stc-firewall.h index ee40f27..f813d7a 100644 --- a/include/stc-firewall.h +++ b/include/stc-firewall.h @@ -20,7 +20,7 @@ #include #include "stc.h" #include "stc-gdbus.h" -#include "table-firewall.h" +#include "db/table-firewall.h" /***************************************************************************** * Macros and Typedefs diff --git a/include/stc-gdbus.h b/include/stc-gdbus.h index 141742c..6715b26 100644 --- a/include/stc-gdbus.h +++ b/include/stc-gdbus.h @@ -18,7 +18,7 @@ #define __STC_MANAGER_GDBUS_H__ #include "stc.h" -#include "generated-code.h" +#include "stc-generated-dbus.h" #define STC_DBUS_SERVICE "net.stc" #define STC_DBUS_INTERFACE_RESTRICTION STC_DBUS_SERVICE ".restriction" diff --git a/manager/CMakeLists.txt b/manager/CMakeLists.txt index 3c0d1b7..57ed068 100644 --- a/manager/CMakeLists.txt +++ b/manager/CMakeLists.txt @@ -1,91 +1,22 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(REQUIRES_LIST glib-2.0 gio-2.0 gio-unix-2.0 dlog vconf capi-system-info openssl1.1 + sqlite3) -SET(REQUIRES_LIST ${REQUIRES_LIST} - glib-2.0 - gio-2.0 - gio-unix-2.0 - dlog - vconf - capi-system-info - openssl1.1 - ) - -IF("${ENABLE_DATABASE}" STREQUAL "YES") - SET(REQUIRES_LIST ${REQUIRES_LIST} sqlite3) -ENDIF() - -INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(stc_pkgs REQUIRED "${REQUIRES_LIST}") +INCLUDE_DIRECTORIES(${stc_pkgs_INCLUDE_DIRS}) +LINK_DIRECTORIES(${stc_pkgs_LIBRARY_DIRS}) -FOREACH(flag ${stc_pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/manager) -SET(HELPER_SOURCE_DIR ${SOURCE_DIR}/helper) -SET(DATABASE_SOURCE_DIR ${SOURCE_DIR}/database) -SET(LIMITATION_SOURCE_DIR ${SOURCE_DIR}/limitation) -SET(PLUGIN_DIR ${CMAKE_SOURCE_DIR}/plugin) -SET(APPSTATUS_SOURCE_DIR ${PLUGIN_DIR}/appstatus) -SET(EXCEPTION_SOURCE_DIR ${PLUGIN_DIR}/exception) -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) -SET(FIREWALL_SOURCE_DIR ${PLUGIN_DIR}/firewall) - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbus-interface) - -INCLUDE_DIRECTORIES(${SOURCE_DIR}) -INCLUDE_DIRECTORIES(${HELPER_SOURCE_DIR}) - -INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/db) - -INCLUDE_DIRECTORIES(${APPSTATUS_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${EXCEPTION_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${PROCFS_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${PCAP_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${TETHER_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${FIREWALL_SOURCE_DIR}) - -FILE(GLOB SOURCE_SRCS ${SOURCE_DIR}/*.c util/*.c) -FILE(GLOB HELPER_SRCS ${HELPER_SOURCE_DIR}/*.c) +FILE(GLOB SRCS *.c helper/*.c util/*.c) -SET(SRCS ${SRCS} ${SOURCE_SRCS} ${HELPER_SRCS}) +SET(SRCS ${SRCS} ${DBUS_IFACE}/stc-generated-dbus.c) +SET_SOURCE_FILES_PROPERTIES(${DBUS_IFACE}/stc-generated-dbus.c PROPERTIES GENERATED TRUE) -IF("${ENABLE_DATABASE}" STREQUAL "YES") - FILE(GLOB DATABASE_SRCS ${DATABASE_SOURCE_DIR}/*.c) - - SET(SRCS ${SRCS} ${DATABASE_SRCS}) - - INSTALL(FILES ${DATA_DIR}/traffic_db.sql DESTINATION /usr/share) - INSTALL(FILES ${DATA_DIR}/firewall_db.sql DESTINATION /usr/share) -ENDIF() - -IF(BUILD_GTESTS) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -Wall -Werror-implicit-function-declaration") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fprofile-arcs -ftest-coverage") -ELSE(BUILD_GTESTS) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -Wall -Werror-implicit-function-declaration -fvisibility=hidden") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -ENDIF(BUILD_GTESTS) - -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") - -ADD_DEFINITIONS("-DUSE_DLOG") -ADD_DEFINITIONS("-DDATABASE_FULL_PATH=\"${DATABASE_FULL_PATH}\"") -ADD_DEFINITIONS("-DDATABASE_BACKUP_PATH=\"${DATABASE_BACKUP_PATH}\"") -IF(BUILD_GTESTS) - ADD_DEFINITIONS(-DTIZEN_GTESTS) -ENDIF(BUILD_GTESTS) - -SET(SRCS ${SRCS} ${INTERFACES}/generated-code.c) -SET_SOURCE_FILES_PROPERTIES(${INTERFACES}/generated-code.c PROPERTIES GENERATED TRUE) - -ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${stc_pkgs_LDFLAGS} -ldl) -INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR}) +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS} $) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${stc_pkgs_LIBRARIES} dl) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES + POSITION_INDEPENDENT_CODE ON + ENABLE_EXPORTS 1) +TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC ${stc_pkgs_CFLAGS_OTHER}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BIN_INSTALL_DIR}) ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE) + +ADD_SUBDIRECTORY(database) diff --git a/manager/database/CMakeLists.txt b/manager/database/CMakeLists.txt new file mode 100644 index 0000000..b63ef69 --- /dev/null +++ b/manager/database/CMakeLists.txt @@ -0,0 +1,8 @@ +FILE(GLOB DB_SRCS *.c) + +ADD_DEFINITIONS("-DDATABASE_FULL_PATH=\"${DATABASE_FULL_PATH}\"") +ADD_DEFINITIONS("-DDATABASE_BACKUP_PATH=\"${DATABASE_BACKUP_PATH}\"") + +ADD_LIBRARY(${DB_OBJ} OBJECT ${DB_SRCS}) +SET_TARGET_PROPERTIES(${DB_OBJ} PROPERTIES POSITION_INDEPENDENT_CODE ON) +ADD_DEPENDENCIES(${DB_OBJ} GENERATED_DBUS_CODE) diff --git a/manager/helper/helper-cgroup.c b/manager/helper/helper-cgroup.c index 1d5ba2b..5cd7a66 100644 --- a/manager/helper/helper-cgroup.c +++ b/manager/helper/helper-cgroup.c @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#define _GNU_SOURCE #include "helper-cgroup.h" #define RELEASE_AGENT "release_agent" diff --git a/manager/helper/helper-file.c b/manager/helper/helper-file.c index e2f284f..d93741c 100644 --- a/manager/helper/helper-file.c +++ b/manager/helper/helper-file.c @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#define _GNU_SOURCE #include "helper-file.h" #define BUF_MAX (BUFSIZ) diff --git a/manager/stcmgr.c b/manager/stcmgr.c index 66bb119..baf3b6d 100644 --- a/manager/stcmgr.c +++ b/manager/stcmgr.c @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#define _GNU_SOURCE #include #include #include diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt index c9ca10b..1f778c8 100644 --- a/misc/CMakeLists.txt +++ b/misc/CMakeLists.txt @@ -1,5 +1,5 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - SET(NET_CLS_RELEASE "net-cls-release") -ADD_EXECUTABLE(${NET_CLS_RELEASE} ${CMAKE_CURRENT_SOURCE_DIR}/${NET_CLS_RELEASE}.c) -INSTALL(TARGETS ${NET_CLS_RELEASE} RUNTIME DESTINATION ${BIN_DIR}) + +ADD_EXECUTABLE(${NET_CLS_RELEASE} ${NET_CLS_RELEASE}.c) +SET_TARGET_PROPERTIES(${NET_CLS_RELEASE} PROPERTIES POSITION_INDEPENDENT_CODE ON) +INSTALL(TARGETS ${NET_CLS_RELEASE} DESTINATION ${BIN_INSTALL_DIR}) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 5763874..4997b6e 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,20 +1,12 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.4 +Version: 0.1.5 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest -%define enable_database YES -%define enable_statistics YES -%define enable_restriction YES -%define database_full_path %{TZ_SYS_GLOBALUSER_DB}/.stc-manager-datausage.db -%define database_backup_path %{TZ_SYS_RO_SHARE}/stc/.stc-manager-datausage.db -%define upgrade_script_filename 500.stc-manager_upgrade.sh -%define upgrade_script_path %{TZ_SYS_RO_SHARE}/upgrade/scripts - BuildRequires: cmake BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) @@ -25,14 +17,9 @@ BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(openssl1.1) - -%if %{?enable_database} == YES -BuildRequires: pkgconfig(sqlite3) -%endif - BuildRequires: python BuildRequires: python-xml - +BuildRequires: pkgconfig(sqlite3) %if 0%{?gtests:1} BuildRequires: pkgconfig(gmock) %endif @@ -92,123 +79,120 @@ Summary: Firewall plugin for managing firewall rules %description plugin-firewall A smart traffic control manager extension for firewall plugin +%if 0%{?gcov:1} +%package gcov +Summary: Coverage Data of %{name} +Group: System/Testing + +%description gcov +The %{name}-gcov pacakge contains gcov objects +%endif + +%global stc_db_file %{TZ_SYS_GLOBALUSER_DB}/.%{name}-datausage.db +%global stc_backup_db_file %{TZ_SYS_RO_SHARE}/stc/.%{name}-datausage.db + %prep %setup -q cp %{SOURCE1001} ./%{name}.manifest %build - -export CFLAGS="$CFLAGS -D_GNU_SOURCE" -export CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE" - %if "%{tizen_profile_name}" == "tv" CFLAGS+=" -DTIZEN_TV_EXT" %endif +%if 0%{?gcov:1} +export CFLAGS+=" -fprofile-arcs -ftest-coverage" +export CXXFLAGS+=" -fprofile-arcs -ftest-coverage" +export LDFLAGS+=" -lgcov -Wl,--dynamic-list-data" +%endif + %cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ - -DBIN_DIR=%{_bindir} \ - -DLIB_PATH=%{_lib} \ - -DENABLE_DATABASE=%{enable_database} \ - -DDATABASE_FULL_PATH=%{database_full_path} \ - -DDATABASE_BACKUP_PATH=%{database_backup_path} \ - -DENABLE_STATISTICS=%{enable_statistics} \ - -DENABLE_RESTRICTION=%{enable_restriction} \ + -DCMAKE_VERBOSE_MAKEFILE=OFF \ + -DBIN_INSTALL_DIR:PATH=%{_bindir} \ + -DSYSTEMD_DIR:PATH=%{_unitdir} \ + -DSYSCONF_DIR:PATH=%{_sysconfdir} \ + -DSTC_RW_DIR:PATH=%{_localstatedir}/lib/stc \ + -DDATABASE_FULL_PATH=%{stc_db_file} \ + -DDATABASE_BACKUP_PATH=%{stc_backup_db_file} \ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} - make %{?_smp_mflags} %install -rm -rf %{buildroot} - %make_install -#database initialization -%if %{?enable_database} == YES - mkdir -p %{buildroot}%{TZ_SYS_GLOBALUSER_DB} - sqlite3 %{buildroot}%{database_full_path} < %{buildroot}/usr/share/traffic_db.sql - sqlite3 %{buildroot}%{database_full_path} < %{buildroot}/usr/share/firewall_db.sql - mkdir -p %{buildroot}%{TZ_SYS_RO_SHARE}/stc - cp %{buildroot}%{database_full_path} %{buildroot}%{database_backup_path} - rm %{buildroot}/usr/share/traffic_db.sql - rm %{buildroot}/usr/share/firewall_db.sql +%if 0%{?gcov:1} +find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T - +install -d -m 0755 %{buildroot}%{_datadir}/gcov/obj +tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj %endif -#Exceptions file -mkdir -p %{buildroot}/%{_localstatedir}/lib/stc -cp res/exceptions %{buildroot}/%{_localstatedir}/lib/stc/exceptions - -#Systemd service file -mkdir -p %{buildroot}%{_unitdir} -cp res/systemd/stc-manager.service %{buildroot}%{_unitdir}/stc-manager.service - -mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/ -ln -s ../stc-manager.service %{buildroot}%{_unitdir}/multi-user.target.wants/stc-manager.service +#database initialization +mkdir -p %{buildroot}%{TZ_SYS_GLOBALUSER_DB} +sqlite3 %{buildroot}%{stc_db_file} < res/traffic_db.sql +sqlite3 %{buildroot}%{stc_db_file} < res/firewall_db.sql +install -D -m 0660 %{buildroot}%{stc_db_file} %{buildroot}%{stc_backup_db_file} -#DBus DAC (stc-manager.manifest enables DBus SMACK) -mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d -cp res/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf +mkdir -p %{buildroot}%{TZ_SYS_UPGRADE_SCRIPTS} +install -m 0755 res/500.%{name}_upgrade.sh %{buildroot}%{TZ_SYS_UPGRADE_SCRIPTS} -mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -cp res/dbus/net.stc.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service +%install_service multi-user.target.wants %{name}.service -#OS Upgrade -mkdir -p %{buildroot}%{upgrade_script_path} -cp -f res/%{upgrade_script_filename} %{buildroot}%{upgrade_script_path} %files %manifest %{name}.manifest -%license LICENSE.APLv2 -%defattr(-,root,root,-) -%attr(500,root,root) %{_bindir}/* - -%attr(644,root,root) %{_unitdir}/stc-manager.service -%attr(644,root,root) %{_unitdir}/multi-user.target.wants/stc-manager.service - -%attr(755,network_fw,network_fw) /%{_localstatedir}/lib/stc -%attr(600,root,root) /%{_localstatedir}/lib/stc/exceptions - -#DBus DAC -%attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/* -%attr(644,root,root) %{_datadir}/dbus-1/system-services/* - -%if %{?enable_database} == YES -%config(noreplace) %attr(660, root, root) %{database_full_path} -%config(noreplace) %attr(660, root, root) %{database_full_path}-journal -%config(noreplace) %attr(660, root, root) %{database_backup_path} -%endif - +%{_bindir}/* +%{_unitdir}/%{name}.service +%{_unitdir}/multi-user.target.wants/%{name}.service +%{_localstatedir}/lib/stc/exceptions +%{_sysconfdir}/dbus-1/system.d/* +%{_datadir}/dbus-1/system-services/* +%dir %attr(0755,network_fw,network_fw) %{_localstatedir}/lib/stc +%config(noreplace) %{stc_db_file}* +%config(noreplace) %{stc_backup_db_file} +%{TZ_SYS_UPGRADE_SCRIPTS}/500.%{name}_upgrade.sh %if 0%{?gtests:1} %{_bindir}/gtest* %endif - -%{upgrade_script_path}/%{upgrade_script_filename} +%license LICENSE.APLv2 %files plugin-appstatus %manifest %{name}.manifest -%attr(644, -,-) %{_datadir}/icons/*.png -%attr(500,root,root) %{_libdir}/stc-plugin-appstatus.so +%{_datadir}/icons/*.png +%{_libdir}/stc-plugin-appstatus.so +%license LICENSE.APLv2 %files plugin-exception %manifest %{name}.manifest -%attr(500,root,root) %{_libdir}/stc-plugin-exception.so +%{_libdir}/stc-plugin-exception.so +%license LICENSE.APLv2 %files plugin-procfs %manifest %{name}.manifest -%attr(500,root,root) %{_libdir}/stc-plugin-procfs.so +%{_libdir}/stc-plugin-procfs.so +%license LICENSE.APLv2 %files plugin-pcap %manifest %{name}.manifest -%attr(500,root,root) %{_libdir}/stc-plugin-pcap.so +%{_libdir}/stc-plugin-pcap.so +%license LICENSE.APLv2 %files plugin-tether %manifest %{name}.manifest -%attr(500,root,root) %{_libdir}/stc-plugin-tether.so +%{_libdir}/stc-plugin-tether.so +%license LICENSE.APLv2 %files plugin-monitor %manifest %{name}.manifest -%attr(500,root,root) %{_libdir}/stc-plugin-monitor.so +%{_libdir}/stc-plugin-monitor.so +%license LICENSE.APLv2 %files plugin-firewall %manifest %{name}.manifest -%attr(500,root,root) %{_libdir}/stc-plugin-firewall.so +%{_libdir}/stc-plugin-firewall.so +%license LICENSE.APLv2 + +%if 0%{?gcov:1} +%files gcov +%{_datadir}/gcov/* +%endif diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index d1777f2..6b73005 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -1,14 +1,6 @@ -SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/manager) -SET(HELPER_SOURCE_DIR ${SOURCE_DIR}/helper) -SET(DATABASE_SOURCE_DIR ${SOURCE_DIR}/database) - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbus-interface) - -INCLUDE_DIRECTORIES(${SOURCE_DIR}) -INCLUDE_DIRECTORIES(${HELPER_SOURCE_DIR}) - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/db) +PKG_CHECK_MODULES(plugin_pkgs REQUIRED dlog gio-2.0 gio-unix-2.0 glib-2.0) +INCLUDE_DIRECTORIES(${plugin_pkgs_INCLUDE_DIRS}) +LINK_DIRECTORIES(${plugin_pkgs_LIBRARY_DIRS}) ADD_SUBDIRECTORY(appstatus) ADD_SUBDIRECTORY(exception) diff --git a/plugin/appstatus/CMakeLists.txt b/plugin/appstatus/CMakeLists.txt index 30b45f3..975778a 100644 --- a/plugin/appstatus/CMakeLists.txt +++ b/plugin/appstatus/CMakeLists.txt @@ -1,36 +1,15 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(stc-plugin-appstatus C) +SET(STC_PI_APPSTATUS "stc-plugin-appstatus") -# Set required packages -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(appstatus_plugin REQUIRED - dlog - gio-2.0 - gio-unix-2.0 - glib-2.0 - bundle - syspopup-caller - ) +PKG_CHECK_MODULES(appstatus_pkgs REQUIRED bundle syspopup-caller) +INCLUDE_DIRECTORIES(${appstatus_pkgs_INCLUDE_DIRS}) +LINK_DIRECTORIES(${appstatus_pkgs_LIBRARY_DIRS}) -FOREACH(flag ${appstatus_plugin_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) +FILE(GLOB APPSTATUS_SRCS *.c) -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_LIBRARY(${STC_PI_APPSTATUS} SHARED ${APPSTATUS_SRCS}) +TARGET_LINK_LIBRARIES(${STC_PI_APPSTATUS} ${plugin_pkgs_LIBRARIES} ${appstatus_pkgs_LIBRARIES}) +TARGET_COMPILE_OPTIONS(${STC_PI_APPSTATUS} PUBLIC ${plugin_pkgs_CFLAGS_OTHER} ${appstatus_pkgs_CFLAGS_OTHER}) +SET_TARGET_PROPERTIES(${STC_PI_APPSTATUS} PROPERTIES PREFIX "" OUTPUT_NAME ${STC_PI_APPSTATUS}) -ADD_DEFINITIONS("-DUSE_DLOG") - -SET(SRCS_PLUGIN - stcplugin-appstatus.c - ) - -# library build -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${appstatus_plugin_LDFLAGS}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME}) - -# install -INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR}) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/stc_noti_datausage.png DESTINATION /usr/share/icons) +INSTALL(TARGETS ${STC_PI_APPSTATUS} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES data/stc_noti_datausage.png DESTINATION ${SHARE_INSTALL_PREFIX}/icons) diff --git a/plugin/exception/CMakeLists.txt b/plugin/exception/CMakeLists.txt index 734f587..b9e791a 100644 --- a/plugin/exception/CMakeLists.txt +++ b/plugin/exception/CMakeLists.txt @@ -1,34 +1,14 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(stc-plugin-exception C) +SET(STC_PI_EXCEPTION "stc-plugin-exception") -# Set required packages -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(exception_plugin REQUIRED - dlog - gio-2.0 - gio-unix-2.0 - glib-2.0 - pkgmgr-info - ) +PKG_CHECK_MODULES(exception_pkgs REQUIRED pkgmgr-info) +INCLUDE_DIRECTORIES(${exception_pkgs_INCLUDE_DIRS}) +LINK_DIRECTORIES(${exception_pkgs_LIBRARY_DIRS}) -FOREACH(flag ${exception_plugin_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) +FILE(GLOB EXCEPTION_SRCS *.c) -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_LIBRARY(${STC_PI_EXCEPTION} SHARED ${EXCEPTION_SRCS}) +TARGET_LINK_LIBRARIES(${STC_PI_EXCEPTION} ${plugin_pkgs_LIBRARIES} ${exception_pkgs_LIBRARIES}) +TARGET_COMPILE_OPTIONS(${STC_PI_EXCEPTION} PUBLIC ${plugin_pkgs_CFLAGS_OTHER} ${exception_pkgs_CFLAGS_OTHER}) +SET_TARGET_PROPERTIES(${STC_PI_EXCEPTION} PROPERTIES PREFIX "" OUTPUT_NAME ${STC_PI_EXCEPTION}) -ADD_DEFINITIONS("-DUSE_DLOG") - -SET(SRCS_PLUGIN - stcplugin-exception.c - ) - -# library build -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${exception_plugin_LDFLAGS}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME}) - -# install -INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR}) +INSTALL(TARGETS ${STC_PI_EXCEPTION} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/plugin/firewall/CMakeLists.txt b/plugin/firewall/CMakeLists.txt index d09e512..7a9433c 100644 --- a/plugin/firewall/CMakeLists.txt +++ b/plugin/firewall/CMakeLists.txt @@ -1,34 +1,10 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(stc-plugin-firewall C) +SET(STC_PI_FIREWALL "stc-plugin-firewall") -# Set required packages -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(firewall_plugin REQUIRED - dlog - gio-2.0 - gio-unix-2.0 - glib-2.0 - ) +FILE(GLOB FIREWALL_SRCS *.c) +ADD_LIBRARY(${STC_PI_FIREWALL} SHARED ${FIREWALL_SRCS}) +TARGET_LINK_LIBRARIES(${STC_PI_FIREWALL} ${plugin_pkgs_LIBRARIES}) +TARGET_COMPILE_OPTIONS(${STC_PI_FIREWALL} PUBLIC ${plugin_pkgs_CFLAGS_OTHER}) +SET_TARGET_PROPERTIES(${STC_PI_FIREWALL} PROPERTIES PREFIX "" OUTPUT_NAME ${STC_PI_FIREWALL}) +ADD_DEPENDENCIES(${STC_PI_FIREWALL} GENERATED_DBUS_CODE) -FOREACH(flag ${firewall_plugin_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -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 - stcplugin-firewall.c - ) - -# library build -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN}) -ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${firewall_plugin_LDFLAGS}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME}) - -# install -INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR}) +INSTALL(TARGETS ${STC_PI_FIREWALL} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/plugin/monitor/CMakeLists.txt b/plugin/monitor/CMakeLists.txt index ce792eb..abe818f 100644 --- a/plugin/monitor/CMakeLists.txt +++ b/plugin/monitor/CMakeLists.txt @@ -1,49 +1,14 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(stc-plugin-monitor C) +SET(STC_PI_MONITOR "stc-plugin-monitor") -# Set required packages -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(monitor_plugin REQUIRED - dlog - gio-2.0 - gio-unix-2.0 - glib-2.0 - vconf - openssl1.1 - bundle - syspopup-caller - ) +PKG_CHECK_MODULES(monitor_pkgs REQUIRED vconf openssl1.1 bundle syspopup-caller) +INCLUDE_DIRECTORIES(${monitor_pkgs_INCLUDE_DIRS}) +LINK_DIRECTORIES(${monitor_pkgs_LIBRARY_DIRS}) -FOREACH(flag ${monitor_plugin_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) +FILE(GLOB MONITOR_SRCS *.c) +ADD_LIBRARY(${STC_PI_MONITOR} SHARED ${MONITOR_SRCS}) +TARGET_LINK_LIBRARIES(${STC_PI_MONITOR} ${plugin_pkgs_LIBRARIES} ${monitor_pkgs_LIBRARIES}) +TARGET_COMPILE_OPTIONS(${STC_PI_MONITOR} PUBLIC ${plugin_pkgs_CFLAGS_OTHER} ${monitor_pkgs_CFLAGS_OTHER}) +SET_TARGET_PROPERTIES(${STC_PI_MONITOR} PROPERTIES PREFIX "" OUTPUT_NAME ${STC_PI_MONITOR}) +ADD_DEPENDENCIES(${STC_PI_MONITOR} GENERATED_DBUS_CODE) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/tether) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/appstatus) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/firewall) - -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 - stcplugin-monitor.c - stcplugin-monitor-proc.c - stcplugin-monitor-connection.c - stcplugin-monitor-rstn.c - stcplugin-monitor-app.c - stcplugin-monitor-ipt.c - stcplugin-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}) +INSTALL(TARGETS ${STC_PI_MONITOR} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/plugin/pcap/CMakeLists.txt b/plugin/pcap/CMakeLists.txt index d388170..38c071c 100644 --- a/plugin/pcap/CMakeLists.txt +++ b/plugin/pcap/CMakeLists.txt @@ -1,34 +1,10 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(stc-plugin-pcap C) +SET(STC_PI_PCAP "stc-plugin-pcap") -# Set required packages -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(pcap_plugin REQUIRED - dlog - gio-2.0 - gio-unix-2.0 - glib-2.0 - ) +FILE(GLOB PCAP_SRCS *.c) -FOREACH(flag ${pcap_plugin_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) +ADD_LIBRARY(${STC_PI_PCAP} SHARED ${PCAP_SRCS}) +TARGET_LINK_LIBRARIES(${STC_PI_PCAP} ${plugin_pkgs_LIBRARIES} pcap) +TARGET_COMPILE_OPTIONS(${STC_PI_PCAP} PUBLIC ${plugin_pkgs_CFLAGS_OTHER}) +SET_TARGET_PROPERTIES(${STC_PI_PCAP} PROPERTIES PREFIX "" OUTPUT_NAME ${STC_PI_PCAP}) -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 - stcplugin-pcap.c - ) - -# library build -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN}) -ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pcap_plugin_LDFLAGS} -lpcap) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME}) - -# install -INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR}) +INSTALL(TARGETS ${STC_PI_PCAP} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/plugin/procfs/CMakeLists.txt b/plugin/procfs/CMakeLists.txt index c61b895..2ea7fa7 100644 --- a/plugin/procfs/CMakeLists.txt +++ b/plugin/procfs/CMakeLists.txt @@ -1,37 +1,11 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(stc-plugin-procfs C) +SET(STC_PI_PROCFS "stc-plugin-procfs") -# Set required packages -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(procfs_plugin REQUIRED - dlog - gio-2.0 - gio-unix-2.0 - glib-2.0 - ) +FILE(GLOB PROCFS_SRCS *.c) -FOREACH(flag ${procfs_plugin_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) +ADD_LIBRARY(${STC_PI_PROCFS} SHARED ${PROCFS_SRCS}) +TARGET_LINK_LIBRARIES(${STC_PI_PROCFS} ${plugin_pkgs_LIBRARIES}) +TARGET_COMPILE_OPTIONS(${STC_PI_PROCFS} PUBLIC ${plugin_pkgs_CFLAGS_OTHER}) +SET_TARGET_PROPERTIES(${STC_PI_PROCFS} PROPERTIES PREFIX "" OUTPUT_NAME ${STC_PI_PROCFS}) +ADD_DEPENDENCIES(${STC_PI_PROCFS} GENERATED_DBUS_CODE) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception) - -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 - stcplugin-procfs.c - ) - -# library build -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN}) -ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${procfs_plugin_LDFLAGS}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME}) - -# install -INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR}) +INSTALL(TARGETS ${STC_PI_PROCFS} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/plugin/tether/CMakeLists.txt b/plugin/tether/CMakeLists.txt index 52d8970..e067a1d 100644 --- a/plugin/tether/CMakeLists.txt +++ b/plugin/tether/CMakeLists.txt @@ -1,36 +1,10 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(stc-plugin-tether C) +SET(STC_PI_TETHER "stc-plugin-tether") -# Set required packages -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(tether_plugin REQUIRED - dlog - gio-2.0 - gio-unix-2.0 - glib-2.0 - ) +FILE(GLOB TETHER_SRCS *.c) -FOREACH(flag ${tether_plugin_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) +ADD_LIBRARY(${STC_PI_TETHER} SHARED ${TETHER_SRCS}) +TARGET_LINK_LIBRARIES(${STC_PI_TETHER} ${plugin_pkgs_LIBRARIES}) +TARGET_COMPILE_OPTIONS(${STC_PI_TETHER} PUBLIC ${plugin_pkgs_CFLAGS_OTHER}) +SET_TARGET_PROPERTIES(${STC_PI_TETHER} PROPERTIES PREFIX "" OUTPUT_NAME ${STC_PI_TETHER}) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor) - -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 - stcplugin-tether.c - ) - -# library build -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN}) -ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${tether_plugin_LDFLAGS}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME}) - -# install -INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR}) +INSTALL(TARGETS ${STC_PI_TETHER} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/res/CMakeLists.txt b/res/CMakeLists.txt new file mode 100644 index 0000000..12fa35e --- /dev/null +++ b/res/CMakeLists.txt @@ -0,0 +1,9 @@ +INSTALL(FILES systemd/${PROJECT_NAME}.service DESTINATION ${SYSTEMD_DIR}) + +INSTALL(FILES dbus/${PROJECT_NAME}.conf DESTINATION ${SYSCONF_DIR}/dbus-1/system.d) +INSTALL(FILES dbus/net.stc.service DESTINATION ${SHARE_INSTALL_PREFIX}/dbus-1/system-services) + +INSTALL(FILES exceptions DESTINATION ${STC_RW_DIR}) + +#INSTALL(FILES ${DATA_DIR}/traffic_db.sql DESTINATION /usr/share) +#INSTALL(FILES ${DATA_DIR}/firewall_db.sql DESTINATION /usr/share) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6ae9e48..492a50e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,32 +1,15 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(gtest-stc-manager C CXX) - SET(GTEST_TEST "gtest-stc-manager") -ADD_DEFINITIONS("-DUSE_DLOG") - -SET(REQUIRES_LIST ${REQUIRES_LIST} - glib-2.0 - gio-2.0 - gmock - dlog -) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(GTEST_TEST_PKG REQUIRED ${REQUIRES_LIST}) - -FOREACH(flag ${GTEST_TEST_PKG_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") +SET(REQUIRES_LIST ${REQUIRES_LIST} glib-2.0 gio-2.0 gmock dlog) +PKG_CHECK_MODULES(test_pkgs REQUIRED ${REQUIRES_LIST}) +INCLUDE_DIRECTORIES(${test_pkgs_INCLUDE_DIRS}) +LINK_DIRECTORIES(${test_pkgs_LIBRARY_DIRS}) -FILE(GLOB GTEST_TEST_SRCS *.cpp) -SET(GTEST_TEST_SRCS ${GTEST_TEST_SRCS}) +FILE(GLOB TEST_SRCS *.cpp) -ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS}) -TARGET_LINK_LIBRARIES(${GTEST_TEST} ${GTEST_TEST_LDFLAGS} ${GTEST_TEST_PKG_LDFLAGS} -ldl -lgcov) +ADD_EXECUTABLE(${GTEST_TEST} ${TEST_SRCS}) +SET_TARGET_PROPERTIES(${GTEST_TEST} PROPERTIES POSITION_INDEPENDENT_CODE ON) +TARGET_COMPILE_OPTIONS(${GTEST_TEST} PUBLIC ${test_pkgs_CFLAGS_OTHER}) +TARGET_LINK_LIBRARIES(${GTEST_TEST} ${test_pkgs_LIBRARIES} dl) -INSTALL(TARGETS ${GTEST_TEST} RUNTIME DESTINATION ${BIN_DIR}) +INSTALL(TARGETS ${GTEST_TEST} DESTINATION ${BIN_INSTALL_DIR}) -- 2.7.4