*
* Connection Manager
*
- * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2010 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
#include <config.h>
#endif
+#include <errno.h>
#include <string.h>
#include <gdbus.h>
#include "connman.h"
+static unsigned int hidden_counter = 0;
+
struct connman_network {
struct connman_element element;
enum connman_network_type type;
enum connman_network_protocol protocol;
connman_bool_t available;
connman_bool_t connected;
- connman_bool_t remember;
- connman_uint8_t priority;
+ connman_bool_t roaming;
+ connman_bool_t hidden;
connman_uint8_t strength;
+ connman_uint16_t frequency;
char *identifier;
char *address;
char *name;
char *node;
char *group;
+ struct connman_ipconfig *ipconfig;
struct connman_network_driver *driver;
void *driver_data;
connman_bool_t registered;
+ connman_bool_t connecting;
+ connman_bool_t associating;
struct connman_device *device;
void *ssid;
int ssid_len;
char *mode;
+ unsigned short channel;
char *security;
char *passphrase;
+ char *eap;
+ char *identity;
+ char *ca_cert_path;
+ char *client_cert_path;
+ char *private_key_path;
+ char *private_key_passphrase;
+ char *phase2_auth;
} wifi;
};
case CONNMAN_NETWORK_TYPE_UNKNOWN:
case CONNMAN_NETWORK_TYPE_VENDOR:
break;
+ case CONNMAN_NETWORK_TYPE_ETHERNET:
+ return "ethernet";
case CONNMAN_NETWORK_TYPE_WIFI:
return "wifi";
case CONNMAN_NETWORK_TYPE_WIMAX:
case CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN:
case CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN:
return "bluetooth";
- case CONNMAN_NETWORK_TYPE_HSO:
+ case CONNMAN_NETWORK_TYPE_CELLULAR:
return "cellular";
}
dbus_message_iter_init_append(reply, &array);
- dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ connman_dbus_dict_open(&array, &dict);
if (network->device) {
const char *path = connman_device_get_path(network->device);
if (path != NULL)
- connman_dbus_dict_append_variant(&dict, "Device",
+ connman_dbus_dict_append_basic(&dict, "Device",
DBUS_TYPE_OBJECT_PATH, &path);
}
if (network->address != NULL)
- connman_dbus_dict_append_variant(&dict, "Address",
+ connman_dbus_dict_append_basic(&dict, "Address",
DBUS_TYPE_STRING, &network->address);
if (network->name != NULL)
- connman_dbus_dict_append_variant(&dict, "Name",
+ connman_dbus_dict_append_basic(&dict, "Name",
DBUS_TYPE_STRING, &network->name);
- connman_dbus_dict_append_variant(&dict, "Available",
- DBUS_TYPE_BOOLEAN, &network->available);
-
- connman_dbus_dict_append_variant(&dict, "Connected",
+ connman_dbus_dict_append_basic(&dict, "Connected",
DBUS_TYPE_BOOLEAN, &network->connected);
- connman_dbus_dict_append_variant(&dict, "Remember",
- DBUS_TYPE_BOOLEAN, &network->remember);
-
- if (network->priority > 0)
- connman_dbus_dict_append_variant(&dict, "Priority",
- DBUS_TYPE_BYTE, &network->priority);
-
if (network->strength > 0)
- connman_dbus_dict_append_variant(&dict, "Strength",
+ connman_dbus_dict_append_basic(&dict, "Strength",
DBUS_TYPE_BYTE, &network->strength);
+ if (network->frequency > 0)
+ connman_dbus_dict_append_basic(&dict, "Frequency",
+ DBUS_TYPE_UINT16, &network->frequency);
+
if (network->wifi.ssid != NULL && network->wifi.ssid_len > 0)
- connman_dbus_dict_append_array(&dict, "WiFi.SSID",
+ connman_dbus_dict_append_fixed_array(&dict, "WiFi.SSID",
DBUS_TYPE_BYTE, &network->wifi.ssid,
network->wifi.ssid_len);
if (network->wifi.mode != NULL)
- connman_dbus_dict_append_variant(&dict, "WiFi.Mode",
+ connman_dbus_dict_append_basic(&dict, "WiFi.Mode",
DBUS_TYPE_STRING, &network->wifi.mode);
- if (network->wifi.security != NULL)
- connman_dbus_dict_append_variant(&dict, "WiFi.Security",
+ if (network->wifi.channel > 0)
+ connman_dbus_dict_append_basic(&dict, "WiFi.Channel",
+ DBUS_TYPE_UINT16, &network->wifi.channel);
+
+ if (network->wifi.security != NULL) {
+ connman_dbus_dict_append_basic(&dict, "WiFi.Security",
DBUS_TYPE_STRING, &network->wifi.security);
+ if (g_strcmp0(network->wifi.security, "ieee8021x") == 0 &&
+ network->wifi.eap != NULL)
+ connman_dbus_dict_append_basic(&dict, "WiFi.EAP",
+ DBUS_TYPE_STRING, &network->wifi.eap);
+ }
+
+
if (network->wifi.passphrase != NULL &&
__connman_security_check_privilege(msg,
CONNMAN_SECURITY_PRIVILEGE_SECRET) == 0)
- connman_dbus_dict_append_variant(&dict, "WiFi.Passphrase",
+ connman_dbus_dict_append_basic(&dict, "WiFi.Passphrase",
DBUS_TYPE_STRING, &network->wifi.passphrase);
- dbus_message_iter_close_container(&array, &dict);
+ connman_dbus_dict_close(&array, &dict);
return reply;
}
-static DBusMessage *set_property(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct connman_network *network = data;
- DBusMessageIter iter, value;
- const char *name;
- int type;
-
- DBG("conn %p", conn);
-
- if (dbus_message_iter_init(msg, &iter) == FALSE)
- return __connman_error_invalid_arguments(msg);
-
- dbus_message_iter_get_basic(&iter, &name);
- dbus_message_iter_next(&iter);
- dbus_message_iter_recurse(&iter, &value);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
- type = dbus_message_iter_get_arg_type(&value);
-
- if (g_str_equal(name, "Remember") == TRUE) {
- connman_bool_t remember;
-
- if (type != DBUS_TYPE_BOOLEAN)
- return __connman_error_invalid_arguments(msg);
-
- dbus_message_iter_get_basic(&value, &remember);
-
- if (network->remember == remember)
- return __connman_error_invalid_arguments(msg);
-
- network->remember = remember;
- } else if (g_str_equal(name, "WiFi.Passphrase") == TRUE) {
- const char *passphrase;
-
- if (type != DBUS_TYPE_STRING)
- return __connman_error_invalid_arguments(msg);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_SECRET) < 0)
- return __connman_error_permission_denied(msg);
-
- dbus_message_iter_get_basic(&value, &passphrase);
-
- g_free(network->wifi.passphrase);
- network->wifi.passphrase = g_strdup(passphrase);
- } else if (g_str_equal(name, "Priority") == TRUE) {
- connman_uint8_t priority;
-
- if (type != DBUS_TYPE_BYTE)
- return __connman_error_invalid_arguments(msg);
-
- dbus_message_iter_get_basic(&value, &priority);
-
- network->priority = priority;
- }
-
- __connman_storage_save_network(network);
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
-static DBusMessage *do_connect(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct connman_network *network = data;
- int err;
-
- DBG("conn %p", conn);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
- if (network->connected == TRUE)
- return __connman_error_failed(msg);
-
- if (network->driver && network->driver->connect) {
- enum connman_device_mode mode;
-
- mode = connman_device_get_mode(network->device);
- if (mode == CONNMAN_DEVICE_MODE_NETWORK_SINGLE)
- __connman_device_disconnect(network->device);
-
- err = network->driver->connect(network);
- if (err < 0 && err != -EINPROGRESS)
- return __connman_error_failed(msg);
- } else
- network->connected = TRUE;
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
-static DBusMessage *do_disconnect(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct connman_network *network = data;
- int err;
-
- DBG("conn %p", conn);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
- if (network->connected == FALSE)
- return __connman_error_failed(msg);
-
- connman_element_unregister_children(&network->element);
-
- connman_device_set_disconnected(network->device, TRUE);
-
- if (network->driver && network->driver->disconnect) {
- err = network->driver->disconnect(network);
- if (err < 0 && err != -EINPROGRESS)
- return __connman_error_failed(msg);
- } else
- network->connected = FALSE;
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
static GDBusMethodTable network_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property },
- { "Connect", "", "", do_connect },
- { "Disconnect", "", "", do_disconnect },
{ },
};
static DBusConnection *connection;
-static void append_networks(struct connman_device *device,
- DBusMessageIter *entry)
+static void append_networks(DBusMessageIter *iter, void *user_data)
{
- DBusMessageIter value, iter;
- const char *key = "Networks";
+ struct connman_device *device = user_data;
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
__connman_element_list((struct connman_element *) device,
- CONNMAN_ELEMENT_TYPE_NETWORK, &iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(entry, &value);
+ CONNMAN_ELEMENT_TYPE_NETWORK, iter);
}
static void emit_networks_signal(struct connman_device *device)
{
const char *path = connman_device_get_path(device);
- DBusMessage *signal;
- DBusMessageIter entry;
-
- signal = dbus_message_new_signal(path,
- CONNMAN_DEVICE_INTERFACE, "PropertyChanged");
- if (signal == NULL)
- return;
-
- dbus_message_iter_init_append(signal, &entry);
- append_networks(device, &entry);
-
- g_dbus_send_message(connection, signal);
+ connman_dbus_property_changed_array(path,
+ CONNMAN_DEVICE_INTERFACE, "Networks",
+ DBUS_TYPE_OBJECT_PATH, append_networks, device);
}
static int register_interface(struct connman_element *element)
network->registered = FALSE;
- emit_networks_signal(network->device);
+ if (network->device != NULL)
+ emit_networks_signal(network->device);
g_dbus_unregister_interface(connection, element->path,
CONNMAN_NETWORK_INTERFACE);
g_free(network->name);
g_free(network->address);
g_free(network->identifier);
+
+ if (network->ipconfig) {
+ connman_ipconfig_unref(network->ipconfig);
+ network->ipconfig = NULL;
+ }
+
+ network->device = NULL;
}
/**
__connman_element_initialize(&network->element);
//temp = connman_dbus_encode_string(identifier);
- temp = g_strdup(identifier);
+ if (identifier == NULL) {
+ temp = g_strdup_printf("hidden_%d", hidden_counter++);
+ network->hidden = TRUE;
+ } else
+ temp = g_strdup(identifier);
+
if (temp == NULL) {
g_free(network);
return NULL;
connman_element_set_uint8(&network->element, "Strength", strength);
- network->type = type;
- network->identifier = g_strdup(identifier);
+ network->type = type;
+ network->identifier = g_strdup(temp);
return network;
}
*/
void connman_network_set_index(struct connman_network *network, int index)
{
+ struct connman_service *service;
+
+ service = __connman_service_lookup_from_network(network);
+ if (service == NULL)
+ goto done;
+
+ if (network->element.index < 0)
+ /*
+ * This is needed for plugins that havent set their ipconfig
+ * layer yet, due to not being able to get a network index
+ * prior to creating a service.
+ */
+ __connman_service_create_ipconfig(service, index);
+ else {
+ struct connman_ipconfig *ipconfig;
+
+ /* If index changed, the index of ipconfig must be reset. */
+ ipconfig = __connman_service_get_ipconfig(service);
+ if (ipconfig == NULL)
+ goto done;
+
+ __connman_ipconfig_set_index(ipconfig, index);
+ }
+
+done:
network->element.index = index;
}
}
/**
+ * connman_network_get_element:
+ * @network: network structure
+ *
+ * Get connman_element of network
+ */
+struct connman_element *connman_network_get_element(
+ struct connman_network *network)
+{
+ return &network->element;
+}
+
+/**
* connman_network_set_protocol:
* @network: network structure
* @protocol: network protocol
void connman_network_set_group(struct connman_network *network,
const char *group)
{
- g_free(network->group);
+ switch (network->type) {
+ case CONNMAN_NETWORK_TYPE_UNKNOWN:
+ case CONNMAN_NETWORK_TYPE_VENDOR:
+ return;
+ case CONNMAN_NETWORK_TYPE_ETHERNET:
+ case CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN:
+ case CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN:
+ case CONNMAN_NETWORK_TYPE_CELLULAR:
+ case CONNMAN_NETWORK_TYPE_WIFI:
+ case CONNMAN_NETWORK_TYPE_WIMAX:
+ break;
+ }
+
+ if (g_strcmp0(network->group, group) == 0) {
+ if (group != NULL)
+ __connman_profile_update_network(network);
+ return;
+ }
+
+ if (network->group != NULL) {
+ __connman_profile_remove_network(network);
+
+ g_free(network->group);
+ }
+
network->group = g_strdup(group);
+
+ if (network->group != NULL)
+ __connman_profile_add_network(network);
}
-const char *__connman_network_get_group(struct connman_network *network)
+/**
+ * connman_network_get_group:
+ * @network: network structure
+ *
+ * Get group name for automatic clustering
+ */
+const char *connman_network_get_group(struct connman_network *network)
{
return network->group;
}
return __connman_device_get_ident(network->device);
}
+connman_bool_t __connman_network_get_weakness(struct connman_network *network)
+{
+ switch (network->type) {
+ case CONNMAN_NETWORK_TYPE_UNKNOWN:
+ case CONNMAN_NETWORK_TYPE_VENDOR:
+ case CONNMAN_NETWORK_TYPE_ETHERNET:
+ case CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN:
+ case CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN:
+ case CONNMAN_NETWORK_TYPE_CELLULAR:
+ case CONNMAN_NETWORK_TYPE_WIMAX:
+ break;
+ case CONNMAN_NETWORK_TYPE_WIFI:
+ if (g_strcmp0(network->wifi.mode, "adhoc") == 0)
+ return TRUE;
+ if (network->strength > 0 && network->strength < 20)
+ return TRUE;
+ break;
+ }
+
+ return FALSE;
+}
+
+connman_bool_t __connman_network_get_connecting(struct connman_network *network)
+{
+ return network->connecting;
+}
+
/**
* connman_network_set_available:
* @network: network structure
int connman_network_set_available(struct connman_network *network,
connman_bool_t available)
{
- DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Available";
-
DBG("network %p available %d", network, available);
if (network->available == available)
network->available = available;
- if (network->registered == FALSE)
- return 0;
-
- if (network->connected == TRUE)
- return 0;
-
- if (network->remember == FALSE)
- return 0;
-
- signal = dbus_message_new_signal(network->element.path,
- CONNMAN_NETWORK_INTERFACE, "PropertyChanged");
- if (signal == NULL)
- return 0;
-
- dbus_message_iter_init_append(signal, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &available);
- dbus_message_iter_close_container(&entry, &value);
-
- g_dbus_send_message(connection, signal);
-
return 0;
}
*/
connman_bool_t connman_network_get_available(struct connman_network *network)
{
+ if (network->hidden == TRUE)
+ return TRUE;
+
return network->available;
}
-static gboolean set_connected(gpointer user_data)
+/**
+ * connman_network_set_associating:
+ * @network: network structure
+ * @associating: associating state
+ *
+ * Change associating state of network
+ */
+int connman_network_set_associating(struct connman_network *network,
+ connman_bool_t associating)
{
- struct connman_network *network = user_data;
+ DBG("network %p associating %d", network, associating);
- if (network->connected == TRUE) {
- struct connman_element *element;
- enum connman_element_type type = CONNMAN_ELEMENT_TYPE_UNKNOWN;
-
- switch (network->protocol) {
- case CONNMAN_NETWORK_PROTOCOL_UNKNOWN:
- return 0;
- case CONNMAN_NETWORK_PROTOCOL_IP:
- type = CONNMAN_ELEMENT_TYPE_DHCP;
- break;
- case CONNMAN_NETWORK_PROTOCOL_PPP:
- type = CONNMAN_ELEMENT_TYPE_PPP;
- break;
- }
+ if (network->associating == associating)
+ return -EALREADY;
- __connman_device_increase_connections(network->device);
+ network->associating = associating;
- __connman_device_set_network(network->device, network);
+ if (associating == TRUE) {
+ struct connman_service *service;
- connman_device_set_disconnected(network->device, FALSE);
+ service = __connman_service_lookup_from_network(network);
+ __connman_service_indicate_state(service,
+ CONNMAN_SERVICE_STATE_ASSOCIATION);
+ }
- element = connman_element_create(NULL);
- if (element != NULL) {
- element->type = type;
- element->index = network->element.index;
+ return 0;
+}
- if (connman_element_register(element,
- &network->element) < 0)
- connman_element_unref(element);
- }
- } else {
- connman_element_unregister_children(&network->element);
+static void set_associate_error(struct connman_network *network)
+{
+ struct connman_service *service;
- __connman_device_set_network(network->device, NULL);
+ if (network->associating == FALSE)
+ return ;
- __connman_device_decrease_connections(network->device);
- }
+ network->associating = FALSE;
- return FALSE;
+ service = __connman_service_lookup_from_network(network);
+
+ __connman_service_indicate_state(service,
+ CONNMAN_SERVICE_STATE_FAILURE);
}
-/**
- * connman_network_set_connected:
- * @network: network structure
- * @connected: connected state
- *
- * Change connected state of network
- */
-int connman_network_set_connected(struct connman_network *network,
- connman_bool_t connected)
+static void set_configure_error(struct connman_network *network)
{
- DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Connected";
+ struct connman_service *service;
- DBG("network %p connected %d", network, connected);
+ network->connecting = FALSE;
- if (network->connected == connected)
- return -EALREADY;
+ service = __connman_service_lookup_from_network(network);
- network->connected = connected;
+ __connman_service_indicate_state(service,
+ CONNMAN_SERVICE_STATE_FAILURE);
+}
- if (network->registered == FALSE) {
- g_idle_add(set_connected, network);
- return 0;
- }
+void connman_network_set_method(struct connman_network *network,
+ enum connman_ipconfig_method method)
+{
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig;
- signal = dbus_message_new_signal(network->element.path,
- CONNMAN_NETWORK_INTERFACE, "PropertyChanged");
- if (signal == NULL)
- return 0;
+ network->element.ipv4.method = method;
- dbus_message_iter_init_append(signal, &entry);
+ service = __connman_service_lookup_from_network(network);
+ if (service == NULL)
+ return;
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+ ipconfig = __connman_service_get_ipconfig(service);
+ if (ipconfig == NULL)
+ return;
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &connected);
- dbus_message_iter_close_container(&entry, &value);
+ connman_ipconfig_set_method(ipconfig, method);
+}
- g_dbus_send_message(connection, signal);
+void connman_network_set_error(struct connman_network *network,
+ enum connman_network_error error)
+{
+ DBG("nework %p, error %d", network, error);
- set_connected(network);
+ network->connecting = FALSE;
- return 0;
+ switch (error) {
+ case CONNMAN_NETWORK_ERROR_UNKNOWN:
+ return;
+ case CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL:
+ set_associate_error(network);
+ break;
+ case CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL:
+ set_configure_error(network);
+ break;
+ }
}
-/**
- * connman_network_get_connected:
- * @network: network structure
- *
- * Get network connection status
- */
-connman_bool_t connman_network_get_connected(struct connman_network *network)
+static void set_configuration(struct connman_network *network)
{
- return network->connected;
+ struct connman_service *service;
+
+ DBG("network %p", network);
+
+ __connman_device_increase_connections(network->device);
+
+ __connman_device_set_network(network->device, network);
+
+ connman_device_set_disconnected(network->device, FALSE);
+
+ service = __connman_service_lookup_from_network(network);
+ __connman_service_indicate_state(service,
+ CONNMAN_SERVICE_STATE_CONFIGURATION);
}
-/**
- * connman_network_set_remember:
- * @network: network structure
- * @remember: remember state
- *
- * Change remember state of network (known networks)
- */
-int connman_network_set_remember(struct connman_network *network,
- connman_bool_t remember)
+static void set_connected_manual(struct connman_network *network)
{
- DBusMessage *signal;
- DBusMessageIter entry, value;
- const char *key = "Remember";
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig;
+ const char *nameserver = NULL;
+ int err;
- DBG("network %p remember %d", network, remember);
+ DBG("network %p", network);
- if (network->remember == remember)
- return -EALREADY;
+ service = __connman_service_lookup_from_network(network);
- network->remember = remember;
+ ipconfig = __connman_service_get_ipconfig(service);
- if (network->registered == FALSE)
- return 0;
+ set_configuration(network);
- signal = dbus_message_new_signal(network->element.path,
- CONNMAN_NETWORK_INTERFACE, "PropertyChanged");
- if (signal == NULL)
- return 0;
+ err = __connman_ipconfig_set_address(ipconfig);
+ if (err < 0) {
+ connman_network_set_error(network,
+ CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
+ return;
+ }
- dbus_message_iter_init_append(signal, &entry);
+ connman_element_get_value(&network->element,
+ CONNMAN_PROPERTY_ID_IPV4_NAMESERVER, &nameserver);
+ if (nameserver != NULL)
+ __connman_service_append_nameserver(service, nameserver);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+ __connman_ipconfig_set_gateway(ipconfig, &network->element);
- dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_BOOLEAN_AS_STRING, &value);
- dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &remember);
- dbus_message_iter_close_container(&entry, &value);
+ network->connecting = FALSE;
- g_dbus_send_message(connection, signal);
+ connman_network_set_associating(network, FALSE);
- return 0;
+ __connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY);
}
-/**
- * connman_network_get_remember:
- * @network: network structure
- *
- * Get network remember setting
- */
-connman_bool_t connman_network_get_remember(struct connman_network *network)
+static int set_connected_dhcp(struct connman_network *network)
{
- return network->remember;
-}
+ struct connman_element *element;
+ int error;
-/**
- * connman_network_connect:
- * @network: network structure
- *
- * Connect network
- */
-int connman_network_connect(struct connman_network *network)
-{
- if (network->connected == TRUE)
- return -EALREADY;
+ DBG("network %p", network);
- if (network->driver && network->driver->connect)
- return network->driver->connect(network);
+ if (network->protocol != CONNMAN_NETWORK_PROTOCOL_IP)
+ return -EINVAL;
- network->connected = TRUE;
+ element = connman_element_create(NULL);
+ if (element == NULL)
+ return -ENOMEM;
+
+ element->type = CONNMAN_ELEMENT_TYPE_DHCP;
+ element->index = network->element.index;
+
+ error = connman_element_register(element, &network->element);
+ if (error < 0) {
+ connman_element_unref(element);
+ return error;
+ }
+
+ set_configuration(network);
+
+ return 0;
+}
+
+static gboolean set_connected(gpointer user_data)
+{
+ struct connman_network *network = user_data;
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig;
+ enum connman_ipconfig_method method;
+
+ service = __connman_service_lookup_from_network(network);
+
+ ipconfig = __connman_service_get_ipconfig(service);
+
+ method = __connman_ipconfig_get_method(ipconfig);
+
+ DBG("method %d", method);
+
+ if (network->connected == TRUE) {
+ switch (method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ return FALSE;
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ set_connected_manual(network);
+ return TRUE;
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ if (set_connected_dhcp(network) < 0) {
+ connman_network_set_error(network,
+ CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
+ return FALSE;
+ }
+ }
+
+ } else {
+ struct connman_service *service;
+
+ connman_element_unregister_children(&network->element);
+
+ __connman_device_set_network(network->device, NULL);
+ network->hidden = FALSE;
+
+ __connman_device_decrease_connections(network->device);
+
+ service = __connman_service_lookup_from_network(network);
+
+ __connman_service_indicate_state(service,
+ CONNMAN_SERVICE_STATE_IDLE);
+ }
+
+ network->connecting = FALSE;
+
+ connman_network_set_associating(network, FALSE);
+
+ return FALSE;
+}
+
+/**
+ * connman_network_set_connected:
+ * @network: network structure
+ * @connected: connected state
+ *
+ * Change connected state of network
+ */
+int connman_network_set_connected(struct connman_network *network,
+ connman_bool_t connected)
+{
+ DBG("network %p connected %d", network, connected);
+
+ if ((network->connecting == TRUE || network->associating == TRUE) &&
+ connected == FALSE) {
+ connman_element_set_error(&network->element,
+ CONNMAN_ELEMENT_ERROR_CONNECT_FAILED);
+ __connman_network_disconnect(network);
+ }
+
+ if (network->connected == connected)
+ return -EALREADY;
+
+ network->connected = connected;
+
+ if (network->registered == FALSE) {
+ g_idle_add(set_connected, network);
+ return 0;
+ }
+
+ connman_dbus_property_changed_basic(network->element.path,
+ CONNMAN_NETWORK_INTERFACE, "Connected",
+ DBUS_TYPE_BOOLEAN, &connected);
+
+ set_connected(network);
return 0;
}
+/**
+ * connman_network_get_connected:
+ * @network: network structure
+ *
+ * Get network connection status
+ */
+connman_bool_t connman_network_get_connected(struct connman_network *network)
+{
+ return network->connected;
+}
+
+/**
+ * connman_network_get_associating:
+ * @network: network structure
+ *
+ * Get network associating status
+ */
+connman_bool_t connman_network_get_associating(struct connman_network *network)
+{
+ return network->associating;
+}
+
+/**
+ * __connman_network_connect:
+ * @network: network structure
+ *
+ * Connect network
+ */
+int __connman_network_connect(struct connman_network *network)
+{
+ int err;
+
+ DBG("network %p", network);
+
+ if (network->connected == TRUE)
+ return -EISCONN;
+
+ if (network->connecting == TRUE || network->associating == TRUE)
+ return -EALREADY;
+
+ if (network->driver == NULL)
+ return -EUNATCH;
+
+ if (network->driver->connect == NULL)
+ return -ENOSYS;
+
+ __connman_device_disconnect(network->device);
+
+ network->connecting = TRUE;
+
+ err = network->driver->connect(network);
+ if (err < 0) {
+ if (err == -EINPROGRESS)
+ connman_network_set_associating(network, TRUE);
+ else {
+ network->connecting = FALSE;
+ network->hidden = FALSE;
+ }
+
+ return err;
+ }
+
+ network->connected = TRUE;
+ set_connected(network);
+
+ return err;
+}
+
+/**
+ * __connman_network_disconnect:
+ * @network: network structure
+ *
+ * Disconnect network
+ */
int __connman_network_disconnect(struct connman_network *network)
{
- if (network->connected == FALSE)
+ int err;
+
+ DBG("network %p", network);
+
+ if (network->connected == FALSE && network->connecting == FALSE &&
+ network->associating == FALSE)
return -ENOTCONN;
- connman_element_unregister_children(&network->element);
+ if (network->driver == NULL)
+ return -EUNATCH;
- if (network->driver && network->driver->disconnect)
- return network->driver->disconnect(network);
+ if (network->driver->disconnect == NULL)
+ return -ENOSYS;
- network->connected = FALSE;
+ network->connecting = FALSE;
+
+ err = network->driver->disconnect(network);
+ if (err == 0) {
+ connman_network_set_connected(network, FALSE);
+ set_connected(network);
+ }
+
+ return err;
+}
+
+static int dhcp_start(struct connman_network *network)
+{
+ struct connman_element *element;
+ int error;
+
+ if (network->protocol != CONNMAN_NETWORK_PROTOCOL_IP)
+ return -EINVAL;
+
+ element = connman_element_create(NULL);
+ if (element == NULL)
+ return -ENOMEM;
+
+ element->type = CONNMAN_ELEMENT_TYPE_DHCP;
+ element->index = network->element.index;
+
+ error = connman_element_register(element, &network->element);
+ if (error < 0) {
+ connman_element_unref(element);
+ return error;
+ }
+
+ return 0;
+}
+
+static int dhcp_stop(struct connman_network *network)
+{
+ if (network->protocol != CONNMAN_NETWORK_PROTOCOL_IP)
+ return -EINVAL;
+
+ connman_element_unregister_children_type(&network->element,
+ CONNMAN_ELEMENT_TYPE_CONNECTION);
+ connman_element_unregister_children_type(&network->element,
+ CONNMAN_ELEMENT_TYPE_IPV4);
+ connman_element_unregister_children_type(&network->element,
+ CONNMAN_ELEMENT_TYPE_DHCP);
+
+ return 0;
+}
+
+static int manual_ipv4_set(struct connman_network *network,
+ struct connman_ipconfig *ipconfig)
+{
+ struct connman_service *service;
+ int err;
+
+ service = __connman_service_lookup_from_network(network);
+ if (service == NULL)
+ return -EINVAL;
+
+ err = __connman_ipconfig_set_address(ipconfig);
+ if (err < 0) {
+ connman_network_set_error(network,
+ CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
+ return err;
+ }
+
+ __connman_ipconfig_set_gateway(ipconfig, &network->element);
+
+ __connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY);
+
+ return 0;
+}
+
+int __connman_network_clear_ipconfig(struct connman_network *network,
+ struct connman_ipconfig *ipconfig)
+{
+ struct connman_service *service;
+ enum connman_ipconfig_method method;
+
+ service = __connman_service_lookup_from_network(network);
+ if (service == NULL)
+ return -EINVAL;
+
+ method = __connman_ipconfig_get_method(ipconfig);
+
+ switch (method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ return -EINVAL;
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ connman_element_unregister_children_type(&network->element,
+ CONNMAN_ELEMENT_TYPE_CONNECTION);
+ __connman_ipconfig_clear_address(ipconfig);
+ break;
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ dhcp_stop(network);
+ break;
+ }
+
+ __connman_service_indicate_state(service,
+ CONNMAN_SERVICE_STATE_CONFIGURATION);
+
+ return 0;
+}
+
+int __connman_network_set_ipconfig(struct connman_network *network, struct connman_ipconfig *ipconfig)
+{
+ enum connman_ipconfig_method method;
+
+ method = __connman_ipconfig_get_method(ipconfig);
+
+ switch (method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ return -EINVAL;
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ return manual_ipv4_set(network, ipconfig);
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ return dhcp_start(network);
+ }
return 0;
}
/**
+ * connman_network_set_address:
+ * @network: network structure
+ * @address: binary address value
+ * @size: binary address length
+ *
+ * Set unique address value for network
+ */
+int connman_network_set_address(struct connman_network *network,
+ const void *address, unsigned int size)
+{
+ const unsigned char *addr_octet = address;
+ char *str;
+
+ DBG("network %p size %d", network, size);
+
+ if (size != 6)
+ return -EINVAL;
+
+ str = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X",
+ addr_octet[0], addr_octet[1], addr_octet[2],
+ addr_octet[3], addr_octet[4], addr_octet[5]);
+ if (str == NULL)
+ return -ENOMEM;
+
+ g_free(network->address);
+ network->address = str;
+
+ return connman_element_set_string(&network->element,
+ "Address", network->address);
+}
+
+/**
+ * connman_network_set_name:
+ * @network: network structure
+ * @name: name value
+ *
+ * Set display name value for network
+ */
+int connman_network_set_name(struct connman_network *network,
+ const char *name)
+{
+ DBG("network %p name %s", network, name);
+
+ g_free(network->name);
+ network->name = g_strdup(name);
+
+ return connman_element_set_string(&network->element, "Name", name);
+}
+
+/**
+ * connman_network_set_strength:
+ * @network: network structure
+ * @strength: strength value
+ *
+ * Set signal strength value for network
+ */
+int connman_network_set_strength(struct connman_network *network,
+ connman_uint8_t strength)
+{
+ DBG("network %p strengh %d", network, strength);
+
+ network->strength = strength;
+
+ return connman_element_set_uint8(&network->element,
+ "Strength", strength);
+}
+
+/**
+ * connman_network_set_roaming:
+ * @network: network structure
+ * @roaming: roaming state
+ *
+ * Set roaming state for network
+ */
+int connman_network_set_roaming(struct connman_network *network,
+ connman_bool_t roaming)
+{
+ DBG("network %p roaming %d", network, roaming);
+
+ network->roaming = roaming;
+
+ return connman_element_set_bool(&network->element,
+ "Roaming", roaming);
+}
+
+/**
* connman_network_set_string:
* @network: network structure
* @key: unique identifier
int connman_network_set_string(struct connman_network *network,
const char *key, const char *value)
{
+ int err;
+
DBG("network %p key %s value %s", network, key, value);
+ if (g_strcmp0(key, "Name") == 0)
+ return connman_network_set_name(network, value);
+
if (g_str_equal(key, "Address") == TRUE) {
g_free(network->address);
network->address = g_strdup(value);
- } else if (g_str_equal(key, "Name") == TRUE) {
- g_free(network->name);
- network->name = g_strdup(value);
} else if (g_str_equal(key, "Node") == TRUE) {
g_free(network->node);
network->node = g_strdup(value);
} else if (g_str_equal(key, "WiFi.Passphrase") == TRUE) {
g_free(network->wifi.passphrase);
network->wifi.passphrase = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.EAP") == TRUE) {
+ g_free(network->wifi.eap);
+ network->wifi.eap = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.Identity") == TRUE) {
+ g_free(network->wifi.identity);
+ network->wifi.identity = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.CACertFile") == TRUE) {
+ g_free(network->wifi.ca_cert_path);
+ network->wifi.ca_cert_path = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.ClientCertFile") == TRUE) {
+ g_free(network->wifi.client_cert_path);
+ network->wifi.client_cert_path = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.PrivateKeyFile") == TRUE) {
+ g_free(network->wifi.private_key_path);
+ network->wifi.private_key_path = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.PrivateKeyPassphrase") == TRUE) {
+ g_free(network->wifi.private_key_passphrase);
+ network->wifi.private_key_passphrase = g_strdup(value);
+ } else if (g_str_equal(key, "WiFi.Phase2") == TRUE) {
+ g_free(network->wifi.phase2_auth);
+ network->wifi.phase2_auth = g_strdup(value);
}
- return connman_element_set_string(&network->element, key, value);
+ err = connman_element_set_string(&network->element, key, value);
+ if (err < 0)
+ return err;
+
+ if (network->driver == NULL)
+ return 0;
+
+ if (network->driver->setup)
+ return network->driver->setup(network, key);
+
+ return 0;
}
/**
return network->wifi.security;
else if (g_str_equal(key, "WiFi.Passphrase") == TRUE)
return network->wifi.passphrase;
+ else if (g_str_equal(key, "WiFi.EAP") == TRUE)
+ return network->wifi.eap;
+ else if (g_str_equal(key, "WiFi.Identity") == TRUE)
+ return network->wifi.identity;
+ else if (g_str_equal(key, "WiFi.CACertFile") == TRUE)
+ return network->wifi.ca_cert_path;
+ else if (g_str_equal(key, "WiFi.ClientCertFile") == TRUE)
+ return network->wifi.client_cert_path;
+ else if (g_str_equal(key, "WiFi.PrivateKeyFile") == TRUE)
+ return network->wifi.private_key_path;
+ else if (g_str_equal(key, "WiFi.PrivateKeyPassphrase") == TRUE)
+ return network->wifi.private_key_passphrase;
+ else if (g_str_equal(key, "WiFi.Phase2") == TRUE)
+ return network->wifi.phase2_auth;
return connman_element_get_string(&network->element, key);
}
/**
+ * connman_network_set_bool:
+ * @network: network structure
+ * @key: unique identifier
+ * @value: boolean value
+ *
+ * Set boolean value for specific key
+ */
+int connman_network_set_bool(struct connman_network *network,
+ const char *key, connman_bool_t value)
+{
+ DBG("network %p key %s value %d", network, key, value);
+
+ if (g_strcmp0(key, "Roaming") == 0)
+ return connman_network_set_roaming(network, value);
+
+ return connman_element_set_bool(&network->element, key, value);
+}
+
+/**
+ * connman_network_get_bool:
+ * @network: network structure
+ * @key: unique identifier
+ *
+ * Get boolean value for specific key
+ */
+connman_bool_t connman_network_get_bool(struct connman_network *network,
+ const char *key)
+{
+ DBG("network %p key %s", network, key);
+
+ if (g_str_equal(key, "Roaming") == TRUE)
+ return network->roaming;
+
+ return connman_element_get_bool(&network->element, key);
+}
+
+/**
* connman_network_set_uint8:
* @network: network structure
* @key: unique identifier
{
DBG("network %p key %s value %d", network, key, value);
- if (g_str_equal(key, "Priority") == TRUE)
- network->priority = value;
- else if (g_str_equal(key, "Strength") == TRUE)
- network->strength = value;
+ if (g_strcmp0(key, "Strength") == 0)
+ return connman_network_set_strength(network, value);
return connman_element_set_uint8(&network->element, key, value);
}
{
DBG("network %p key %s", network, key);
- if (g_str_equal(key, "Priority") == TRUE)
- return network->priority;
- else if (g_str_equal(key, "Strength") == TRUE)
+ if (g_str_equal(key, "Strength") == TRUE)
return network->strength;
return connman_element_get_uint8(&network->element, key);
}
/**
+ * connman_network_set_uint16:
+ * @network: network structure
+ * @key: unique identifier
+ * @value: integer value
+ *
+ * Set integer value for specific key
+ */
+int connman_network_set_uint16(struct connman_network *network,
+ const char *key, connman_uint16_t value)
+{
+ DBG("network %p key %s value %d", network, key, value);
+
+ if (g_str_equal(key, "Frequency") == TRUE)
+ network->frequency = value;
+ else if (g_str_equal(key, "WiFi.Channel") == TRUE)
+ network->wifi.channel = value;
+
+ return -EINVAL;
+}
+
+/**
+ * connman_network_get_uint16:
+ * @network: network structure
+ * @key: unique identifier
+ *
+ * Get integer value for specific key
+ */
+connman_uint16_t connman_network_get_uint16(struct connman_network *network,
+ const char *key)
+{
+ DBG("network %p key %s", network, key);
+
+ if (g_str_equal(key, "Frequency") == TRUE)
+ return network->frequency;
+ else if (g_str_equal(key, "WiFi.Channel") == TRUE)
+ return network->wifi.channel;
+
+ return 0;
+}
+
+/**
* connman_network_set_blob:
* @network: network structure
* @key: unique identifier
{
DBG("network %p key %s size %d", network, key, size);
+ if (g_strcmp0(key, "Address") == 0)
+ return connman_network_set_address(network, data, size);
+
if (g_str_equal(key, "WiFi.SSID") == TRUE) {
g_free(network->wifi.ssid);
network->wifi.ssid = g_try_malloc(size);
switch (network->type) {
case CONNMAN_NETWORK_TYPE_UNKNOWN:
case CONNMAN_NETWORK_TYPE_VENDOR:
+ break;
+ case CONNMAN_NETWORK_TYPE_ETHERNET:
case CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN:
case CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN:
- case CONNMAN_NETWORK_TYPE_HSO:
- break;
+ case CONNMAN_NETWORK_TYPE_CELLULAR:
case CONNMAN_NETWORK_TYPE_WIFI:
case CONNMAN_NETWORK_TYPE_WIMAX:
- __connman_profile_add_network(network);
+ if (network->group != NULL)
+ __connman_profile_add_network(network);
break;
}
switch (network->type) {
case CONNMAN_NETWORK_TYPE_UNKNOWN:
case CONNMAN_NETWORK_TYPE_VENDOR:
+ break;
+ case CONNMAN_NETWORK_TYPE_ETHERNET:
case CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN:
case CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN:
- case CONNMAN_NETWORK_TYPE_HSO:
- break;
+ case CONNMAN_NETWORK_TYPE_CELLULAR:
case CONNMAN_NETWORK_TYPE_WIFI:
case CONNMAN_NETWORK_TYPE_WIMAX:
- __connman_profile_remove_network(network);
+ if (network->group != NULL) {
+ __connman_profile_remove_network(network);
+
+ g_free(network->group);
+ network->group = NULL;
+ }
break;
}
.change = network_change,
};
-static int network_init(struct connman_device *device)
-{
- DBG("device %p", device);
-
- return 0;
-}
-
-static int network_load(struct connman_network *network)
-{
- GKeyFile *keyfile;
- gchar *pathname, *data = NULL;
- gsize length;
- const char *name;
- char *str;
- int val;
-
- DBG("network %p", network);
-
- name = connman_device_get_name(network->device);
- if (name == NULL)
- return -EINVAL;
-
- pathname = g_strdup_printf("%s/%s.conf", STORAGEDIR, name);
- if (pathname == NULL)
- return -ENOMEM;
-
- keyfile = g_key_file_new();
-
- if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE) {
- g_free(pathname);
- return -ENOENT;
- }
-
- g_free(pathname);
-
- if (g_key_file_load_from_data(keyfile, data, length,
- 0, NULL) == FALSE) {
- g_free(data);
- return -EILSEQ;
- }
-
- g_free(data);
-
- network->remember = g_key_file_get_boolean(keyfile,
- network->identifier, "Remember", NULL);
-
- val = g_key_file_get_integer(keyfile, network->identifier,
- "Priority", NULL);
- if (val > 0)
- network->priority = val;
-
- str = g_key_file_get_string(keyfile,
- network->identifier, "WiFi.Security", NULL);
- if (str != NULL) {
- g_free(network->wifi.security);
- network->wifi.security = str;
- }
-
- str = g_key_file_get_string(keyfile,
- network->identifier, "WiFi.Passphrase", NULL);
- if (str != NULL) {
- g_free(network->wifi.passphrase);
- network->wifi.passphrase = str;
- }
-
- g_key_file_free(keyfile);
-
- return 0;
-}
-
-static int network_save(struct connman_network *network)
-{
- GKeyFile *keyfile;
- gchar *pathname, *data = NULL;
- gsize length;
- const char *name;
-
- DBG("network %p", network);
-
- name = connman_device_get_name(network->device);
- if (name == NULL)
- return -EINVAL;
-
- pathname = g_strdup_printf("%s/%s.conf", STORAGEDIR, name);
- if (pathname == NULL)
- return -ENOMEM;
-
- keyfile = g_key_file_new();
-
- if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE)
- goto update;
-
- if (length > 0) {
- if (g_key_file_load_from_data(keyfile, data, length,
- 0, NULL) == FALSE)
- goto done;
- }
-
- g_free(data);
-
-update:
- g_key_file_set_boolean(keyfile, network->identifier,
- "Remember", network->remember);
-
- if (network->priority > 0)
- g_key_file_set_integer(keyfile, network->identifier,
- "Priority", network->priority);
-
- if (network->remember == TRUE || network->connected == TRUE) {
- if (network->wifi.security != NULL)
- g_key_file_set_string(keyfile, network->identifier,
- "WiFi.Security", network->wifi.security);
-
- if (network->wifi.passphrase != NULL)
- g_key_file_set_string(keyfile, network->identifier,
- "WiFi.Passphrase", network->wifi.passphrase);
- }
-
- data = g_key_file_to_data(keyfile, &length, NULL);
-
- if (g_file_set_contents(pathname, data, length, NULL) == FALSE)
- connman_error("Failed to store network information");
-
-done:
- g_free(data);
-
- g_key_file_free(keyfile);
-
- g_free(pathname);
-
- return 0;
-}
-
-static struct connman_storage network_storage = {
- .name = "network",
- .priority = CONNMAN_STORAGE_PRIORITY_LOW,
- .network_init = network_init,
- .network_load = network_load,
- .network_save = network_save,
-};
-
int __connman_network_init(void)
{
DBG("");
connection = connman_dbus_get_connection();
- if (connman_storage_register(&network_storage) < 0)
- connman_error("Failed to register network storage");
-
return connman_driver_register(&network_driver);
}
connman_driver_unregister(&network_driver);
- connman_storage_unregister(&network_storage);
-
dbus_connection_unref(connection);
}