void __initialize_rstn_rule(table_restrictions_info *rule)
{
rule->app_id = NULL;
- rule->ifname = NULL;
+
rule->iftype = STC_IFACE_ALL;
+ rule->ifname = NULL;
+
+ rule->subscriber_id = NULL;
+ rule->roaming = STC_ROAMING_DISABLE;
+
rule->rstn_type = STC_RSTN_TYPE_UNKNOWN;
rule->data_limit = -1;
rule->data_warn_limit = -1;
+
+ rule->month_start_date = 1;
rule->monthly_limit = -1;
rule->weekly_limit = -1;
rule->daily_limit = -1;
- rule->roaming = STC_ROAMING_DISABLE;
- rule->subscriber_id = NULL;
+
+ rule->mac = NULL;
}
gboolean __validate_rstn_rule(table_restrictions_info *rule)
return FALSE; //LCOV_EXCL_LINE
}
- if (rule->roaming >= STC_ROAMING_LAST_ELEM) {
+ if (rule->roaming > STC_ROAMING_ENABLE) {
__STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
return FALSE; //LCOV_EXCL_LINE
}
rule->rstn_type = g_variant_get_uint16(value);
STC_LOGD("type: [%u]", (unsigned int) rule->rstn_type);
+ } else if (!g_strcmp0(key, "mac")) {
+ guint str_length;
+ const gchar *str = g_variant_get_string(value, &str_length);
+ rule->mac = g_strdup(str);
+ STC_LOGD("mac: [%s]", rule->mac);
+
} else {
STC_LOGD("Unknown select rule"); //LCOV_EXCL_LINE
}
__STC_LOG_FUNC_ENTER__;
GVariantIter *iter = NULL;
table_restrictions_info rule;
+ stc_error_e ret = STC_ERROR_NONE;
memset(&rule, 0, sizeof(table_restrictions_info));
__initialize_rstn_rule(&rule);
return TRUE;
}
- table_restrictions_update(&rule);
- /* update restriction rule in runtime structure */
- stc_monitor_rstns_tree_add(&rule);
+ ret = table_restrictions_update(&rule);
+ if (ret != STC_ERROR_NONE) {
+ STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
+ STC_ERROR_DB_FAILED);
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return TRUE;
+ }
+ stc_monitor_rstn_add(&rule);
STC_DBUS_REPLY_ERROR_NONE(invocation);
__STC_LOG_FUNC_EXIT__;
return TRUE;
__STC_LOG_FUNC_ENTER__;
GVariantIter *iter = NULL;
table_restrictions_info rule;
+ stc_error_e ret = STC_ERROR_NONE;
memset(&rule, 0, sizeof(table_restrictions_info));
__initialize_rstn_rule(&rule);
return TRUE;
}
- table_restrictions_delete(rule.app_id, rule.iftype, rule.subscriber_id);
- /* remove restriction rule from runtime structure */
- stc_monitor_rstns_tree_remove(&rule);
+ ret = table_restrictions_delete(rule.app_id, rule.iftype, rule.ifname,
+ rule.subscriber_id, rule.roaming);
+ if (ret != STC_ERROR_NONE) {
+ STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
+ STC_ERROR_DB_FAILED);
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return TRUE;
+ }
+ stc_monitor_rstn_remove(&rule);
STC_DBUS_REPLY_ERROR_NONE(invocation);
__STC_LOG_FUNC_EXIT__;
return TRUE;