g_variant_builder_add(builder, "{sv}",
STC_RESTRICTION_RULE_RX_LIMIT,
- g_variant_new_uint64(restriction_rule->rx_limit));
+ g_variant_new_int64(restriction_rule->rx_limit));
g_variant_builder_add(builder, "{sv}",
STC_RESTRICTION_RULE_TX_LIMIT,
- g_variant_new_uint64(restriction_rule->tx_limit));
+ g_variant_new_int64(restriction_rule->tx_limit));
g_variant_builder_add(builder, "{sv}",
STC_RESTRICTION_RULE_RX_WARNING_LIMIT,
- g_variant_new_uint64(restriction_rule->rx_warning_limit));
+ g_variant_new_int64(restriction_rule->rx_warning_limit));
g_variant_builder_add(builder, "{sv}",
STC_RESTRICTION_RULE_TX_WARNING_LIMIT,
- g_variant_new_uint64(restriction_rule->tx_warning_limit));
+ g_variant_new_int64(restriction_rule->tx_warning_limit));
*params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
g_variant_builder_unref(builder);
if (!g_strcmp0(key, STC_RESTRICTION_INFO_APP_ID)) {
const char *app_id = g_variant_get_string(value, NULL);
if (app_id != NULL)
- g_strlcpy(restriction_info->app_id,
- app_id, strlen(restriction_info->app_id));
-
+ g_strlcpy(restriction_info->app_id, app_id, STC_APP_ID_LEN);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_IFNAME)) {
const char *iface_name = g_variant_get_string(value, NULL);
if (iface_name != NULL)
- g_strlcpy(restriction_info->iface_name,
- iface_name, strlen(restriction_info->iface_name));
+ g_strlcpy(restriction_info->iface_name, iface_name, STC_IFNAME_LEN);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_IMSI)) {
const char *imsi = g_variant_get_string(value, NULL);
if (imsi != NULL)
- g_strlcpy(restriction_info->imsi,
- imsi, strlen(restriction_info->imsi));
+ g_strlcpy(restriction_info->imsi, imsi, STC_IMSI_LEN);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_IFTYPE)) {
restriction_info->iface_type =
(stc_restriction_status_e)g_variant_get_uint16(value);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_RX_LIMIT)) {
- restriction_info->rx_limit = g_variant_get_uint64(value);
+ restriction_info->rx_limit = g_variant_get_int64(value);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_TX_LIMIT)) {
- restriction_info->tx_limit = g_variant_get_uint64(value);
+ restriction_info->tx_limit = g_variant_get_int64(value);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_RX_WARNING_LIMIT)) {
- restriction_info->rx_warning_limit = g_variant_get_uint64(value);
+ restriction_info->rx_warning_limit = g_variant_get_int64(value);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_TX_WARNING_LIMIT)) {
- restriction_info->tx_warning_limit = g_variant_get_uint64(value);
+ restriction_info->tx_warning_limit = g_variant_get_int64(value);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_ROAMING)) {
restriction_info->roaming_type =
static void __stc_restriction_print_info(
stc_restriction_info_s *info)
{
- STC_LOGD("App_id: [%s] Ifname: [%s] Iftype: [%s] Imsi: [%s] Roaming: [%s] "
- "Status: [%s] Limit: Rx [%llu] Tx [%llu] Warning_limit: Rx [%llu] Tx [%llu]",
- (info->app_id[0] != '\0') ? info->app_id : "NULL",
- (info->iface_name[0] != '\0') ? info->iface_name : "NULL",
- _stc_convert_iface_type_to_string(info->iface_type),
- (info->imsi[0] != '\0') ? info->imsi : "NULL",
- _stc_convert_roaming_to_string(info->roaming_type),
- _stc_convert_rst_status_to_string(info->rst_status),
- info->rx_limit, info->tx_limit,
- info->rx_warning_limit, info->tx_warning_limit);
+ STC_LOGD(STC_HR_SINGLE);
+
+ STC_LOGD("App_id: [%s]", (info->app_id[0] != '\0') ? info->app_id : "NULL");
+ STC_LOGD("Ifname: [%s]", (info->iface_name[0] != '\0') ? info->iface_name : "NULL");
+
+ if (info->iface_type != STC_IFACE_UNKNOWN)
+ STC_LOGD("Iftype: [%s]", _stc_convert_iface_type_to_string(info->iface_type));
+
+ if (info->imsi[0] != '\0')
+ STC_LOGD("Imsi: [%s]", info->imsi);
+
+ if (info->roaming_type != STC_ROAMING_UNKNOWN)
+ STC_LOGD("Roaming: [%s]", _stc_convert_roaming_to_string(info->roaming_type));
+
+ if (info->rst_status != STC_RESTRICTION_UNKNOWN)
+ STC_LOGD("Status: [%s]", _stc_convert_rst_status_to_string(info->rst_status));
+
+ STC_LOGD("Limit: [%lld, %lld]", info->rx_limit, info->tx_limit);
+ STC_LOGD("Warning: [%lld, %lld]", info->rx_warning_limit, info->tx_warning_limit);
+
+ STC_LOGD(STC_HR_SINGLE);
}
static void __stc_restriction_get_per_app_id_reply(
"Invalid restriction network interface type [%s]",
_stc_convert_iface_type_to_string(restriction_rule->iface_type));
+ if (rst_type == STC_RST_TYPE_SET) {
+ STC_RETURN_VAL_IF(restriction_rule->tx_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid tx limit [%lld]",
+ restriction_rule->tx_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid rx limit [%lld]",
+ restriction_rule->rx_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid tx warning limit [%lld]",
+ restriction_rule->tx_warning_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid rx warning limit [%lld]",
+ restriction_rule->rx_warning_limit);
+ }
+
STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
restriction_rule->roaming_type > STC_ROAMING_DISABLED,
STC_ERROR_INVALID_PARAMETER,
"Invalid restriction network interface type [%s]",
_stc_convert_iface_type_to_string(restriction_rule->iface_type));
+ STC_RETURN_VAL_IF(restriction_rule->tx_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid tx limit [%lld]",
+ restriction_rule->tx_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid rx limit [%lld]",
+ restriction_rule->rx_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid tx warning limit [%lld]",
+ restriction_rule->tx_warning_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid rx warning limit [%lld]",
+ restriction_rule->rx_warning_limit);
+
STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
restriction_rule->roaming_type > STC_ROAMING_DISABLED,
STC_ERROR_INVALID_PARAMETER,
"Invalid restriction network interface type [%d]",
restriction_rule->iface_type);
+ STC_RETURN_VAL_IF(restriction_rule->tx_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid tx limit [%lld]",
+ restriction_rule->tx_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid rx limit [%lld]",
+ restriction_rule->rx_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid tx warning limit [%lld]",
+ restriction_rule->tx_warning_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid rx warning limit [%lld]",
+ restriction_rule->rx_warning_limit);
+
STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
restriction_rule->roaming_type > STC_ROAMING_DISABLED,
STC_ERROR_INVALID_PARAMETER,
"Invalid restriction network interface type [%d]",
restriction_rule->iface_type);
+ STC_RETURN_VAL_IF(restriction_rule->tx_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid tx limit [%lld]",
+ restriction_rule->tx_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid rx limit [%lld]",
+ restriction_rule->rx_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid tx warning limit [%lld]",
+ restriction_rule->tx_warning_limit);
+
+ STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+ STC_ERROR_INVALID_PARAMETER,
+ "Invalid rx warning limit [%lld]",
+ restriction_rule->rx_warning_limit);
+
STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
restriction_rule->roaming_type > STC_ROAMING_DISABLED,
STC_ERROR_INVALID_PARAMETER,
}
EXPORT_API int stc_restriction_rule_set_limit(stc_restriction_rule_h rule,
- uint64_t rx_limit, uint64_t tx_limit)
+ int64_t rx_limit, int64_t tx_limit)
{
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
restriction_rule->rx_limit = rx_limit;
restriction_rule->tx_limit = tx_limit;
- STC_LOGI("Limit rx[%llu] tx[%llu]",
+ STC_LOGI("Limit rx[%lld] tx[%lld]",
restriction_rule->rx_limit, restriction_rule->tx_limit);
return STC_ERROR_NONE;
}
EXPORT_API int stc_restriction_rule_set_warning_limit(stc_restriction_rule_h rule,
- uint64_t rx_warning_limit, uint64_t tx_warning_limit)
+ int64_t rx_warning_limit, int64_t tx_warning_limit)
{
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
restriction_rule->rx_warning_limit = rx_warning_limit;
restriction_rule->tx_warning_limit = tx_warning_limit;
- STC_LOGI("Warning limit rx[%llu] tx[%llu]",
+ STC_LOGI("Warning limit rx[%lld] tx[%lld]",
restriction_rule->rx_warning_limit, restriction_rule->tx_warning_limit);
return STC_ERROR_NONE;
}
EXPORT_API int stc_restriction_rule_get_limit(stc_restriction_rule_h rule,
- uint64_t *rx_limit, uint64_t *tx_limit)
+ int64_t *rx_limit, int64_t *tx_limit)
{
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
*rx_limit = restriction_rule->rx_limit;
*tx_limit = restriction_rule->tx_limit;
- STC_LOGI("Limit rx[%llu] tx[%llu]", *rx_limit, *tx_limit);
+ STC_LOGI("Limit rx[%lld] tx[%lld]", *rx_limit, *tx_limit);
return STC_ERROR_NONE;
}
EXPORT_API int stc_restriction_rule_get_warning_limit(stc_restriction_rule_h rule,
- uint64_t *rx_warning_limit, uint64_t *tx_warning_limit)
+ int64_t *rx_warning_limit, int64_t *tx_warning_limit)
{
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
*rx_warning_limit = restriction_rule->rx_warning_limit;
*tx_warning_limit = restriction_rule->tx_warning_limit;
- STC_LOGI("Warning limit rx[%llu] tx[%llu]",
+ STC_LOGI("Warning limit rx[%lld] tx[%lld]",
*rx_warning_limit, *tx_warning_limit);
return STC_ERROR_NONE;
if (!g_strcmp0(key, STC_STATS_INFO_APP_ID)) {
const char *app_id = g_variant_get_string(value, NULL);
if (app_id != NULL)
- g_strlcpy(stats_info->app_id, app_id, strlen(stats_info->app_id));
+ g_strlcpy(stats_info->app_id, app_id, STC_APP_ID_LEN);
} else if (!g_strcmp0(key, STC_STATS_INFO_IFNAME)) {
const char *iface_name = g_variant_get_string(value, NULL);
if (iface_name != NULL)
- g_strlcpy(stats_info->iface_name, iface_name, strlen(stats_info->iface_name));
+ g_strlcpy(stats_info->iface_name, iface_name, STC_IFNAME_LEN);
} else if (!g_strcmp0(key, STC_STATS_INFO_IMSI)) {
const char *imsi = g_variant_get_string(value, NULL);
if (imsi != NULL)
- g_strlcpy(stats_info->imsi, imsi, strlen(stats_info->imsi));
+ g_strlcpy(stats_info->imsi, imsi, STC_IMSI_LEN);
} else if (!g_strcmp0(key, STC_STATS_INFO_INTERVAL_FROM)) {
stats_info->interval.from = g_variant_get_uint64(value);
stats_info->interval.to = g_variant_get_uint64(value);
} else if (!g_strcmp0(key, STC_STATS_INFO_OUTGOING_BYTES)) {
- stats_info->cnt.outgoing_bytes = g_variant_get_uint64(value);
+ stats_info->cnt.outgoing_bytes = g_variant_get_int64(value);
} else if (!g_strcmp0(key, STC_STATS_INFO_INCOMING_BYTES)) {
- stats_info->cnt.incoming_bytes = g_variant_get_uint64(value);
+ stats_info->cnt.incoming_bytes = g_variant_get_int64(value);
} else if (!g_strcmp0(key, STC_STATS_INFO_IFTYPE)) {
stats_info->iface_type =
if (info->roaming_type != STC_ROAMING_UNKNOWN)
STC_LOGD("Roaming: [%d]", info->roaming_type);
- STC_LOGD("Received: [%llu]", info->cnt.incoming_bytes);
- STC_LOGD("Sent: [%llu]", info->cnt.outgoing_bytes);
+ STC_LOGD("Received: [%lld]", info->cnt.incoming_bytes);
+ STC_LOGD("Sent: [%lld]", info->cnt.outgoing_bytes);
if (info->protocol_type != STC_PROTOCOL_UNKNOWN)
STC_LOGD("Protocol: [%d]", info->protocol_type);
STC_LOGD("Process: [%d]", info->process_state);
if (info->interval.from > 0)
- STC_LOGD("From: [%lu]", info->interval.from);
+ STC_LOGD("From: [%llu]", info->interval.from);
if (info->interval.to > 0)
- STC_LOGD("To: [%lu]", info->interval.to);
+ STC_LOGD("To: [%llu]", info->interval.to);
STC_LOGD(STC_HR_SINGLE);
}
char *imsi;
stc_restriction_status_e rst_status;
stc_iface_type_e iface_type;
- uint64_t rx_limit;
- uint64_t tx_limit;
- uint64_t rx_warning_limit;
- uint64_t tx_warning_limit;
+ int64_t rx_limit;
+ int64_t tx_limit;
+ int64_t rx_warning_limit;
+ int64_t tx_warning_limit;
stc_roaming_type_e roaming;
msg(HR_SINGLE);
ret = stc_restriction_info_get_limit(info, &rx_limit, &tx_limit);
if (ret == STC_ERROR_NONE) {
- msg("Rx_limit: [%llu]", rx_limit);
- msg("Tx_limit: [%llu]", tx_limit);
+ msg("Rx_limit: [%lld]", rx_limit);
+ msg("Tx_limit: [%lld]", tx_limit);
}
ret = stc_restriction_info_get_warning_limit(info,
&rx_warning_limit, &tx_warning_limit);
if (ret == STC_ERROR_NONE) {
- msg("Rx_warning_limit: [%llu]", rx_warning_limit);
- msg("Tx_warning_limit: [%llu]", tx_warning_limit);
+ msg("Rx_warning_limit: [%lld]", rx_warning_limit);
+ msg("Tx_warning_limit: [%lld]", tx_warning_limit);
}
msg(HR_SINGLE);
{
stc_iface_type_e iface_type = (int)strtol(g_iface_type, NULL, 10);
stc_roaming_type_e roaming = (int)strtol(g_roaming, NULL, 10);
- uint64_t rx_limit = (uint64_t)strtol(g_rx_limit, NULL, 10);
- uint64_t tx_limit = (uint64_t)strtol(g_tx_limit, NULL, 10);
- uint64_t rx_warning_limit = (uint64_t)strtol(g_rx_warning_limit, NULL, 10);
- uint64_t tx_warning_limit = (uint64_t)strtol(g_tx_warning_limit, NULL, 10);
+ int64_t rx_limit = (int64_t)strtol(g_rx_limit, NULL, 10);
+ int64_t tx_limit = (int64_t)strtol(g_tx_limit, NULL, 10);
+ int64_t rx_warning_limit = (int64_t)strtol(g_rx_warning_limit, NULL, 10);
+ int64_t tx_warning_limit = (int64_t)strtol(g_tx_warning_limit, NULL, 10);
char *app_id = NULL;
char *imsi = NULL;
char *iface_name = NULL;
return ret;
}
- if ((rx_limit < G_MAXUINT64) && (tx_limit < G_MAXUINT64)) {
+ if ((rx_limit >= 0 && rx_limit < G_MAXINT64) &&
+ (tx_limit >= 0 && tx_limit < G_MAXINT64)) {
ret = stc_restriction_rule_set_limit(g_restriction_rule,
rx_limit, tx_limit);
if (ret == STC_ERROR_NONE)
}
}
- if ((rx_warning_limit < G_MAXUINT64) && (tx_warning_limit < G_MAXUINT64)) {
+ if ((rx_warning_limit >= 0 && rx_warning_limit < G_MAXINT64) &&
+ (tx_warning_limit >= 0 && tx_warning_limit < G_MAXINT64)) {
ret = stc_restriction_rule_set_warning_limit(g_restriction_rule,
rx_warning_limit, tx_warning_limit);
if (ret == STC_ERROR_NONE)
tx_limit = 0;
ret = stc_restriction_rule_get_limit(g_restriction_rule, &rx_limit, &tx_limit);
if (ret == STC_ERROR_NONE) {
- msg("Rx_limit: " LOG_CYAN "[%llu]" LOG_END, rx_limit);
- msg("Tx_limit: " LOG_CYAN "[%llu]" LOG_END, tx_limit);
+ msg("Rx_limit: " LOG_CYAN "[%lld]" LOG_END, rx_limit);
+ msg("Tx_limit: " LOG_CYAN "[%lld]" LOG_END, tx_limit);
}
rx_warning_limit = 0;
ret = stc_restriction_rule_get_warning_limit(g_restriction_rule,
&rx_warning_limit, &tx_warning_limit);
if (ret == STC_ERROR_NONE) {
- msg("Rx_warning_limit: " LOG_CYAN "[%llu]" LOG_END, rx_warning_limit);
- msg("Tx_warning_limit: " LOG_CYAN "[%llu]" LOG_END, tx_warning_limit);
+ msg("Rx_warning_limit: " LOG_CYAN "[%lld]" LOG_END, rx_warning_limit);
+ msg("Tx_warning_limit: " LOG_CYAN "[%lld]" LOG_END, tx_warning_limit);
}
msg(HR_SINGLE);