Added dbus method to commit ip6tables 14/178314/1 accepted/tizen/unified/20180510.134338 submit/tizen/20180510.023945
authorhyunuktak <hyunuk.tak@samsung.com>
Wed, 9 May 2018 08:33:45 +0000 (17:33 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Wed, 9 May 2018 08:33:49 +0000 (17:33 +0900)
Change-Id: Ic446d4575fc9fc901f7a609377475f1be64657ea
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/stc-manager-gdbus.h
interfaces/stcmanager-iface-manager.xml
src/helper/helper-iptables.c
src/stc-manager-gdbus.c

index b422b62..860b766 100755 (executable)
@@ -87,5 +87,9 @@ gboolean handle_manager_commit_iptables(StcManager *object,
                                        GDBusMethodInvocation *invocation,
                                        const gchar *option,
                                        void *user_data);
+gboolean handle_manager_commit_ip6tables(StcManager *object,
+                                       GDBusMethodInvocation *invocation,
+                                       const gchar *option,
+                                       void *user_data);
 
 #endif /* __STC_MANAGER_GDBUS_H__ */
index 33697b4..6ac32d3 100644 (file)
@@ -9,5 +9,11 @@
                        <arg type='i' name='error_num' direction='out'/>
                        <arg type='s' name='error_str' direction='out'/>
                </method>
+               <method name='CommitIp6tables'>
+                       <arg type='s' name='option' direction='in'/>
+                       <arg type='i' name='error_code' direction='out'/>
+                       <arg type='i' name='error_num' direction='out'/>
+                       <arg type='s' name='error_str' direction='out'/>
+               </method>
        </interface>
 </node>
index b1ca634..6ca96af 100755 (executable)
@@ -96,7 +96,8 @@ static int __iptables_rule_add(GDBusConnection *connection,
        }
 
        g_variant_get(message, "(i)", &result);
-       STC_LOGD("Successfully Add Rule [%d:%s]", result, rule->nfacct_name);
+       if (STC_DEBUG_LOG)
+               STC_LOGD("Successfully Add Rule [%d:%s]", result, rule->nfacct_name);
        g_variant_unref(message);
 
        return STC_ERROR_NONE;
@@ -128,7 +129,8 @@ static int __iptables_rule_remove(GDBusConnection *connection,
        }
 
        g_variant_get(message, "(i)", &result);
-       STC_LOGD("Successfully Remove Rule [%d:%s]", result, rule->nfacct_name);
+       if (STC_DEBUG_LOG)
+               STC_LOGD("Successfully Remove Rule [%d:%s]", result, rule->nfacct_name);
        g_variant_unref(message);
 
        return STC_ERROR_NONE;
@@ -160,7 +162,8 @@ static int __ip6tables_rule_add(GDBusConnection *connection,
        }
 
        g_variant_get(message, "(i)", &result);
-       STC_LOGD("Successfully Add 6 Rule [%d:%s]", result, rule->nfacct_name);
+       if (STC_DEBUG_LOG)
+               STC_LOGD("Successfully Add 6 Rule [%d:%s]", result, rule->nfacct_name);
        g_variant_unref(message);
 
        return STC_ERROR_NONE;
@@ -192,7 +195,8 @@ static int __ip6tables_rule_remove(GDBusConnection *connection,
        }
 
        g_variant_get(message, "(i)", &result);
-       STC_LOGD("Successfully Remove 6 Rule [%d:%s]", result, rule->nfacct_name);
+       if (STC_DEBUG_LOG)
+               STC_LOGD("Successfully Remove 6 Rule [%d:%s]", result, rule->nfacct_name);
        g_variant_unref(message);
 
        return STC_ERROR_NONE;
index a31deb0..ddad1ef 100755 (executable)
@@ -255,6 +255,9 @@ static gboolean __stc_manager_gdbus_manager_init(stc_s *stc)
        g_signal_connect(manager, "handle-commit-iptables",
                         G_CALLBACK(handle_manager_commit_iptables), stc);
 
+       g_signal_connect(manager, "handle-commit-ip6tables",
+                        G_CALLBACK(handle_manager_commit_ip6tables), stc);
+
        g_dbus_object_manager_server_export(stc->obj_mgr,
                                            G_DBUS_OBJECT_SKELETON(object));
        g_object_unref(object);
@@ -389,7 +392,7 @@ GVariant *stc_manager_gdbus_call_sync(GDBusConnection *connection,
        if (reply == NULL) {
                if (error != NULL) {
                        STC_LOGE("g_dbus_connection_call_sync() failed" //LCOV_EXCL_LINE
-                                "error [%d: %s]", error->code, error->message);
+                                " error [%d: %s]", error->code, error->message);
                        g_error_free(error); //LCOV_EXCL_LINE
                } else {
                        STC_LOGE("g_dbus_connection_call_sync() failed"); //LCOV_EXCL_LINE
@@ -548,3 +551,36 @@ gboolean handle_manager_commit_iptables(StcManager *object,
        __STC_LOG_FUNC_EXIT__;
        return TRUE;
 }
+
+gboolean handle_manager_commit_ip6tables(StcManager *object,
+                                       GDBusMethodInvocation *invocation,
+                                       const gchar *option,
+                                       void *user_data)
+{
+       __STC_LOG_FUNC_ENTER__;
+       GVariant *return_parameters = NULL;
+       int ret = STC_ERROR_NONE;
+       int err_num = 0;
+       char *err_str = NULL;
+       char cmd[STC_CMD_SIZE] = { 0, };
+
+       if (option == NULL) {
+               STC_MANAGER_DBUS_REPLY_ERROR(invocation,
+                                                STC_ERROR_INVALID_PARAMETER);
+               __STC_LOG_FUNC_EXIT__;
+               return TRUE;
+       }
+
+       STC_LOGD("[%s]", option);
+       g_snprintf(cmd, STC_CMD_SIZE, "%s %s", STC_IP6TABLES, option);
+
+       ret = stc_commit_iptables(cmd, &err_num, &err_str);
+
+       return_parameters = g_variant_new("(iis)", ret, err_num, err_str);
+
+       DEBUG_GDBUS_VARIANT("Return parameters: ", return_parameters);
+       STC_DBUS_REPLY(invocation, return_parameters);
+
+       __STC_LOG_FUNC_EXIT__;
+       return TRUE;
+}