char *passphrase;
char *agent_passphrase;
connman_bool_t roaming;
- connman_bool_t login_required;
connman_bool_t network_created;
struct connman_ipconfig *ipconfig_ipv4;
struct connman_ipconfig *ipconfig_ipv6;
char **excludes;
char *pac;
connman_bool_t wps;
+ int online_check_count;
};
static void append_path(gpointer value, gpointer user_data)
struct connman_service *service = value;
DBusMessageIter *iter = user_data;
- if (service->path == NULL || service->hidden == TRUE)
+ if (service->path == NULL)
return;
dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
case CONNMAN_SERVICE_SECURITY_WEP:
return "wep";
case CONNMAN_SERVICE_SECURITY_PSK:
+ case CONNMAN_SERVICE_SECURITY_WPA:
+ case CONNMAN_SERVICE_SECURITY_RSN:
return "psk";
case CONNMAN_SERVICE_SECURITY_8021X:
return "ieee8021x";
- case CONNMAN_SERVICE_SECURITY_WPA:
- return "wpa";
- case CONNMAN_SERVICE_SECURITY_RSN:
- return "rsn";
}
return NULL;
__connman_notifier_default_changed(service);
}
-const char *__connman_service_default(void)
-{
- struct connman_service *service;
-
- service = get_default();
- if (service == NULL)
- return "";
-
- return __connman_service_type2string(service->type);
-}
-
static void state_changed(struct connman_service *service)
{
const char *str;
DBUS_TYPE_BOOLEAN, &service->autoconnect);
}
-static void passphrase_changed(struct connman_service *service)
-{
- dbus_bool_t required;
-
- switch (service->type) {
- case CONNMAN_SERVICE_TYPE_UNKNOWN:
- case CONNMAN_SERVICE_TYPE_SYSTEM:
- case CONNMAN_SERVICE_TYPE_ETHERNET:
- case CONNMAN_SERVICE_TYPE_WIMAX:
- case CONNMAN_SERVICE_TYPE_BLUETOOTH:
- case CONNMAN_SERVICE_TYPE_CELLULAR:
- case CONNMAN_SERVICE_TYPE_GPS:
- case CONNMAN_SERVICE_TYPE_VPN:
- case CONNMAN_SERVICE_TYPE_GADGET:
- return;
- case CONNMAN_SERVICE_TYPE_WIFI:
- required = FALSE;
-
- switch (service->security) {
- case CONNMAN_SERVICE_SECURITY_UNKNOWN:
- case CONNMAN_SERVICE_SECURITY_NONE:
- break;
- case CONNMAN_SERVICE_SECURITY_WEP:
- case CONNMAN_SERVICE_SECURITY_PSK:
- case CONNMAN_SERVICE_SECURITY_WPA:
- case CONNMAN_SERVICE_SECURITY_RSN:
- if (service->passphrase == NULL)
- required = TRUE;
- break;
- case CONNMAN_SERVICE_SECURITY_8021X:
- break;
- }
- break;
- }
-
- connman_dbus_property_changed_basic(service->path,
- CONNMAN_SERVICE_INTERFACE, "PassphraseRequired",
- DBUS_TYPE_BOOLEAN, &required);
-}
-
-static void login_changed(struct connman_service *service)
-{
- dbus_bool_t required = service->login_required;
-
- if (service->path == NULL)
- return;
-
- connman_dbus_property_changed_basic(service->path,
- CONNMAN_SERVICE_INTERFACE, "LoginRequired",
- DBUS_TYPE_BOOLEAN, &required);
-}
-
static void append_security(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
stats->data.time = stats->data_last.time + seconds;
}
-static char *wifi_build_group_name(const unsigned char *ssid,
- unsigned int ssid_len,
- const char *mode,
- const char *security)
-{
- GString *str;
- unsigned int i;
-
- /* the last 3 is for the 2 '_' and '\0' */
- str = g_string_sized_new((ssid_len * 2) + strlen(mode)
- + strlen(security) + 3);
- if (str == NULL)
- return NULL;
-
- for (i = 0; i < ssid_len; i++)
- g_string_append_printf(str, "%02x", ssid[i]);
-
- g_string_append_printf(str, "_%s_%s", mode, security);
-
- return g_string_free(str, FALSE);
-}
-
void __connman_service_notify(struct connman_service *service,
unsigned int rx_packets, unsigned int tx_packets,
unsigned int rx_bytes, unsigned int tx_bytes,
static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
struct connman_service *service)
{
- dbus_bool_t required;
const char *str;
str = __connman_service_type2string(service->type);
connman_dbus_dict_append_basic(dict, "Name",
DBUS_TYPE_STRING, &service->name);
- connman_dbus_dict_append_basic(dict, "LoginRequired",
- DBUS_TYPE_BOOLEAN, &service->login_required);
-
switch (service->type) {
case CONNMAN_SERVICE_TYPE_UNKNOWN:
case CONNMAN_SERVICE_TYPE_SYSTEM:
append_ethernet, service);
break;
case CONNMAN_SERVICE_TYPE_WIFI:
- if (service->passphrase != NULL && limited == FALSE)
- connman_dbus_dict_append_basic(dict, "Passphrase",
- DBUS_TYPE_STRING, &service->passphrase);
-
- required = FALSE;
-
- switch (service->security) {
- case CONNMAN_SERVICE_SECURITY_UNKNOWN:
- case CONNMAN_SERVICE_SECURITY_NONE:
- break;
- case CONNMAN_SERVICE_SECURITY_WEP:
- case CONNMAN_SERVICE_SECURITY_PSK:
- case CONNMAN_SERVICE_SECURITY_WPA:
- case CONNMAN_SERVICE_SECURITY_RSN:
- if (service->passphrase == NULL)
- required = TRUE;
- break;
- case CONNMAN_SERVICE_SECURITY_8021X:
- break;
- }
-
- connman_dbus_dict_append_basic(dict, "PassphraseRequired",
- DBUS_TYPE_BOOLEAN, &required);
-
- /* fall through */
case CONNMAN_SERVICE_TYPE_ETHERNET:
case CONNMAN_SERVICE_TYPE_WIMAX:
case CONNMAN_SERVICE_TYPE_BLUETOOTH:
DBusMessageIter *iter = user_data;
DBusMessageIter entry, dict;
- if (service->path == NULL || service->hidden == TRUE)
+ if (service->path == NULL)
return;
dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, NULL, &entry);
g_sequence_foreach(service_list, append_struct, iter);
}
+connman_bool_t __connman_service_is_hidden(struct connman_service *service)
+{
+ return service->hidden;
+}
+
int __connman_service_get_index(struct connman_service *service)
{
if (service == NULL)
void __connman_service_set_domainname(struct connman_service *service,
const char *domainname)
{
- if (service == NULL)
+ if (service == NULL || service->hidden == TRUE)
return;
g_free(service->domainname);
return NULL;
if (service->nameservers_config != NULL)
- return service->nameservers_config;
- else if (service->nameservers != NULL)
- return service->nameservers;
+ return g_strdupv(service->nameservers_config);
+ else if (service->nameservers != NULL ||
+ service->nameservers_auto != NULL) {
+ int len = 0, len_auto = 0, i;
+ char **nameservers;
+
+ if (service->nameservers != NULL)
+ len = g_strv_length(service->nameservers);
+ if (service->nameservers_auto != NULL)
+ len_auto = g_strv_length(service->nameservers_auto);
+
+ nameservers = g_try_new0(char *, len + len_auto + 1);
+ if (nameservers == NULL)
+ return NULL;
+
+ for (i = 0; i < len; i++)
+ nameservers[i] = g_strdup(service->nameservers[i]);
+
+ for (i = 0; i < len_auto; i++)
+ nameservers[i + len] =
+ g_strdup(service->nameservers_auto[i]);
+
+ return nameservers;
+ }
return NULL;
}
void connman_service_set_proxy_method(struct connman_service *service,
enum connman_service_proxy_method method)
{
- if (service == NULL)
+ if (service == NULL || service->hidden == TRUE)
return;
service->proxy = method;
void __connman_service_set_proxy_autoconfig(struct connman_service *service,
const char *url)
{
- if (service == NULL)
+ if (service == NULL || service->hidden == TRUE)
return;
service->proxy = CONNMAN_SERVICE_PROXY_METHOD_AUTO;
const char *timeserver)
{
char **servers;
- int len, i, j;
+ int len, i, j, found = 0;
DBG("service %p timeserver %s", service, timeserver);
if (service->timeservers == NULL)
return 0;
+ for (i = 0; service->timeservers != NULL &&
+ service->timeservers[i] != NULL; i++)
+ if (g_strcmp0(service->timeservers[i], timeserver) == 0) {
+ found = 1;
+ break;
+ }
+
+ if (found == 0)
+ return 0;
+
len = g_strv_length(service->timeservers);
- if (len == 1) {
- if (g_strcmp0(service->timeservers[0], timeserver) != 0)
- return 0;
+ if (len == 1) {
g_strfreev(service->timeservers);
service->timeservers = NULL;
return 0;
}
- servers = g_try_new0(char *, len - 1);
+ servers = g_try_new0(char *, len);
if (servers == NULL)
return -ENOMEM;
for (i = 0, j = 0; i < len; i++) {
if (g_strcmp0(service->timeservers[i], timeserver) != 0) {
servers[j] = g_strdup(service->timeservers[i]);
+ if (servers[j] == NULL)
+ return -ENOMEM;
j++;
}
}
- servers[len - 2] = NULL;
+ servers[len - 1] = NULL;
g_strfreev(service->timeservers);
service->timeservers = servers;
void __connman_service_set_pac(struct connman_service *service,
const char *pac)
{
+ if (service->hidden == TRUE)
+ return;
g_free(service->pac);
service->pac = g_strdup(pac);
void __connman_service_set_identity(struct connman_service *service,
const char *identity)
{
- if (service->immutable)
+ if (service->immutable || service->hidden == TRUE)
return;
g_free(service->identity);
void __connman_service_set_agent_identity(struct connman_service *service,
const char *agent_identity)
{
+ if (service->hidden == TRUE)
+ return;
g_free(service->agent_identity);
service->agent_identity = g_strdup(agent_identity);
void __connman_service_set_passphrase(struct connman_service *service,
const char* passphrase)
{
- if (service->immutable == TRUE)
+ if (service->immutable == TRUE || service->hidden == TRUE)
return;
g_free(service->passphrase);
service->passphrase = g_strdup(passphrase);
- passphrase_changed(service);
-
if (service->network != NULL)
connman_network_set_string(service->network,
"WiFi.Passphrase",
void __connman_service_set_agent_passphrase(struct connman_service *service,
const char *agent_passphrase)
{
+ if (service->hidden == TRUE)
+ return;
g_free(service->agent_passphrase);
service->agent_passphrase = g_strdup(agent_passphrase);
autoconnect_changed(service);
service_save(service);
- } else if (g_str_equal(name, "Passphrase") == TRUE) {
- const char *passphrase;
-
- if (type != DBUS_TYPE_STRING)
- return __connman_error_invalid_arguments(msg);
-
- if (service->immutable == TRUE)
- return __connman_error_not_supported(msg);
-
- dbus_message_iter_get_basic(&value, &passphrase);
-
- __connman_service_set_passphrase(service, passphrase);
} else if (g_str_equal(name, "Nameservers.Configuration") == TRUE) {
DBusMessageIter entry;
GString *str;
g_get_current_time(&service->modified);
service_save(service);
- } else if (g_str_equal(name, "Passphrase") == TRUE) {
- if (service->immutable == TRUE)
- return __connman_error_not_supported(msg);
-
- g_free(service->passphrase);
- service->passphrase = NULL;
-
- passphrase_changed(service);
-
- service_save(service);
} else
return __connman_error_invalid_property(msg);
if (service->type == CONNMAN_SERVICE_TYPE_ETHERNET)
return __connman_error_not_supported(msg);
- if (service->immutable == TRUE)
+ if (service->immutable == TRUE || service->hidden == TRUE)
return __connman_error_not_supported(msg);
if (service->favorite == FALSE && service->state !=
g_free(service->passphrase);
service->passphrase = NULL;
- passphrase_changed(service);
-
set_idle(service);
__connman_service_set_favorite(service, FALSE);
g_hash_table_destroy(service->counter_table);
if (service->network != NULL) {
+ __connman_network_disconnect(service->network);
if (service->network_created == TRUE)
connman_network_unref(service->network);
}
{
GSequenceIter *iter;
+ if (service->hidden == TRUE)
+ return -EOPNOTSUPP;
iter = g_hash_table_lookup(service_hash, service->identifier);
if (iter == NULL)
return -ENOENT;
int __connman_service_set_immutable(struct connman_service *service,
connman_bool_t immutable)
{
+ if (service->hidden == TRUE)
+ return -EOPNOTSUPP;
service->immutable = immutable;
immutable_changed(service);
void __connman_service_set_string(struct connman_service *service,
const char *key, const char *value)
{
+ if (service->hidden == TRUE)
+ return;
if (g_str_equal(key, "EAP") == TRUE) {
g_free(service->eap);
service->eap = g_strdup(value);
}
}
+void __connman_service_add_passphrase(struct connman_service *service,
+ const gchar *passphrase)
+{
+ switch (service->security) {
+ case CONNMAN_SERVICE_SECURITY_WEP:
+ case CONNMAN_SERVICE_SECURITY_PSK:
+ __connman_service_set_passphrase(service, passphrase);
+ break;
+ case CONNMAN_SERVICE_SECURITY_8021X:
+ __connman_service_set_agent_passphrase(service,
+ passphrase);
+ break;
+ case CONNMAN_SERVICE_SECURITY_UNKNOWN:
+ case CONNMAN_SERVICE_SECURITY_NONE:
+ case CONNMAN_SERVICE_SECURITY_WPA:
+ case CONNMAN_SERVICE_SECURITY_RSN:
+ DBG("service security '%s' (%d) not handled",
+ security2string(service->security),
+ service->security);
+ break;
+ }
+
+}
+
static void request_input_cb (struct connman_service *service,
+ connman_bool_t values_received,
+ const char *name, int name_len,
const char *identity, const char *passphrase,
void *user_data)
{
+ struct connman_device *device;
+
DBG ("RequestInput return, %p", service);
- if (identity == NULL && passphrase == NULL && service->wps == FALSE) {
+ if (service->hidden == TRUE && name_len > 0 && name_len <= 32) {
+ device = connman_network_get_device(service->network);
+ __connman_device_request_hidden_scan(device,
+ name, name_len,
+ identity, passphrase);
+ }
+
+ if (values_received == FALSE || service->hidden == TRUE) {
service_complete(service);
services_changed(FALSE);
__connman_device_request_scan(CONNMAN_DEVICE_TYPE_UNKNOWN);
if (identity != NULL)
__connman_service_set_agent_identity(service, identity);
- if (passphrase != NULL) {
- switch (service->security) {
- case CONNMAN_SERVICE_SECURITY_WEP:
- case CONNMAN_SERVICE_SECURITY_PSK:
- __connman_service_set_passphrase(service, passphrase);
- break;
- case CONNMAN_SERVICE_SECURITY_8021X:
- __connman_service_set_agent_passphrase(service,
- passphrase);
- break;
- case CONNMAN_SERVICE_SECURITY_UNKNOWN:
- case CONNMAN_SERVICE_SECURITY_NONE:
- case CONNMAN_SERVICE_SECURITY_WPA:
- case CONNMAN_SERVICE_SECURITY_RSN:
- DBG("service security '%s' not handled",
- security2string(service->security));
- break;
- }
- }
+ if (passphrase != NULL)
+ __connman_service_add_passphrase(service, passphrase);
__connman_service_connect(service);
}
if (new_state == CONNMAN_SERVICE_STATE_ONLINE) {
- if (service->login_required == TRUE) {
- service->login_required = FALSE;
- login_changed(service);
- }
-
connman_timeserver_sync();
}
connected_networks_count, original_rp_filter);
}
+static gboolean redo_wispr(gpointer user_data)
+{
+ struct connman_service *service = user_data;
+
+ DBG("");
+
+ __connman_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV6);
+
+ return FALSE;
+}
+
+int __connman_service_online_check_failed(struct connman_service *service,
+ enum connman_ipconfig_type type)
+{
+ DBG("service %p type %d count %d", service, type,
+ service->online_check_count);
+
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+ /* currently we only retry IPv6 stuff */
+ return 0;
+
+ if (service->online_check_count != 1)
+ return 0;
+
+ service->online_check_count = 0;
+
+ /*
+ * We set the timeout to 1 sec so that we have a chance to get
+ * necessary IPv6 router advertisement messages that might have
+ * DNS data etc.
+ */
+ g_timeout_add_seconds(1, redo_wispr, service);
+
+ return EAGAIN;
+}
+
int __connman_service_ipconfig_indicate_state(struct connman_service *service,
enum connman_service_state new_state,
enum connman_ipconfig_type type)
if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
check_proxy_setup(service);
service_rp_filter(service, TRUE);
- } else
+ } else {
+ service->online_check_count = 1;
__connman_wispr_start(service, type);
+ }
break;
case CONNMAN_SERVICE_STATE_ONLINE:
break;
return ret;
}
-int __connman_service_request_login(struct connman_service *service)
-{
- DBG("service %p", service);
-
- if (service == NULL)
- return -EINVAL;
-
- service->login_required = TRUE;
- login_changed(service);
-
- return 0;
-}
-
static connman_bool_t prepare_network(struct connman_service *service)
{
enum connman_network_type type;
{
int err;
+ if (service->hidden == TRUE)
+ return -EPERM;
+
switch (service->type) {
case CONNMAN_SERVICE_TYPE_UNKNOWN:
case CONNMAN_SERVICE_TYPE_SYSTEM:
__connman_provider_disconnect(service->provider);
if (service->userconnect == TRUE) {
- if (err == -ENOKEY) {
+ if (err == -ENOKEY || err == -EPERM) {
if (__connman_agent_request_passphrase_input(service,
request_input_cb,
NULL) == -EIO)
}
/**
- * __connman_service_lookup:
- * @pattern: search pattern
- * @path: return object path
- *
- * Look up a service path from a search pattern
- */
-int __connman_service_lookup(const char *pattern, const char **path)
-{
- GHashTableIter iter;
- gpointer key, value;
- struct connman_device *device;
- const char *ifname;
-
- g_hash_table_iter_init(&iter, service_hash);
-
- while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
- GSequenceIter *iter = value;
- struct connman_service *service = g_sequence_get(iter);
-
- if (g_strcmp0(service->identifier, pattern) == 0 ||
- g_strcmp0(service->name, pattern) == 0) {
- *path = (const char *) service->path;
- return 0;
- }
-
- if (service->network == NULL)
- continue;
-
- device = connman_network_get_device(service->network);
- if (device == NULL)
- continue;
-
- ifname = connman_device_get_string(device, "Interface");
- if (ifname != NULL && g_strcmp0(ifname, pattern) == 0) {
- *path = (const char *) service->path;
- return 0;
- }
-
- }
-
- return -ENXIO;
-}
-
-/**
* lookup_by_identifier:
* @identifier: service identifier
*
return NULL;
}
-static struct connman_network *create_hidden_wifi(struct connman_device *device,
- const char *ssid, const char *mode, const char *security,
- const char *group)
-{
- struct connman_network *network;
- char *name;
- int index;
- unsigned int i, ssid_len;
-
- ssid_len = strlen(ssid);
- if (ssid_len < 1)
- return NULL;
-
- network = connman_network_create(group, CONNMAN_NETWORK_TYPE_WIFI);
- if (network == NULL)
- return NULL;
-
- connman_network_set_blob(network, "WiFi.SSID",
- (unsigned char *) ssid, ssid_len);
-
- connman_network_set_string(network, "WiFi.Mode", mode);
- connman_network_set_string(network, "WiFi.Security", security);
-
- name = g_try_malloc0(ssid_len + 1);
- if (name == NULL) {
- connman_network_unref(network);
- return NULL;
- }
-
- for (i = 0; i < ssid_len; i++) {
- if (g_ascii_isprint(ssid[i]))
- name[i] = ssid[i];
- else
- name[i] = ' ';
- }
-
- connman_network_set_name(network, name);
-
- g_free(name);
-
- index = connman_device_get_index(device);
- connman_network_set_index(network, index);
-
- if (connman_device_add_network(device, network) < 0) {
- connman_network_unref(network);
- return NULL;
- }
-
- connman_network_set_available(network, TRUE);
-
- return network;
-}
-
-int __connman_service_create_and_connect(DBusMessage *msg)
-{
- struct connman_service *service;
- struct connman_network *network;
- struct connman_device *device;
- DBusMessageIter iter, array;
- const char *mode = "managed", *security = "none", *group_security;
- const char *type = NULL, *ssid = NULL, *passphrase = NULL;
- connman_bool_t network_created = FALSE;
- unsigned int ssid_len = 0;
- const char *ident;
- char *name, *group;
- int err;
-
- dbus_message_iter_init(msg, &iter);
- dbus_message_iter_recurse(&iter, &array);
-
- while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter entry, value;
- const char *key;
-
- dbus_message_iter_recurse(&array, &entry);
- dbus_message_iter_get_basic(&entry, &key);
-
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &value);
-
- switch (dbus_message_iter_get_arg_type(&value)) {
- case DBUS_TYPE_STRING:
- if (g_str_equal(key, "Type") == TRUE)
- dbus_message_iter_get_basic(&value, &type);
- else if (g_str_equal(key, "WiFi.Mode") == TRUE ||
- g_str_equal(key, "Mode") == TRUE)
- dbus_message_iter_get_basic(&value, &mode);
- else if (g_str_equal(key, "WiFi.Security") == TRUE ||
- g_str_equal(key, "Security") == TRUE)
- dbus_message_iter_get_basic(&value, &security);
- else if (g_str_equal(key, "WiFi.Passphrase") == TRUE ||
- g_str_equal(key, "Passphrase") == TRUE)
- dbus_message_iter_get_basic(&value, &passphrase);
- else if (g_str_equal(key, "WiFi.SSID") == TRUE ||
- g_str_equal(key, "SSID") == TRUE)
- dbus_message_iter_get_basic(&value, &ssid);
- }
-
- dbus_message_iter_next(&array);
- }
-
- if (type == NULL)
- return -EINVAL;
-
- if (g_strcmp0(type, "wifi") != 0 || g_strcmp0(mode, "managed") != 0)
- return -EOPNOTSUPP;
-
- if (ssid == NULL)
- return -EINVAL;
-
- ssid_len = strlen(ssid);
- if (ssid_len < 1)
- return -EINVAL;
-
- if (g_strcmp0(security, "none") != 0 &&
- g_strcmp0(security, "wep") != 0 &&
- g_strcmp0(security, "psk") != 0 &&
- g_strcmp0(security, "wpa") != 0 &&
- g_strcmp0(security, "rsn") != 0 &&
- g_strcmp0(security, "ieee8021x") != 0)
- return -EINVAL;
-
- device = __connman_device_find_device(CONNMAN_SERVICE_TYPE_WIFI);
- if (device == NULL)
- return -EOPNOTSUPP;
-
- ident = connman_device_get_ident(device);
- if (ident == NULL)
- return -EOPNOTSUPP;
-
-
- if (!g_strcmp0(security, "wpa") ||
- !g_strcmp0(security, "rsn"))
- group_security = "psk";
- else
- group_security = security;
-
- group = wifi_build_group_name((unsigned char *) ssid,
- ssid_len, mode, group_security);
- if (group == NULL)
- return -EINVAL;
-
- name = g_strdup_printf("%s_%s_%s", type, ident, group);
-
- service = lookup_by_identifier(name);
-
- if (service == NULL) {
- network = create_hidden_wifi(device, ssid,
- mode, security, group);
- if (network != NULL) {
- connman_network_set_group(network, group);
- network_created = TRUE;
- }
-
- service = lookup_by_identifier(name);
- }
-
- g_free(name);
- g_free(group);
-
- if (service == NULL) {
- err = -EOPNOTSUPP;
- goto failed;
- }
-
- service->network_created = network_created;
-
- if (is_connected(service) == TRUE) {
- err = -EISCONN;
- goto failed;
- }
-
- if (is_connecting(service) == TRUE) {
- err = -EALREADY;
- goto failed;
- }
-
- set_reconnect_state(service, FALSE);
-
- __connman_device_disconnect(device);
-
- if (passphrase != NULL) {
- g_free(service->passphrase);
- service->passphrase = g_strdup(passphrase);
- }
-
- service->userconnect = TRUE;
-
- err = __connman_service_connect(service);
- if (err < 0 && err != -EINPROGRESS)
- goto failed;
-
- service->pending = dbus_message_ref(msg);
-
- return 0;
-
-failed:
- if (service != NULL && service->network_created == TRUE) {
- struct connman_network *network = service->network;
-
- if (network != NULL) {
- connman_network_set_available(network, FALSE);
- __connman_device_cleanup_networks(device);
- } else
- __connman_service_put(service);
- }
-
- return err;
-}
-
static void provision_changed(gpointer value, gpointer user_data)
{
struct connman_service *service = value;
g_sequence_foreach(service_list, provision_changed, (void *)ident);
}
-int __connman_service_provision(DBusMessage *msg)
-{
- GKeyFile *keyfile = NULL;
- const char *config_str = NULL;
- char *group = NULL, *ident = NULL;
- int err = 0;
- struct connman_service *service;
-
- DBG("");
-
- dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &config_str,
- DBUS_TYPE_INVALID);
-
- if (config_str == NULL || strlen(config_str) == 0)
- return -EINVAL;
-
- keyfile = g_key_file_new();
-
- /* populate GKeyFile with config_str */
- if (g_key_file_load_from_data(keyfile, config_str,
- strlen(config_str), 0, NULL) == FALSE) {
- err = -EINVAL;
- goto done;
- }
-
- /*
- * read only one group of settings (only one service supported, no
- * global settings)
- */
- group = g_key_file_get_start_group(keyfile);
-
- if (group == NULL || g_str_has_prefix(group, "service_") == FALSE) {
- err = -EINVAL;
- goto done;
- }
-
- err = __connman_config_load_service(keyfile, group, TRUE);
- if (err < 0)
- goto done;
-
- ident = group + strlen("service_");
-
- /* trigger service provisioning if service exists */
- service = lookup_by_identifier(ident);
- if (service != NULL)
- __connman_config_provision_service(service);
-
- g_dbus_send_reply(connection, msg, DBUS_TYPE_INVALID);
-
-done:
- if (group != NULL)
- g_free(group);
-
- if (keyfile != NULL)
- g_key_file_free(keyfile);
-
- return err;
-}
-
/**
* __connman_service_get:
* @identifier: service identifier
static void setup_ip4config(struct connman_service *service, int index,
enum connman_ipconfig_method method)
{
- if (index < 0)
- return;
-
service->ipconfig_ipv4 = connman_ipconfig_create(index,
CONNMAN_IPCONFIG_TYPE_IPV4);
if (service->ipconfig_ipv4 == NULL)
static void setup_ip6config(struct connman_service *service, int index)
{
- if (index < 0)
- return;
-
service->ipconfig_ipv6 = connman_ipconfig_create(index,
CONNMAN_IPCONFIG_TYPE_IPV6);
if (service->ipconfig_ipv6 == NULL)