return CONNMAN_SERVICE_ERROR_UNKNOWN;
}
+static connman_bool_t is_connecting(struct connman_service *service)
+{
+ switch (service->state) {
+ case CONNMAN_SERVICE_STATE_UNKNOWN:
+ case CONNMAN_SERVICE_STATE_IDLE:
+ case CONNMAN_SERVICE_STATE_FAILURE:
+ case CONNMAN_SERVICE_STATE_DISCONNECT:
+ case CONNMAN_SERVICE_STATE_READY:
+ case CONNMAN_SERVICE_STATE_LOGIN:
+ case CONNMAN_SERVICE_STATE_ONLINE:
+ break;
+ case CONNMAN_SERVICE_STATE_ASSOCIATION:
+ case CONNMAN_SERVICE_STATE_CONFIGURATION:
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static connman_bool_t is_connected(const struct connman_service *service)
+{
+ switch (service->state) {
+ case CONNMAN_SERVICE_STATE_UNKNOWN:
+ case CONNMAN_SERVICE_STATE_IDLE:
+ case CONNMAN_SERVICE_STATE_ASSOCIATION:
+ case CONNMAN_SERVICE_STATE_CONFIGURATION:
+ case CONNMAN_SERVICE_STATE_DISCONNECT:
+ case CONNMAN_SERVICE_STATE_FAILURE:
+ break;
+ case CONNMAN_SERVICE_STATE_READY:
+ case CONNMAN_SERVICE_STATE_LOGIN:
+ case CONNMAN_SERVICE_STATE_ONLINE:
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static struct connman_service *get_default(void)
{
struct connman_service *service;
service = g_sequence_get(iter);
- if (service->state != CONNMAN_SERVICE_STATE_READY)
+ if (is_connected(service) == FALSE)
return NULL;
return service;
{
struct connman_service *service = user_data;
- switch (service->state) {
- case CONNMAN_SERVICE_STATE_UNKNOWN:
- case CONNMAN_SERVICE_STATE_IDLE:
- case CONNMAN_SERVICE_STATE_FAILURE:
- case CONNMAN_SERVICE_STATE_DISCONNECT:
+ if (is_connecting(service) == FALSE &&
+ is_connected(service) == FALSE)
return;
- case CONNMAN_SERVICE_STATE_ASSOCIATION:
- case CONNMAN_SERVICE_STATE_CONFIGURATION:
- case CONNMAN_SERVICE_STATE_READY:
- case CONNMAN_SERVICE_STATE_LOGIN:
- case CONNMAN_SERVICE_STATE_ONLINE:
- break;
- }
if (service->ipconfig != NULL)
__connman_ipconfig_append_ethernet(service->ipconfig, iter);
{
struct connman_service *service = user_data;
- switch (service->state) {
- case CONNMAN_SERVICE_STATE_UNKNOWN:
- case CONNMAN_SERVICE_STATE_IDLE:
- case CONNMAN_SERVICE_STATE_FAILURE:
- case CONNMAN_SERVICE_STATE_DISCONNECT:
- case CONNMAN_SERVICE_STATE_ASSOCIATION:
- case CONNMAN_SERVICE_STATE_CONFIGURATION:
+ if (is_connected(service) == FALSE)
return;
- case CONNMAN_SERVICE_STATE_READY:
- case CONNMAN_SERVICE_STATE_LOGIN:
- case CONNMAN_SERVICE_STATE_ONLINE:
- break;
- }
if (service->ipconfig != NULL)
__connman_ipconfig_append_ipv4(service->ipconfig, iter);
{
struct connman_service *service = user_data;
- switch (service->state) {
- case CONNMAN_SERVICE_STATE_UNKNOWN:
- case CONNMAN_SERVICE_STATE_IDLE:
- case CONNMAN_SERVICE_STATE_FAILURE:
- case CONNMAN_SERVICE_STATE_DISCONNECT:
- case CONNMAN_SERVICE_STATE_ASSOCIATION:
- case CONNMAN_SERVICE_STATE_CONFIGURATION:
+ if (is_connected(service) == FALSE)
return;
- case CONNMAN_SERVICE_STATE_READY:
- case CONNMAN_SERVICE_STATE_LOGIN:
- case CONNMAN_SERVICE_STATE_ONLINE:
- break;
- }
if (service->ipconfig != NULL)
__connman_ipconfig_append_proxy(service->ipconfig, iter);
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
-static connman_bool_t is_connecting(struct connman_service *service)
-{
- switch (service->state) {
- case CONNMAN_SERVICE_STATE_UNKNOWN:
- case CONNMAN_SERVICE_STATE_IDLE:
- case CONNMAN_SERVICE_STATE_FAILURE:
- case CONNMAN_SERVICE_STATE_DISCONNECT:
- case CONNMAN_SERVICE_STATE_READY:
- case CONNMAN_SERVICE_STATE_LOGIN:
- case CONNMAN_SERVICE_STATE_ONLINE:
- break;
- case CONNMAN_SERVICE_STATE_ASSOCIATION:
- case CONNMAN_SERVICE_STATE_CONFIGURATION:
- return TRUE;
- }
-
- return FALSE;
-}
-
static connman_bool_t is_ignore(struct connman_service *service)
{
if (service->autoconnect == FALSE)
if (service->favorite == FALSE)
return;
- if (service->state == CONNMAN_SERVICE_STATE_READY)
+ if (is_connected(service) == TRUE)
return;
if (is_ignore(service) == FALSE &&
struct connman_service *service_b = (void *) b;
if (service_a->state != service_b->state) {
- if (service_a->state == CONNMAN_SERVICE_STATE_READY)
+ if (is_connected(service_a) == TRUE)
return -1;
- if (service_b->state == CONNMAN_SERVICE_STATE_READY)
+ if (is_connected(service_b) == TRUE)
return 1;
}
__connman_service_auto_connect();
}
- if (state == CONNMAN_SERVICE_STATE_READY) {
+ if (state == CONNMAN_SERVICE_STATE_READY ||
+ state == CONNMAN_SERVICE_STATE_ONLINE) {
set_reconnect_state(service, TRUE);
__connman_service_set_favorite(service, TRUE);
DBG("service %p", service);
- if (service->state == CONNMAN_SERVICE_STATE_READY)
+ if (is_connected(service) == TRUE)
return -EISCONN;
if (is_connecting(service) == TRUE)
DBG("service %p network %p", service, network);
- if (service->state == CONNMAN_SERVICE_STATE_READY)
+ if (is_connected(service) == TRUE)
return;
if (is_connecting(service) == TRUE)