Added gateway argument for route execute file 40/160740/2
authortaesub kim <taesub.kim@samsung.com>
Mon, 20 Nov 2017 01:35:42 +0000 (10:35 +0900)
committertaesub kim <taesub.kim@samsung.com>
Mon, 20 Nov 2017 02:22:14 +0000 (11:22 +0900)
Change-Id: I15023b93111d66b2c2f6958d5e9c2d85182b0d7f
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
src/network-state.c

index 2aad402..17179e4 100755 (executable)
@@ -1206,8 +1206,14 @@ static gboolean handle_add_route(
                gchar *interface,  gchar *gateway, gint address_family)
 {
        const gchar *path = ROUTE_EXEC_PATH;
-       gchar *const args[] = { "/sbin/route", "add", "-net", ip_addr,
-               "netmask", netmask, "dev", interface, NULL };
+
+       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 *const envs[] = { NULL };
        const gchar* buf = NULL;
        gchar* ch = NULL;
@@ -1273,8 +1279,14 @@ static gboolean handle_remove_route(
                gchar *interface, gchar *gateway, gint address_family)
 {
        const char *path = ROUTE_EXEC_PATH;
-       gchar *const args[] = { "/sbin/route", "del", "-net", ip_addr,
-               "netmask", netmask, "dev", interface, NULL };
+
+       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 };
+
        char *const envs[] = { NULL };
        const char* buf = NULL;
        char* ch = NULL;