int *err_num, char **err_str);
/**
+ * @brief Commits ip6tables rule.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/firewall.common
+ * @remarks You must release @a err_str using free().
+ *
+ * @param[in] stc The stc handle
+ * @param[in] option The option of iptables rule
+ * @param[out] err_num The error number
+ * @param[out] err_str The error string
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see stc_initialize()
+ */
+int stc_ip6tables_commit(stc_h stc, const char *option,
+ int *err_num, char **err_str);
+
+/**
* @}
*/
Name: capi-network-stc
Summary: A Smart Traffic Control (STC) libraries in Native API
-Version: 0.0.28
+Version: 0.0.29
Release: 1
Group: Network & Connectivity/API
License: Apache-2.0
#define STC_MANAGER_METHOD_RESTRICTION_UNSET "Unset"
#define STC_MANAGER_METHOD_IPTABLES_COMMIT "CommitIptables"
+#define STC_MANAGER_METHOD_IP6TABLES_COMMIT "CommitIp6tables"
#define STC_DEBUG_GDBUS_VARIANT(str, parameters) \
do { \
return STC_ERROR_OPERATION_FAILED;
}
+stc_error_e _stc_ip6tables_commit(const char *option,
+ int *err_num, char **err_str)
+{
+ GVariant *message = NULL;
+ GVariant *params = NULL;
+ stc_error_e error = STC_ERROR_NONE;
+ int result = 0;
+ int errnum = 0;
+ char *errstr = NULL;
+
+ params = g_variant_new("(s)", option);
+
+ message = _stc_dbus_invoke_method(
+ STC_MANAGER_SERVICE,
+ STC_MANAGER_PATH,
+ STC_MANAGER_INTERFACE,
+ STC_MANAGER_METHOD_IP6TABLES_COMMIT,
+ params,
+ &error);
+
+ STC_RETURN_VAL_IF(message == NULL,
+ error, "Failed to invoke dbus method");
+
+ g_variant_get(message, "(iis)", &result, &errnum, &errstr);
+ STC_LOGI("Commit ip6tables result [%d:%d:%s]", result, errnum, errstr);
+ g_variant_unref(message);
+
+ if (err_num)
+ *err_num = errnum;
+ if (err_str)
+ *err_str = g_strdup(errstr);
+
+ if (result == STC_ERROR_NONE)
+ return STC_ERROR_NONE;
+ else
+ return STC_ERROR_OPERATION_FAILED;
+}
+
EXPORT_API int stc_reset_stats(stc_h stc, stc_reset_rule_h rule)
{
int ret = STC_ERROR_NONE;
return STC_ERROR_NONE;
}
+
+EXPORT_API int stc_ip6tables_commit(stc_h stc, const char *option,
+ int *err_num, char **err_str)
+{
+ int ret = STC_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+ if (!(_stc_handle_check_validity(stc))) {
+ STC_LOGE("Invalid parameter");
+ return STC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (option == NULL) {
+ STC_LOGE("Invalid parameter");
+ return STC_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _stc_ip6tables_commit(option, err_num, err_str);
+ if (ret != STC_ERROR_NONE) {
+ STC_LOGE("Failed to commit ip6tables [%s]",
+ _stc_convert_error_type_to_string(ret));
+ return ret;
+ }
+
+ return STC_ERROR_NONE;
+}
//LCOV_EXCL_STOP
return ret;
}
+static int __test_stc_commit_ip6tables(MManager *mm, struct menu_data *menu)
+{
+ int ret = STC_ERROR_NONE;
+ int err_num = 0;
+ char *err_str = NULL;
+
+ ret = stc_ip6tables_commit(g_stc, g_iptables_option, &err_num, &err_str);
+
+ if (ret == STC_ERROR_NONE)
+ msg(LOG_GREEN "Success to commit ip6tables" LOG_END);
+ else
+ msg("Fail to commit ip6tables " LOG_RED "[%s:%d:%s]" LOG_END,
+ test_stc_convert_error_type_to_string(ret), err_num, err_str);
+
+ FREE(err_str);
+
+ return ret;
+}
+
static struct menu_data menu_iptables_commit[] = {
{ "1", "Option", NULL, NULL, g_iptables_option},
- { "c", LOG_LIGHTMAGENTA "[Commit]" LOG_END, NULL, __test_stc_commit_iptables, NULL},
+ { "2", LOG_LIGHTMAGENTA "[Commit]" LOG_END "iptables", NULL, __test_stc_commit_iptables, NULL},
+ { "3", LOG_LIGHTMAGENTA "[Commit]" LOG_END "ip6tables", NULL, __test_stc_commit_ip6tables, NULL},
{ NULL, NULL, },
};
struct menu_data menu_iptables[] = {
- { "1", LOG_LIGHTBLUE "[Commit]" LOG_END " iptables", menu_iptables_commit, NULL, NULL},
+ { "1", LOG_LIGHTBLUE "[Commit]" LOG_END " iptable rule", menu_iptables_commit, NULL, NULL},
{ "2", LOG_LIGHTMAGENTA "[Stop]" LOG_END " manager", NULL, NULL, NULL},
{ NULL, NULL, },
};