summaryrefslogtreecommitdiff
path: root/src/service.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-07-09 17:17:08 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-08-17 16:13:36 +0300
commit730cc6e7649de6b82d92983251c84e49ccefed4e (patch)
treea6e3236e1bc1af3b0c43997281735dc652f02bac /src/service.c
parent9b0851196880a79fbcca76616c27bb9d16ba94c7 (diff)
downloadconnman-730cc6e7649de6b82d92983251c84e49ccefed4e.tar.gz
connman-730cc6e7649de6b82d92983251c84e49ccefed4e.tar.bz2
connman-730cc6e7649de6b82d92983251c84e49ccefed4e.zip
service: Allow connection if there are interfaces available
Allow user to initiate connection if there are multiple devices of the same technology type available (like having multiple wifi cards).
Diffstat (limited to 'src/service.c')
-rw-r--r--src/service.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/service.c b/src/service.c
index 890a3133..adcfb640 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3608,6 +3608,29 @@ static connman_bool_t get_reconnect_state(struct connman_service *service)
return __connman_device_get_reconnect(device);
}
+static connman_bool_t is_interface_available(struct connman_service *service,
+ struct connman_service *other_service)
+{
+ unsigned int index = 0, other_index = 0;
+
+ if (service->ipconfig_ipv4 != NULL)
+ index = __connman_ipconfig_get_index(service->ipconfig_ipv4);
+ else if (service->ipconfig_ipv6 != NULL)
+ index = __connman_ipconfig_get_index(service->ipconfig_ipv6);
+
+ if (other_service->ipconfig_ipv4 != NULL)
+ other_index = __connman_ipconfig_get_index(
+ other_service->ipconfig_ipv4);
+ else if (other_service->ipconfig_ipv6 != NULL)
+ other_index = __connman_ipconfig_get_index(
+ other_service->ipconfig_ipv6);
+
+ if (index > 0 && other_index != index)
+ return TRUE;
+
+ return FALSE;
+}
+
static DBusMessage *connect_service(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -3625,7 +3648,15 @@ static DBusMessage *connect_service(DBusConnection *conn,
while (g_sequence_iter_is_end(iter) == FALSE) {
struct connman_service *temp = g_sequence_get(iter);
- if (service->type == temp->type && is_connecting(temp) == TRUE)
+ /*
+ * We should allow connection if there are available
+ * interfaces for a given technology type (like having
+ * more than one wifi card).
+ */
+ if (service->type == temp->type &&
+ is_connecting(temp) == TRUE &&
+ is_interface_available(service,
+ temp) == FALSE)
return __connman_error_in_progress(msg);
iter = g_sequence_iter_next(iter);