*/
/**
- * @brief Enumeration for network restriction status.
- * @since_tizen 4.0
+ * @brief Enumeration for network restriction type.
+ * @since_tizen 5.0
*/
typedef enum {
- STC_RESTRICTION_UNKNOWN,
- STC_RESTRICTION_ACTIVATED, /** < restriction has been activated */
- STC_RESTRICTION_REMOVED, /** < restriction has been removed */
- STC_RESTRICTION_EXCLUDED, /** < restriction has been excluded */
- STC_RESTRICTION_BACKGROUND, /** < background restriction has been activated */
- STC_RESTRICTION_LAST_ELEM,
-} stc_restriction_status_e;
+ STC_RSTN_TYPE_UNKNOWN,
+ STC_RSTN_TYPE_ACCEPT,
+ STC_RSTN_TYPE_DROP,
+ STC_RSTN_TYPE_LAST_ELEM,
+} stc_restriction_type_e;
/**
* @}
* @see stc_restriction_info_get_app_id()
* @see stc_restriction_info_get_iface_name()
* @see stc_restriction_info_get_subscriber_id()
- * @see stc_restriction_info_get_status()
+ * @see stc_restriction_info_get_type()
* @see stc_restriction_info_get_iface_type()
* @see stc_restriction_info_get_limit()
* @see stc_restriction_info_get_warning_limit()
* @see stc_restriction_rule_get_process_state()
* @see stc_get_restriction()
* @see stc_foreach_restriction()
- * @see stc_get_restriction_status()
+ * @see stc_get_restriction_type()
* @see stc_unset_restriction()
* @see stc_exclude_restriction()
*/
* @see stc_set_restriction()
* @see stc_get_restriction()
* @see stc_foreach_restriction()
- * @see stc_get_restriction_status()
+ * @see stc_get_restriction_type()
* @see stc_unset_restriction()
*/
int stc_exclude_restriction(stc_h stc, stc_restriction_rule_h rule);
* @see stc_set_restriction()
* @see stc_get_restriction()
* @see stc_foreach_restriction()
- * @see stc_get_restriction_status()
+ * @see stc_get_restriction_type()
* @see stc_exclude_restriction()
*/
int stc_unset_restriction(stc_h stc, stc_restriction_rule_h rule);
* @see stc_restriction_info_cb()
* @see stc_set_restriction()
* @see stc_foreach_restriction()
- * @see stc_get_restriction_status()
+ * @see stc_get_restriction_type()
* @see stc_unset_restriction()
* @see stc_exclude_restriction()
*/
* @see stc_restriction_info_cb()
* @see stc_set_restriction()
* @see stc_get_restriction()
- * @see stc_get_restriction_status()
+ * @see stc_get_restriction_type()
* @see stc_unset_restriction()
* @see stc_exclude_restriction()
*/
stc_restriction_info_cb info_cb, void *user_data);
/**
- * @brief Gets the restriction status information.
+ * @brief Gets the restriction type information.
* @since_tizen 4.0
* @privlevel platform
* @privilege %http://tizen.org/privilege/network.get
*
* @param[in] stc The stc handle
* @param[in] rule The restriction rule handle
- * @param[out] status The restriction status
+ * @param[out] type The restriction type
*
* @return 0 on success, otherwise a negative error value
* @retval #STC_ERROR_NONE Successful
*
* @see #stc_h
* @see #stc_restriction_rule_h
- * @see #stc_restriction_status_e
+ * @see #stc_restriction_type_e
* @see stc_initialize()
* @see stc_restriction_rule_create()
* @see stc_restriction_rule_destroy()
* @see stc_unset_restriction()
* @see stc_exclude_restriction()
*/
-int stc_get_restriction_status(stc_h stc, stc_restriction_rule_h rule,
- stc_restriction_status_e *status);
+int stc_get_restriction_type(stc_h stc, stc_restriction_rule_h rule,
+ stc_restriction_type_e *type);
/**
* @}
int stc_restriction_info_get_subscriber_id(stc_restriction_info_h info, char **subscriber_id);
/**
- * @brief Gets the restriction status for restriction information.
- * @since_tizen 4.0
+ * @brief Gets the restriction type for restriction information.
+ * @since_tizen 5.0
* @privlevel platform
* @privilege %http://tizen.org/privilege/network.get
*
* @param[in] info The restriction information handle
- * @param[out] status The restriction status
+ * @param[out] type The restriction type
*
* @return 0 on success, otherwise a negative error value
* @retval #STC_ERROR_NONE Successful
* @retval #STC_ERROR_PERMISSION_DENIED Permission denied
*
* @see #stc_restriction_info_h
- * @see #stc_restriction_status_e
+ * @see #stc_restriction_type_e
* @see stc_restriction_info_cb()
*/
-int stc_restriction_info_get_status(stc_restriction_info_h info,
- stc_restriction_status_e *status);
+int stc_restriction_info_get_type(stc_restriction_info_h info,
+ stc_restriction_type_e *type);
+
/**
* @brief Gets the interface type for restriction information.
* @since_tizen 5.0
* @privlevel platform
* @privilege %http://tizen.org/privilege/firewall.common
+ * @remarks You should set only one chain.
*
* @param[in] chain The firewall chain handle
* @param[in] target The target type
Name: capi-network-stc
Summary: A Smart Traffic Control (STC) libraries in Native API
-Version: 0.0.25
+Version: 0.0.26
Release: 1
Group: Network & Connectivity/API
License: Apache-2.0
#define STC_RESTRICTION_INFO_IFNAME "ifname"
#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_RSTN_TYPE "type"
#define STC_RESTRICTION_INFO_ROAMING "roaming"
#define STC_RESTRICTION_INFO_SUBSCRIBER_ID "subscriber_id"
char iface_name[STC_IFNAME_LEN];
char subscriber_id[STC_SUBSCRIBER_ID_LEN];
stc_iface_type_e iface_type;
- stc_restriction_status_e rst_status;
+ stc_restriction_type_e rstn_type;
int64_t data_limit;
int64_t data_warn_limit;
stc_roaming_type_e roaming_type;
#define STC_RESTRICTION_RULE_DATA_WARN_LIMIT "data_warn_limit"
typedef enum {
- STC_RST_TYPE_UNDEF,
- STC_RST_TYPE_SET,
- STC_RST_TYPE_UNSET,
- STC_RST_TYPE_EXCLUDE,
- STC_RST_TYPE_MAX_VALUE,
-} stc_restriction_type_e;
+ STC_RSTN_TYPE_UNDEF,
+ STC_RSTN_TYPE_SET,
+ STC_RSTN_TYPE_UNSET,
+ STC_RSTN_TYPE_EXCLUDE,
+ STC_RSTN_TYPE_MAX_VALUE,
+} stc_rstn_type_e;
typedef struct {
char app_id[STC_APP_ID_LEN];
char iface_name[STC_IFNAME_LEN];
char subscriber_id[STC_SUBSCRIBER_ID_LEN];
stc_iface_type_e iface_type;
- stc_restriction_status_e rst_state;
+ stc_rstn_type_e rstn_type;
int64_t data_limit;
int64_t data_warn_limit;
stc_roaming_type_e roaming_type;
*****************************************************************************/
stc_error_e _stc_restriction_validate_rule(
- stc_restriction_rule_h rule, stc_restriction_type_e rst_type);
+ stc_restriction_rule_h rule, stc_rstn_type_e rstn_type);
stc_error_e _stc_restriction_check_get_rule(stc_restriction_rule_h rule);
stc_error_e _stc_restriction_check_get_all_rule(
stc_restriction_rule_h rule);
-stc_error_e _stc_restriction_check_get_status_rule(
+stc_error_e _stc_restriction_check_get_type_rule(
stc_restriction_rule_h rule);
stc_error_e _stc_restriction_set(stc_restriction_rule_h rule);
stc_error_e _stc_restriction_exclude(stc_restriction_rule_h rule);
stc_error_e _stc_restriction_unset(stc_restriction_rule_h rule);
-stc_error_e _stc_restriction_get_status(stc_restriction_rule_h rule,
- stc_restriction_status_e *status);
+stc_error_e _stc_restriction_get_type(stc_restriction_rule_h rule,
+ stc_restriction_type_e *type);
stc_error_e _stc_restriction_get(stc_restriction_rule_h rule);
stc_error_e _stc_restriction_get_all(stc_restriction_rule_h rule);
#define STC_MANAGER_METHOD_STATS_RESET "Reset"
#define STC_MANAGER_METHOD_RESTRICTION_SET "Set"
-#define STC_MANAGER_METHOD_RESTRICTION_GET_STATUS "GetState"
+#define STC_MANAGER_METHOD_RESTRICTION_GET_TYPE "GetType"
#define STC_MANAGER_METHOD_RESTRICTION_GET_PER_APP_ID "Get"
#define STC_MANAGER_METHOD_RESTRICTION_GET_ALL "GetAll"
#define STC_MANAGER_METHOD_RESTRICTION_UNSET "Unset"
int _stc_convert_error_string_to_enum(const char *error);
const char *_stc_convert_iface_type_to_string(stc_iface_type_e type);
const char *_stc_convert_roaming_to_string(stc_roaming_type_e type);
-const char *_stc_convert_rst_status_to_string(stc_restriction_status_e state);
+const char *_stc_convert_rstn_type_to_string(stc_restriction_type_e type);
const char *_stc_convert_protocol_to_string(stc_protocol_type_e type);
const char *_stc_convert_process_state_to_string(stc_process_state_e state);
const char *_stc_convert_connection_period_to_string(
}
}
-const char *_stc_convert_rst_status_to_string(stc_restriction_status_e status)
+const char *_stc_convert_rstn_type_to_string(stc_restriction_type_e type)
{
- switch (status) {
- case STC_RESTRICTION_UNKNOWN:
- return "Undefined";
- case STC_RESTRICTION_ACTIVATED:
- return "Activated";
- case STC_RESTRICTION_REMOVED:
- return "Removed";
- case STC_RESTRICTION_EXCLUDED:
- return "Excluded";
- case STC_RESTRICTION_BACKGROUND:
- return "Background";
+ switch (type) {
+ case STC_RSTN_TYPE_UNKNOWN:
+ return "Unknown";
+ case STC_RSTN_TYPE_ACCEPT:
+ return "Accept";
+ case STC_RSTN_TYPE_DROP:
+ return "Drop";
default:
return "Unknown";
}
return STC_ERROR_NONE;
}
-EXPORT_API int stc_restriction_info_get_status(stc_restriction_info_h info,
- stc_restriction_status_e *status)
+EXPORT_API int stc_restriction_info_get_type(stc_restriction_info_h info,
+ stc_restriction_type_e *type)
{
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
stc_restriction_info_s *restriction_info =
(stc_restriction_info_s *)info;
- *status = restriction_info->rst_status;
+ *type = restriction_info->rstn_type;
- STC_LOGI("Status [%s]",
- _stc_convert_rst_status_to_string(*status));
+ STC_LOGI("Type [%s]",
+ _stc_convert_rstn_type_to_string(*type));
return STC_ERROR_NONE;
}
return STC_ERROR_INVALID_PARAMETER;
}
- ret = _stc_restriction_validate_rule(rule, STC_RST_TYPE_SET);
+ ret = _stc_restriction_validate_rule(rule, STC_RSTN_TYPE_SET);
if (ret != STC_ERROR_NONE) {
STC_LOGE("Invalid restriction rule [%s]",
_stc_convert_error_type_to_string(ret));
return STC_ERROR_INVALID_PARAMETER;
}
- ret = _stc_restriction_validate_rule(rule, STC_RST_TYPE_EXCLUDE);
+ ret = _stc_restriction_validate_rule(rule, STC_RSTN_TYPE_EXCLUDE);
if (ret != STC_ERROR_NONE) {
STC_LOGE("Invalid restriction rule [%s]",
_stc_convert_error_type_to_string(ret));
return STC_ERROR_INVALID_PARAMETER;
}
- ret = _stc_restriction_validate_rule(rule, STC_RST_TYPE_UNSET);
+ ret = _stc_restriction_validate_rule(rule, STC_RSTN_TYPE_UNSET);
if (ret != STC_ERROR_NONE) {
STC_LOGE("Invalid restriction rule [%s]",
_stc_convert_error_type_to_string(ret));
return STC_ERROR_NONE;
}
-EXPORT_API int stc_get_restriction_status(stc_h stc, stc_restriction_rule_h rule,
- stc_restriction_status_e *status)
+EXPORT_API int stc_get_restriction_type(stc_h stc, stc_restriction_rule_h rule,
+ stc_restriction_type_e *type)
{
int ret = STC_ERROR_NONE;
return STC_ERROR_INVALID_PARAMETER;
}
- ret = _stc_restriction_check_get_status_rule(rule);
+ ret = _stc_restriction_check_get_type_rule(rule);
if (ret != STC_ERROR_NONE) {
STC_LOGE("Invalid restriction rule [%s]",
_stc_convert_error_type_to_string(ret));
return ret;
}
- ret = _stc_restriction_get_status(rule, status);
+ ret = _stc_restriction_get_type(rule, type);
if (ret != STC_ERROR_NONE) {
- STC_LOGE("Failed to get restriction status [%s]",
+ STC_LOGE("Failed to get restriction type [%s]",
_stc_convert_error_type_to_string(ret));
return ret;
}
- STC_LOGI("Get restriction status");
+ STC_LOGI("Get restriction type");
return STC_ERROR_NONE;
}
rule->app_id[0] = '\0';
rule->iface_name[0] = '\0';
rule->iface_type = STC_IFACE_ALL;
- rule->rst_state = STC_RESTRICTION_REMOVED;
+ rule->rstn_type = STC_RSTN_TYPE_UNKNOWN;
rule->data_limit = 0;
rule->data_warn_limit = 0;
rule->roaming_type = STC_ROAMING_DISABLED;
*params = g_variant_new("(s)", restriction_rule->app_id);
}
-static void __stc_restriction_get_status_make_params(
+static void __stc_restriction_get_type_make_params(
stc_restriction_rule_h rule,
GVariant **params)
{
restriction_info->iface_type =
(stc_iface_type_e)g_variant_get_uint16(value);
- } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_RST_STATUS)) {
- restriction_info->rst_status =
- (stc_restriction_status_e)g_variant_get_uint16(value);
+ } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_RSTN_TYPE)) {
+ restriction_info->rstn_type =
+ (stc_restriction_type_e)g_variant_get_uint16(value);
} else if (!g_strcmp0(key, STC_RESTRICTION_INFO_DATA_LIMIT)) {
restriction_info->data_limit = g_variant_get_int64(value);
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));
+ if (info->rstn_type != STC_RSTN_TYPE_UNKNOWN)
+ STC_LOGD("Type: [%s]", _stc_convert_rstn_type_to_string(info->rstn_type));
STC_LOGD("Limit: [%lld] bytes", info->data_limit);
STC_LOGD("Warning: [%lld] bytes", info->data_warn_limit);
}
stc_error_e _stc_restriction_validate_rule(
- stc_restriction_rule_h rule, stc_restriction_type_e rst_type)
+ stc_restriction_rule_h rule, stc_rstn_type_e rstn_type)
{
stc_restriction_rule_s *restriction_rule = rule;
STC_ERROR_INVALID_PARAMETER,
"Restriction rule should be set");
- STC_RETURN_VAL_IF(rst_type <= STC_RST_TYPE_UNDEF ||
- rst_type >= STC_RST_TYPE_MAX_VALUE,
+ STC_RETURN_VAL_IF(rstn_type <= STC_RSTN_TYPE_UNDEF ||
+ rstn_type >= STC_RSTN_TYPE_MAX_VALUE,
STC_ERROR_INVALID_PARAMETER,
"Invalid restriction type");
"Invalid restriction network interface type [%s]",
_stc_convert_iface_type_to_string(restriction_rule->iface_type));
- if (rst_type == STC_RST_TYPE_SET) {
+ if (rstn_type == STC_RSTN_TYPE_SET) {
STC_RETURN_VAL_IF(restriction_rule->data_limit < 0,
STC_ERROR_INVALID_PARAMETER,
"Invalid tx limit [%lld] bytes",
return STC_ERROR_NONE;
}
-stc_error_e _stc_restriction_check_get_status_rule(
+stc_error_e _stc_restriction_check_get_type_rule(
stc_restriction_rule_h rule)
{
stc_restriction_rule_s *restriction_rule = rule;
return __stc_restriction_get_all(rule);
}
-stc_error_e _stc_restriction_get_status(
+stc_error_e _stc_restriction_get_type(
stc_restriction_rule_h rule,
- stc_restriction_status_e *status)
+ stc_restriction_type_e *type)
{
GVariant *message = NULL;
GVariant *params = NULL;
stc_error_e error = STC_ERROR_NONE;
int result = 0;
- __stc_restriction_get_status_make_params(rule, ¶ms);
+ __stc_restriction_get_type_make_params(rule, ¶ms);
message = _stc_dbus_invoke_method(
STC_MANAGER_SERVICE,
STC_MANAGER_RESTRICTION_PATH,
STC_MANAGER_RESTRICTION_INTERFACE,
- STC_MANAGER_METHOD_RESTRICTION_GET_STATUS,
+ STC_MANAGER_METHOD_RESTRICTION_GET_TYPE,
params,
&error);
STC_RETURN_VAL_IF(message == NULL,
error, "Failed to invoke dbus method");
- g_variant_get(message, "(ii)", &result, status);
- STC_LOGI("Successfully get restriction status [%s]",
- _stc_convert_rst_status_to_string(*status));
+ g_variant_get(message, "(ii)", &result, type);
+ STC_LOGI("Successfully get restriction type [%s]",
+ _stc_convert_rstn_type_to_string(*type));
g_variant_unref(message);
return STC_ERROR_NONE;
char *app_id = NULL;
char *iface_name = NULL;
char *subscriber_id = NULL;
- stc_restriction_status_e rst_status;
+ stc_restriction_type_e rstn_type;
stc_iface_type_e iface_type;
int64_t data_limit;
int64_t data_warn_limit;
if (ret == STC_ERROR_NONE)
msg("Sub_id: [%s]", subscriber_id);
- ret = stc_restriction_info_get_status(info, &rst_status);
+ ret = stc_restriction_info_get_type(info, &rstn_type);
if (ret == STC_ERROR_NONE)
- msg("Status: [%s]", test_stc_convert_rst_status_to_string(rst_status));
+ msg("Type: [%s]", test_stc_convert_rstn_type_to_string(rstn_type));
ret = stc_restriction_info_get_iface_type(info, &iface_type);
if (ret == STC_ERROR_NONE)
return ret;
}
-static int __test_stc_restriction_get_status(MManager *mm, struct menu_data *menu)
+static int __test_stc_restriction_get_type(MManager *mm, struct menu_data *menu)
{
int ret = STC_ERROR_NONE;
- stc_restriction_status_e rst_status;
+ stc_restriction_type_e rstn_type;
- ret = stc_get_restriction_status(g_stc, g_restriction_rule, &rst_status);
+ ret = stc_get_restriction_type(g_stc, g_restriction_rule, &rstn_type);
if (ret == STC_ERROR_NONE) {
- msg("Restriction status " LOG_CYAN "[%s]" LOG_END,
- test_stc_convert_rst_status_to_string(rst_status));
- msg(LOG_GREEN "Success to get restriction status" LOG_END);
+ msg("Restriction type " LOG_CYAN "[%s]" LOG_END,
+ test_stc_convert_rstn_type_to_string(rstn_type));
+ msg(LOG_GREEN "Success to get restriction type" LOG_END);
} else
- msg("Fail to get restriction status " LOG_RED "[%s]" LOG_END,
+ msg("Fail to get restriction type " LOG_RED "[%s]" LOG_END,
test_stc_convert_error_type_to_string(ret));
return ret;
{ "1", LOG_LIGHTMAGENTA "[Set]" LOG_END " restriction rule", menu_restriction_rule, NULL, NULL},
{ "2", LOG_LIGHTBLUE "[Get]" LOG_END " restriction", NULL, __test_stc_restriction_get, NULL},
{ "3", LOG_LIGHTBLUE "[Get]" LOG_END " all restrictions", NULL, __test_stc_restriction_get_all, NULL},
- { "4", LOG_LIGHTBLUE "[Get]" LOG_END " restriction status", NULL, __test_stc_restriction_get_status, NULL},
+ { "4", LOG_LIGHTBLUE "[Get]" LOG_END " restriction type", NULL, __test_stc_restriction_get_type, NULL},
{ "5", LOG_LIGHTMAGENTA "[Set]" LOG_END " restriction", NULL, __test_stc_restriction_set, NULL},
{ "6", LOG_LIGHTMAGENTA "[Remove]" LOG_END " restriction", NULL, __test_stc_restriction_unset, NULL},
{ "7", LOG_LIGHTMAGENTA "[Exlcude]" LOG_END " restriction", NULL, __test_stc_restriction_exclude, NULL},
}
}
-const char *test_stc_convert_rst_status_to_string(stc_restriction_status_e status)
+const char *test_stc_convert_rstn_type_to_string(stc_restriction_type_e type)
{
- switch (status) {
- case STC_RESTRICTION_UNKNOWN:
+ switch (type) {
+ case STC_RSTN_TYPE_UNKNOWN:
return "Undefined";
- case STC_RESTRICTION_ACTIVATED:
- return "Activated";
- case STC_RESTRICTION_REMOVED:
- return "Removed";
- case STC_RESTRICTION_EXCLUDED:
- return "Excluded";
- case STC_RESTRICTION_BACKGROUND:
- return "Background";
+ case STC_RSTN_TYPE_ACCEPT:
+ return "Accept";
+ case STC_RSTN_TYPE_DROP:
+ return "Drop";
default:
return "Unknown";
}
const char *test_stc_convert_error_type_to_string(stc_error_e err);
const char *test_stc_convert_iface_type_to_string(stc_iface_type_e type);
const char *test_stc_convert_roaming_to_string(stc_roaming_type_e type);
-const char *test_stc_convert_rst_status_to_string(stc_restriction_status_e status);
+const char *test_stc_convert_rstn_type_to_string(stc_restriction_type_e type);
const char *test_stc_convert_protocol_to_string(stc_protocol_type_e type);
const char *test_stc_convert_process_state_to_string(stc_process_state_e state);
const char *test_stc_convert_time_period_to_string(stc_time_period_e time);