* @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 {
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;
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
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__ */
#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;
}
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);
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;
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,
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;
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;
}
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)
}
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)
}
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)
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;
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);
typedef struct {
struct nfacct_rule *counter;
- uint64_t bytes;
+ int64_t bytes;
gboolean in_limit_reached;
gboolean out_limit_reached;
} classid_bytes_context_s;
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);
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,
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);
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 = {
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);
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;
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));
} 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);
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("===========================================");
}
}
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));