Add initial source codes for gtest
[platform/core/connectivity/stc-manager.git] / src / helper / helper-iptables.c
index 96eacb8..06b9378 100755 (executable)
@@ -44,7 +44,7 @@ static void __add_rule_info_to_builder(GVariantBuilder *builder,
                                       iptables_rule_s *rule)
 {
        if (builder == NULL || rule == NULL)
-               return;
+               return; //LCOV_EXCL_LINE
 
        g_variant_builder_add(builder, "{sv}", RULE_CHAIN,
                              g_variant_new_string(rule->chain));
@@ -91,8 +91,8 @@ static int __iptables_rule_add(GDBusConnection *connection,
                                              params);
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -123,8 +123,8 @@ static int __iptables_rule_remove(GDBusConnection *connection,
                                              params);
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -155,8 +155,8 @@ static int __ip6tables_rule_add(GDBusConnection *connection,
                                              params);
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -187,8 +187,8 @@ static int __ip6tables_rule_remove(GDBusConnection *connection,
                                              params);
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -212,8 +212,8 @@ static int __iptables_add_chain(GDBusConnection *connection,
                                              g_variant_new("(s)", chain));
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -237,8 +237,8 @@ static int __ip6tables_add_chain(GDBusConnection *connection,
                                              g_variant_new("(s)", chain));
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -262,8 +262,8 @@ static int __iptables_remove_chain(GDBusConnection *connection,
                                              g_variant_new("(s)", chain));
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -287,8 +287,8 @@ static int __ip6tables_remove_chain(GDBusConnection *connection,
                                              g_variant_new("(s)", chain));
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -312,8 +312,8 @@ static int __iptables_flush_chain(GDBusConnection *connection,
                                              g_variant_new("(s)", chain));
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -337,8 +337,8 @@ static int __ip6tables_flush_chain(GDBusConnection *connection,
                                              g_variant_new("(s)", chain));
 
        if (message == NULL) {
-               STC_LOGE("Failed to invoke dbus method");
-               return STC_ERROR_FAIL;
+               STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
        g_variant_get(message, "(i)", &result);
@@ -372,11 +372,11 @@ stc_error_e iptables_add(iptables_rule_s *rule)
        stc_s *stc = stc_get_manager();
 
        if (!stc || !stc->connection)
-               return STC_ERROR_INVALID_PARAMETER;
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
 
        ret = __iptables_rule_add(stc->connection, rule);
        if (ret != STC_ERROR_NONE)
-               goto done;
+               goto done; //LCOV_EXCL_LINE
 
        ret = __ip6tables_rule_add(stc->connection, rule);
 done:
@@ -389,11 +389,11 @@ stc_error_e iptables_remove(iptables_rule_s *rule)
        stc_s *stc = stc_get_manager();
 
        if (!stc || !stc->connection)
-               return STC_ERROR_INVALID_PARAMETER;
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
 
        ret = __iptables_rule_remove(stc->connection, rule);
        if (ret != STC_ERROR_NONE)
-               goto done;
+               goto done; //LCOV_EXCL_LINE
 
        ret = __ip6tables_rule_remove(stc->connection, rule);
 done:
@@ -406,27 +406,27 @@ stc_error_e iptables_flush_chains(void)
        stc_s *stc = stc_get_manager();
 
        if (!stc || !stc->connection)
-               return STC_ERROR_INVALID_PARAMETER;
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
 
        ret = __iptables_flush_chain(stc->connection, STC_IN_CHAIN);
        if (ret != STC_ERROR_NONE)
-               goto done;
+               goto done; //LCOV_EXCL_LINE
 
        ret = __iptables_flush_chain(stc->connection, STC_OUT_CHAIN);
        if (ret != STC_ERROR_NONE)
-               goto done;
+               goto done; //LCOV_EXCL_LINE
 
        ret = __iptables_flush_chain(stc->connection, STC_FRWD_CHAIN);
        if (ret != STC_ERROR_NONE)
-               goto done;
+               goto done; //LCOV_EXCL_LINE
 
        ret = __ip6tables_flush_chain(stc->connection, STC_IN_CHAIN);
        if (ret != STC_ERROR_NONE)
-               goto done;
+               goto done; //LCOV_EXCL_LINE
 
        ret = __ip6tables_flush_chain(stc->connection, STC_OUT_CHAIN);
        if (ret != STC_ERROR_NONE)
-               goto done;
+               goto done; //LCOV_EXCL_LINE
 
        ret = __ip6tables_flush_chain(stc->connection, STC_FRWD_CHAIN);
 done:
@@ -441,56 +441,56 @@ stc_error_e iptables_init(void)
        stc_s *stc = stc_get_manager();
 
        if (!stc || !stc->connection) {
-               __STC_LOG_FUNC_EXIT__;
-               return STC_ERROR_INVALID_PARAMETER;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_add_chain(stc->connection, STC_IN_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_add_chain(stc->connection, STC_OUT_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_add_chain(stc->connection, STC_FRWD_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __ip6tables_add_chain(stc->connection, STC_IN_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __ip6tables_add_chain(stc->connection, STC_OUT_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __ip6tables_add_chain(stc->connection, STC_FRWD_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_add_chain_jump_rule("INPUT", STC_IN_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_add_chain_jump_rule("OUTPUT", STC_OUT_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_add_chain_jump_rule("FORWARD", STC_FRWD_CHAIN);
@@ -506,38 +506,38 @@ stc_error_e iptables_deinit(void)
        stc_s *stc = stc_get_manager();
 
        if (!stc || !stc->connection) {
-               __STC_LOG_FUNC_EXIT__;
-               return STC_ERROR_INVALID_PARAMETER;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_remove_chain(stc->connection, STC_IN_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_remove_chain(stc->connection, STC_OUT_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __iptables_remove_chain(stc->connection, STC_FRWD_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __ip6tables_remove_chain(stc->connection, STC_IN_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __ip6tables_remove_chain(stc->connection, STC_OUT_CHAIN);
        if (ret != STC_ERROR_NONE) {
-               __STC_LOG_FUNC_EXIT__;
-               goto done;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto done; //LCOV_EXCL_LINE
        }
 
        ret = __ip6tables_remove_chain(stc->connection, STC_FRWD_CHAIN);