Added gateway argument for route execute file #2 71/160871/2
authortaesub kim <taesub.kim@samsung.com>
Mon, 20 Nov 2017 09:37:59 +0000 (18:37 +0900)
committertaesub kim <taesub.kim@samsung.com>
Mon, 20 Nov 2017 23:05:41 +0000 (08:05 +0900)
Change-Id: I5fb48e490039661255d7b2f7d1ca8435cccb060f
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
include/ip-conflict-detect.h [changed mode: 0644->0755]
src/ip-conflict-detect.c [changed mode: 0644->0755]
src/network-state.c

old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 17179e4..794db9f 100755 (executable)
@@ -1206,14 +1206,11 @@ static gboolean handle_add_route(
                gchar *interface,  gchar *gateway, gint address_family)
 {
        const gchar *path = ROUTE_EXEC_PATH;
-
-       if (gateway == NULL || strcmp(gateway, "") == 0)
-               gchar *const args[] = { "/sbin/route", "add", "-net", ip_addr,
-                       "netmask", netmask, "dev", interface, NULL };
-       else
-               gchar *const args[] = { "/sbin/route", "add", "-net", ip_addr, "gw", gateway,
-                       "netmask", netmask, "dev", interface, NULL };
-
+       gchar gw_str[64] = {0,};
+       if (gateway != NULL && strlen(gateway) > 1)
+               g_snprintf(gw_str, 64, "gw %s", gateway);
+       gchar *const args[] = { "/sbin/route", "add", "-net", ip_addr, gw_str,
+               "netmask", netmask, "dev", interface, NULL };
        gchar *const envs[] = { NULL };
        const gchar* buf = NULL;
        gchar* ch = NULL;
@@ -1279,14 +1276,11 @@ static gboolean handle_remove_route(
                gchar *interface, gchar *gateway, gint address_family)
 {
        const char *path = ROUTE_EXEC_PATH;
-
-       if (gateway == NULL || strcmp(gateway, "") == 0)
-               gchar *const args[] = { "/sbin/route", "del", "-net", ip_addr,
-                       "netmask", netmask, "dev", interface, NULL };
-       else
-               gchar *const args[] = { "/sbin/route", "del", "-net", ip_addr, "gw", gateway,
-                       "netmask", netmask, "dev", interface, NULL };
-
+       gchar gw_str[64] = {0,};
+       if (gateway != NULL && strlen(gateway) > 1)
+               g_snprintf(gw_str, 64, "gw %s", gateway);
+       gchar *const args[] = { "/sbin/route", "del", "-net", ip_addr, gw_str,
+               "netmask", netmask, "dev", interface, NULL };
        char *const envs[] = { NULL };
        const char* buf = NULL;
        char* ch = NULL;