summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c148
1 files changed, 77 insertions, 71 deletions
diff --git a/src/network.c b/src/network.c
index badb7702..ed56210f 100644
--- a/src/network.c
+++ b/src/network.c
@@ -78,8 +78,13 @@ struct connman_network {
char *passphrase;
char *eap;
char *identity;
+ char *anonymous_identity;
char *agent_identity;
char *ca_cert_path;
+ char *subject_match;
+ char *altsubject_match;
+ char *domain_suffix_match;
+ char *domain_match;
char *client_cert_path;
char *private_key_path;
char *private_key_passphrase;
@@ -135,8 +140,6 @@ static void set_configuration(struct connman_network *network,
__connman_device_set_network(network->device, network);
- connman_device_set_disconnected(network->device, false);
-
service = connman_service_lookup_from_network(network);
__connman_service_ipconfig_indicate_state(service,
CONNMAN_SERVICE_STATE_CONFIGURATION,
@@ -168,6 +171,8 @@ static void dhcp_success(struct connman_network *network)
if (err < 0)
goto err;
+ __connman_service_save(service);
+
return;
err:
@@ -218,8 +223,8 @@ static int set_connected_manual(struct connman_network *network)
network->connecting = false;
service = connman_service_lookup_from_network(network);
-
ipconfig = __connman_service_get_ip4config(service);
+ __connman_ipconfig_enable(ipconfig);
if (!__connman_ipconfig_get_local(ipconfig))
__connman_service_read_ip4config(service);
@@ -246,6 +251,7 @@ static int set_connected_dhcp(struct connman_network *network)
service = connman_service_lookup_from_network(network);
ipconfig_ipv4 = __connman_service_get_ip4config(service);
+ __connman_ipconfig_enable(ipconfig_ipv4);
err = __connman_dhcp_start(ipconfig_ipv4, network,
dhcp_callback, NULL);
@@ -285,13 +291,8 @@ static int manual_ipv6_set(struct connman_network *network,
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);
-
connman_network_set_associating(network, false);
network->connecting = false;
@@ -556,8 +557,6 @@ static void autoconf_ipv6_set(struct connman_network *network)
__connman_device_set_network(network->device, network);
- connman_device_set_disconnected(network->device, false);
-
service = connman_service_lookup_from_network(network);
if (!service)
return;
@@ -566,6 +565,8 @@ static void autoconf_ipv6_set(struct connman_network *network)
if (!ipconfig)
return;
+ __connman_ipconfig_enable(ipconfig);
+
__connman_ipconfig_enable_ipv6(ipconfig);
__connman_ipconfig_address_remove(ipconfig);
@@ -647,10 +648,20 @@ static void set_disconnected(struct connman_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_AUTO:
+ /*
+ * If the current method is AUTO then next time we
+ * try first DHCP. DHCP also needs to be stopped
+ * in this case because if we fell in AUTO means
+ * that DHCP was launched for IPv4 but it failed.
+ */
+ __connman_ipconfig_set_method(ipconfig_ipv4,
+ CONNMAN_IPCONFIG_METHOD_DHCP);
+ __connman_service_notify_ipv4_configuration(service);
+ /* fall through */
case CONNMAN_IPCONFIG_METHOD_DHCP:
__connman_dhcp_stop(ipconfig_ipv4);
break;
@@ -800,23 +811,6 @@ static void network_remove(struct connman_network *network)
network->driver = NULL;
}
-static void network_change(struct connman_network *network)
-{
- DBG("network %p name %s", network, network->name);
-
- if (!network->connected)
- return;
-
- connman_device_set_disconnected(network->device, true);
-
- if (network->driver && network->driver->disconnect) {
- network->driver->disconnect(network);
- return;
- }
-
- network->connected = false;
-}
-
static void probe_driver(struct connman_network_driver *driver)
{
GSList *list;
@@ -839,20 +833,6 @@ static void probe_driver(struct connman_network_driver *driver)
}
}
-static void remove_driver(struct connman_network_driver *driver)
-{
- GSList *list;
-
- DBG("driver %p name %s", driver, driver->name);
-
- for (list = network_list; list; list = list->next) {
- struct connman_network *network = list->data;
-
- if (network->driver == driver)
- network_remove(network);
- }
-}
-
static gint compare_priority(gconstpointer a, gconstpointer b)
{
const struct connman_network_driver *driver1 = a;
@@ -889,11 +869,18 @@ int connman_network_driver_register(struct connman_network_driver *driver)
*/
void connman_network_driver_unregister(struct connman_network_driver *driver)
{
+ GSList *list;
+
DBG("driver %p name %s", driver, driver->name);
driver_list = g_slist_remove(driver_list, driver);
- remove_driver(driver);
+ for (list = network_list; list; list = list->next) {
+ struct connman_network *network = list->data;
+
+ if (network->driver == driver)
+ network_remove(network);
+ }
}
static void network_destruct(struct connman_network *network)
@@ -906,8 +893,13 @@ static void network_destruct(struct connman_network *network)
g_free(network->wifi.passphrase);
g_free(network->wifi.eap);
g_free(network->wifi.identity);
+ g_free(network->wifi.anonymous_identity);
g_free(network->wifi.agent_identity);
g_free(network->wifi.ca_cert_path);
+ g_free(network->wifi.subject_match);
+ g_free(network->wifi.altsubject_match);
+ g_free(network->wifi.domain_suffix_match);
+ g_free(network->wifi.domain_match);
g_free(network->wifi.client_cert_path);
g_free(network->wifi.private_key_path);
g_free(network->wifi.private_key_passphrase);
@@ -939,14 +931,10 @@ struct connman_network *connman_network_create(const char *identifier,
struct connman_network *network;
char *ident;
- DBG("identifier %s type %d", identifier, type);
-
network = g_try_new0(struct connman_network, 1);
if (!network)
return NULL;
- DBG("network %p", network);
-
network->refcount = 1;
ident = g_strdup(identifier);
@@ -961,6 +949,8 @@ struct connman_network *connman_network_create(const char *identifier,
network_list = g_slist_prepend(network_list, network);
+ DBG("network %p identifier %s type %s", network, identifier,
+ type2string(type));
return network;
}
@@ -1265,6 +1255,16 @@ static void set_connect_error(struct connman_network *network)
CONNMAN_SERVICE_ERROR_CONNECT_FAILED);
}
+static void set_blocked_error(struct connman_network *network)
+{
+ struct connman_service *service;
+
+ service = connman_service_lookup_from_network(network);
+
+ __connman_service_indicate_error(service,
+ CONNMAN_SERVICE_ERROR_BLOCKED);
+}
+
void connman_network_set_ipv4_method(struct connman_network *network,
enum connman_ipconfig_method method)
{
@@ -1304,9 +1304,6 @@ void connman_network_set_error(struct connman_network *network,
{
DBG("network %p error %d", network, error);
- network->connecting = false;
- network->associating = false;
-
switch (error) {
case CONNMAN_NETWORK_ERROR_UNKNOWN:
return;
@@ -1322,9 +1319,12 @@ void connman_network_set_error(struct connman_network *network,
case CONNMAN_NETWORK_ERROR_CONNECT_FAIL:
set_connect_error(network);
break;
+ case CONNMAN_NETWORK_ERROR_BLOCKED:
+ set_blocked_error(network);
+ break;
}
- network_change(network);
+ __connman_network_disconnect(network);
}
/**
@@ -1345,8 +1345,7 @@ int connman_network_set_connected(struct connman_network *network,
!connected) {
connman_network_set_error(network,
CONNMAN_NETWORK_ERROR_CONNECT_FAIL);
- if (__connman_network_disconnect(network) == 0)
- return 0;
+ return 0;
}
if (network->connected == connected)
@@ -1737,8 +1736,6 @@ int connman_network_set_name(struct connman_network *network,
int connman_network_set_strength(struct connman_network *network,
uint8_t strength)
{
- DBG("network %p strengh %d", network, strength);
-
network->strength = strength;
return 0;
@@ -1752,8 +1749,6 @@ uint8_t connman_network_get_strength(struct connman_network *network)
int connman_network_set_frequency(struct connman_network *network,
uint16_t frequency)
{
- DBG("network %p frequency %d", network, frequency);
-
network->frequency = frequency;
return 0;
@@ -1767,8 +1762,6 @@ uint16_t connman_network_get_frequency(struct connman_network *network)
int connman_network_set_wifi_channel(struct connman_network *network,
uint16_t channel)
{
- DBG("network %p wifi channel %d", network, channel);
-
network->wifi.channel = channel;
return 0;
@@ -1790,8 +1783,6 @@ uint16_t connman_network_get_wifi_channel(struct connman_network *network)
int connman_network_set_string(struct connman_network *network,
const char *key, const char *value)
{
- DBG("network %p key %s value %s", network, key, value);
-
if (g_strcmp0(key, "Name") == 0)
return connman_network_set_name(network, value);
@@ -1816,12 +1807,27 @@ int connman_network_set_string(struct connman_network *network,
} else if (g_str_equal(key, "WiFi.Identity")) {
g_free(network->wifi.identity);
network->wifi.identity = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.AnonymousIdentity")) {
+ g_free(network->wifi.anonymous_identity);
+ network->wifi.anonymous_identity = g_strdup(value);
} else if (g_str_equal(key, "WiFi.AgentIdentity")) {
g_free(network->wifi.agent_identity);
network->wifi.agent_identity = g_strdup(value);
} else if (g_str_equal(key, "WiFi.CACertFile")) {
g_free(network->wifi.ca_cert_path);
network->wifi.ca_cert_path = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.SubjectMatch")) {
+ g_free(network->wifi.subject_match);
+ network->wifi.subject_match = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.AltSubjectMatch")) {
+ g_free(network->wifi.altsubject_match);
+ network->wifi.altsubject_match = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.DomainSuffixMatch")) {
+ g_free(network->wifi.domain_suffix_match);
+ network->wifi.domain_suffix_match = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.DomainMatch")) {
+ g_free(network->wifi.domain_match);
+ network->wifi.domain_match = g_strdup(value);
} else if (g_str_equal(key, "WiFi.ClientCertFile")) {
g_free(network->wifi.client_cert_path);
network->wifi.client_cert_path = g_strdup(value);
@@ -1854,8 +1860,6 @@ int connman_network_set_string(struct connman_network *network,
const char *connman_network_get_string(struct connman_network *network,
const char *key)
{
- DBG("network %p key %s", network, key);
-
if (g_str_equal(key, "Path"))
return network->path;
else if (g_str_equal(key, "Name"))
@@ -1872,10 +1876,20 @@ const char *connman_network_get_string(struct connman_network *network,
return network->wifi.eap;
else if (g_str_equal(key, "WiFi.Identity"))
return network->wifi.identity;
+ else if (g_str_equal(key, "WiFi.AnonymousIdentity"))
+ return network->wifi.anonymous_identity;
else if (g_str_equal(key, "WiFi.AgentIdentity"))
return network->wifi.agent_identity;
else if (g_str_equal(key, "WiFi.CACertFile"))
return network->wifi.ca_cert_path;
+ else if (g_str_equal(key, "WiFi.SubjectMatch"))
+ return network->wifi.subject_match;
+ else if (g_str_equal(key, "WiFi.AltSubjectMatch"))
+ return network->wifi.altsubject_match;
+ else if (g_str_equal(key, "WiFi.DomainSuffixMatch"))
+ return network->wifi.domain_suffix_match;
+ else if (g_str_equal(key, "WiFi.DomainMatch"))
+ return network->wifi.domain_match;
else if (g_str_equal(key, "WiFi.ClientCertFile"))
return network->wifi.client_cert_path;
else if (g_str_equal(key, "WiFi.PrivateKeyFile"))
@@ -1901,8 +1915,6 @@ const char *connman_network_get_string(struct connman_network *network,
int connman_network_set_bool(struct connman_network *network,
const char *key, bool value)
{
- DBG("network %p key %s value %d", network, key, value);
-
if (g_strcmp0(key, "Roaming") == 0)
network->roaming = value;
else if (g_strcmp0(key, "WiFi.WPS") == 0)
@@ -1923,8 +1935,6 @@ int connman_network_set_bool(struct connman_network *network,
bool connman_network_get_bool(struct connman_network *network,
const char *key)
{
- DBG("network %p key %s", network, key);
-
if (g_str_equal(key, "Roaming"))
return network->roaming;
else if (g_str_equal(key, "WiFi.WPS"))
@@ -1947,8 +1957,6 @@ bool connman_network_get_bool(struct connman_network *network,
int connman_network_set_blob(struct connman_network *network,
const char *key, const void *data, unsigned int size)
{
- DBG("network %p key %s size %d", network, key, size);
-
if (g_str_equal(key, "WiFi.SSID")) {
g_free(network->wifi.ssid);
network->wifi.ssid = g_try_malloc(size);
@@ -1975,8 +1983,6 @@ int connman_network_set_blob(struct connman_network *network,
const void *connman_network_get_blob(struct connman_network *network,
const char *key, unsigned int *size)
{
- DBG("network %p key %s", network, key);
-
if (g_str_equal(key, "WiFi.SSID")) {
if (size)
*size = network->wifi.ssid_len;