static void update_network_connected(struct iwd_network *iwdn)
{
struct iwd_device *iwdd;
- int index;
iwdd = g_hash_table_lookup(devices, iwdn->device);
if (!iwdd)
return;
- index = connman_inet_ifindex(iwdd->name);
- if (index < 0)
- return;
-
- DBG("interface name %s index %d", iwdd->name, index);
- connman_network_set_index(iwdn->network, index);
+ DBG("interface name %s index %d", iwdd->name,
+ connman_network_get_index(iwdn->network));
connman_network_set_connected(iwdn->network, true);
}
if (!iwds)
return -EIO;
+ connman_network_set_associating(network, false);
+
if (!g_dbus_proxy_method_call(iwds->proxy, "Disconnect",
NULL, cm_network_disconnect_cb, g_strdup(iwdn->path), g_free))
return -EIO;
- return -EINPROGRESS;
+ return 0;
}
struct auto_connect_cb_data {
const char *path = user_data;
struct iwd_station *iwds;
- iwds = g_hash_table_lookup(networks, path);
+ iwds = g_hash_table_lookup(stations, path);
if (!iwds)
return;
}
static int cm_tech_tethering(struct connman_technology *technology,
- const char *identifier, const char *passphrase,
const char *bridge, bool enabled)
{
GHashTableIter iter;
gpointer key, value;
int err = 0, res;
+ const char *ssid;
+ const char *psk;
+ int freq;
+
+ connman_technology_get_wifi_tethering(technology, &ssid, &psk, &freq);
g_hash_table_iter_init(&iter, devices);
continue;
if (!enabled && !g_strcmp0("ap", iwdd->mode)) {
- res = cm_change_tethering(iwdd, technology, identifier,
- passphrase, bridge, enabled);
+ res = cm_change_tethering(iwdd, technology, ssid,
+ psk, bridge, enabled);
if (res)
connman_warn("%s switching to Station mode failed",
iwdd->path);
}
if (enabled && !g_strcmp0("station", iwdd->mode)) {
- err = cm_change_tethering(iwdd, technology, identifier,
- passphrase, bridge, enabled);
+ err = cm_change_tethering(iwdd, technology, ssid,
+ psk, bridge, enabled);
if (err)
connman_warn("%s switching to AccessPoint mode failed",
iwdd->path);
{
struct iwd_device *iwdd;
char *identifier;
+ int index;
iwdd = g_hash_table_lookup(devices, iwdn->device);
if (!iwdd)
identifier = create_identifier(path, iwdn->type);
iwdn->network = connman_network_create(identifier,
CONNMAN_NETWORK_TYPE_WIFI);
+
+ index = connman_inet_ifindex(iwdd->name);
+ if (index >= 0)
+ connman_network_set_index(iwdn->network, index);
+
connman_network_set_data(iwdn->network, iwdn);
connman_network_set_name(iwdn->network, iwdn->name);
}
iwdn->iwdd = iwdd;
- connman_network_set_available(iwdn->network, true);
+ if (connman_network_get_strength(iwdn->network))
+ connman_network_set_available(iwdn->network, true);
+
connman_network_set_group(iwdn->network, identifier);
g_free(identifier);
struct iwd_adapter *iwda;
GSList *modes, *list;
- iwda = g_try_new0(struct iwd_adapter, 1);
-
- if (!iwda) {
- connman_error("Out of memory creating IWD adapter");
- return;
- }
-
+ iwda = g_new0(struct iwd_adapter, 1);
iwda->path = g_strdup(path);
g_hash_table_replace(adapters, iwda->path, iwda);
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_device *iwdd;
- iwdd = g_try_new0(struct iwd_device, 1);
-
- if (!iwdd) {
- connman_error("Out of memory creating IWD device");
- return;
- }
-
+ iwdd = g_new0(struct iwd_device, 1);
iwdd->path = g_strdup(path);
g_hash_table_replace(devices, iwdd->path, iwdd);
return get_reply_on_error(message, EINVAL);
passwd = connman_network_get_string(iwdn->network, "WiFi.Passphrase");
+ if (!passwd)
+ return get_reply_on_error(message, ENOKEY);
return g_dbus_create_reply(message, DBUS_TYPE_STRING, &passwd,
DBUS_TYPE_INVALID);
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_network *iwdn;
- iwdn = g_try_new0(struct iwd_network, 1);
-
- if (!iwdn) {
- connman_error("Out of memory creating IWD network");
- return;
- }
-
+ iwdn = g_new0(struct iwd_network, 1);
iwdn->path = g_strdup(path);
g_hash_table_replace(networks, iwdn->path, iwdn);
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_known_network *iwdkn;
- iwdkn = g_try_new0(struct iwd_known_network, 1);
- if (!iwdkn) {
- connman_error("Out of memory creating IWD known network");
- return;
- }
-
+ iwdkn = g_new0(struct iwd_known_network, 1);
iwdkn->path = g_strdup(path);
g_hash_table_replace(known_networks, iwdkn->path, iwdkn);
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_station *iwds;
- iwds = g_try_new0(struct iwd_station, 1);
- if (!iwds) {
- connman_error("Out of memory creating IWD station");
- return;
- }
-
+ iwds = g_new0(struct iwd_station, 1);
iwds->path = g_strdup(path);
g_hash_table_replace(stations, iwds->path, iwds);
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_ap *iwdap;
- iwdap = g_try_new0(struct iwd_ap, 1);
- if (!iwdap) {
- connman_error("Out of memory creating IWD access point");
- return;
- }
+ iwdap = g_new0(struct iwd_ap, 1);
iwdap->index = -1;
iwdap->path = g_strdup(path);