Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via email, send a message with subject or
body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [RFC v0 5/8] iwd: Add Station API support (Daniel Wagner)
2. [RFC v0 7/8] iwd: Add AccessPoint API support (Daniel Wagner)
3. [RFC v0 8/8] iwd: Re-add update_signal_strenght() (Daniel Wagner)
----------------------------------------------------------------------
Date: Wed, 1 Jan 2020 19:47:49 +0100
From: Daniel Wagner <[email protected]>
Subject: [RFC v0 5/8] iwd: Add Station API support
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>
iwd exposes the Station API under the same path as the Device API. Add
the initial D-Bus parsing code to the plugin.
---
plugins/iwd.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 104 insertions(+)
diff --git a/plugins/iwd.c b/plugins/iwd.c
index 94284996a6bb..a76e1550f6c0 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -43,6 +43,7 @@ static GHashTable *adapters;
static GHashTable *devices;
static GHashTable *networks;
static GHashTable *known_networks;
+static GHashTable *stations;
static bool agent_registered;
#define IWD_SERVICE "net.connman.iwd"
@@ -52,6 +53,7 @@ static bool agent_registered;
#define IWD_DEVICE_INTERFACE "net.connman.iwd.Device"
#define IWD_NETWORK_INTERFACE "net.connman.iwd.Network"
#define IWD_KNOWN_NETWORK_INTERFACE "net.connman.iwd.KnownNetwork"
+#define IWD_STATION_INTERFACE "net.connman.iwd.Station"
#define IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
#define IWD_AGENT_ERROR_INTERFACE "net.connman.iwd.Agent.Error"
@@ -103,6 +105,14 @@ struct iwd_known_network {
bool auto_connect;
};
+struct iwd_station {
+ GDBusProxy *proxy;
+ char *path;
+ char *state;
+ char *connected_network;
+ bool scanning;
+};
+
static const char *proxy_get_string(GDBusProxy *proxy, const char *property)
{
DBusMessageIter iter;
@@ -625,6 +635,43 @@ static void network_property_change(GDBusProxy *proxy,
const char *name,
}
}
+static void station_property_change(GDBusProxy *proxy, const char *name,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct iwd_station *iwds;
+ const char *path;
+
+ path = g_dbus_proxy_get_path(proxy);
+ iwds = g_hash_table_lookup(stations, path);
+ if (!iwds)
+ return;
+
+ if (!strcmp(name, "State")) {
+ const char *state;
+
+ dbus_message_iter_get_basic(iter, &state);
+ g_free(iwds->state);
+ iwds->state = g_strdup(state);
+
+ DBG("%s state %s", path, iwds->state);
+ } else if (!strcmp(name, "ConnectedNetwork")) {
+ const char *connected_network;
+
+ dbus_message_iter_get_basic(iter, &connected_network);
+ g_free(iwds->connected_network);
+ iwds->connected_network = g_strdup(connected_network);
+
+ DBG("%s connected_network %s", path, iwds->connected_network);
+ } else if (!strcmp(name, "Scanning")) {
+ dbus_bool_t scanning;
+
+ dbus_message_iter_get_basic(iter, &scanning);
+ iwds->scanning = scanning;
+
+ DBG("%s scanning %d", path, iwds->scanning);
+ }
+}
+
static void adapter_free(gpointer data)
{
struct iwd_adapter *iwda = data;
@@ -693,6 +740,19 @@ static void known_network_free(gpointer data)
g_free(iwdkn);
}
+static void station_free(gpointer data)
+{
+ struct iwd_station *iwds = data;
+
+ if (iwds->proxy) {
+ g_dbus_proxy_unref(iwds->proxy);
+ iwds->proxy = NULL;
+ }
+ g_free(iwds->path);
+ g_free(iwds->connected_network);
+ g_free(iwds);
+}
+
static void create_adapter(GDBusProxy *proxy)
{
const char *path = g_dbus_proxy_get_path(proxy);
@@ -991,6 +1051,39 @@ static void create_know_network(GDBusProxy *proxy)
iwdkn->last_connected_time, iwdkn->auto_connect);
}
+static void create_station(GDBusProxy *proxy)
+{
+ 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->path = g_strdup(path);
+ g_hash_table_replace(stations, iwds->path, iwds);
+
+ iwds->proxy = g_dbus_proxy_ref(proxy);
+
+ if (!iwds->proxy) {
+ connman_error("Cannot create IWD station watcher %s", path);
+ g_hash_table_remove(stations, path);
+ return;
+ }
+
+ iwds->state = g_strdup(proxy_get_string(proxy, "State"));
+ iwds->connected_network = g_strdup(proxy_get_string(proxy,
"ConnectedNetwork"));
+ iwds->scanning = proxy_get_bool(proxy, "Scanning");
+
+ DBG("state '%s' connected_network %s scanning %d",
+ iwds->state, iwds->connected_network, iwds->scanning);
+
+ g_dbus_proxy_set_property_watch(iwds->proxy,
+ station_property_change, NULL);
+}
+
static void object_added(GDBusProxy *proxy, void *user_data)
{
const char *interface;
@@ -1014,6 +1107,8 @@ static void object_added(GDBusProxy *proxy, void
*user_data)
create_network(proxy);
else if (!strcmp(interface, IWD_KNOWN_NETWORK_INTERFACE))
create_know_network(proxy);
+ else if (!strcmp(interface, IWD_STATION_INTERFACE))
+ create_station(proxy);
}
static void object_removed(GDBusProxy *proxy, void *user_data)
@@ -1040,6 +1135,8 @@ static void object_removed(GDBusProxy *proxy, void
*user_data)
g_hash_table_remove(networks, path);
else if (!strcmp(interface, IWD_KNOWN_NETWORK_INTERFACE))
g_hash_table_remove(known_networks, path);
+ else if (!strcmp(interface, IWD_STATION_INTERFACE))
+ g_hash_table_remove(stations, path);
}
static int iwd_init(void)
@@ -1060,6 +1157,9 @@ static int iwd_init(void)
known_networks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
known_network_free);
+ stations = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ station_free);
+
if (connman_technology_driver_register(&tech_driver) < 0) {
connman_warn("Failed to initialize technology for IWD");
goto out;
@@ -1102,6 +1202,9 @@ static int iwd_init(void)
if (known_networks)
g_hash_table_destroy(known_networks);
+ if (stations)
+ g_hash_table_destroy(stations);
+
if (adapters)
g_hash_table_destroy(adapters);
@@ -1119,6 +1222,7 @@ static void iwd_exit(void)
g_dbus_client_unref(client);
+ g_hash_table_destroy(stations);
g_hash_table_destroy(known_networks);
g_hash_table_destroy(networks);
g_hash_table_destroy(devices);
--
2.24.1
------------------------------
Date: Wed, 1 Jan 2020 19:47:51 +0100
From: Daniel Wagner <[email protected]>
Subject: [RFC v0 7/8] iwd: Add AccessPoint API support
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>
iwd exposes the AcessPoint API under the same path as the Device API. Add
the initial D-Bus parsing code to the plugin.
---
plugins/iwd.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/plugins/iwd.c b/plugins/iwd.c
index 7aa64e2e3e87..119ad8caefa9 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -45,6 +45,7 @@ static GHashTable *networks;
static GHashTable *known_networks;
static GHashTable *stations;
static GHashTable *adhocs;
+static GHashTable *access_points;
static bool agent_registered;
#define IWD_SERVICE "net.connman.iwd"
@@ -56,6 +57,7 @@ static bool agent_registered;
#define IWD_KNOWN_NETWORK_INTERFACE "net.connman.iwd.KnownNetwork"
#define IWD_STATION_INTERFACE "net.connman.iwd.Station"
#define IWD_ADHOC_INTERFACE "net.connman.iwd.AdHoc"
+#define IWD_AP_INTERFACE "net.connman.iwd.AccessPoint"
#define IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
#define IWD_AGENT_ERROR_INTERFACE "net.connman.iwd.Agent.Error"
@@ -122,6 +124,12 @@ struct iwd_adhoc {
bool started;
};
+struct iwd_ap {
+ GDBusProxy *proxy;
+ char *path;
+ bool started;
+};
+
static const char *proxy_get_string(GDBusProxy *proxy, const char *property)
{
DBusMessageIter iter;
@@ -704,6 +712,27 @@ static void adhoc_property_change(GDBusProxy *proxy, const
char *name,
}
}
+static void ap_property_change(GDBusProxy *proxy, const char *name,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct iwd_ap *iwdap;
+ const char *path;
+
+ path = g_dbus_proxy_get_path(proxy);
+ iwdap = g_hash_table_lookup(access_points, path);
+ if (!iwdap)
+ return;
+
+ if (!strcmp(name, "Started")) {
+ dbus_bool_t started;
+
+ dbus_message_iter_get_basic(iter, &started);
+ iwdap->started = started;
+
+ DBG("%s started %d", path, iwdap->started);
+ }
+}
+
static void adapter_free(gpointer data)
{
struct iwd_adapter *iwda = data;
@@ -797,6 +826,17 @@ static void adhoc_free(gpointer data)
g_free(iwdah);
}
+static void ap_free(gpointer data)
+{
+ struct iwd_ap *iwdap = data;
+
+ if (iwdap->proxy) {
+ g_dbus_proxy_unref(iwdap->proxy);
+ iwdap->proxy = NULL;
+ }
+ g_free(iwdap);
+}
+
static void create_adapter(GDBusProxy *proxy)
{
const char *path = g_dbus_proxy_get_path(proxy);
@@ -1175,6 +1215,36 @@ static void create_adhoc(GDBusProxy *proxy)
adhoc_property_change, NULL);
}
+static void create_ap(GDBusProxy *proxy)
+{
+ 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->path = g_strdup(path);
+ g_hash_table_replace(access_points, iwdap->path, iwdap);
+
+ iwdap->proxy = g_dbus_proxy_ref(proxy);
+
+ if (!iwdap->proxy) {
+ connman_error("Cannot create IWD access point watcher %s",
path);
+ g_hash_table_remove(access_points, path);
+ return;
+ }
+
+ iwdap->started = proxy_get_bool(proxy, "Started");
+
+ DBG("started %d", iwdap->started);
+
+ g_dbus_proxy_set_property_watch(iwdap->proxy,
+ ap_property_change, NULL);
+}
+
static void object_added(GDBusProxy *proxy, void *user_data)
{
const char *interface;
@@ -1202,6 +1272,8 @@ static void object_added(GDBusProxy *proxy, void
*user_data)
create_station(proxy);
else if (!strcmp(interface, IWD_ADHOC_INTERFACE))
create_adhoc(proxy);
+ else if (!strcmp(interface, IWD_AP_INTERFACE))
+ create_ap(proxy);
}
static void object_removed(GDBusProxy *proxy, void *user_data)
@@ -1232,6 +1304,8 @@ static void object_removed(GDBusProxy *proxy, void
*user_data)
g_hash_table_remove(stations, path);
else if (!strcmp(interface, IWD_ADHOC_INTERFACE))
g_hash_table_remove(adhocs, path);
+ else if (!strcmp(interface, IWD_AP_INTERFACE))
+ g_hash_table_remove(access_points, path);
}
static int iwd_init(void)
@@ -1258,6 +1332,9 @@ static int iwd_init(void)
adhocs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
adhoc_free);
+ access_points = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ ap_free);
+
if (connman_technology_driver_register(&tech_driver) < 0) {
connman_warn("Failed to initialize technology for IWD");
goto out;
@@ -1306,6 +1383,9 @@ static int iwd_init(void)
if (adhocs)
g_hash_table_destroy(adhocs);
+ if (access_points)
+ g_hash_table_destroy(access_points);
+
if (adapters)
g_hash_table_destroy(adapters);
@@ -1323,6 +1403,7 @@ static void iwd_exit(void)
g_dbus_client_unref(client);
+ g_hash_table_destroy(access_points);
g_hash_table_destroy(adhocs);
g_hash_table_destroy(stations);
g_hash_table_destroy(known_networks);
--
2.24.1
------------------------------
Date: Wed, 1 Jan 2020 19:47:52 +0100
From: Daniel Wagner <[email protected]>
Subject: [RFC v0 8/8] iwd: Re-add update_signal_strenght()
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>
Bring back the update_signal_strenght() code.
---
plugins/iwd.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/plugins/iwd.c b/plugins/iwd.c
index 119ad8caefa9..eb5c1a26b854 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -652,6 +652,84 @@ static void network_property_change(GDBusProxy *proxy,
const char *name,
}
}
+static unsigned char calculate_strength(int strength)
+{
+ unsigned char res;
+
+ /*
+ * Network's maximum signal strength expressed in 100 * dBm.
+ * The value is the range of 0 (strongest signal) to -10000
+ * (weakest signal)
+ *
+ * ConnMan expects it in the range from 100 (strongest) to 0
+ * (weakest).
+ */
+ res = (unsigned char)((strength * -10000) / 100);
+
+ return res;
+}
+
+static void _update_signal_strength(const char *path, int16_t signal_strength)
+{
+ struct iwd_station *iwds;
+ struct iwd_network *iwdn;
+
+ iwds = g_hash_table_lookup(stations, path);
+ if (!iwds)
+ return;
+
+ if (!iwds->connected_network)
+ return;
+
+ iwdn = g_hash_table_lookup(networks, iwds->connected_network);
+ if (!iwdn)
+ return;
+
+ connman_network_set_strength(iwdn->network,
+ calculate_strength(signal_strength));
+}
+
+static void ordered_networks_cb(DBusMessage *message, void *user_data)
+{
+ DBusMessageIter array, entry;
+
+ DBG("");
+
+ if (!dbus_message_iter_init(message, &array))
+ return;
+
+ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
+ return;
+
+ dbus_message_iter_recurse(&array, &entry);
+ while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRUCT) {
+ DBusMessageIter value;
+ const char *path;
+ int16_t signal_strength;
+
+
+ dbus_message_iter_recurse(&entry, &value);
+
+ dbus_message_iter_get_basic(&value, &path);
+
+ dbus_message_iter_next(&value);
+ dbus_message_iter_get_basic(&value, &signal_strength);
+
+ _update_signal_strength(path, signal_strength);
+
+ dbus_message_iter_next(&entry);
+ }
+}
+
+static void update_signal_strength(struct iwd_station *iwds)
+{
+ if (!g_dbus_proxy_method_call(iwds->proxy,
+ "GetOrderedNetworks",
+ NULL, ordered_networks_cb,
+ NULL, NULL))
+ DBG("GetOrderedNetworks() failed");
+}
+
static void station_property_change(GDBusProxy *proxy, const char *name,
DBusMessageIter *iter, void *user_data)
{
@@ -685,6 +763,9 @@ static void station_property_change(GDBusProxy *proxy,
const char *name,
dbus_message_iter_get_basic(iter, &scanning);
iwds->scanning = scanning;
+ if (!iwds->scanning)
+ update_signal_strength(iwds);
+
DBG("%s scanning %d", path, iwds->scanning);
}
}
--
2.24.1
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list -- [email protected]
To unsubscribe send an email to [email protected]
------------------------------
End of connman Digest, Vol 51, Issue 3
**************************************