g_free(ipaddress->broadcast);
g_free(ipaddress->peer);
g_free(ipaddress->local);
+ g_free(ipaddress->gateway);
g_free(ipaddress);
}
}
void connman_ipaddress_set(struct connman_ipaddress *ipaddress,
- const char *address, const char *netmask)
+ const char *address, const char *netmask, const char *gateway)
{
if (ipaddress == NULL)
return;
g_free(ipaddress->local);
ipaddress->local = g_strdup(address);
+
+ g_free(ipaddress->gateway);
+ ipaddress->gateway = g_strdup(gateway);
}
void connman_ipaddress_clear(struct connman_ipaddress *ipaddress)
g_free(ipaddress->broadcast);
ipaddress->broadcast = NULL;
+
+ g_free(ipaddress->gateway);
+ ipaddress->gateway = NULL;
}
void connman_ipaddress_copy(struct connman_ipaddress *ipaddress,
g_free(ipaddress->broadcast);
ipaddress->broadcast = g_strdup(source->broadcast);
+
+ g_free(ipaddress->gateway);
+ ipaddress->gateway = g_strdup(source->gateway);
}
static void free_address_list(struct connman_ipdevice *ipdevice)
DBusMessageIter *array)
{
enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
- const char *address = NULL, *netmask = NULL;
+ const char *address = NULL, *netmask = NULL, *gateway = NULL;
DBusMessageIter dict;
DBG("ipconfig %p", ipconfig);
return -EINVAL;
dbus_message_iter_get_basic(&entry, &netmask);
- }
+ } else if (g_str_equal(key, "Gateway") == TRUE) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+ dbus_message_iter_get_basic(&entry, &gateway);
+ }
dbus_message_iter_next(&dict);
}
- DBG("method %d address %s netmask %s", method, address, netmask);
+ DBG("method %d address %s netmask %s gateway %s",
+ method, address, netmask, gateway);
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
return -EINVAL;
ipconfig->method = method;
- connman_ipaddress_set(ipconfig->address, address, netmask);
+ connman_ipaddress_set(ipconfig->address,
+ address, netmask, gateway);
break;
case CONNMAN_IPCONFIG_METHOD_DHCP:
keyfile, identifier, key, NULL);
g_free(key);
+ key = g_strdup_printf("%sgateway", prefix);
+ ipconfig->address->gateway = g_key_file_get_string(
+ keyfile, identifier, key, NULL);
+ g_free(key);
+
return 0;
}
key = g_strdup_printf("%sbroadcast_address", prefix);
if (ipconfig->address->broadcast != NULL)
g_key_file_set_string(keyfile, identifier,
- "broadcast_address", ipconfig->address->broadcast);
+ key, ipconfig->address->broadcast);
+ g_free(key);
+
+ key = g_strdup_printf("%sgateway", prefix);
+ if (ipconfig->address->gateway != NULL)
+ g_key_file_set_string(keyfile, identifier,
+ key, ipconfig->address->gateway);
g_free(key);
return 0;