Modified properly data type 50/128750/1 accepted/tizen/unified/20170512.023827 submit/tizen/20170512.003940
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 11 May 2017 07:59:18 +0000 (16:59 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 11 May 2017 07:59:23 +0000 (16:59 +0900)
Change-Id: Ie0e775abb7c349847aa5d43fce211c0b60b6c8d1
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
16 files changed:
include/stc-manager.h
include/stc-restriction.h
packaging/stc-manager.spec
src/configure/include/netlink-restriction.h
src/configure/nf-restriction.c
src/database/include/db-internal.h [changed mode: 0644->0755]
src/database/include/stc-db.h [changed mode: 0644->0755]
src/database/include/table-counters.h [changed mode: 0644->0755]
src/database/include/table-restrictions.h [changed mode: 0644->0755]
src/database/include/table-statistics.h [changed mode: 0644->0755]
src/database/tables/table-counters.c
src/helper/helper-nfacct-rule.c
src/helper/helper-nfacct-rule.h
src/monitor/stc-monitor.c
src/stc-restriction.c
src/stc-statistics.c

index 4e952b9..6df86af 100755 (executable)
@@ -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 {
index 81df4bd..219dad8 100755 (executable)
 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;
index 686702f..df4b9c9 100644 (file)
@@ -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
index 2734fbf..069a4a3 100755 (executable)
@@ -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__ */
index 9e65904..2423ee0 100755 (executable)
@@ -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;
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 556fdba..70e545c
@@ -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,
old mode 100644 (file)
new mode 100755 (executable)
index ede1439..2814199
@@ -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;
 
old mode 100644 (file)
new mode 100755 (executable)
index 070ef46..9fb6fba 100755 (executable)
@@ -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;
index 94ad5d1..7e7f5cb 100755 (executable)
@@ -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)
index 7ce4ed7..2220868 100755 (executable)
@@ -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);
index a2b662e..8633c84 100755 (executable)
@@ -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;
index 462f503..721d25c 100755 (executable)
@@ -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);
index a2a72fd..ba65f7e 100755 (executable)
@@ -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));