From: hyunuktak Date: Thu, 11 May 2017 07:58:44 +0000 (+0900) Subject: Modified properly data type X-Git-Tag: submit/tizen/20170512.003940^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d62182822d0913841620c02541f67418bfd61055;p=platform%2Fcore%2Fapi%2Fsmart-traffic-control.git Modified properly data type Change-Id: Ifb1914cdee2c6ebefb4c2dcc73e70fc9fe518859 Signed-off-by: hyunuktak --- diff --git a/include/stc.h b/include/stc.h index 6de29d0..cae174e 100755 --- a/include/stc.h +++ b/include/stc.h @@ -803,7 +803,7 @@ int stc_stats_info_get_iface_type(stc_stats_info_h info, * @see stc_stats_info_cb() */ int stc_stats_info_get_counter(stc_stats_info_h info, - uint64_t *incoming, uint64_t *outgoing); + int64_t *incoming, int64_t *outgoing); /** * @brief Gets the roaming type from statistics information. diff --git a/include/stc_internal.h b/include/stc_internal.h index e502a55..c41deb2 100755 --- a/include/stc_internal.h +++ b/include/stc_internal.h @@ -986,7 +986,7 @@ int stc_restriction_rule_set_iface_type(stc_restriction_rule_h rule, * @see stc_restriction_rule_get_limit() */ 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); /** * @brief Sets the warning limit for restriction rule. @@ -1014,7 +1014,7 @@ int stc_restriction_rule_set_limit(stc_restriction_rule_h rule, * @see stc_restriction_rule_get_warning_limit() */ 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); /** * @brief Sets the roaming type for restriction rule. @@ -1178,7 +1178,7 @@ int stc_restriction_rule_get_iface_type(stc_restriction_rule_h rule, * @see stc_restriction_rule_set_limit() */ 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); /** * @brief Gets the warning limit for restriction rule. @@ -1206,7 +1206,7 @@ int stc_restriction_rule_get_limit(stc_restriction_rule_h rule, * @see stc_restriction_rule_set_warning_limit() */ 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); /** * @brief Gets the roaming type for restriction rule. @@ -1434,7 +1434,7 @@ int stc_restriction_info_get_iface_type(stc_restriction_info_h info, * @see stc_restriction_info_cb() */ int stc_restriction_info_get_limit(stc_restriction_info_h info, - uint64_t *rx_limit, uint64_t *tx_limit); + int64_t *rx_limit, int64_t *tx_limit); /** * @brief Gets the warning limit for restriction information. @@ -1460,7 +1460,7 @@ int stc_restriction_info_get_limit(stc_restriction_info_h info, * @see stc_restriction_info_cb() */ int stc_restriction_info_get_warning_limit(stc_restriction_info_h info, - uint64_t *rx_warning_limit, uint64_t *tx_warning_limit); + int64_t *rx_warning_limit, int64_t *tx_warning_limit); /** * @brief Gets the roaming type for restriction information. diff --git a/packaging/capi-network-stc.spec b/packaging/capi-network-stc.spec index 2282831..021d03d 100755 --- a/packaging/capi-network-stc.spec +++ b/packaging/capi-network-stc.spec @@ -1,6 +1,6 @@ Name: capi-network-stc Summary: A Smart Traffic Control (STC) libraries in Native API -Version: 0.0.2 +Version: 0.0.3 Release: 1 Group: Network & Connectivity/API License: Apache-2.0 diff --git a/src/include/stc-info.h b/src/include/stc-info.h index 6cc834f..f7546cc 100755 --- a/src/include/stc-info.h +++ b/src/include/stc-info.h @@ -75,8 +75,8 @@ extern "C" { #define STC_RESTRICTION_INFO_IMSI "imsi" typedef struct { - uint64_t incoming_bytes; /** cnt.incoming_bytes; *outgoing = stats_info->cnt.outgoing_bytes; - STC_LOGI("Counters incoming[%llu] outgoing[%llu]", + STC_LOGI("Counters incoming[%lld] outgoing[%lld]", *incoming, *outgoing); return STC_ERROR_NONE; @@ -359,7 +359,7 @@ EXPORT_API int stc_restriction_info_get_iface_type(stc_restriction_info_h info, } EXPORT_API int stc_restriction_info_get_limit(stc_restriction_info_h info, - uint64_t *rx_limit, uint64_t *tx_limit) + int64_t *rx_limit, int64_t *tx_limit) { CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC); @@ -374,14 +374,14 @@ EXPORT_API int stc_restriction_info_get_limit(stc_restriction_info_h info, *rx_limit = restriction_info->rx_limit; *tx_limit = restriction_info->tx_limit; - STC_LOGI("Limit rx[%llu] tx[%llu]", + STC_LOGI("Limit rx[%lld] tx[%lld]", *rx_limit, *tx_limit); return STC_ERROR_NONE; } EXPORT_API int stc_restriction_info_get_warning_limit(stc_restriction_info_h info, - 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); @@ -396,7 +396,7 @@ EXPORT_API int stc_restriction_info_get_warning_limit(stc_restriction_info_h inf *rx_warning_limit = restriction_info->rx_warning_limit; *tx_warning_limit = restriction_info->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; diff --git a/src/stc-restriction.c b/src/stc-restriction.c index 3723ee2..8475f93 100755 --- a/src/stc-restriction.c +++ b/src/stc-restriction.c @@ -112,19 +112,19 @@ static void __stc_restriction_rule_make_params( 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); @@ -160,21 +160,17 @@ static void __stc_restriction_extract_info_cb(const char *key, 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 = @@ -185,16 +181,16 @@ static void __stc_restriction_extract_info_cb(const char *key, (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 = @@ -207,16 +203,27 @@ static void __stc_restriction_extract_info_cb(const char *key, 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( @@ -435,6 +442,28 @@ stc_error_e _stc_restriction_validate_rule( "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, @@ -463,6 +492,26 @@ stc_error_e _stc_restriction_check_set_rule( "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, @@ -557,6 +606,26 @@ stc_error_e _stc_restriction_check_remove_rule( "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, @@ -589,6 +658,26 @@ stc_error_e _stc_restriction_check_exclude_rule( "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, @@ -860,7 +949,7 @@ EXPORT_API int stc_restriction_rule_set_iface_type(stc_restriction_rule_h rule, } 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); @@ -875,14 +964,14 @@ EXPORT_API int stc_restriction_rule_set_limit(stc_restriction_rule_h rule, 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); @@ -897,7 +986,7 @@ EXPORT_API int stc_restriction_rule_set_warning_limit(stc_restriction_rule_h rul 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; @@ -1019,7 +1108,7 @@ EXPORT_API int stc_restriction_rule_get_iface_type(stc_restriction_rule_h rule, } 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); @@ -1034,13 +1123,13 @@ EXPORT_API int stc_restriction_rule_get_limit(stc_restriction_rule_h rule, *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); @@ -1055,7 +1144,7 @@ EXPORT_API int stc_restriction_rule_get_warning_limit(stc_restriction_rule_h rul *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; diff --git a/src/stc-statistics.c b/src/stc-statistics.c index 59510a1..8eab56c 100755 --- a/src/stc-statistics.c +++ b/src/stc-statistics.c @@ -187,17 +187,17 @@ static void __stc_stats_extract_info_cb(const char *key, 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); @@ -206,10 +206,10 @@ static void __stc_stats_extract_info_cb(const char *key, 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 = @@ -247,8 +247,8 @@ static void __stc_stats_print_info(stc_stats_info_s *info) 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); @@ -257,10 +257,10 @@ static void __stc_stats_print_info(stc_stats_info_s *info) 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); } diff --git a/test/restriction.c b/test/restriction.c index 6c04c16..7d120bd 100755 --- a/test/restriction.c +++ b/test/restriction.c @@ -70,10 +70,10 @@ static stc_callback_ret_e __test_stc_restriction_info_cb( 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); @@ -104,15 +104,15 @@ static stc_callback_ret_e __test_stc_restriction_info_cb( 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); @@ -128,10 +128,10 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu) { 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; @@ -186,7 +186,8 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu) 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) @@ -198,7 +199,8 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu) } } - 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) @@ -244,8 +246,8 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu) 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; @@ -253,8 +255,8 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu) 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); diff --git a/test/statistics.c b/test/statistics.c index 0e37c89..813fffb 100755 --- a/test/statistics.c +++ b/test/statistics.c @@ -82,8 +82,8 @@ static stc_callback_ret_e __test_stc_stats_info_cb( time_t from; time_t to; stc_iface_type_e iface_type; - uint64_t incoming; - uint64_t outgoing; + int64_t incoming; + int64_t outgoing; stc_roaming_type_e roaming; stc_protocol_type_e prototype; stc_process_state_e procstate; @@ -108,8 +108,8 @@ static stc_callback_ret_e __test_stc_stats_info_cb( ret = stc_stats_info_get_counter(info, &incoming, &outgoing); if (ret == STC_ERROR_NONE) { - msg("Received: [%llu]", incoming); - msg("Sent: [%llu]", outgoing); + msg("Received: [%lld]", incoming); + msg("Sent: [%lld]", outgoing); } ret = stc_stats_info_get_roaming_type(info, &roaming);