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_WIFI:
case CONNMAN_NETWORK_TYPE_WIMAX:
network->driver = driver;
- if (__connman_service_create_from_network(network) == NULL)
+ if (__connman_service_create_from_network(network) == NULL) {
+ network->driver = NULL;
return -EINVAL;
+ }
}
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:
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;
network->refcount = 1;
- if (identifier == NULL) {
- ident = g_strdup_printf("hidden_%d", hidden_counter++);
- network->hidden = TRUE;
- } else
- ident = g_strdup(identifier);
+ ident = g_strdup(identifier);
if (ident == NULL) {
g_free(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);
*/
connman_bool_t connman_network_get_available(struct connman_network *network)
{
- if (network->hidden == TRUE)
- return TRUE;
-
return network->available;
}
{
struct connman_service *service;
- if (network->associating == FALSE)
- return ;
-
- network->associating = FALSE;
-
service = __connman_service_lookup_from_network(network);
__connman_service_ipconfig_indicate_state(service,
{
struct connman_service *service;
- network->connecting = FALSE;
-
service = __connman_service_lookup_from_network(network);
__connman_service_ipconfig_indicate_state(service,
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);
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);
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,
__connman_connection_gateway_activate(service,
CONNMAN_IPCONFIG_TYPE_IPV6);
- __connman_device_increase_connections(network->device);
-
__connman_device_set_network(network->device, network);
connman_device_set_disconnected(network->device, FALSE);
{
DBG("network %p", network);
- __connman_device_increase_connections(network->device);
-
__connman_device_set_network(network->device, network);
connman_device_set_disconnected(network->device, FALSE);
}
} 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:
break;
}
- __connman_service_ipconfig_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_ipconfig_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);
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;
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)