int __connman_ipconfig_address_add(struct connman_ipconfig *ipconfig);
int __connman_ipconfig_address_remove(struct connman_ipconfig *ipconfig);
+int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig);
+void __connman_ipconfig_gateway_remove(struct connman_ipconfig *ipconfig);
unsigned char __connman_ipconfig_netmask_prefix_len(const char *netmask);
int __connman_ipconfig_set_proxy_autoconfig(struct connman_ipconfig *ipconfig,
void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig, const char *gateway)
{
- struct connman_service *service;
+ DBG("");
if (ipconfig->address == NULL)
return;
+ g_free(ipconfig->address->gateway);
+ ipconfig->address->gateway = g_strdup(gateway);
+}
+
+int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig)
+{
+ struct connman_service *service;
+
+ DBG("");
+
+ if (ipconfig->address == NULL || ipconfig->address->gateway == NULL)
+ return -EINVAL;
service = __connman_service_lookup_from_index(ipconfig->index);
- if (service != NULL)
- __connman_connection_gateway_remove(service);
+ if (service == NULL)
+ return -EINVAL;
- g_free(ipconfig->address->gateway);
- ipconfig->address->gateway = g_strdup(gateway);
+ __connman_connection_gateway_remove(service);
- if (service != NULL && ipconfig->address->gateway != NULL) {
- if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6) {
- __connman_connection_gateway_add(service,
- NULL,
+ if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6) {
+ return __connman_connection_gateway_add(service, NULL,
ipconfig->address->gateway,
- ipconfig->address->peer);
- } else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
- __connman_connection_gateway_add(service,
+ ipconfig->address->peer);
+ } else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
+ return __connman_connection_gateway_add(service,
ipconfig->address->gateway,
- NULL,
- ipconfig->address->peer);
- }
+ NULL, ipconfig->address->peer);
}
+
+ return 0;
+}
+
+void __connman_ipconfig_gateway_remove(struct connman_ipconfig *ipconfig)
+{
+ struct connman_service *service;
+
+ DBG("");
+
+ service = __connman_service_lookup_from_index(ipconfig->index);
+ if (service != NULL)
+ __connman_connection_gateway_remove(service);
}
unsigned char __connman_ipconfig_get_prefixlen(struct connman_ipconfig *ipconfig)
set_configuration(network);
err = __connman_ipconfig_address_add(ipconfig);
- if (err < 0) {
- connman_network_set_error(network,
- CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
- return;
- }
+ if (err < 0)
+ goto err;
connman_element_get_value(&network->element,
CONNMAN_PROPERTY_ID_IPV4_NAMESERVER, &nameserver);
connman_element_get_value(&network->element,
CONNMAN_PROPERTY_ID_IPV4_GATEWAY, &gateway);
- if (gateway != NULL)
+ if (gateway != NULL) {
__connman_ipconfig_set_gateway(ipconfig, gateway);
+ err = __connman_ipconfig_gateway_add(ipconfig);
+ if (err < 0)
+ goto err;
+ }
network->connecting = FALSE;
__connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY,
CONNMAN_IPCONFIG_TYPE_IPV4);
+
+err:
+ connman_network_set_error(network,
+ CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
+ return;
}
static int set_connected_dhcp(struct connman_network *network)
connman_element_get_value(&network->element,
CONNMAN_PROPERTY_ID_IPV4_GATEWAY, &gateway);
- if (gateway != NULL)
+ if (gateway != NULL) {
__connman_ipconfig_set_gateway(ipconfig, gateway);
+ __connman_ipconfig_gateway_add(ipconfig);
+ }
__connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY,
CONNMAN_IPCONFIG_TYPE_IPV4);
__connman_ipconfig_set_local(ipconfig, ipaddress->local);
__connman_ipconfig_set_peer(ipconfig, ipaddress->peer);
__connman_ipconfig_set_broadcast(ipconfig, ipaddress->broadcast);
- __connman_ipconfig_set_gateway(ipconfig, ipaddress->gateway);
__connman_ipconfig_set_prefixlen(ipconfig, ipaddress->prefixlen);
+ __connman_ipconfig_set_gateway(ipconfig, ipaddress->gateway);
- return 0;
+ return __connman_ipconfig_gateway_add(ipconfig);
}
int connman_network_set_pac(struct connman_network *network,