*
* Connection Manager
*
- * Copyright (C) 2007-2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2013 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
struct connman_provider {
int refcount;
+ bool immutable;
struct connman_service *vpn_service;
int index;
char *identifier;
{
const char *host, *domain, *type;
- if (provider->driver == NULL || provider->driver->get_property == NULL)
+ if (!provider->driver || !provider->driver->get_property)
return;
host = provider->driver->get_property(provider, "Host");
domain = provider->driver->get_property(provider, "Domain");
type = provider->driver->get_property(provider, "Type");
- if (host != NULL)
+ if (host)
connman_dbus_dict_append_basic(iter, "Host",
DBUS_TYPE_STRING, &host);
- if (domain != NULL)
+ if (domain)
connman_dbus_dict_append_basic(iter, "Domain",
DBUS_TYPE_STRING, &domain);
- if (type != NULL)
+ if (type)
connman_dbus_dict_append_basic(iter, "Type", DBUS_TYPE_STRING,
&type);
}
static void provider_remove(struct connman_provider *provider)
{
- if (provider->driver != NULL) {
+ if (provider->driver) {
provider->driver->remove(provider);
provider->driver = NULL;
}
DBG("provider %p", provider);
- if (provider->driver != NULL && provider->driver->disconnect != NULL)
+ if (provider->driver && provider->driver->disconnect)
err = provider->driver->disconnect(provider);
else
return -EOPNOTSUPP;
- if (provider->vpn_service != NULL)
+ if (provider->vpn_service)
provider_indicate_state(provider,
CONNMAN_SERVICE_STATE_DISCONNECT);
- if (err < 0) {
- if (err != -EINPROGRESS)
- return err;
+ if (err < 0)
+ return err;
- return -EINPROGRESS;
- }
+ if (provider->vpn_service)
+ provider_indicate_state(provider,
+ CONNMAN_SERVICE_STATE_IDLE);
return 0;
}
return 0;
}
-int __connman_provider_connect(struct connman_provider *provider)
+int __connman_provider_connect(struct connman_provider *provider,
+ const char *dbus_sender)
{
int err;
DBG("provider %p", provider);
- if (provider->driver != NULL && provider->driver->connect != NULL) {
- err = provider->driver->connect(provider);
- } else
+ if (provider->driver && provider->driver->connect)
+ err = provider->driver->connect(provider, dbus_sender);
+ else
return -EOPNOTSUPP;
if (err < 0) {
DBG("path %s", path);
g_hash_table_iter_init(&iter, provider_hash);
- while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
const char *srv_path;
provider = value;
- if (provider->vpn_service == NULL)
+ if (!provider->vpn_service)
continue;
srv_path = __connman_service_get_path(provider->vpn_service);
}
static int set_connected(struct connman_provider *provider,
- connman_bool_t connected)
+ bool connected)
{
struct connman_service *service = provider->vpn_service;
struct connman_ipconfig *ipconfig;
- if (service == NULL)
+ if (!service)
return -ENODEV;
ipconfig = __connman_service_get_ipconfig(service, provider->family);
- if (connected == TRUE) {
- if (ipconfig == NULL) {
+ if (connected) {
+ if (!ipconfig) {
provider_indicate_state(provider,
CONNMAN_SERVICE_STATE_FAILURE);
return -EIO;
}
__connman_ipconfig_address_add(ipconfig);
+#if defined TIZEN_EXT
+ __connman_ipconfig_gateway_add(ipconfig, service);
+#else
__connman_ipconfig_gateway_add(ipconfig);
+#endif
provider_indicate_state(provider,
CONNMAN_SERVICE_STATE_READY);
- if (provider->driver != NULL && provider->driver->set_routes)
+ if (provider->driver && provider->driver->set_routes)
provider->driver->set_routes(provider,
CONNMAN_PROVIDER_ROUTE_ALL);
} else {
- if (ipconfig != NULL) {
+ if (ipconfig) {
provider_indicate_state(provider,
CONNMAN_SERVICE_STATE_DISCONNECT);
__connman_ipconfig_gateway_remove(ipconfig);
int connman_provider_set_state(struct connman_provider *provider,
enum connman_provider_state state)
{
- if (provider == NULL || provider->vpn_service == NULL)
+ if (!provider || !provider->vpn_service)
return -EINVAL;
switch (state) {
case CONNMAN_PROVIDER_STATE_UNKNOWN:
return -EINVAL;
case CONNMAN_PROVIDER_STATE_IDLE:
- return set_connected(provider, FALSE);
+ return set_connected(provider, false);
case CONNMAN_PROVIDER_STATE_CONNECT:
return provider_indicate_state(provider,
CONNMAN_SERVICE_STATE_ASSOCIATION);
case CONNMAN_PROVIDER_STATE_READY:
- return set_connected(provider, TRUE);
+ return set_connected(provider, true);
case CONNMAN_PROVIDER_STATE_DISCONNECT:
return provider_indicate_state(provider,
CONNMAN_SERVICE_STATE_DISCONNECT);
int connman_provider_create_service(struct connman_provider *provider)
{
- if (provider->vpn_service != NULL) {
- connman_bool_t connected;
+ if (provider->vpn_service) {
+ bool connected;
connected = __connman_service_is_connected_state(
provider->vpn_service, CONNMAN_IPCONFIG_TYPE_IPV4);
- if (connected == TRUE)
+ if (connected)
return -EALREADY;
connected = __connman_service_is_connected_state(
provider->vpn_service, CONNMAN_IPCONFIG_TYPE_IPV6);
- if (connected == TRUE)
+ if (connected)
return -EALREADY;
return 0;
provider->vpn_service =
__connman_service_create_from_provider(provider);
- if (provider->vpn_service == NULL) {
+ if (!provider->vpn_service) {
connman_warn("service creation failed for provider %s",
provider->identifier);
return 0;
}
+bool __connman_provider_is_immutable(struct connman_provider *provider)
+
+{
+ if (provider)
+ return provider->immutable;
+
+ return false;
+}
+
int connman_provider_set_immutable(struct connman_provider *provider,
- connman_bool_t immutable)
+ bool immutable)
{
- if (provider == NULL)
+ if (!provider)
return -EINVAL;
- if (provider->vpn_service == NULL)
- return -ESRCH;
+ provider->immutable = immutable;
- return __connman_service_set_immutable(provider->vpn_service,
- immutable);
+ return 0;
}
static struct connman_provider *provider_lookup(const char *identifier)
if (error_code != 0) {
reply = __connman_error_failed(msg, -error_code);
- if (g_dbus_send_message(connection, reply) == FALSE)
+ if (!g_dbus_send_message(connection, reply))
DBG("reply %p send failed", reply);
} else {
const char *path;
struct connman_provider *provider;
provider = provider_lookup(identifier);
- if (provider == NULL) {
- reply = __connman_error_failed(msg, -EINVAL);
+ if (!provider) {
+ reply = __connman_error_failed(msg, EINVAL);
g_dbus_send_message(connection, reply);
return;
}
{
struct connman_provider_driver *driver;
- if (driver_list == NULL)
+ if (!driver_list)
return -EINVAL;
driver = driver_list->data;
- if (driver == NULL || driver->create == NULL)
+ if (!driver || !driver->create)
return -EINVAL;
DBG("msg %p", msg);
return driver->create(msg, connection_ready);
}
-const char * __connman_provider_get_ident(struct connman_provider *provider)
+const char *__connman_provider_get_ident(struct connman_provider *provider)
{
- if (provider == NULL)
+ if (!provider)
return NULL;
return provider->identifier;
int connman_provider_set_string(struct connman_provider *provider,
const char *key, const char *value)
{
- if (provider->driver != NULL && provider->driver->set_property)
+ if (provider->driver && provider->driver->set_property)
return provider->driver->set_property(provider, key, value);
return 0;
const char *connman_provider_get_string(struct connman_provider *provider,
const char *key)
{
- if (provider->driver != NULL && provider->driver->get_property)
+ if (provider->driver && provider->driver->get_property)
return provider->driver->get_property(provider, key);
return NULL;
}
-connman_bool_t
+bool
__connman_provider_check_routes(struct connman_provider *provider)
{
- if (provider == NULL)
- return FALSE;
+ if (!provider)
+ return false;
- if (provider->driver != NULL && provider->driver->check_routes)
+ if (provider->driver && provider->driver->check_routes)
return provider->driver->check_routes(provider);
- return FALSE;
+ return false;
}
void *connman_provider_get_data(struct connman_provider *provider)
DBG("");
- if (service == NULL)
+ if (!service)
return;
ipconfig = __connman_service_get_ip4config(service);
- if (ipconfig == NULL) {
+ if (!ipconfig) {
connman_service_create_ip4config(service, index);
ipconfig = __connman_service_get_ip4config(service);
- if (ipconfig == NULL) {
+ if (!ipconfig) {
DBG("Couldnt create ipconfig");
goto done;
}
ipconfig = __connman_service_get_ip6config(service);
- if (ipconfig == NULL) {
+ if (!ipconfig) {
connman_service_create_ip6config(service, index);
ipconfig = __connman_service_get_ip6config(service);
- if (ipconfig == NULL) {
+ if (!ipconfig) {
DBG("Couldnt create ipconfig for IPv6");
goto done;
}
ipconfig = __connman_service_get_ipconfig(provider->vpn_service,
ipaddress->family);
- if (ipconfig == NULL)
+ if (!ipconfig)
return -EINVAL;
provider->family = ipaddress->family;
}
int connman_provider_set_nameservers(struct connman_provider *provider,
- char * const * nameservers)
+ char * const *nameservers)
{
int i;
__connman_service_nameserver_clear(provider->vpn_service);
- if (nameservers == NULL)
+ if (!nameservers)
return 0;
- for (i = 0; nameservers[i] != NULL; i++)
+ for (i = 0; nameservers[i]; i++)
+#if defined TIZEN_EXT
__connman_service_nameserver_append(provider->vpn_service,
- nameservers[i], FALSE);
+ nameservers[i], false,
+ CONNMAN_IPCONFIG_TYPE_ALL);
+#else
+ __connman_service_nameserver_append(provider->vpn_service,
+ nameservers[i], false);
+#endif
return 0;
}
DBG("provider %p service %p", provider, provider->vpn_service);
- if (provider->vpn_service != NULL) {
+ if (provider->vpn_service) {
connman_service_unref(provider->vpn_service);
provider->vpn_service = NULL;
}
connman_provider_disconnect(provider);
}
-static void provider_offline_mode(connman_bool_t enabled)
+static void provider_offline_mode(bool enabled)
{
DBG("enabled %d", enabled);
- if (enabled == TRUE)
+ if (enabled)
g_hash_table_foreach(provider_hash, provider_disconnect_all,
NULL);
struct connman_provider *provider;
provider = g_try_new0(struct connman_provider, 1);
- if (provider == NULL)
+ if (!provider)
return NULL;
provider->refcount = 1;
struct connman_provider *provider;
provider = g_hash_table_lookup(provider_hash, identifier);
- if (provider != NULL)
+ if (provider)
return provider;
provider = provider_new();
- if (provider == NULL)
+ if (!provider)
return NULL;
DBG("provider %p", provider);
g_hash_table_iter_init(&iter, provider_hash);
- while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
struct connman_provider *provider = value;
if (provider->index == index)
struct connman_provider *provider;
int vpn_index, service_index;
- if (service == NULL)
+ if (!service)
return;
switch (state) {
return;
provider = provider_get(vpn_index);
- if (provider == NULL)
+ if (!provider)
return;
DBG("disconnect %p index %d", provider, vpn_index);