Added fluch chain for test 79/163879/1
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 14 Dec 2017 01:03:35 +0000 (10:03 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 14 Dec 2017 01:03:41 +0000 (10:03 +0900)
Change-Id: I10eaf996c70dc90264d55da6fc2e74107e10c709
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
test/stc_ipt_chain.c
test/stc_ipt_gdbus.h

index bd58fb9..6d347d9 100755 (executable)
@@ -87,6 +87,68 @@ static int __stc_ip6t_add_chain(void)
        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;
@@ -164,6 +226,21 @@ static int test_stc_ipt_add_chain(MManager *mm, struct menu_data *menu)
        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;
@@ -182,6 +259,7 @@ static int test_stc_ipt_remove_chain(MManager *mm, struct menu_data *menu)
 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, },
 };
index c485750..da52f2b 100755 (executable)
 #define STC_IPT_DBUS_RULE_PATH             "/net/stc/iptables/rule"
 #define STC_IPT_DBUS_CHAIN_PATH            "/net/stc/iptables/chain"
 #define STC_IPT_DBUS_METHOD_IPT_ADD_CHAIN      "IptAddChain"
+#define STC_IPT_DBUS_METHOD_IPT_FLUSH_CHAIN    "IptFlushChain"
 #define STC_IPT_DBUS_METHOD_IPT_REMOVE_CHAIN   "IptRemoveChain"
 #define STC_IPT_DBUS_METHOD_IP6T_ADD_CHAIN     "Ip6tAddChain"
+#define STC_IPT_DBUS_METHOD_IP6T_FLUSH_CHAIN   "Ip6tFlushChain"
 #define STC_IPT_DBUS_METHOD_IP6T_REMOVE_CHAIN  "Ip6tRemoveChain"
 #define STC_IPT_DBUS_METHOD_IPT_ADD_RULE       "IptAddRule"
 #define STC_IPT_DBUS_METHOD_IPT_REMOVE_RULE    "IptRemoveRule"