/* SELECT statements */
#define SELECT_RESTRICTIONS "SELECT binpath, data_limit, " \
- " iftype, rst_state, roaming, ifname, subscriber_id, " \
+ " iftype, rst_type, roaming, ifname, subscriber_id, " \
" data_warn_limit, restriction_id FROM restrictions"
#define SELECT_RESTRICTIONS_PER_APP "SELECT binpath, data_limit, " \
- " iftype, rst_state, roaming, ifname, subscriber_id, " \
+ " iftype, rst_type, roaming, ifname, subscriber_id, " \
" data_warn_limit, restriction_id " \
" FROM restrictions INDEXED BY restrictions_index " \
" WHERE binpath = ?"
-#define SELECT_RESTRICTION_STATE "SELECT rst_state " \
+#define SELECT_RESTRICTION_STATE "SELECT rst_type " \
" FROM restrictions INDEXED BY restrictions_index " \
" WHERE binpath = ? AND iftype = ?"
-#define SELECT_RESTRICTION_STATE_SUBSCRIBER_ID "SELECT rst_state " \
+#define SELECT_RESTRICTION_STATE_SUBSCRIBER_ID "SELECT rst_type " \
" FROM restrictions INDEXED BY restrictions_index " \
" WHERE binpath = ? AND iftype = ? AND subscriber_id = ?"
#define SELECT_RESTRICTION_ID "SELECT restriction_id FROM restrictions " \
" WHERE binpath = ? AND iftype = ? AND subscriber_id = ? AND " \
- " rst_state = ? AND roaming = ? AND ifname = ?"
+ " rst_type = ? AND roaming = ? AND ifname = ?"
/* UPDATE statement */
#define UPDATE_NET_RESTRICTIONS "UPDATE restrictions " \
- " SET binpath = ?, data_limit = ?, iftype = ?, rst_state = ?, " \
+ " SET binpath = ?, data_limit = ?, iftype = ?, rst_type = ?, " \
" roaming = ?, ifname = ?, subscriber_id = ?, data_warn_limit = ? " \
" WHERE restriction_id = ?"
/* INSERT statement */
#define INSERT_NET_RESTRICTIONS "INSERT INTO restrictions " \
- " (binpath, data_limit, iftype, rst_state, " \
+ " (binpath, data_limit, iftype, rst_type, " \
" roaming, ifname, subscriber_id, data_warn_limit) " \
" VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
data.app_id = (char *)sqlite3_column_text(stmt, 0);
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, 3);
+ data.rst_type =
+ (stc_rstn_type_e)sqlite3_column_int(stmt, 3);
data.roaming = sqlite3_column_int(stmt, 4);
data.ifname = (char *)sqlite3_column_text(stmt, 5);
data.subscriber_id = (char *)sqlite3_column_text(stmt, 6);
data.app_id = (char *)sqlite3_column_text(stmt, 0);
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, 3);
+ data.rst_type =
+ (stc_rstn_type_e)sqlite3_column_int(stmt, 3);
data.roaming = sqlite3_column_int(stmt, 4);
data.ifname = (char *)sqlite3_column_text(stmt, 5);
data.subscriber_id = (char *)sqlite3_column_text(stmt, 6);
DB_ACTION(sqlite3_bind_int(stmt, 2, info->iftype));
DB_ACTION(sqlite3_bind_text(stmt, 3, info->subscriber_id ? info->subscriber_id : "",
-1, SQLITE_TRANSIENT));
- DB_ACTION(sqlite3_bind_int(stmt, 4, info->rst_state));
+ DB_ACTION(sqlite3_bind_int(stmt, 4, info->rst_type));
DB_ACTION(sqlite3_bind_int(stmt, 5, info->roaming));
DB_ACTION(sqlite3_bind_text(stmt, 6, info->ifname ? info->ifname : "",
-1, SQLITE_TRANSIENT));
-1, SQLITE_TRANSIENT));
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, 4, info->rst_type));
DB_ACTION(sqlite3_bind_int(stmt, 5, info->roaming));
DB_ACTION(sqlite3_bind_text(stmt, 6, info->ifname ? info->ifname : "",
-1, SQLITE_TRANSIENT));
if (ret != 0)
return ret;
+ ret = key_a->roaming - key_b->roaming;
+ if (ret != 0)
+ return ret;
+
return 0;
}
rstn_value->restriction_id = value->restriction_id;
rstn_value->rst_state = value->rst_state;
+ rstn_value->rst_type = value->rst_type;
rstn_value->classid = value->classid;
rstn_value->data_limit = value->data_limit;
rstn_value->data_warn_limit = value->data_warn_limit;
key.iftype = info->iftype;
key.roaming = info->roaming;
- value.rst_state = info->rst_state;
+ value.rst_type = info->rst_type;
+ value.rst_state = STC_RESTRICTION_UNKNOWN;
value.restriction_id = info->restriction_id;
- if (value.rst_state != STC_RESTRICTION_EXCLUDED && info->app_id)
+ if (info->app_id)
value.classid = get_classid_by_app_id(info->app_id, TRUE);
else
value.classid = STC_UNKNOWN_CLASSID;
key.iftype = info->iftype;
key.roaming = info->roaming;
- value.rst_state = info->rst_state;
+ value.rst_type = info->rst_type;
+ value.rst_state = STC_RESTRICTION_UNKNOWN;
value.restriction_id = info->restriction_id;
- if (value.rst_state > STC_RESTRICTION_UNKNOWN &&
- value.rst_state < STC_RESTRICTION_LAST_ELEM &&
- info->app_id)
+ if (info->app_id)
value.classid = get_classid_by_app_id(info->app_id, TRUE);
else
value.classid = STC_UNKNOWN_CLASSID;
rule->app_id = NULL;
rule->ifname = NULL;
rule->iftype = STC_IFACE_ALL;
- rule->rst_state = STC_RESTRICTION_REMOVED;
+ rule->rst_type = STC_RSTN_TYPE_UNKNOWN;
rule->data_limit = 0;
rule->data_warn_limit = 0;
rule->roaming = STC_ROAMING_DISABLE;
g_variant_builder_add(builder, "{sv}", "iftype",
g_variant_new_uint16(info->iftype));
- g_variant_builder_add(builder, "{sv}", "rst_state",
- g_variant_new_uint16(info->rst_state));
+ g_variant_builder_add(builder, "{sv}", "rst_type",
+ g_variant_new_uint16(info->rst_type));
g_variant_builder_add(builder, "{sv}", "data_limit",
g_variant_new_int64(info->data_limit));
g_variant_iter_free(iter);
}
- rule.rst_state = STC_RESTRICTION_REMOVED;
+ rule.rst_type = STC_RSTN_TYPE_BLOCKED;
if (__validate_rstn_rule(&rule, RST_SET) == FALSE) {
STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
g_variant_iter_free(iter);
}
- rule.rst_state = STC_RESTRICTION_EXCLUDED;
+ rule.rst_type = STC_RSTN_TYPE_EXCLUDED;
if (__validate_rstn_rule(&rule, RST_EXCLUDE) == FALSE) {
STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE