return err;
}
+static int __stc_ipt_flush_chain(void)
+{
+ GVariant *message = NULL;
+ GVariant *params = NULL;
+ int err = STC_ERROR_NONE;
+ int result = 0;
+
+ params = g_variant_new("(s)", g_chain_name);
+
+ message = stc_ipt_dbus_invoke_method(
+ STC_IPT_DBUS_SERVICE,
+ STC_IPT_DBUS_CHAIN_PATH,
+ STC_IPT_DBUS_CHAIN_INTERFACE,
+ STC_IPT_DBUS_METHOD_IPT_FLUSH_CHAIN,
+ params,
+ &err);
+
+ if (message == NULL) {
+ msg(LOG_RED "Failed to invoke dbus method" LOG_END);
+ return err;
+ }
+
+ g_variant_get(message, "(i)", &result);
+ msg(LOG_GREEN "Successfully flush chain [%d]" LOG_END, result);
+ g_variant_unref(message);
+
+ stc_ipt_exe_cmd(CHECK_IPTABLES);
+
+ return err;
+}
+
+static int __stc_ip6t_flush_chain(void)
+{
+ GVariant *message = NULL;
+ GVariant *params = NULL;
+ int err = STC_ERROR_NONE;
+ int result = 0;
+
+ params = g_variant_new("(s)", g_chain_name);
+
+ message = stc_ipt_dbus_invoke_method(
+ STC_IPT_DBUS_SERVICE,
+ STC_IPT_DBUS_CHAIN_PATH,
+ STC_IPT_DBUS_CHAIN_INTERFACE,
+ STC_IPT_DBUS_METHOD_IP6T_FLUSH_CHAIN,
+ params,
+ &err);
+
+ if (message == NULL) {
+ msg(LOG_RED "Failed to invoke dbus method" LOG_END);
+ return err;
+ }
+
+ g_variant_get(message, "(i)", &result);
+ msg(LOG_GREEN "Successfully flush 6 chain [%d]" LOG_END, result);
+ g_variant_unref(message);
+
+ stc_ipt_exe_cmd(CHECK_IP6TABLES);
+
+ return err;
+}
+
static int __stc_ipt_remove_chain(void)
{
GVariant *message = NULL;
return err;
}
+static int test_stc_ipt_add_flush(MManager *mm, struct menu_data *menu)
+{
+ int err = STC_ERROR_NONE;
+
+ err = __stc_ipt_flush_chain();
+ if (err != STC_ERROR_NONE)
+ msg(LOG_RED "Failed to flush chain" LOG_END);
+
+ err = __stc_ip6t_flush_chain();
+ if (err != STC_ERROR_NONE)
+ msg(LOG_RED "Failed to flush 6 chain" LOG_END);
+
+ return err;
+}
+
static int test_stc_ipt_remove_chain(MManager *mm, struct menu_data *menu)
{
int err = STC_ERROR_NONE;
struct menu_data menu_chain[] = {
{ "1", LOG_LIGHTMAGENTA "[Set]" LOG_END " chain name", NULL, NULL, g_chain_name},
{ "a", LOG_LIGHTBLUE "[Add]" LOG_END " chain", NULL, test_stc_ipt_add_chain, NULL},
+ { "f", LOG_LIGHTBLUE "[Flush]" LOG_END " chain", NULL, test_stc_ipt_add_flush, NULL},
{ "r", LOG_LIGHTMAGENTA "[Remove]" LOG_END " chain", NULL, test_stc_ipt_remove_chain, NULL},
{ NULL, NULL, },
};