rst_state INT,
roaming INT,
imsi TEXT NOT NULL,
- rcv_limit BIGINT,
- send_limit BIGINT,
- rcv_warn_limit BIGINT,
- send_warn_limit BIGINT
+ data_limit BIGINT,
+ data_warn_limit BIGINT
);
CREATE INDEX IF NOT EXISTS restrictions_index ON restrictions (binpath, iftype, ifname);
CREATE TABLE IF NOT EXISTS counters (
restriction_id INTEGER NOT NULL,
- sent_bytes BIGINT,
- rcv_bytes BIGINT,
+ data_counter BIGINT,
PRIMARY KEY (restriction_id)
);
Name: stc-manager
Summary: STC(Smart Traffic Control) manager
-Version: 0.0.14
+Version: 0.0.15
Release: 0
Group: Network & Connectivity/Other
License: Apache-2.0
*/
typedef struct {
char *app_id;
- unsigned int snd_count;
- unsigned int rcv_count;
- unsigned int delta_snd;
- unsigned int delta_rcv;
+ int64_t rcv_count;
+ int64_t snd_count;
#ifndef CONFIG_DATAUSAGE_NFACCT
pid_t pid;
typedef struct {
uint64_t restriction_id;
- int64_t sent_bytes;
- int64_t rcv_bytes;
+ int64_t data_counter;
} 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;
- int64_t rcv_limit;
- int64_t send_limit;
- int64_t rcv_warn_limit;
- int64_t send_warn_limit;
+ int64_t data_limit;
+ int64_t data_warn_limit;
uint64_t restriction_id;
} table_restrictions_info;
#define DELETE_COUNTER "DELETE FROM counters WHERE restriction_id=?"
-#define SELECT_COUNTER "SELECT sent_bytes, rcv_bytes FROM counters WHERE restriction_id=?"
+#define SELECT_COUNTER "SELECT data_counter FROM counters WHERE restriction_id=?"
-#define INSERT_COUNTER "INSERT INTO counters (restriction_id, sent_bytes, rcv_bytes) " \
- " VALUES (?, ?, ?)"
+#define INSERT_COUNTER "INSERT INTO counters (restriction_id, data_counter) " \
+ " VALUES (?, ?)"
-#define UPDATE_COUNTER "REPLACE INTO counters (restriction_id, sent_bytes, rcv_bytes) " \
- " VALUES (?, ?, ?)"
+#define UPDATE_COUNTER "REPLACE INTO counters (restriction_id, data_counter) " \
+ " VALUES (?, ?)"
static void __finalize_delete(void);
if (info == NULL)
goto handle_error;
+ info->restriction_id = restriction_id;
+
DB_ACTION(sqlite3_bind_int64(stmt, 1, restriction_id));
do {
case SQLITE_DONE:
break;
case SQLITE_ROW:
- info->sent_bytes = sqlite3_column_int64(stmt, 0);
- info->rcv_bytes = sqlite3_column_int64(stmt, 1);
+ info->data_counter = sqlite3_column_int64(stmt, 0);
- STC_LOGD("rstn_id [%llu] counters [sent = %lld rcv = %lld]",
- restriction_id, info->sent_bytes,
- info->rcv_bytes);
+ STC_LOGD("rstn_id [%llu] data_counters [%lld] bytes",
+ restriction_id, info->data_counter);
break;
case SQLITE_ERROR:
default:
stc_error_e error_code = STC_ERROR_NONE;
sqlite3_stmt *stmt = update_counter;
- if (!info->rcv_bytes && !info->sent_bytes) {
+ if (!info->data_counter) {
error_code = STC_ERROR_INVALID_PARAMETER;
goto handle_error;
}
DB_ACTION(sqlite3_bind_int64(stmt, 1, info->restriction_id));
- DB_ACTION(sqlite3_bind_int64(stmt, 2, info->sent_bytes));
- DB_ACTION(sqlite3_bind_int64(stmt, 3, info->rcv_bytes));
+ DB_ACTION(sqlite3_bind_int64(stmt, 2, info->data_counter));
if (sqlite3_step(stmt) != SQLITE_DONE) {
STC_LOGE("Failed to update counter: %s\n",
/* DELETE statements */
#define DELETE_RESTRICTIONS "DELETE FROM restrictions " \
- "WHERE binpath=? AND iftype=? AND imsi = ?"
+ " WHERE binpath = ? AND iftype = ? AND imsi = ?"
/* SELECT statements */
-#define SELECT_RESTRICTIONS "SELECT binpath, rcv_limit, " \
- "send_limit, iftype, rst_state, roaming, ifname, imsi, " \
- "rcv_warn_limit, send_warn_limit, restriction_id FROM restrictions"
+#define SELECT_RESTRICTIONS "SELECT binpath, data_limit, " \
+ " iftype, rst_state, roaming, ifname, imsi, " \
+ " data_warn_limit, restriction_id FROM restrictions"
-#define SELECT_RESTRICTIONS_PER_APP "SELECT binpath, rcv_limit, " \
- "send_limit, iftype, rst_state, roaming, ifname, imsi, " \
- "rcv_warn_limit, send_warn_limit, restriction_id " \
- "FROM restrictions INDEXED BY restrictions_index " \
- "WHERE binpath = ?"
+#define SELECT_RESTRICTIONS_PER_APP "SELECT binpath, data_limit, " \
+ " iftype, rst_state, roaming, ifname, imsi, " \
+ " data_warn_limit, restriction_id " \
+ " FROM restrictions INDEXED BY restrictions_index " \
+ " WHERE binpath = ?"
#define SELECT_RESTRICTION_STATE "SELECT rst_state " \
- "FROM restrictions INDEXED BY restrictions_index " \
- "WHERE binpath = ? AND iftype = ?"
+ " FROM restrictions INDEXED BY restrictions_index " \
+ " WHERE binpath = ? AND iftype = ?"
#define SELECT_RESTRICTION_STATE_IMSI "SELECT rst_state " \
- "FROM restrictions INDEXED BY restrictions_index " \
- "WHERE binpath = ? AND iftype = ? AND imsi = ?"
+ " FROM restrictions INDEXED BY restrictions_index " \
+ " WHERE binpath = ? AND iftype = ? AND imsi = ?"
#define SELECT_RESTRICTION_ID "SELECT restriction_id FROM restrictions " \
- "WHERE binpath = ? AND iftype = ? AND imsi = ? AND send_limit=? " \
- "AND rcv_limit=? AND rcv_warn_limit=? AND send_warn_limit=? " \
- "AND rst_state=? AND roaming=? AND ifname=?"
+ " WHERE binpath = ? AND iftype = ? AND imsi = ? AND " \
+ " data_limit = ? AND data_warn_limit = ? AND " \
+ " rst_state = ? AND roaming = ? AND ifname = ?"
/* UPDATE statement */
#define UPDATE_NET_RESTRICTIONS "UPDATE restrictions " \
- "SET binpath=?, rcv_limit=?, send_limit=?, iftype=?, rst_state=?, " \
- "roaming=?, ifname=?, imsi=?, rcv_warn_limit=?, send_warn_limit=? " \
- "WHERE restriction_id=?"
+ " SET binpath = ?, data_limit = ?, iftype = ?, rst_state = ?, " \
+ " roaming = ?, ifname = ?, imsi = ?, data_warn_limit = ? " \
+ " WHERE restriction_id = ?"
/* INSERT statement */
#define INSERT_NET_RESTRICTIONS "INSERT INTO restrictions " \
- "(binpath, rcv_limit, send_limit, iftype, rst_state, " \
- "roaming, ifname, imsi, rcv_warn_limit, send_warn_limit) " \
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
+ " (binpath, data_limit, iftype, rst_state, " \
+ " roaming, ifname, imsi, data_warn_limit) " \
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
static void __finalize_delete(void);
break;
case SQLITE_ROW:
data.app_id = (char *)sqlite3_column_text(stmt, 0);
- data.rcv_limit = sqlite3_column_int64(stmt, 1);
- data.send_limit = sqlite3_column_int64(stmt, 2);
- data.iftype = (stc_iface_type_e)sqlite3_column_int(stmt, 3);
+ data.data_limit = sqlite3_column_int64(stmt, 1);
+ data.iftype = (stc_iface_type_e)sqlite3_column_int(stmt, 2);
data.rst_state =
- (stc_restriction_state_e)sqlite3_column_int(stmt, 4);
- data.roaming = sqlite3_column_int(stmt, 5);
- data.ifname = (char *)sqlite3_column_text(stmt, 6);
- data.imsi = (char *)sqlite3_column_text(stmt, 7);
- data.rcv_warn_limit = sqlite3_column_int64(stmt, 8);
- data.send_warn_limit = sqlite3_column_int64(stmt, 9);
- data.restriction_id = sqlite3_column_int64(stmt, 10);
+ (stc_restriction_state_e)sqlite3_column_int(stmt, 3);
+ data.roaming = sqlite3_column_int(stmt, 4);
+ data.ifname = (char *)sqlite3_column_text(stmt, 5);
+ data.imsi = (char *)sqlite3_column_text(stmt, 6);
+ data.data_warn_limit = sqlite3_column_int64(stmt, 7);
+ data.restriction_id = sqlite3_column_int64(stmt, 8);
if (restriction_cb(&data, user_data) == STC_CANCEL)
rc = SQLITE_DONE;
break;
case SQLITE_ROW:
data.app_id = (char *)sqlite3_column_text(stmt, 0);
- data.rcv_limit = sqlite3_column_int64(stmt, 1);
- data.send_limit = sqlite3_column_int64(stmt, 2);
- data.iftype = (stc_iface_type_e)sqlite3_column_int(stmt, 3);
+ data.data_limit = sqlite3_column_int64(stmt, 1);
+ data.iftype = (stc_iface_type_e)sqlite3_column_int(stmt, 2);
data.rst_state =
- (stc_restriction_state_e)sqlite3_column_int(stmt, 4);
- data.roaming = sqlite3_column_int(stmt, 5);
- data.ifname = (char *)sqlite3_column_text(stmt, 6);
- data.imsi = (char *)sqlite3_column_text(stmt, 7);
- data.rcv_warn_limit = sqlite3_column_int64(stmt, 8);
- data.send_warn_limit = sqlite3_column_int64(stmt, 9);
- data.restriction_id = sqlite3_column_int64(stmt, 10);
+ (stc_restriction_state_e)sqlite3_column_int(stmt, 3);
+ data.roaming = sqlite3_column_int(stmt, 4);
+ data.ifname = (char *)sqlite3_column_text(stmt, 5);
+ data.imsi = (char *)sqlite3_column_text(stmt, 6);
+ data.data_warn_limit = sqlite3_column_int64(stmt, 7);
+ data.restriction_id = sqlite3_column_int64(stmt, 8);
if (restriction_cb(&data, user_data) == STC_CANCEL)
rc = SQLITE_DONE;
DB_ACTION(sqlite3_bind_int(stmt, 2, info->iftype));
DB_ACTION(sqlite3_bind_text(stmt, 3, info->imsi ? info->imsi : "",
-1, SQLITE_TRANSIENT));
- DB_ACTION(sqlite3_bind_int64(stmt, 4, info->send_limit));
- DB_ACTION(sqlite3_bind_int64(stmt, 5, info->rcv_limit));
- DB_ACTION(sqlite3_bind_int64(stmt, 6, info->rcv_warn_limit));
- DB_ACTION(sqlite3_bind_int64(stmt, 7, info->send_warn_limit));
-
- DB_ACTION(sqlite3_bind_int(stmt, 8, info->rst_state));
- DB_ACTION(sqlite3_bind_int(stmt, 9, info->roaming));
- DB_ACTION(sqlite3_bind_text(stmt, 10, info->ifname ? info->ifname : "",
+ DB_ACTION(sqlite3_bind_int64(stmt, 4, info->data_limit));
+ DB_ACTION(sqlite3_bind_int64(stmt, 5, info->data_warn_limit));
+ DB_ACTION(sqlite3_bind_int(stmt, 6, info->rst_state));
+ DB_ACTION(sqlite3_bind_int(stmt, 7, info->roaming));
+ DB_ACTION(sqlite3_bind_text(stmt, 8, info->ifname ? info->ifname : "",
-1, SQLITE_TRANSIENT));
rc = sqlite3_step(stmt);
DB_ACTION(sqlite3_bind_text(stmt, 1, info->app_id ? info->app_id : "",
-1, SQLITE_TRANSIENT));
- DB_ACTION(sqlite3_bind_int64(stmt, 2, info->rcv_limit));
- DB_ACTION(sqlite3_bind_int64(stmt, 3, info->send_limit));
- DB_ACTION(sqlite3_bind_int(stmt, 4, info->iftype));
- DB_ACTION(sqlite3_bind_int(stmt, 5, info->rst_state));
- DB_ACTION(sqlite3_bind_int(stmt, 6, info->roaming));
- DB_ACTION(sqlite3_bind_text(stmt, 7, info->ifname ? info->ifname : "",
+ DB_ACTION(sqlite3_bind_int64(stmt, 2, info->data_limit));
+ DB_ACTION(sqlite3_bind_int(stmt, 3, info->iftype));
+ DB_ACTION(sqlite3_bind_int(stmt, 4, info->rst_state));
+ DB_ACTION(sqlite3_bind_int(stmt, 5, info->roaming));
+ DB_ACTION(sqlite3_bind_text(stmt, 6, info->ifname ? info->ifname : "",
-1, SQLITE_TRANSIENT));
- DB_ACTION(sqlite3_bind_text(stmt, 8, info->imsi ? info->imsi : "",
+ DB_ACTION(sqlite3_bind_text(stmt, 7, info->imsi ? info->imsi : "",
-1, SQLITE_TRANSIENT));
- DB_ACTION(sqlite3_bind_int64(stmt, 9, info->rcv_warn_limit));
- DB_ACTION(sqlite3_bind_int64(stmt, 10, info->send_warn_limit));
+ DB_ACTION(sqlite3_bind_int64(stmt, 8, info->data_warn_limit));
if (info->restriction_id)
DB_ACTION(sqlite3_bind_int64(stmt, 11, info->restriction_id));
uint64_t restriction_id;
uint32_t classid;
stc_restriction_state_e rst_state;
- stc_data_counter_s limit;
- stc_data_counter_s warn_limit;
- stc_data_counter_s counter;
- gboolean in_limit_reached;
- gboolean out_limit_reached;
+ int64_t data_limit;
+ int64_t data_warn_limit;
+ int64_t data_counter;
+ gboolean data_limit_reached;
gboolean warn_limit_crossed_notified;
gboolean rstn_limit_crossed_notified;
} stc_rstn_value_s;
typedef struct {
struct nfacct_rule *counter;
int64_t bytes;
- gboolean in_limit_reached;
- gboolean out_limit_reached;
+ gboolean data_limit_reached;
} classid_bytes_context_s;
static stc_system_s *g_system = NULL;
STC_LOGI("rstn info => rstn_id [%llu], "
"app_id [%s], classid [%lu], ifname [%s], "
"iftype [%d], rst_state [%d], "
- "limit [ in (%lld), out (%lld)], "
- "warn_limit [ in (%lld), out (%lld)], "
- "counter [ in (%lld), out (%lld)], "
+ "limit [ (%lld) bytes], "
+ "warn_limit [ (%lld) bytes], "
+ "counter [ (%lld) bytes], "
"roaming [%d], imsi [%s]",
rstn_value->restriction_id,
rstn_key->app_id, rstn_value->classid , rstn_key->ifname,
rstn_key->iftype, rstn_value->rst_state,
- rstn_value->limit.in_bytes, rstn_value->limit.out_bytes,
- rstn_value->warn_limit.in_bytes,
- rstn_value->warn_limit.out_bytes,
- rstn_value->counter.in_bytes, rstn_value->counter.out_bytes,
+ rstn_value->data_limit,
+ rstn_value->data_warn_limit,
+ rstn_value->data_counter,
rstn_key->roaming, rstn_key->imsi);
}
stc_rstn_key_s *rstn_key,
stc_rstn_value_s *rstn_value, void *data)
{
- stc_data_counter_s effective_limit, effective_warn_limit;
+ int64_t effective_data_limit, effective_data_warn_limit;
default_connection_s *old_connection = (default_connection_s *)data;
default_connection_s *connection = NULL;
if (rstn_value->classid == STC_UNKNOWN_CLASSID)
return;
- effective_limit.out_bytes = rstn_value->limit.out_bytes;
- effective_limit.in_bytes = rstn_value->limit.in_bytes;
- effective_warn_limit.out_bytes = rstn_value->warn_limit.out_bytes;
- effective_warn_limit.in_bytes = rstn_value->warn_limit.in_bytes;
+ effective_data_limit = rstn_value->data_limit;
+ effective_data_warn_limit = rstn_value->data_warn_limit;
if (rst_type == RST_SET) {
/* TODO: Change this to runtime memory */
memset(&info, 0, sizeof(table_counters_info));
table_counters_get(rstn_value->restriction_id, &info);
- effective_limit.out_bytes -= info.sent_bytes;
- effective_limit.in_bytes -= info.rcv_bytes;
- effective_warn_limit.out_bytes -= info.sent_bytes;
- effective_warn_limit.in_bytes -= info.rcv_bytes;
+ effective_data_limit -= info.data_counter;
+ effective_data_warn_limit -= info.data_counter;
- if (effective_limit.in_bytes < 0) {
- effective_limit.in_bytes = 0;
- rstn_value->in_limit_reached = TRUE;
+ if (effective_data_limit < 0) {
+ effective_data_limit = 0;
+ rstn_value->data_limit_reached = TRUE;
}
- if (effective_limit.out_bytes < 0) {
- effective_limit.out_bytes = 0;
- rstn_value->out_limit_reached = TRUE;
- }
-
- if (effective_warn_limit.in_bytes < 0)
- effective_warn_limit.in_bytes = 0;
+ if (effective_data_warn_limit < 0)
+ effective_data_warn_limit = 0;
- if (effective_warn_limit.out_bytes < 0)
- effective_warn_limit.out_bytes = 0;
- STC_LOGD("datausage [in: %lld, out: %lld]",
- info.rcv_bytes, info.sent_bytes);
+ STC_LOGD("datausage [%lld] bytes", info.data_counter);
}
- 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);
+ STC_LOGD("rstn_id [%llu], effective_data_limit [%lld] bytes, "
+ "effective_data_warn_limit [%lld] bytes",
+ rstn_value->restriction_id, effective_data_limit,
+ effective_data_warn_limit);
switch (rst_type) {
case RST_SET:
rstn_value->rst_state = STC_RESTRICTION_ACTIVATED;
- rstn_value->in_limit_reached = FALSE;
- rstn_value->out_limit_reached = FALSE;
+ rstn_value->data_limit_reached = FALSE;
break;
case RST_EXCLUDE:
;//Do Nothing
break;
case RST_UNSET:
rstn_value->rst_state = STC_RESTRICTION_REMOVED;
- rstn_value->in_limit_reached = FALSE;
- rstn_value->out_limit_reached = FALSE;
+ rstn_value->data_limit_reached = FALSE;
break;
default:
;//Do Nothing
if (rstn_value->classid != context->counter->classid)
goto try_next_callback;
- if (rstn_value->in_limit_reached == TRUE) {
- context->in_limit_reached = TRUE;
- goto try_next_callback;
- }
-
- if (rstn_value->out_limit_reached == TRUE) {
- context->out_limit_reached = TRUE;
+ if (rstn_value->data_limit_reached == TRUE) {
+ context->data_limit_reached = TRUE;
goto try_next_callback;
}
switch (context->counter->iotype) {
case NFACCT_COUNTER_IN:
- rstn_value->counter.in_bytes += context->bytes;
+ case NFACCT_COUNTER_OUT:
+ rstn_value->data_counter += context->bytes;
+
+ if (rstn_value->data_counter >= rstn_value->data_warn_limit &&
+ rstn_value->warn_limit_crossed_notified == FALSE) {
- if (rstn_value->counter.in_bytes >= rstn_value->warn_limit.in_bytes
- && rstn_value->warn_limit_crossed_notified == FALSE) {
gboolean rv = FALSE;
char iftype[MAX_INT_LENGTH];
char byte[MAX_INT_LENGTH];
stc_s *stc = (stc_s *)stc_get_manager();
ret_value_msg_if(stc == NULL, FALSE, "failed to get stc data");
+ /* emit signal */
rv = stc_manager_dbus_emit_signal(stc->connection,
STC_DBUS_SERVICE_RESTRICTION_PATH,
STC_DBUS_INTERFACE_RESTRICTION,
rstn_value->warn_limit_crossed_notified = TRUE;
snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
- snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit.in_bytes);
+ snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->data_warn_limit);
stc_send_warn_message_to_net_popup("warn threshold crossed",
- "warning_noti", rstn_key->app_id, iftype, byte);
- }
-
- /* block immediately */
- if (rstn_value->counter.in_bytes >= rstn_value->limit.in_bytes) {
- context->counter->intend = NFACCT_BLOCK;
- __del_iptables_in(context->counter);
- __add_iptables_in(context->counter);
- context->counter->intend = NFACCT_COUNTER;
- rstn_value->in_limit_reached = TRUE;
-
- if (rstn_value->rstn_limit_crossed_notified == FALSE) {
- gboolean rv = FALSE;
- int ret = 0;
- char iftype[MAX_INT_LENGTH];
- char byte[MAX_INT_LENGTH];
- stc_s *stc = (stc_s *)stc_get_manager();
- ret_value_msg_if(stc == NULL, FALSE, "failed to get stc data");
-
- rv = stc_manager_dbus_emit_signal(stc->connection,
- STC_DBUS_SERVICE_RESTRICTION_PATH,
- STC_DBUS_INTERFACE_RESTRICTION,
- "RestrictionThresholdCrossed",
- g_variant_new("(s)", rstn_key->app_id));
- if (rv == TRUE)
- rstn_value->rstn_limit_crossed_notified = TRUE;
-
- snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
- snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit.in_bytes);
- stc_send_restriction_message_to_net_popup("restriction threshold crossed",
- "restriction_noti", rstn_key->app_id, iftype, byte);
- }
+ "warning_noti",
+ rstn_key->app_id,
+ iftype, byte);
}
- g_system->rstns_tree_updated = TRUE;
- __print_rstn(rstn_key, rstn_value);
- break;
- case NFACCT_COUNTER_OUT:
- rstn_value->counter.out_bytes += context->bytes;
+ if (rstn_value->data_counter >= rstn_value->data_limit &&
+ rstn_value->rstn_limit_crossed_notified == FALSE) {
- if (rstn_value->counter.out_bytes >= rstn_value->limit.out_bytes
- && rstn_value->warn_limit_crossed_notified == FALSE) {
gboolean rv = FALSE;
char iftype[MAX_INT_LENGTH];
char byte[MAX_INT_LENGTH];
stc_s *stc = (stc_s *)stc_get_manager();
ret_value_msg_if(stc == NULL, FALSE, "failed to get stc data");
+ /* block immediately */
+ context->counter->intend = NFACCT_BLOCK;
+ __del_iptables_in(context->counter);
+ __del_iptables_out(context->counter);
+ __add_iptables_in(context->counter);
+ __add_iptables_out(context->counter);
+ context->counter->intend = NFACCT_COUNTER;
+
+ rstn_value->data_limit_reached = TRUE;
+
+ /* emit signal */
rv = stc_manager_dbus_emit_signal(stc->connection,
STC_DBUS_SERVICE_RESTRICTION_PATH,
STC_DBUS_INTERFACE_RESTRICTION,
- "WarnThresholdCrossed",
+ "RestrictionThresholdCrossed",
g_variant_new("(s)", rstn_key->app_id));
if (rv == TRUE)
- rstn_value->warn_limit_crossed_notified = TRUE;
+ rstn_value->rstn_limit_crossed_notified = TRUE;
snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
- snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit.out_bytes);
- stc_send_warn_message_to_net_popup("warn threshold crossed",
- "warning_noti", rstn_key->app_id, iftype, byte);
- }
-
- /* block immediately */
- if (rstn_value->counter.out_bytes >= rstn_value->limit.out_bytes) {
- context->counter->intend = NFACCT_BLOCK;
- __del_iptables_out(context->counter);
- __add_iptables_out(context->counter);
- context->counter->intend = NFACCT_COUNTER;
- rstn_value->out_limit_reached = TRUE;
-
- if (rstn_value->rstn_limit_crossed_notified == FALSE) {
- gboolean rv = FALSE;
- char iftype[MAX_INT_LENGTH];
- char byte[MAX_INT_LENGTH];
- stc_s *stc = (stc_s *)stc_get_manager();
- ret_value_msg_if(stc == NULL, FALSE, "failed to get stc data");
-
- rv = stc_manager_dbus_emit_signal(stc->connection,
- STC_DBUS_SERVICE_RESTRICTION_PATH,
- STC_DBUS_INTERFACE_RESTRICTION,
- "RestrictionThresholdCrossed",
- g_variant_new("(s)", rstn_key->app_id));
- if (rv == TRUE)
- rstn_value->rstn_limit_crossed_notified = TRUE;
-
- snprintf(iftype, MAX_INT_LENGTH, "%d", rstn_key->iftype);
- snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->limit.out_bytes);
- stc_send_restriction_message_to_net_popup("restriction threshold crossed",
- "restriction_noti", rstn_key->app_id, iftype, byte);
- }
+ snprintf(byte, MAX_INT_LENGTH, "%lld", rstn_value->data_limit);
+ stc_send_restriction_message_to_net_popup("restriction threshold crossed",
+ "restriction_noti", rstn_key->app_id,
+ iftype, byte);
}
g_system->rstns_tree_updated = TRUE;
stat.app_id = g_strdup(app_key->app_id);
stat.snd_count = app_value->counter.out_bytes;
stat.rcv_count = app_value->counter.in_bytes;
- stat.delta_snd = 0;
- stat.delta_rcv = 0;
stat.is_roaming = stc_default_connection_get_roaming();
stat.ground = STC_APP_STATE_UNKNOWN;
stc_rstn_value_s *rstn_value = (stc_rstn_value_s *)value;
table_counters_info info = {
.restriction_id = rstn_value->restriction_id,
- .sent_bytes = rstn_value->counter.out_bytes,
- .rcv_bytes = rstn_value->counter.in_bytes
+ .data_counter = rstn_value->data_counter
};
table_counters_update_counters(&info);
classid_bytes_context_s context = {
.counter = &counter,
.bytes = bytes,
- .in_limit_reached = FALSE,
- .out_limit_reached = FALSE
+ .data_limit_reached = FALSE,
};
STC_LOGD("cnt_name %s", cnt_name);
rstn_value->restriction_id = value->restriction_id;
rstn_value->rst_state = value->rst_state;
rstn_value->classid = value->classid;
- rstn_value->limit.in_bytes = value->limit.in_bytes;
- rstn_value->limit.out_bytes = value->limit.out_bytes;
- rstn_value->warn_limit.in_bytes = value->warn_limit.in_bytes;
- rstn_value->warn_limit.out_bytes = value->warn_limit.out_bytes;
- rstn_value->counter.in_bytes = 0;
- rstn_value->counter.out_bytes = 0;
+ rstn_value->data_limit = value->data_limit;
+ rstn_value->data_warn_limit = value->data_warn_limit;
+ rstn_value->data_counter = 0;
rstn_value->warn_limit_crossed_notified = FALSE;
rstn_value->rstn_limit_crossed_notified = FALSE;
else
value.classid = STC_UNKNOWN_CLASSID;
- value.limit.in_bytes = info->rcv_limit;
- value.limit.out_bytes = info->send_limit;
- value.warn_limit.in_bytes = info->rcv_warn_limit;
- value.warn_limit.out_bytes = info->send_warn_limit;
+ value.data_limit = info->data_limit;
+ value.data_warn_limit = info->data_warn_limit;
if (__rstn_tree_add(&key, &value, FALSE) != STC_ERROR_NONE)
ret = STC_CANCEL;
key->pkg_id = g_strdup(app_key.pkg_id);
value->type = app_value.type;
- value->counter.in_bytes = app_value.counter.in_bytes;
- value->counter.out_bytes = app_value.counter.out_bytes;
+ value->data_usage.in_bytes = app_value.data_usage.in_bytes;
+ value->data_usage.out_bytes = app_value.data_usage.out_bytes;
value->processes = g_tree_new_full(__processes_tree_key_compare, NULL,
__processes_tree_key_free,
else
value.classid = STC_UNKNOWN_CLASSID;
- value.limit.in_bytes = info->rcv_limit;
- value.limit.out_bytes = info->send_limit;
- value.warn_limit.in_bytes = info->rcv_warn_limit;
- value.warn_limit.out_bytes = info->send_warn_limit;
+ value.data_limit = info->data_limit;
+ value.data_warn_limit = info->data_warn_limit;
ret = __rstn_tree_add(&key, &value, TRUE);
rule->ifname = NULL;
rule->iftype = STC_IFACE_ALL;
rule->rst_state = STC_RESTRICTION_REMOVED;
- rule->rcv_limit = 0;
- rule->send_limit = 0;
- rule->rcv_warn_limit = 0;
- rule->send_warn_limit = 0;
+ rule->data_limit = 0;
+ rule->data_warn_limit = 0;
rule->roaming = STC_ROAMING_DISABLE;
rule->imsi = NULL;
}
g_variant_builder_add(builder, "{sv}", "rst_state",
g_variant_new_uint16(info->rst_state));
- g_variant_builder_add(builder, "{sv}", "rcv_limit",
- g_variant_new_int64(info->rcv_limit));
+ g_variant_builder_add(builder, "{sv}", "data_limit",
+ g_variant_new_int64(info->data_limit));
- g_variant_builder_add(builder, "{sv}", "send_limit",
- g_variant_new_int64(info->send_limit));
-
- g_variant_builder_add(builder, "{sv}", "rcv_warn_limit",
- g_variant_new_int64(info->rcv_warn_limit));
-
- g_variant_builder_add(builder, "{sv}", "send_warn_limit",
- g_variant_new_int64(info->send_warn_limit));
+ g_variant_builder_add(builder, "{sv}", "data_warn_limit",
+ g_variant_new_int64(info->data_warn_limit));
g_variant_builder_add(builder, "{sv}", "roaming",
g_variant_new_uint16(info->roaming));
rule->iftype = g_variant_get_uint16(value);
STC_LOGD("iftype: [%u]", (unsigned int) rule->iftype);
- } else if (!g_strcmp0(key, "rcv_limit")) {
- rule->rcv_limit = g_variant_get_int64(value);
- STC_LOGD("rcv_limit: [%lld]", rule->rcv_limit);
-
- } else if (!g_strcmp0(key, "send_limit")) {
- rule->send_limit = g_variant_get_int64(value);
- STC_LOGD("send_limit: [%lld]", rule->send_limit);
-
- } else if (!g_strcmp0(key, "rcv_warn_limit")) {
- rule->rcv_warn_limit = g_variant_get_int64(value);
- STC_LOGD("rcv_warn_limit: [%lld]", rule->rcv_warn_limit);
+ } else if (!g_strcmp0(key, "data_limit")) {
+ rule->data_limit = g_variant_get_int64(value);
+ STC_LOGD("data_limit: [%lld]", rule->data_limit);
- } else if (!g_strcmp0(key, "send_warn_limit")) {
- rule->send_warn_limit = g_variant_get_int64(value);
- STC_LOGD("send_warn_limit: [%lld]", rule->send_warn_limit);
+ } else if (!g_strcmp0(key, "data_warn_limit")) {
+ rule->data_warn_limit = g_variant_get_int64(value);
+ STC_LOGD("data_warn_limit: [%lld]", rule->data_warn_limit);
} else if (!g_strcmp0(key, "roaming")) {
rule->roaming = g_variant_get_uint16(value);