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;
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;