Support set/get for total data usage(Tx + Rx) in restriction. 47/134147/3 submit/tizen/20170620.103311
authorNishant Chaprana <n.chaprana@samsung.com>
Thu, 15 Jun 2017 04:00:09 +0000 (09:30 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Thu, 15 Jun 2017 04:07:39 +0000 (09:37 +0530)
Description: This patch removes seperate data usage limits for Tx
and Rx data and uses total data limit for setting Tx and Rx limits.

Change-Id: I10176d12e78416aec7c58c7010faf89d0ff923a4
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
include/stc_internal.h
packaging/capi-network-stc.spec
src/include/stc-info.h
src/include/stc-restriction.h
src/stc-info.c
src/stc-restriction.c
src/stc-statistics.c
test/restriction.c

index e405b28..8e860d7 100755 (executable)
@@ -116,8 +116,8 @@ typedef enum {
  * @since_tizen 4.0
  *
  * @param[in] result           The result
- * @param[in] info                     The restriction information handle
- * @param[in] user_data        The user data passed from the callback registration function
+ * @param[in] info             The restriction information handle
+ * @param[in] user_data                The user data passed from the callback registration function
  * @return     @c STC_CALLBACK_CONTINUE to continue with the next iteration of the loop,
  *                     otherwise @c STC_CALLBACK_CANCEL to break out of the loop
  *
@@ -980,8 +980,7 @@ int stc_restriction_rule_set_iface_type(stc_restriction_rule_h rule,
  * @privilege %http://tizen.org/privilege/network.get
  *
  * @param[in] rule The restriction rule handle
- * @param[in] rx_limit The receive limit
- * @param[in] tx_limit The send limit
+ * @param[in] data_limit The data limit
  *
  * @return 0 on success, otherwise a negative error value
  * @retval #STC_ERROR_NONE Successful
@@ -999,7 +998,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,
-               int64_t rx_limit, int64_t tx_limit);
+                                  int64_t data_limit);
 
 /**
  * @brief Sets the warning limit for restriction rule.
@@ -1008,8 +1007,7 @@ int stc_restriction_rule_set_limit(stc_restriction_rule_h rule,
  * @privilege %http://tizen.org/privilege/network.get
  *
  * @param[in] rule The restriction rule handle
- * @param[in] rx_warning_limit The receive warning limit
- * @param[in] tx_warning_limit The send warning limit
+ * @param[in] data_warn_limit The data warning limit
  *
  * @return 0 on success, otherwise a negative error value
  * @retval #STC_ERROR_NONE Successful
@@ -1027,7 +1025,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,
-               int64_t rx_warning_limit, int64_t tx_warning_limit);
+                                          int64_t data_warn_limit);
 
 /**
  * @brief Sets the roaming type for restriction rule.
@@ -1172,8 +1170,7 @@ int stc_restriction_rule_get_iface_type(stc_restriction_rule_h rule,
  * @privilege %http://tizen.org/privilege/network.get
  *
  * @param[in] rule The restriction rule handle
- * @param[out] rx_limit The receive limit
- * @param[out] tx_limit The send limit
+ * @param[out] data_limit The data limit
  *
  * @return 0 on success, otherwise a negative error value
  * @retval #STC_ERROR_NONE Successful
@@ -1191,7 +1188,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,
-               int64_t *rx_limit, int64_t *tx_limit);
+                                  int64_t *data_limit);
 
 /**
  * @brief Gets the warning limit for restriction rule.
@@ -1200,8 +1197,7 @@ int stc_restriction_rule_get_limit(stc_restriction_rule_h rule,
  * @privilege %http://tizen.org/privilege/network.get
  *
  * @param[in] rule The restriction rule handle
- * @param[out] rx_warning_limit The receive warning limit
- * @param[out] tx_warning_limit The send warning limit
+ * @param[out] data_warn_limit The data warning limit
  *
  * @return 0 on success, otherwise a negative error value
  * @retval #STC_ERROR_NONE Successful
@@ -1219,7 +1215,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,
-               int64_t *rx_warning_limit, int64_t *tx_warning_limit);
+                                          int64_t *data_warn_limit);
 
 /**
  * @brief Gets the roaming type for restriction rule.
@@ -1430,8 +1426,7 @@ int stc_restriction_info_get_iface_type(stc_restriction_info_h info,
  * @privilege %http://tizen.org/privilege/network.get
  *
  * @param[in] info The restriction information handle
- * @param[out] rx_limit The receive limit
- * @param[out] tx_limit The send limit
+ * @param[out] data_limit The data limit
  *
  * @return 0 on success, otherwise a negative error value
  * @retval #STC_ERROR_NONE Successful
@@ -1447,7 +1442,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,
-               int64_t *rx_limit, int64_t *tx_limit);
+                                  int64_t *data_limit);
 
 /**
  * @brief Gets the warning limit for restriction information.
@@ -1456,8 +1451,7 @@ int stc_restriction_info_get_limit(stc_restriction_info_h info,
  * @privilege %http://tizen.org/privilege/network.get
  *
  * @param[in] info The restriction information handle
- * @param[out] rx_warning_limit The receive warning limit
- * @param[out] tx_warning_limit The send warning limit
+ * @param[out] data_warn_limit The data warning limit
  *
  * @return 0 on success, otherwise a negative error value
  * @retval #STC_ERROR_NONE Successful
@@ -1473,7 +1467,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,
-               int64_t *rx_warning_limit, int64_t *tx_warning_limit);
+                                          int64_t *data_warn_limit);
 
 /**
  * @brief Gets the roaming type for restriction information.
index db48f25..cac2b4c 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-network-stc
 Summary:    A Smart Traffic Control (STC) libraries in Native API
-Version:    0.0.11
+Version:    0.0.12
 Release:    1
 Group:      Network & Connectivity/API
 License:    Apache-2.0
index f7546cc..8cef4eb 100755 (executable)
@@ -66,10 +66,8 @@ extern "C" {
 #define STC_RESTRICTION_INFO_APP_ID                            "app_id"
 #define STC_RESTRICTION_INFO_IFTYPE                            "iftype"
 #define STC_RESTRICTION_INFO_IFNAME                            "ifname"
-#define STC_RESTRICTION_INFO_RX_LIMIT                  "rcv_limit"
-#define STC_RESTRICTION_INFO_TX_LIMIT                  "send_limit"
-#define STC_RESTRICTION_INFO_RX_WARNING_LIMIT  "rcv_warn_limit"
-#define STC_RESTRICTION_INFO_TX_WARNING_LIMIT  "send_warn_limit"
+#define STC_RESTRICTION_INFO_DATA_LIMIT                        "data_limit"
+#define STC_RESTRICTION_INFO_DATA_WARN_LIMIT           "data_warn_limit"
 #define STC_RESTRICTION_INFO_RST_STATUS                        "rst_state"
 #define STC_RESTRICTION_INFO_ROAMING                   "roaming"
 #define STC_RESTRICTION_INFO_IMSI                              "imsi"
@@ -97,10 +95,8 @@ typedef struct {
        char imsi[STC_IMSI_LEN];
        stc_iface_type_e iface_type;
        stc_restriction_status_e rst_status;
-       int64_t rx_limit;
-       int64_t tx_limit;
-       int64_t rx_warning_limit;
-       int64_t tx_warning_limit;
+       int64_t data_limit;
+       int64_t data_warn_limit;
        stc_roaming_type_e roaming_type;
 } stc_restriction_info_s;
 
index e0476b0..3532233 100755 (executable)
@@ -53,10 +53,8 @@ extern "C" {
 #define STC_RESTRICTION_RULE_IFTYPE                            "iftype"
 #define STC_RESTRICTION_RULE_ROAMING                   "roaming"
 #define STC_RESTRICTION_RULE_IMSI                              "imsi"
-#define STC_RESTRICTION_RULE_RX_LIMIT                  "rcv_limit"
-#define STC_RESTRICTION_RULE_TX_LIMIT                  "send_limit"
-#define STC_RESTRICTION_RULE_RX_WARNING_LIMIT  "rcv_warn_limit"
-#define STC_RESTRICTION_RULE_TX_WARNING_LIMIT  "send_warn_limit"
+#define STC_RESTRICTION_RULE_DATA_LIMIT                        "data_limit"
+#define STC_RESTRICTION_RULE_DATA_WARN_LIMIT           "data_warn_limit"
 
 typedef enum {
        STC_RST_TYPE_UNDEF,
@@ -72,10 +70,8 @@ typedef struct {
        char imsi[STC_IMSI_LEN];
        stc_iface_type_e iface_type;
        stc_restriction_status_e rst_state;
-       int64_t tx_limit;
-       int64_t rx_limit;
-       int64_t tx_warning_limit;
-       int64_t rx_warning_limit;
+       int64_t data_limit;
+       int64_t data_warn_limit;
        stc_roaming_type_e roaming_type;
 } stc_restriction_rule_s;
 
index 9a70063..7f9dc3e 100755 (executable)
@@ -362,11 +362,11 @@ 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,
-               int64_t *rx_limit, int64_t *tx_limit)
+                                             int64_t *data_limit)
 {
        CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
 
-       if (info == NULL) {
+       if (info == NULL || data_limit == NULL) {
                STC_LOGE("Invalid parameter");
                return STC_ERROR_INVALID_PARAMETER;
        }
@@ -374,21 +374,19 @@ EXPORT_API int stc_restriction_info_get_limit(stc_restriction_info_h info,
        stc_restriction_info_s *restriction_info =
                (stc_restriction_info_s *)info;
 
-       *rx_limit = restriction_info->rx_limit;
-       *tx_limit = restriction_info->tx_limit;
+       *data_limit = restriction_info->data_limit;
 
-       STC_LOGI("Limit rx[%lld] tx[%lld]",
-               *rx_limit, *tx_limit);
+       STC_LOGI("Data limit [%lld] bytes", *data_limit);
 
        return STC_ERROR_NONE;
 }
 
 EXPORT_API int stc_restriction_info_get_warning_limit(stc_restriction_info_h info,
-               int64_t *rx_warning_limit, int64_t *tx_warning_limit)
+                                                     int64_t *data_warn_limit)
 {
        CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
 
-       if (info == NULL) {
+       if (info == NULL || data_warn_limit == NULL) {
                STC_LOGE("Invalid parameter");
                return STC_ERROR_INVALID_PARAMETER;
        }
@@ -396,11 +394,9 @@ EXPORT_API int stc_restriction_info_get_warning_limit(stc_restriction_info_h inf
        stc_restriction_info_s *restriction_info =
                (stc_restriction_info_s *)info;
 
-       *rx_warning_limit = restriction_info->rx_warning_limit;
-       *tx_warning_limit = restriction_info->tx_warning_limit;
+       *data_warn_limit = restriction_info->data_warn_limit;
 
-       STC_LOGI("Warning limit rx[%lld] tx[%lld]",
-               *rx_warning_limit, *tx_warning_limit);
+       STC_LOGI("Data warn limit [%lld] bytes", *data_warn_limit);
 
        return STC_ERROR_NONE;
 }
index 516b304..99cdf2f 100755 (executable)
@@ -69,10 +69,8 @@ static void __stc_restriction_init_rule(stc_restriction_rule_s *rule)
        rule->iface_name[0] = '\0';
        rule->iface_type = STC_IFACE_ALL;
        rule->rst_state = STC_RESTRICTION_REMOVED;
-       rule->tx_limit = 0;
-       rule->rx_limit = 0;
-       rule->tx_warning_limit = 0;
-       rule->rx_warning_limit = 0;
+       rule->data_limit = 0;
+       rule->data_warn_limit = 0;
        rule->roaming_type = STC_ROAMING_DISABLED;
        rule->imsi[0] = '\0';
 }
@@ -112,20 +110,12 @@ static void __stc_restriction_rule_make_params(
                g_variant_new_string(restriction_rule->imsi));
 
        g_variant_builder_add(builder, "{sv}",
-               STC_RESTRICTION_RULE_RX_LIMIT,
-               g_variant_new_int64(restriction_rule->rx_limit));
+               STC_RESTRICTION_RULE_DATA_LIMIT,
+               g_variant_new_int64(restriction_rule->data_limit));
 
        g_variant_builder_add(builder, "{sv}",
-               STC_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_int64(restriction_rule->rx_warning_limit));
-
-       g_variant_builder_add(builder, "{sv}",
-               STC_RESTRICTION_RULE_TX_WARNING_LIMIT,
-               g_variant_new_int64(restriction_rule->tx_warning_limit));
+               STC_RESTRICTION_RULE_DATA_WARN_LIMIT,
+               g_variant_new_int64(restriction_rule->data_warn_limit));
 
        *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
        g_variant_builder_unref(builder);
@@ -181,17 +171,11 @@ static void __stc_restriction_extract_info_cb(const char *key,
                restriction_info->rst_status =
                        (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_int64(value);
-
-       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_TX_LIMIT)) {
-               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_int64(value);
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_DATA_LIMIT)) {
+               restriction_info->data_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_int64(value);
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_DATA_WARN_LIMIT)) {
+               restriction_info->data_warn_limit = g_variant_get_int64(value);
 
        } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_ROAMING)) {
                restriction_info->roaming_type =
@@ -221,8 +205,8 @@ static void __stc_restriction_print_info(
        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("Limit:     [%lld] bytes", info->data_limit);
+       STC_LOGD("Warning:   [%lld] bytes", info->data_warn_limit);
 
        STC_LOGD(STC_HR_SINGLE);
 }
@@ -444,25 +428,15 @@ stc_error_e _stc_restriction_validate_rule(
                _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_RETURN_VAL_IF(restriction_rule->data_limit < 0,
                        STC_ERROR_INVALID_PARAMETER,
-                       "Invalid tx limit [%lld]",
-                       restriction_rule->tx_limit);
+                       "Invalid tx limit [%lld] bytes",
+                       restriction_rule->data_limit);
 
-               STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+               STC_RETURN_VAL_IF(restriction_rule->data_warn_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);
+                       "Invalid rx limit [%lld] bytes",
+                       restriction_rule->data_warn_limit);
        }
 
        STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
@@ -493,25 +467,15 @@ 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_RETURN_VAL_IF(restriction_rule->data_limit < 0,
                STC_ERROR_INVALID_PARAMETER,
-               "Invalid rx limit [%lld]",
-               restriction_rule->rx_limit);
+               "Invalid tx limit [%lld] bytes",
+               restriction_rule->data_limit);
 
-       STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+       STC_RETURN_VAL_IF(restriction_rule->data_warn_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);
+               "Invalid rx limit [%lld] bytes",
+               restriction_rule->data_warn_limit);
 
        STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
                restriction_rule->roaming_type > STC_ROAMING_DISABLED,
@@ -607,25 +571,15 @@ 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_RETURN_VAL_IF(restriction_rule->data_limit < 0,
                STC_ERROR_INVALID_PARAMETER,
-               "Invalid tx warning limit [%lld]",
-               restriction_rule->tx_warning_limit);
+               "Invalid tx limit [%lld] bytes",
+               restriction_rule->data_limit);
 
-       STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+       STC_RETURN_VAL_IF(restriction_rule->data_warn_limit < 0,
                STC_ERROR_INVALID_PARAMETER,
-               "Invalid rx warning limit [%lld]",
-               restriction_rule->rx_warning_limit);
+               "Invalid rx limit [%lld] bytes",
+               restriction_rule->data_warn_limit);
 
        STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
                restriction_rule->roaming_type > STC_ROAMING_DISABLED,
@@ -659,25 +613,15 @@ 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_RETURN_VAL_IF(restriction_rule->data_limit < 0,
                STC_ERROR_INVALID_PARAMETER,
-               "Invalid tx limit [%lld]",
-               restriction_rule->tx_limit);
+               "Invalid tx limit [%lld] bytes",
+               restriction_rule->data_limit);
 
-       STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+       STC_RETURN_VAL_IF(restriction_rule->data_warn_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);
+               "Invalid rx limit [%lld] bytes",
+               restriction_rule->data_warn_limit);
 
        STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
                restriction_rule->roaming_type > STC_ROAMING_DISABLED,
@@ -950,7 +894,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,
-               int64_t rx_limit, int64_t tx_limit)
+                                             int64_t data_limit)
 {
        CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
 
@@ -962,17 +906,15 @@ EXPORT_API int stc_restriction_rule_set_limit(stc_restriction_rule_h rule,
        stc_restriction_rule_s *restriction_rule =
                (stc_restriction_rule_s *)rule;
 
-       restriction_rule->rx_limit = rx_limit;
-       restriction_rule->tx_limit = tx_limit;
+       restriction_rule->data_limit = data_limit;
 
-       STC_LOGI("Limit rx[%lld] tx[%lld]",
-               restriction_rule->rx_limit, restriction_rule->tx_limit);
+       STC_LOGI("Data limit [%lld] bytes", restriction_rule->data_limit);
 
        return STC_ERROR_NONE;
 }
 
 EXPORT_API int stc_restriction_rule_set_warning_limit(stc_restriction_rule_h rule,
-               int64_t rx_warning_limit, int64_t tx_warning_limit)
+                                                     int64_t data_warn_limit)
 {
        CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
 
@@ -984,11 +926,10 @@ EXPORT_API int stc_restriction_rule_set_warning_limit(stc_restriction_rule_h rul
        stc_restriction_rule_s *restriction_rule =
                (stc_restriction_rule_s *)rule;
 
-       restriction_rule->rx_warning_limit = rx_warning_limit;
-       restriction_rule->tx_warning_limit = tx_warning_limit;
+       restriction_rule->data_warn_limit = data_warn_limit;
 
-       STC_LOGI("Warning limit rx[%lld] tx[%lld]",
-               restriction_rule->rx_warning_limit, restriction_rule->tx_warning_limit);
+       STC_LOGI("Data warn limit [%lld] bytes",
+                restriction_rule->data_warn_limit);
 
        return STC_ERROR_NONE;
 }
@@ -1109,11 +1050,11 @@ 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,
-               int64_t *rx_limit, int64_t *tx_limit)
+                                             int64_t *data_limit)
 {
        CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
 
-       if (rule == NULL) {
+       if (rule == NULL || data_limit == NULL) {
                STC_LOGE("Invalid parameter");
                return STC_ERROR_INVALID_PARAMETER;
        }
@@ -1121,20 +1062,19 @@ EXPORT_API int stc_restriction_rule_get_limit(stc_restriction_rule_h rule,
        stc_restriction_rule_s *restriction_rule =
                (stc_restriction_rule_s *)rule;
 
-       *rx_limit = restriction_rule->rx_limit;
-       *tx_limit = restriction_rule->tx_limit;
+       *data_limit = restriction_rule->data_limit;
 
-       STC_LOGI("Limit rx[%lld] tx[%lld]", *rx_limit, *tx_limit);
+       STC_LOGI("Data limit [%lld] bytes", *data_limit);
 
        return STC_ERROR_NONE;
 }
 
 EXPORT_API int stc_restriction_rule_get_warning_limit(stc_restriction_rule_h rule,
-               int64_t *rx_warning_limit, int64_t *tx_warning_limit)
+                                                     int64_t *data_warn_limit)
 {
        CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
 
-       if (rule == NULL) {
+       if (rule == NULL || data_warn_limit == NULL) {
                STC_LOGE("Invalid parameter");
                return STC_ERROR_INVALID_PARAMETER;
        }
@@ -1142,11 +1082,9 @@ EXPORT_API int stc_restriction_rule_get_warning_limit(stc_restriction_rule_h rul
        stc_restriction_rule_s *restriction_rule =
                (stc_restriction_rule_s *)rule;
 
-       *rx_warning_limit = restriction_rule->rx_warning_limit;
-       *tx_warning_limit = restriction_rule->tx_warning_limit;
+       *data_warn_limit = restriction_rule->data_warn_limit;
 
-       STC_LOGI("Warning limit rx[%lld] tx[%lld]",
-               *rx_warning_limit, *tx_warning_limit);
+       STC_LOGI("Data Warn limit [%lld] bytes", *data_warn_limit);
 
        return STC_ERROR_NONE;
 }
index 74ab63c..f97d8e5 100755 (executable)
@@ -436,7 +436,7 @@ static void __stc_stats_get_total_reply(
                event_data.error = dbus_result;
        } else {
                //LCOV_EXCL_START
-               STC_LOGE("Get stats total response error [%s]", 
+               STC_LOGE("Get stats total response error [%s]",
                        _stc_convert_error_type_to_string(error));
 
                event_data.event = STC_EVENT_STATS_GET_TOTAL_RSP;
index a5c0951..95503f9 100755 (executable)
@@ -47,10 +47,8 @@ static char g_iface_name[MENU_DATA_SIZE] = "";
 static char g_iface_type[MENU_DATA_SIZE] = "0";
 static char g_roaming[MENU_DATA_SIZE] = "0";
 static char g_imsi[MENU_DATA_SIZE] = "";
-static char g_rx_limit[MENU_DATA_SIZE] = "0";
-static char g_tx_limit[MENU_DATA_SIZE] = "0";
-static char g_rx_warning_limit[MENU_DATA_SIZE] = "0";
-static char g_tx_warning_limit[MENU_DATA_SIZE] = "0";
+static char g_data_limit[MENU_DATA_SIZE] = "0";
+static char g_data_warn_limit[MENU_DATA_SIZE] = "0";
 
 extern stc_h g_stc;
 static stc_restriction_rule_h g_restriction_rule = NULL;
@@ -70,10 +68,8 @@ static stc_callback_ret_e __test_stc_restriction_info_cb(
        char *imsi = NULL;
        stc_restriction_status_e rst_status;
        stc_iface_type_e iface_type;
-       int64_t rx_limit;
-       int64_t tx_limit;
-       int64_t rx_warning_limit;
-       int64_t tx_warning_limit;
+       int64_t data_limit;
+       int64_t data_warn_limit;
        stc_roaming_type_e roaming;
 
        msg(HR_SINGLE);
@@ -102,18 +98,13 @@ static stc_callback_ret_e __test_stc_restriction_info_cb(
        if (ret == STC_ERROR_NONE)
                msg("Roaming:   [%s]", test_stc_convert_roaming_to_string(roaming));
 
-       ret = stc_restriction_info_get_limit(info, &rx_limit, &tx_limit);
-       if (ret == STC_ERROR_NONE) {
-               msg("Rx_limit: [%lld]", rx_limit);
-               msg("Tx_limit: [%lld]", tx_limit);
-       }
+       ret = stc_restriction_info_get_limit(info, &data_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Data_limit: [%lld]", data_limit);
 
-       ret = stc_restriction_info_get_warning_limit(info,
-               &rx_warning_limit, &tx_warning_limit);
-       if (ret == STC_ERROR_NONE) {
-               msg("Rx_warning_limit: [%lld]", rx_warning_limit);
-               msg("Tx_warning_limit: [%lld]", tx_warning_limit);
-       }
+       ret = stc_restriction_info_get_warning_limit(info, &data_warn_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Data_warn_limit: [%lld]", data_warn_limit);
 
        msg(HR_SINGLE);
 
@@ -160,10 +151,8 @@ 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);
-       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);
+       int64_t data_limit = (int64_t)strtol(g_data_limit, NULL, 10);
+       int64_t data_warn_limit = (int64_t)strtol(g_data_warn_limit, NULL, 10);
        char *app_id = NULL;
        char *imsi = NULL;
        char *iface_name = NULL;
@@ -218,26 +207,24 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
                return ret;
        }
 
-       if ((rx_limit >= 0 && rx_limit < G_MAXINT64) &&
-               (tx_limit >= 0 && tx_limit < G_MAXINT64)) {
+       if (data_limit >= 0 && data_limit < G_MAXINT64) {
                ret = stc_restriction_rule_set_limit(g_restriction_rule,
-                                       rx_limit, tx_limit);
-               if (ret == STC_ERROR_NONE)
+                                                    data_limit);
+               if (ret == STC_ERROR_NONE) {
                        msg(LOG_GREEN "Success to set limit" LOG_END);
-               else {
+               else {
                        msg("Fail to set limit " LOG_RED "[%s]" LOG_END,
                                test_stc_convert_error_type_to_string(ret));
                        return ret;
                }
        }
 
-       if ((rx_warning_limit >= 0 && rx_warning_limit < G_MAXINT64) &&
-               (tx_warning_limit >= 0 && tx_warning_limit < G_MAXINT64)) {
+       if (data_warn_limit >= 0 && data_warn_limit < G_MAXINT64) {
                ret = stc_restriction_rule_set_warning_limit(g_restriction_rule,
-                                       rx_warning_limit, tx_warning_limit);
-               if (ret == STC_ERROR_NONE)
+                                                            data_warn_limit);
+               if (ret == STC_ERROR_NONE) {
                        msg(LOG_GREEN "Success to set warning limit" LOG_END);
-               else {
+               else {
                        msg("Fail to set warning limit " LOG_RED "[%s]" LOG_END,
                                test_stc_convert_error_type_to_string(ret));
                        return ret;
@@ -274,22 +261,16 @@ static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
                msg("Roaming:   " LOG_CYAN "[%s]" LOG_END,
                        test_stc_convert_roaming_to_string(roaming));
 
-       rx_limit = 0;
-       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 "[%lld]" LOG_END, rx_limit);
-               msg("Tx_limit: " LOG_CYAN "[%lld]" LOG_END, tx_limit);
-       }
+       data_limit = 0;
+       ret = stc_restriction_rule_get_limit(g_restriction_rule, &data_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Data_limit: " LOG_CYAN "[%lld]" LOG_END, data_limit);
 
-       rx_warning_limit = 0;
-       tx_warning_limit = 0;
+       data_warn_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 "[%lld]" LOG_END, rx_warning_limit);
-               msg("Tx_warning_limit: " LOG_CYAN "[%lld]" LOG_END, tx_warning_limit);
-       }
+                                                    &data_warn_limit);
+       if (ret == STC_ERROR_NONE)
+               msg("Data_warn_limit: " LOG_CYAN "[%lld]" LOG_END, data_warn_limit);
 
        msg(HR_SINGLE);
 
@@ -476,10 +457,8 @@ static struct menu_data menu_restriction_rule[] = {
        { "3", "Interface type(1.Tel/2.Wifi/3.Wired/4.BT/5.All)", NULL, NULL, g_iface_type},
        { "4", "Interface name", NULL, NULL, g_iface_name},
        { "5", "Roaming(1.Enable/2.Disable)", NULL, NULL, g_roaming},
-       { "6", "Receive limit", NULL, NULL, g_rx_limit},
-       { "7", "Send limit", NULL, NULL, g_tx_limit},
-       { "8", "Receive warning limit", NULL, NULL, g_rx_warning_limit},
-       { "9", "Send warning limit", NULL, NULL, g_tx_warning_limit},
+       { "6", "Data limit", NULL, NULL, g_data_limit},
+       { "7", "Data warn limit", NULL, NULL, g_data_warn_limit},
        { "s", LOG_LIGHTMAGENTA "[Set]" LOG_END, NULL, __test_stc_set_restriction_rule, NULL},
        { NULL, NULL, },
 };