static GSList *network_list = NULL;
static GSList *driver_list = NULL;
-static unsigned int hidden_counter = 0;
struct connman_network {
- gint refcount;
+ int refcount;
enum connman_network_type type;
connman_bool_t available;
connman_bool_t connected;
connman_bool_t roaming;
- connman_bool_t hidden;
connman_uint8_t strength;
connman_uint16_t frequency;
char *identifier;
unsigned short channel;
char *security;
char *passphrase;
+ char *agent_passphrase;
char *eap;
char *identity;
+ char *agent_identity;
char *ca_cert_path;
char *client_cert_path;
char *private_key_path;
case CONNMAN_NETWORK_TYPE_CELLULAR:
case CONNMAN_NETWORK_TYPE_WIFI:
case CONNMAN_NETWORK_TYPE_WIMAX:
- if (__connman_service_create_from_network(network) == NULL)
+ network->driver = driver;
+ if (__connman_service_create_from_network(network) == NULL) {
+ network->driver = NULL;
return -EINVAL;
+ }
}
- network->driver = driver;
-
return 0;
}
if (network->driver == NULL)
return;
+ connman_network_set_connected(network, FALSE);
+
switch (network->type) {
case CONNMAN_NETWORK_TYPE_UNKNOWN:
case CONNMAN_NETWORK_TYPE_VENDOR:
if (network->connected == FALSE)
return;
- connman_network_unref(network);
-
connman_device_set_disconnected(network->device, TRUE);
if (network->driver && network->driver->disconnect) {
}
}
-int connman_network_register(struct connman_network *network)
-{
- network_list = g_slist_append(network_list, network);
-
- return network_probe(network);
-}
-
-
-void connman_network_unregister(struct connman_network *network)
-{
- network_list = g_slist_remove(network_list, network);
-
- network_remove(network);
-}
-
static void remove_driver(struct connman_network_driver *driver)
{
GSList *list;
g_free(network->wifi.mode);
g_free(network->wifi.security);
g_free(network->wifi.passphrase);
+ g_free(network->wifi.agent_passphrase);
g_free(network->wifi.eap);
g_free(network->wifi.identity);
+ g_free(network->wifi.agent_identity);
g_free(network->wifi.ca_cert_path);
g_free(network->wifi.client_cert_path);
g_free(network->wifi.private_key_path);
g_free(network->node);
g_free(network->name);
g_free(network->identifier);
- g_free(network->path);
network->device = NULL;
enum connman_network_type type)
{
struct connman_network *network;
- char *temp;
+ char *ident;
DBG("identifier %s type %d", identifier, type);
network->refcount = 1;
- if (identifier == NULL) {
- temp = g_strdup_printf("hidden_%d", hidden_counter++);
- network->hidden = TRUE;
- } else
- temp = g_strdup(identifier);
+ ident = g_strdup(identifier);
- if (temp == NULL) {
+ if (ident == NULL) {
g_free(network);
return NULL;
}
network->type = type;
- network->identifier = g_strdup(temp);
+ network->identifier = ident;
+
+ network_list = g_slist_append(network_list, network);
return network;
}
struct connman_network *connman_network_ref(struct connman_network *network)
{
DBG("network %p name %s refcount %d", network, network->name,
- g_atomic_int_get(&network->refcount) + 1);
+ network->refcount + 1);
- g_atomic_int_inc(&network->refcount);
+ __sync_fetch_and_add(&network->refcount, 1);
return network;
}
void connman_network_unref(struct connman_network *network)
{
DBG("network %p name %s refcount %d", network, network->name,
- g_atomic_int_get(&network->refcount) - 1);
+ network->refcount - 1);
- if (g_atomic_int_dec_and_test(&network->refcount) == FALSE)
+ if (__sync_fetch_and_sub(&network->refcount, 1) != 1)
return;
+ network_list = g_slist_remove(network_list, network);
+
network_destruct(network);
}
*/
connman_bool_t connman_network_get_available(struct connman_network *network)
{
- if (network->hidden == TRUE)
- return TRUE;
-
return network->available;
}
struct connman_service *service;
service = __connman_service_lookup_from_network(network);
- __connman_service_indicate_state(service,
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_ASSOCIATION,
CONNMAN_IPCONFIG_TYPE_IPV4);
+ __connman_service_ipconfig_indicate_state(service,
+ CONNMAN_SERVICE_STATE_ASSOCIATION,
+ CONNMAN_IPCONFIG_TYPE_IPV6);
}
return 0;
{
struct connman_service *service;
- if (network->associating == FALSE)
- return ;
-
- network->associating = FALSE;
-
service = __connman_service_lookup_from_network(network);
- __connman_service_indicate_state(service,
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_FAILURE,
CONNMAN_IPCONFIG_TYPE_IPV4);
}
{
struct connman_service *service;
- network->connecting = FALSE;
-
service = __connman_service_lookup_from_network(network);
- __connman_service_indicate_state(service,
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_FAILURE,
CONNMAN_IPCONFIG_TYPE_IPV4);
}
DBG("nework %p, error %d", network, error);
network->connecting = FALSE;
+ network->associating = FALSE;
switch (error) {
case CONNMAN_NETWORK_ERROR_UNKNOWN:
DBG("network %p", network);
- __connman_device_increase_connections(network->device);
+ if (network->device == NULL)
+ return;
__connman_device_set_network(network->device, network);
connman_device_set_disconnected(network->device, FALSE);
service = __connman_service_lookup_from_network(network);
- __connman_service_indicate_state(service,
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_CONFIGURATION,
CONNMAN_IPCONFIG_TYPE_IPV4);
}
if (err < 0)
goto err;
- __connman_service_set_ipconfig_ready(service, CONNMAN_IPCONFIG_TYPE_IPV4);
-
return;
err:
if (service == NULL)
return;
- __connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_IDLE,
- CONNMAN_IPCONFIG_TYPE_IPV4);
+ __connman_service_ipconfig_indicate_state(service,
+ CONNMAN_SERVICE_STATE_IDLE,
+ CONNMAN_IPCONFIG_TYPE_IPV4);
}
static void dhcp_callback(struct connman_network *network,
if (err < 0)
goto err;
- __connman_service_set_ipconfig_ready(service, CONNMAN_IPCONFIG_TYPE_IPV4);
-
return 0;
err:
ipconfig = __connman_service_get_ip4config(service);
+ if (__connman_ipconfig_get_local(ipconfig) == NULL)
+ __connman_service_read_ip4config(service);
+
set_configuration(network);
err = __connman_ipconfig_address_add(ipconfig);
connman_network_set_associating(network, FALSE);
- __connman_service_set_ipconfig_ready(service, CONNMAN_IPCONFIG_TYPE_IPV4);
-
return;
err:
struct connman_service *service;
int err;
+ DBG("network %p ipv6 %p", network, ipconfig_ipv6);
+
service = __connman_service_lookup_from_network(network);
if (service == NULL)
return -EINVAL;
+ if (__connman_ipconfig_get_local(ipconfig_ipv6) == NULL)
+ __connman_service_read_ip6config(service);
+
err = __connman_ipconfig_address_add(ipconfig_ipv6);
if (err < 0) {
connman_network_set_error(network,
return err;
}
- /*
- * READY state will be indicated by IPV4 setting
- * gateway will be set by IPV4 setting
- */
+ err = __connman_ipconfig_gateway_add(ipconfig_ipv6);
+ if (err < 0)
+ return err;
+
+ __connman_connection_gateway_activate(service,
+ CONNMAN_IPCONFIG_TYPE_IPV6);
+
+ __connman_device_set_network(network->device, network);
+
+ connman_device_set_disconnected(network->device, FALSE);
+
+ network->connecting = FALSE;
return 0;
}
static void autoconf_ipv6_set(struct connman_network *network)
{
- struct connman_service *service;
-
DBG("network %p", network);
- service = __connman_service_lookup_from_network(network);
-
- __connman_device_increase_connections(network->device);
-
__connman_device_set_network(network->device, network);
connman_device_set_disconnected(network->device, FALSE);
/* XXX: Append IPv6 nameservers here */
network->connecting = FALSE;
-
- __connman_service_set_ipconfig_ready(service, CONNMAN_IPCONFIG_TYPE_IPV6);
}
static gboolean set_connected(gpointer user_data)
}
} else {
- struct connman_service *service;
+ enum connman_service_state state;
__connman_device_set_network(network->device, NULL);
- network->hidden = FALSE;
- service = __connman_service_lookup_from_network(network);
+ switch (ipv4_method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ case CONNMAN_IPCONFIG_METHOD_AUTO:
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ break;
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ __connman_dhcp_stop(network);
+ break;
+ }
- __connman_service_indicate_state(service,
+ /*
+ * We only set the disconnect state if we were not in idle
+ * or in failure. It does not make sense to go to disconnect
+ * state if we were not connected.
+ */
+ state = __connman_service_ipconfig_get_state(service,
+ CONNMAN_IPCONFIG_TYPE_IPV4);
+ if (state != CONNMAN_SERVICE_STATE_IDLE &&
+ state != CONNMAN_SERVICE_STATE_FAILURE)
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_DISCONNECT,
CONNMAN_IPCONFIG_TYPE_IPV4);
- __connman_service_indicate_state(service,
+ state = __connman_service_ipconfig_get_state(service,
+ CONNMAN_IPCONFIG_TYPE_IPV6);
+ if (state != CONNMAN_SERVICE_STATE_IDLE &&
+ state != CONNMAN_SERVICE_STATE_FAILURE)
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_DISCONNECT,
CONNMAN_IPCONFIG_TYPE_IPV6);
- __connman_connection_gateway_remove(service);
+ __connman_connection_gateway_remove(service,
+ CONNMAN_IPCONFIG_TYPE_ALL);
+
+ __connman_ipconfig_address_unset(ipconfig_ipv4);
+ __connman_ipconfig_address_unset(ipconfig_ipv6);
+
+ /*
+ * Special handling for IPv6 autoconfigured address.
+ * The simplest way to remove autoconfigured routes is to
+ * disable IPv6 temporarily so that kernel will do the cleanup
+ * automagically.
+ */
+ if (ipv6_method == CONNMAN_IPCONFIG_METHOD_AUTO) {
+ __connman_ipconfig_disable_ipv6(ipconfig_ipv6);
+ __connman_ipconfig_enable_ipv6(ipconfig_ipv6);
+ }
- __connman_service_indicate_state(service,
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_IDLE,
CONNMAN_IPCONFIG_TYPE_IPV4);
- __connman_service_indicate_state(service,
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_IDLE,
CONNMAN_IPCONFIG_TYPE_IPV6);
}
if (network->connected == connected)
return -EALREADY;
- if (connected == FALSE)
- __connman_device_decrease_connections(network->device);
-
network->connected = connected;
set_connected(network);
connman_network_set_associating(network, TRUE);
else {
network->connecting = FALSE;
- network->hidden = FALSE;
}
return err;
return err;
}
- __connman_ipconfig_gateway_add(ipconfig);
-
- __connman_service_set_ipconfig_ready(service, CONNMAN_IPCONFIG_TYPE_IPV4);
-
- return 0;
+ return __connman_ipconfig_gateway_add(ipconfig);
}
int __connman_network_clear_ipconfig(struct connman_network *network,
}
if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
- __connman_service_indicate_state(service,
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_CONFIGURATION,
CONNMAN_IPCONFIG_TYPE_IPV6);
else if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
- __connman_service_indicate_state(service,
+ __connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_CONFIGURATION,
CONNMAN_IPCONFIG_TYPE_IPV4);
enum connman_ipconfig_method method;
int ret;
+ if (network == NULL)
+ return -EINVAL;
+
if (ipconfig_ipv6) {
method = __connman_ipconfig_get_method(ipconfig_ipv6);
return 0;
}
-int connman_network_set_pac(struct connman_network *network,
- const char *pac)
-{
- struct connman_service *service;
-
- DBG("network %p pac %s", network, pac);
-
- service = __connman_service_lookup_from_network(network);
- if (service == NULL)
- return -EINVAL;
-
- __connman_service_set_pac(service, pac);
-
- return 0;
-}
-
int connman_network_set_nameservers(struct connman_network *network,
const char *nameservers)
{
} else if (g_str_equal(key, "WiFi.Passphrase") == TRUE) {
g_free(network->wifi.passphrase);
network->wifi.passphrase = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.AgentPassphrase") == TRUE) {
+ g_free(network->wifi.agent_passphrase);
+ network->wifi.agent_passphrase = g_strdup(value);
} else if (g_str_equal(key, "WiFi.EAP") == TRUE) {
g_free(network->wifi.eap);
network->wifi.eap = g_strdup(value);
} else if (g_str_equal(key, "WiFi.Identity") == TRUE) {
g_free(network->wifi.identity);
network->wifi.identity = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.AgentIdentity") == TRUE) {
+ g_free(network->wifi.agent_identity);
+ network->wifi.agent_identity = g_strdup(value);
} else if (g_str_equal(key, "WiFi.CACertFile") == TRUE) {
g_free(network->wifi.ca_cert_path);
network->wifi.ca_cert_path = g_strdup(value);
return network->wifi.security;
else if (g_str_equal(key, "WiFi.Passphrase") == TRUE)
return network->wifi.passphrase;
+ else if (g_str_equal(key, "WiFi.AgentPassphrase") == TRUE)
+ return network->wifi.agent_passphrase;
else if (g_str_equal(key, "WiFi.EAP") == TRUE)
return network->wifi.eap;
else if (g_str_equal(key, "WiFi.Identity") == TRUE)
return network->wifi.identity;
+ else if (g_str_equal(key, "WiFi.AgentIdentity") == TRUE)
+ return network->wifi.agent_identity;
else if (g_str_equal(key, "WiFi.CACertFile") == TRUE)
return network->wifi.ca_cert_path;
else if (g_str_equal(key, "WiFi.ClientCertFile") == TRUE)