--- src/connman.h | 4 ++++ src/service.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/src/connman.h b/src/connman.h index 0c6d6b1..4cc2429 100644 --- a/src/connman.h +++ b/src/connman.h @@ -497,6 +497,10 @@ void __connman_service_set_string(struct connman_service *service, const char *key, const char *value); int __connman_service_set_ipconfig_ready(struct connman_service *service, enum connman_ipconfig_type type); +int __connman_service_ipconfig_indicate_state(struct connman_service *service, + enum connman_service_state state, + enum connman_ipconfig_type type); + int __connman_service_indicate_state(struct connman_service *service, enum connman_service_state new_state, enum connman_ipconfig_type type); diff --git a/src/service.c b/src/service.c index 51cda8f..7361502 100644 --- a/src/service.c +++ b/src/service.c @@ -3727,6 +3727,50 @@ int __connman_service_indicate_default(struct connman_service *service) return 0; } +int __connman_service_ipconfig_indicate_state(struct connman_service *service, + enum connman_service_state state, + enum connman_ipconfig_type type) +{ + enum connman_service_state current_state; + int err = 0; + + DBG("service %p (%s) state %d (%s) type %d (%s)", + service, service ? service->identifier : NULL, + state, state2string(state), + type, __connman_ipconfig_type2string(type)); + + if (service == NULL) + return -EINVAL; + + current_state = combine_state(service->state_ipv4, service->state_ipv6); + + switch (current_state) { + case CONNMAN_SERVICE_STATE_UNKNOWN: + case CONNMAN_SERVICE_STATE_IDLE: + break; + case CONNMAN_SERVICE_STATE_READY: + case CONNMAN_SERVICE_STATE_ONLINE: + if (state == CONNMAN_SERVICE_STATE_READY || + state == CONNMAN_SERVICE_STATE_ONLINE) + return -EALREADY; + break; + case CONNMAN_SERVICE_STATE_FAILURE: + case CONNMAN_SERVICE_STATE_DISCONNECT: + case CONNMAN_SERVICE_STATE_ASSOCIATION: + case CONNMAN_SERVICE_STATE_CONFIGURATION: + break; + } + + if (current_state == state) + return -EALREADY; + + err = __connman_service_indicate_state(service, state, type); + if (err < 0) + return err; + + return 0; +} + int __connman_service_request_login(struct connman_service *service) { DBG("service %p", service); -- 1.7.3.4 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman