From f29609fd118f106e8526cbb65db912c9a87b868d Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Thu, 11 May 2017 16:59:18 +0900 Subject: [PATCH] Modified properly data type Change-Id: Ie0e775abb7c349847aa5d43fce211c0b60b6c8d1 Signed-off-by: hyunuktak --- include/stc-manager.h | 4 ++-- include/stc-restriction.h | 8 ++++---- packaging/stc-manager.spec | 2 +- src/configure/include/netlink-restriction.h | 6 +++--- src/configure/nf-restriction.c | 16 ++++++++-------- src/database/include/db-internal.h | 0 src/database/include/stc-db.h | 0 src/database/include/table-counters.h | 4 ++-- src/database/include/table-restrictions.h | 8 ++++---- src/database/include/table-statistics.h | 0 src/database/tables/table-counters.c | 2 +- src/helper/helper-nfacct-rule.c | 12 ++++++------ src/helper/helper-nfacct-rule.h | 6 +++--- src/monitor/stc-monitor.c | 26 +++++++++++++------------- src/stc-restriction.c | 16 ++++++++-------- src/stc-statistics.c | 8 ++++---- 16 files changed, 59 insertions(+), 59 deletions(-) mode change 100644 => 100755 src/database/include/db-internal.h mode change 100644 => 100755 src/database/include/stc-db.h mode change 100644 => 100755 src/database/include/table-counters.h mode change 100644 => 100755 src/database/include/table-restrictions.h mode change 100644 => 100755 src/database/include/table-statistics.h diff --git a/include/stc-manager.h b/include/stc-manager.h index 4e952b9..6df86af 100755 --- a/include/stc-manager.h +++ b/include/stc-manager.h @@ -141,8 +141,8 @@ typedef struct { * @brief datausage in bytes */ typedef struct { - uint64_t in_bytes; /**< incoming bytes */ - uint64_t out_bytes; /**< outgoing bytes */ + int64_t in_bytes; /**< incoming bytes */ + int64_t out_bytes; /**< outgoing bytes */ } stc_data_counter_s; typedef struct { diff --git a/include/stc-restriction.h b/include/stc-restriction.h index 81df4bd..219dad8 100755 --- a/include/stc-restriction.h +++ b/include/stc-restriction.h @@ -29,10 +29,10 @@ typedef struct { stc_app_state_e rs_type; stc_iface_type_e iftype; - uint64_t send_limit; - uint64_t rcv_limit; - uint64_t snd_warning_limit; - uint64_t rcv_warning_limit; + int64_t send_limit; + int64_t rcv_limit; + int64_t snd_warning_limit; + int64_t rcv_warning_limit; stc_roaming_type_e roaming; char *ifname; char *imsi; diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 686702f..df4b9c9 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.2 +Version: 0.0.3 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/configure/include/netlink-restriction.h b/src/configure/include/netlink-restriction.h index 2734fbf..069a4a3 100755 --- a/src/configure/include/netlink-restriction.h +++ b/src/configure/include/netlink-restriction.h @@ -45,9 +45,9 @@ int send_net_restriction(const enum traffic_restriction_type rst_type, const guint32 classid, const int quota_id, const stc_iface_type_e iftype, - const uint64_t send_limit, const uint64_t rcv_limit, - const uint64_t snd_warning_threshold, - const uint64_t rcv_warning_threshold, + const int64_t send_limit, const int64_t rcv_limit, + const int64_t snd_warning_threshold, + const int64_t rcv_warning_threshold, const char *ifname); #endif /* __STC_NET_RESTRICTION_H__ */ diff --git a/src/configure/nf-restriction.c b/src/configure/nf-restriction.c index 9e65904..2423ee0 100755 --- a/src/configure/nf-restriction.c +++ b/src/configure/nf-restriction.c @@ -17,8 +17,8 @@ #include "counter.h" static stc_error_e apply_net_restriction(struct nfacct_rule *rule, - const uint64_t send_limit, - const uint64_t rcv_limit) + const int64_t send_limit, + const int64_t rcv_limit) { nfacct_rule_jump jump; @@ -37,8 +37,8 @@ static stc_error_e apply_net_restriction(struct nfacct_rule *rule, } static stc_error_e revert_net_restriction(struct nfacct_rule *rule, - const uint64_t send_limit, - const uint64_t rcv_limit) + const int64_t send_limit, + const int64_t rcv_limit) { nfacct_rule_jump jump = ((rule->intend == NFACCT_WARN) ? NFACCT_JUMP_ACCEPT : NFACCT_JUMP_REJECT); @@ -70,10 +70,10 @@ static stc_error_e exclude_net_restriction(struct nfacct_rule *rule) stc_error_e send_net_restriction(const enum traffic_restriction_type rst_type, const guint32 classid, const int quota_id, const stc_iface_type_e iftype, - const uint64_t send_limit, - const uint64_t rcv_limit, - const uint64_t snd_warning_threshold, - const uint64_t rcv_warning_threshold, + const int64_t send_limit, + const int64_t rcv_limit, + const int64_t snd_warning_threshold, + const int64_t rcv_warning_threshold, const char *ifname) { int ret; diff --git a/src/database/include/db-internal.h b/src/database/include/db-internal.h old mode 100644 new mode 100755 diff --git a/src/database/include/stc-db.h b/src/database/include/stc-db.h old mode 100644 new mode 100755 diff --git a/src/database/include/table-counters.h b/src/database/include/table-counters.h old mode 100644 new mode 100755 index 556fdba..70e545c --- a/src/database/include/table-counters.h +++ b/src/database/include/table-counters.h @@ -19,8 +19,8 @@ typedef struct { uint64_t restriction_id; - uint64_t sent_bytes; - uint64_t rcv_bytes; + int64_t sent_bytes; + int64_t rcv_bytes; } table_counters_info; typedef stc_cb_ret_e(*table_counters_info_cb)(const table_counters_info *info, diff --git a/src/database/include/table-restrictions.h b/src/database/include/table-restrictions.h old mode 100644 new mode 100755 index ede1439..2814199 --- a/src/database/include/table-restrictions.h +++ b/src/database/include/table-restrictions.h @@ -24,10 +24,10 @@ typedef struct { stc_iface_type_e iftype; stc_restriction_state_e rst_state; stc_roaming_type_e roaming; - uint64_t rcv_limit; - uint64_t send_limit; - uint64_t rcv_warn_limit; - uint64_t send_warn_limit; + int64_t rcv_limit; + int64_t send_limit; + int64_t rcv_warn_limit; + int64_t send_warn_limit; uint64_t restriction_id; } table_restrictions_info; diff --git a/src/database/include/table-statistics.h b/src/database/include/table-statistics.h old mode 100644 new mode 100755 diff --git a/src/database/tables/table-counters.c b/src/database/tables/table-counters.c index 070ef46..9fb6fba 100755 --- a/src/database/tables/table-counters.c +++ b/src/database/tables/table-counters.c @@ -187,7 +187,7 @@ stc_error_e table_counters_get(uint64_t restriction_id, info->sent_bytes = sqlite3_column_int64(stmt, 0); info->rcv_bytes = sqlite3_column_int64(stmt, 1); - STC_LOGD("rstn_id [%llu] counters [sent = %llu rcv = %llu]", + STC_LOGD("rstn_id [%llu] counters [sent = %lld rcv = %lld]", restriction_id, info->sent_bytes, info->rcv_bytes); break; diff --git a/src/helper/helper-nfacct-rule.c b/src/helper/helper-nfacct-rule.c index 94ad5d1..7e7f5cb 100755 --- a/src/helper/helper-nfacct-rule.c +++ b/src/helper/helper-nfacct-rule.c @@ -606,8 +606,8 @@ static char *get_iptables_jump(const nfacct_rule_jump jump) } static stc_error_e produce_app_rule(nfacct_rule_s *rule, - const uint64_t send_limit, - const uint64_t rcv_limit, + const int64_t send_limit, + const int64_t rcv_limit, const nfacct_rule_action action, const nfacct_rule_jump jump, const nfacct_rule_direction iotype) @@ -717,8 +717,8 @@ static stc_error_e produce_app_rule(nfacct_rule_s *rule, } static stc_error_e produce_iface_rule(nfacct_rule_s *rule, - const uint64_t send_limit, - const uint64_t rcv_limit, + const int64_t send_limit, + const int64_t rcv_limit, const nfacct_rule_action action, const nfacct_rule_jump jump, const nfacct_rule_direction iotype) @@ -851,8 +851,8 @@ static stc_error_e produce_iface_rule(nfacct_rule_s *rule, } stc_error_e produce_net_rule(nfacct_rule_s *rule, - const uint64_t send_limit, - const uint64_t rcv_limit, + const int64_t send_limit, + const int64_t rcv_limit, const nfacct_rule_action action, const nfacct_rule_jump jump, const nfacct_rule_direction iotype) diff --git a/src/helper/helper-nfacct-rule.h b/src/helper/helper-nfacct-rule.h index 7ce4ed7..2220868 100755 --- a/src/helper/helper-nfacct-rule.h +++ b/src/helper/helper-nfacct-rule.h @@ -85,7 +85,7 @@ struct nfacct_rule { nfacct_rule_intend intend; struct counter_arg *carg; stc_error_e(*iptables_rule)(struct nfacct_rule *counter); - uint64_t quota; + int64_t quota; int quota_id; stc_roaming_type_e roaming; stc_restriction_state_e rst_state; @@ -112,8 +112,8 @@ stc_error_e nfacct_send_del(nfacct_rule_s *counter); stc_error_e exec_iptables_cmd(const char *cmd_buf, pid_t *pid); stc_error_e produce_net_rule(nfacct_rule_s *rule, - const uint64_t send_limit, - const uint64_t rcv_limit, + const int64_t send_limit, + const int64_t rcv_limit, const nfacct_rule_action action, const nfacct_rule_jump jump, const nfacct_rule_direction iotype); diff --git a/src/monitor/stc-monitor.c b/src/monitor/stc-monitor.c index a2b662e..8633c84 100755 --- a/src/monitor/stc-monitor.c +++ b/src/monitor/stc-monitor.c @@ -33,7 +33,7 @@ typedef struct { typedef struct { struct nfacct_rule *counter; - uint64_t bytes; + int64_t bytes; gboolean in_limit_reached; gboolean out_limit_reached; } classid_bytes_context_s; @@ -201,7 +201,7 @@ static gboolean __apps_tree_foreach_print(gpointer key, gpointer value, STC_LOGD("Application info => Pkg ID [%s], App ID [%s]," " Type [%d], classid [%d]," - " counter [ in (%llu), out (%llu)]", + " counter [ in (%lld), out (%lld)]", app_key->pkg_id, app_key->app_id, app_value->type, app_value->classid, app_value->data_usage.in_bytes, app_value->data_usage.out_bytes); @@ -327,9 +327,9 @@ static void __print_rstn(stc_rstn_key_s *rstn_key, stc_rstn_value_s *rstn_value) STC_LOGI("rstn info => rstn_id [%llu], " "app_id [%s], classid [%lu], ifname [%s], " "iftype [%d], rst_state [%d], " - "limit [ in (%llu), out (%llu)], " - "warn_limit [ in (%llu), out (%llu)], " - "counter [ in (%llu), out (%llu)], " + "limit [ in (%lld), out (%lld)], " + "warn_limit [ in (%lld), out (%lld)], " + "counter [ in (%lld), out (%lld)], " "roaming [%d], imsi [%s]", rstn_value->restriction_id, rstn_key->app_id, rstn_value->classid , rstn_key->ifname, @@ -399,13 +399,13 @@ static void __process_restriction(enum traffic_restriction_type rst_type, if (effective_warn_limit.out_bytes < 0) effective_warn_limit.out_bytes = 0; - STC_LOGD("datausage [in: %llu, out: %llu]", + STC_LOGD("datausage [in: %lld, out: %lld]", info.rcv_bytes, info.sent_bytes); } - STC_LOGD("rstn_id [%llu], effective limit [in: %llu, out: %llu], " - "effective warn limit [in: %llu, out: %llu], " - "datausage [in: %llu, out: %llu]", + STC_LOGD("rstn_id [%llu], effective limit [in: %lld, out: %lld], " + "effective warn limit [in: %lld, out: %lld], " + "datausage [in: %lld, out: %lld]", rstn_value->restriction_id, effective_limit.in_bytes, effective_limit.out_bytes, effective_warn_limit.in_bytes, effective_warn_limit.out_bytes); @@ -713,7 +713,7 @@ try_next_callback: return FALSE; } -static void __fill_nfacct_result(char *cnt_name, uint64_t bytes, +static void __fill_nfacct_result(char *cnt_name, int64_t bytes, struct counter_arg *carg) { struct nfacct_rule counter = { @@ -737,7 +737,7 @@ static void __fill_nfacct_result(char *cnt_name, uint64_t bytes, return; } - STC_LOGI("classid %lu, iftype %u, iotype %d, intend %d, ifname %s, bytes %llu", + STC_LOGI("classid %lu, iftype %u, iotype %d, intend %d, ifname %s, bytes %lld", context.counter->classid, context.counter->iftype, context.counter->iotype, context.counter->intend, context.counter->ifname, context.bytes); @@ -766,8 +766,8 @@ static int __fill_counters(struct rtattr *attr_list[__NFACCT_MAX], populate_counters(cnt_name, carg); */ } else { - uint64_t *bytes_p = - (uint64_t *)RTA_DATA(attr_list[NFACCT_BYTES]); + int64_t *bytes_p = + (int64_t *)RTA_DATA(attr_list[NFACCT_BYTES]); int bytes = be64toh(*bytes_p); if (bytes) { ++carg->serialized_counters; diff --git a/src/stc-restriction.c b/src/stc-restriction.c index 462f503..721d25c 100755 --- a/src/stc-restriction.c +++ b/src/stc-restriction.c @@ -115,16 +115,16 @@ void __stc_restriction_app_info_builder_add(GVariantBuilder *builder, g_variant_new_uint16(info->rst_state)); g_variant_builder_add(builder, "{sv}", "rcv_limit", - g_variant_new_uint64(info->rcv_limit)); + g_variant_new_int64(info->rcv_limit)); g_variant_builder_add(builder, "{sv}", "send_limit", - g_variant_new_uint64(info->send_limit)); + g_variant_new_int64(info->send_limit)); g_variant_builder_add(builder, "{sv}", "rcv_warn_limit", - g_variant_new_uint64(info->rcv_warn_limit)); + g_variant_new_int64(info->rcv_warn_limit)); g_variant_builder_add(builder, "{sv}", "send_warn_limit", - g_variant_new_uint64(info->send_warn_limit)); + g_variant_new_int64(info->send_warn_limit)); g_variant_builder_add(builder, "{sv}", "roaming", g_variant_new_uint16(info->roaming)); @@ -204,19 +204,19 @@ static void __stc_extract_restriction_rule(const char *key, GVariant *value, } else if (!g_strcmp0(key, "rcv_limit")) { rule->rcv_limit = g_variant_get_uint64(value); - STC_LOGD("rcv_limit: [%llu]", rule->rcv_limit); + STC_LOGD("rcv_limit: [%lld]", rule->rcv_limit); } else if (!g_strcmp0(key, "send_limit")) { rule->send_limit = g_variant_get_uint64(value); - STC_LOGD("send_limit: [%llu]", rule->send_limit); + STC_LOGD("send_limit: [%lld]", rule->send_limit); } else if (!g_strcmp0(key, "rcv_warn_limit")) { rule->rcv_warn_limit = g_variant_get_uint64(value); - STC_LOGD("rcv_warn_limit: [%llu]", rule->rcv_warn_limit); + STC_LOGD("rcv_warn_limit: [%lld]", rule->rcv_warn_limit); } else if (!g_strcmp0(key, "send_warn_limit")) { rule->send_warn_limit = g_variant_get_uint64(value); - STC_LOGD("send_warn_limit: [%llu]", rule->send_warn_limit); + STC_LOGD("send_warn_limit: [%lld]", rule->send_warn_limit); } else if (!g_strcmp0(key, "roaming")) { rule->roaming = g_variant_get_uint16(value); diff --git a/src/stc-statistics.c b/src/stc-statistics.c index a2a72fd..ba65f7e 100755 --- a/src/stc-statistics.c +++ b/src/stc-statistics.c @@ -48,8 +48,8 @@ void __stc_statistics_print_app_info(const table_statistics_info *info) STC_LOGD("========== App data (Statistics) =========="); STC_LOGD("app_id : [%s]", info->app_id ? info->app_id : "NULL"); STC_LOGD("ifname : [%s]", info->ifname ? info->ifname : "NULL"); - STC_LOGD("Sent : [%llu] bytes", info->cnt.out_bytes); - STC_LOGD("Received : [%llu] bytes", info->cnt.in_bytes); + STC_LOGD("Sent : [%lld] bytes", info->cnt.out_bytes); + STC_LOGD("Received : [%lld] bytes", info->cnt.in_bytes); STC_LOGD("==========================================="); } @@ -188,10 +188,10 @@ void __stc_statistics_app_info_builder_add(GVariantBuilder *builder, } g_variant_builder_add(builder, "{sv}", "cnt_out_bytes", - g_variant_new_uint64(info->cnt.out_bytes)); + g_variant_new_int64(info->cnt.out_bytes)); g_variant_builder_add(builder, "{sv}", "cnt_in_bytes", - g_variant_new_uint64(info->cnt.in_bytes)); + g_variant_new_int64(info->cnt.in_bytes)); g_variant_builder_add(builder, "{sv}", "roaming", g_variant_new_uint16(info->roaming)); -- 2.7.4