Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, 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. [PATCH 1/6] tethering: Add storage where tethering client can
be registered (Vasyl Vavrychuk)
2. [PATCH 2/6] manager: Expose tethering clients list via D-Bus
API (Vasyl Vavrychuk)
3. [PATCH 3/6] manager: Add notification of tethering clients
list change (Vasyl Vavrychuk)
4. [PATCH 4/6] client: Add tethering_clients commands that
returns list of them (Vasyl Vavrychuk)
----------------------------------------------------------------------
Message: 1
Date: Fri, 23 Nov 2018 01:36:27 +0200
From: Vasyl Vavrychuk <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>, Vasyl Vavrychuk
<[email protected]>
Subject: [PATCH 1/6] tethering: Add storage where tethering client can
be registered
Message-ID: <[email protected]>
This list will be exposed to clients of connman.
It is supposed to be filled in connman plugins.
---
Makefile.am | 2 +-
include/tethering.h | 37 +++++++++++++++++++++++++++++++++++++
src/connman.h | 2 ++
src/tethering.c | 32 ++++++++++++++++++++++++++++++++
4 files changed, 72 insertions(+), 1 deletion(-)
create mode 100644 include/tethering.h
diff --git a/Makefile.am b/Makefile.am
index d6dfbf1c..8ab59eb1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,7 +12,7 @@ include_HEADERS = include/log.h include/plugin.h \
include/storage.h include/provision.h \
include/session.h include/ipaddress.h include/agent.h \
include/inotify.h include/peer.h include/machine.h \
- include/acd.h
+ include/acd.h include/tethering.h
nodist_include_HEADERS = include/version.h
diff --git a/include/tethering.h b/include/tethering.h
new file mode 100644
index 00000000..827f29af
--- /dev/null
+++ b/include/tethering.h
@@ -0,0 +1,37 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007-2013 Intel Corporation. All rights reserved.
+ * Copyright (C) 2018 GlobalLogic. 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __CONNMAN_TETHERING_H
+#define __CONNMAN_TETHERING_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void __connman_tethering_client_register(const char *addr);
+void __connman_tethering_client_unregister(const char *addr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONNMAN_TETHERING_H */
diff --git a/src/connman.h b/src/connman.h
index c4190fd0..4c7dc55a 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -630,6 +630,8 @@ bool __connman_config_get_bool(GKeyFile *key_file,
bool __connman_config_address_provisioned(const char *address,
const char *netmask);
+#include <connman/tethering.h>
+
int __connman_tethering_init(void);
void __connman_tethering_cleanup(void);
diff --git a/src/tethering.c b/src/tethering.c
index d222afca..e3f19da6 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -61,6 +61,8 @@ static struct connman_ippool *dhcp_ippool = NULL;
static DBusConnection *connection;
static GHashTable *pn_hash;
+static GHashTable *clients_table;
+
struct connman_private_network {
char *owner;
char *path;
@@ -181,6 +183,18 @@ static void tethering_restart(struct connman_ippool *pool,
void *user_data)
__connman_tethering_set_enabled();
}
+static void unregister_client(gpointer key,
+ gpointer value, gpointer user_data)
+{
+ const char *addr = key;
+ __connman_tethering_client_unregister(addr);
+}
+
+static void unregister_all_clients(void)
+{
+ g_hash_table_foreach(clients_table, unregister_client, NULL);
+}
+
int __connman_tethering_set_enabled(void)
{
int index;
@@ -301,6 +315,8 @@ void __connman_tethering_set_disabled(void)
if (__sync_fetch_and_sub(&tethering_enabled, 1) != 1)
return;
+ unregister_all_clients();
+
__connman_ipv6pd_cleanup();
index = connman_inet_ifindex(BRIDGE_NAME);
@@ -529,6 +545,16 @@ int __connman_private_network_release(const char *path)
return 0;
}
+void __connman_tethering_client_register(const char *addr)
+{
+ g_hash_table_insert(clients_table, g_strdup(addr), NULL);
+}
+
+void __connman_tethering_client_unregister(const char *addr)
+{
+ g_hash_table_remove(clients_table, addr);
+}
+
int __connman_tethering_init(void)
{
DBG("");
@@ -542,6 +568,8 @@ int __connman_tethering_init(void)
pn_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, remove_private_network);
+ clients_table = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
return 0;
}
@@ -562,5 +590,9 @@ void __connman_tethering_cleanup(void)
return;
g_hash_table_destroy(pn_hash);
+
+ g_hash_table_destroy(clients_table);
+ clients_table = NULL;
+
dbus_connection_unref(connection);
}
--
2.19.1
------------------------------
Message: 2
Date: Fri, 23 Nov 2018 01:36:28 +0200
From: Vasyl Vavrychuk <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>, Vasyl Vavrychuk
<[email protected]>
Subject: [PATCH 2/6] manager: Expose tethering clients list via D-Bus
API
Message-ID: <[email protected]>
---
doc/manager-api.txt | 5 +++++
src/connman.h | 1 +
src/manager.c | 24 ++++++++++++++++++++++++
src/tethering.c | 15 +++++++++++++++
4 files changed, 45 insertions(+)
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index 2d2739ff..4485921d 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -46,6 +46,11 @@ Methods dict GetProperties()
Possible Errors: [service].Error.InvalidArguments
+ array{string} GetTetheringClients() [experimental]
+
+ Returns a sorted list of MAC addresses of clients
+ connected to tethered technologies.
+
object ConnectProvider(dict provider) [deprecated]
Connect to a VPN specified by the given provider
diff --git a/src/connman.h b/src/connman.h
index 4c7dc55a..761812cd 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -638,6 +638,7 @@ void __connman_tethering_cleanup(void);
const char *__connman_tethering_get_bridge(void);
int __connman_tethering_set_enabled(void);
void __connman_tethering_set_disabled(void);
+void __connman_tethering_list_clients(DBusMessageIter *array);
int __connman_private_network_request(DBusMessage *msg, const char *owner);
int __connman_private_network_release(const char *path);
diff --git a/src/manager.c b/src/manager.c
index dc2e0621..3bf8f4e4 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -214,6 +214,27 @@ static DBusMessage *get_peers(DBusConnection *conn,
return reply;
}
+static DBusMessage *get_tethering_clients(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter, array;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &array);
+
+ __connman_tethering_list_clients(&array);
+
+ dbus_message_iter_close_container(&iter, &array);
+ return reply;
+}
+
static DBusMessage *connect_provider(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -519,6 +540,9 @@ static const GDBusMethodTable manager_methods[] = {
{ GDBUS_METHOD("GetPeers",
NULL, GDBUS_ARGS({ "peers", "a(oa{sv})" }),
get_peers) },
+ { GDBUS_METHOD("GetTetheringClients",
+ NULL, GDBUS_ARGS({ "tethering_clients", "as" }),
+ get_tethering_clients) },
{ GDBUS_DEPRECATED_ASYNC_METHOD("ConnectProvider",
GDBUS_ARGS({ "provider", "a{sv}" }),
GDBUS_ARGS({ "path", "o" }),
diff --git a/src/tethering.c b/src/tethering.c
index e3f19da6..54e9df21 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -343,6 +343,21 @@ void __connman_tethering_set_disabled(void)
DBG("tethering stopped");
}
+static void append_client(gpointer key, gpointer value,
+ gpointer user_data)
+{
+ const char *addr = key;
+ DBusMessageIter *array = user_data;
+
+ dbus_message_iter_append_basic(array, DBUS_TYPE_STRING,
+ &addr);
+}
+
+void __connman_tethering_list_clients(DBusMessageIter *array)
+{
+ g_hash_table_foreach(clients_table, append_client, array);
+}
+
static void setup_tun_interface(unsigned int flags, unsigned change,
void *data)
{
--
2.19.1
------------------------------
Message: 3
Date: Fri, 23 Nov 2018 01:36:29 +0200
From: Vasyl Vavrychuk <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>, Vasyl Vavrychuk
<[email protected]>
Subject: [PATCH 3/6] manager: Add notification of tethering clients
list change
Message-ID: <[email protected]>
---
doc/manager-api.txt | 7 ++++
src/tethering.c | 79 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+)
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index 4485921d..bfb07bd3 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -260,6 +260,13 @@ Signals TechnologyAdded(object path, dict
properties)
object changes. For that it is required to watch the
PropertyChanged signal of the peer object.
+ TetheringClientsChanged(array{string}, array{string})
[experimental]
+
+ This signal indicates a change in the tethering clients.
+ List of all tethering clients currently registered
connman is
+ passed via the first array. And a list of tethering
clients that
+ have been removed via the second array.
+
PropertyChanged(string name, variant value)
This signal indicates a changed value of the given
diff --git a/src/tethering.c b/src/tethering.c
index 54e9df21..e04756ff 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -63,6 +63,11 @@ static GHashTable *pn_hash;
static GHashTable *clients_table;
+struct _clients_notify {
+ int id;
+ GHashTable *remove;
+} *clients_notify;
+
struct connman_private_network {
char *owner;
char *path;
@@ -471,6 +476,70 @@ static void ippool_disconnect(struct connman_ippool *pool,
void *user_data)
g_hash_table_remove(pn_hash, pn->path);
}
+static gboolean client_send_changed(gpointer data)
+{
+ DBusMessage *signal;
+ DBusMessageIter iter, array;
+
+ DBG("");
+
+ clients_notify->id = 0;
+
+ signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE,
"TetheringClientsChanged");
+ if (!signal)
+ return FALSE;
+
+ dbus_message_iter_init_append(signal, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &array);
+
+ g_hash_table_foreach(clients_table, append_client, &array);
+
+ dbus_message_iter_close_container(&iter, &array);
+
+ dbus_message_iter_init_append(signal, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &array);
+
+ g_hash_table_foreach(clients_notify->remove, append_client, &array);
+
+ dbus_message_iter_close_container(&iter, &array);
+
+ dbus_connection_send(connection, signal, NULL);
+ dbus_message_unref(signal);
+
+ g_hash_table_remove_all(clients_notify->remove);
+
+ return FALSE;
+}
+
+static void client_schedule_changed(void)
+{
+ if (clients_notify->id != 0)
+ return;
+
+ clients_notify->id = g_timeout_add(100, client_send_changed, NULL);
+}
+
+static void client_added(const char *addr)
+{
+ DBG("client %s", addr);
+
+ g_hash_table_remove(clients_notify->remove, addr);
+
+ client_schedule_changed();
+}
+
+static void client_removed(const char *addr)
+{
+ DBG("client %s", addr);
+
+ g_hash_table_replace(clients_notify->remove, g_strdup(addr), NULL);
+
+ client_schedule_changed();
+}
+
int __connman_private_network_request(DBusMessage *msg, const char *owner)
{
struct connman_private_network *pn;
@@ -563,11 +632,13 @@ int __connman_private_network_release(const char *path)
void __connman_tethering_client_register(const char *addr)
{
g_hash_table_insert(clients_table, g_strdup(addr), NULL);
+ client_added(addr);
}
void __connman_tethering_client_unregister(const char *addr)
{
g_hash_table_remove(clients_table, addr);
+ client_removed(addr);
}
int __connman_tethering_init(void)
@@ -585,6 +656,10 @@ int __connman_tethering_init(void)
clients_table = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
+
+ clients_notify = g_new0(struct _clients_notify, 1);
+ clients_notify->remove = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
return 0;
}
@@ -606,6 +681,10 @@ void __connman_tethering_cleanup(void)
g_hash_table_destroy(pn_hash);
+ g_hash_table_destroy(clients_notify->remove);
+ g_free(clients_notify);
+ clients_notify = NULL;
+
g_hash_table_destroy(clients_table);
clients_table = NULL;
--
2.19.1
------------------------------
Message: 4
Date: Fri, 23 Nov 2018 01:36:30 +0200
From: Vasyl Vavrychuk <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>, Vasyl Vavrychuk
<[email protected]>
Subject: [PATCH 4/6] client: Add tethering_clients commands that
returns list of them
Message-ID: <[email protected]>
List items are MAC addresses of tethering clients.
---
Makefile.am | 1 +
client/commands.c | 26 +++++++++++++++++++
client/tethering.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
client/tethering.h | 39 ++++++++++++++++++++++++++++
4 files changed, 129 insertions(+)
create mode 100644 client/tethering.c
create mode 100644 client/tethering.h
diff --git a/Makefile.am b/Makefile.am
index 8ab59eb1..4614cb90 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -308,6 +308,7 @@ client_connmanctl_SOURCES = client/dbus_helpers.h
client/dbus_helpers.c \
client/input.h client/input.c \
client/agent.h client/agent.c \
client/peers.h client/peers.c \
+ client/tethering.h client/tethering.c \
client/vpnconnections.h client/vpnconnections.c \
client/main.c
diff --git a/client/commands.c b/client/commands.c
index bf3531fd..097d293a 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -39,6 +39,7 @@
#include "dbus_helpers.h"
#include "input.h"
#include "services.h"
+#include "tethering.h"
#include "peers.h"
#include "commands.h"
#include "agent.h"
@@ -318,6 +319,18 @@ static int peers_list(DBusMessageIter *iter,
return 0;
}
+static int tethering_clients_list(DBusMessageIter *iter,
+ const char *error, void *user_data)
+{
+ if (!error) {
+ __connmanctl_tethering_clients_list(iter);
+ fprintf(stdout, "\n");
+ } else
+ fprintf(stderr, "Error: %s\n", error);
+
+ return 0;
+}
+
static int object_properties(DBusMessageIter *iter,
const char *error, void *user_data)
{
@@ -639,6 +652,17 @@ static int cmd_tether(char *args[], int num, struct
connman_option *options)
return tether_set(args[1], set_tethering);
}
+static int cmd_tethering_clients(char *args[], int num, struct connman_option
*options)
+{
+ if (num > 1)
+ return -E2BIG;
+
+ return __connmanctl_dbus_method_call(connection,
+ CONNMAN_SERVICE, CONNMAN_PATH,
+ "net.connman.Manager", "GetTetheringClients",
+ tethering_clients_list, NULL, NULL, NULL);
+}
+
static int scan_return(DBusMessageIter *iter, const char *error,
void *user_data)
{
@@ -2730,6 +2754,8 @@ static const struct {
NULL, cmd_tether,
"Enable, disable tethering, set SSID and passphrase for wifi",
lookup_tether },
+ { "tethering_clients", NULL, NULL,
cmd_tethering_clients,
+ "Display tethering clients", NULL },
{ "services", "[<service>]", service_options, cmd_services,
"Display services", lookup_service_arg },
{ "peers", "[peer]", NULL, cmd_peers,
diff --git a/client/tethering.c b/client/tethering.c
new file mode 100644
index 00000000..361189be
--- /dev/null
+++ b/client/tethering.c
@@ -0,0 +1,63 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ * Copyright (C) 2018 GlobalLogic. 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 as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <stdio.h>
+
+#include "tethering.h"
+
+void __connmanctl_tethering_clients_list(DBusMessageIter *iter)
+{
+ DBusMessageIter array;
+ char *addr = NULL;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
+ return;
+
+ dbus_message_iter_recurse(iter, &array);
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&array, &addr);
+
+ fprintf(stdout, "%s", addr);
+
+ if (dbus_message_iter_has_next(&array))
+ fprintf(stdout, "\n");
+
+ dbus_message_iter_next(&array);
+ }
+
+ dbus_message_iter_next(iter);
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
+ return;
+
+ dbus_message_iter_recurse(iter, &array);
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&array, &addr);
+
+ fprintf(stdout, "\n%s %s", "removed", addr);
+
+ if (dbus_message_iter_has_next(&array))
+ fprintf(stdout, "\n");
+
+ dbus_message_iter_next(&array);
+ }
+}
diff --git a/client/tethering.h b/client/tethering.h
new file mode 100644
index 00000000..6135e3c5
--- /dev/null
+++ b/client/tethering.h
@@ -0,0 +1,39 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ * Copyright (C) 2018 GlobalLogic. 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 as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __CONNMANCTL_TETHERING_H
+#define __CONNMANCTL_TETHERING_H
+
+#include <dbus/dbus.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void __connmanctl_tethering_clients_list(DBusMessageIter *iter);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONNMANCTL_TETHERING_H */
--
2.19.1
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 37, Issue 10
***************************************