[PATCH] Fix gsupplicant not to fail an active scan on wpa_supplicant side
by Володимир Остап
he issue has been discovered during work on other issue
https://lists.01.org/pipermail/connman/2018-November/023085.html
If connman does ACTIVE scan without adding a list of SSIDs
interface_scan_params() in gsupplicant/supplicant.c calls
supplicant_dbus_dict_append_array(&dict, "SSIDs",
DBUS_TYPE_STRING,
append_ssids,
data->scan_params);
which creates an empty entry for "SSIDs" without anything inside.
This dbus msg goes to wpa supplicant to dbus/dbus_new_handles.c to
wpas_dbus_handler_scan() which calls wpas_dbus_get_scan_ssids() because
there is an entry "SSIDs".
Unfortunately wpas_dbus_get_scan_ssids() fails with an error.
Here are my logs:
Nov 17 03:09:10 LogiCircle daemon.debug wpa_supplicant[344]:
wpas_dbus_get_scan_ssids[dbus]: ssids must be an array of arrays of bytes
Nov 17 03:09:10 LogiCircle daemon.debug wpa_supplicant[344]:
wpas_dbus_get_scan_ssids[dbus]: ssids must be an array of arrays of bytes
Nov 17 03:09:10 LogiCircle daemon.debug wpa_supplicant[344]:
wpas_dbus_get_scan_ssids[dbus]: ssids must be an array of arrays of bytes
Nov 17 03:17:06 LogiCircle daemon.debug wpa_supplicant[344]:
wpas_dbus_get_scan_ssids[dbus]: ssids must be an array of arrays of bytes
Nov 17 03:17:06 LogiCircle daemon.debug wpa_supplicant[344]:
wpas_dbus_get_scan_ssids[dbus]: ssids must be an array of arrays of bytes
Nov 17 03:17:06 LogiCircle daemon.debug wpa_supplicant[344]:
wpas_dbus_get_scan_ssids[dbus]: ssids must be an array of arrays of bytes
The patch below is very simple. If there is no SSID in scan_parameters do
not create "SSIDs". The adjacent function supplicant_add_scan_frequency()
does such verification and does not create any empty "Channels".
==============================
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 0cb621b9..92941c63 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4241,11 +4241,13 @@ static void interface_scan_params(DBusMessageIter
*iter, void *user_data)
supplicant_dbus_dict_append_basic(&dict, "Type",
DBUS_TYPE_STRING, &type);
- supplicant_dbus_dict_append_array(&dict, "SSIDs",
- DBUS_TYPE_STRING,
- append_ssids,
- data->scan_params);
+ if (data->scan_params->ssids) {
+ supplicant_dbus_dict_append_array(&dict, "SSIDs",
+ DBUS_TYPE_STRING,
+ append_ssids,
+ data->scan_params);
+ }
supplicant_add_scan_frequency(&dict, add_scan_frequencies,
data->scan_params);
} else
PS. I sent this patch from other unregistered email. I hope there is not
going to be any duplicate.
2 years, 4 months
[PATCH] Force simple wifi scan over dbus Scan
by Володимир Остап
Hi,
I am using connman for wifi connection and it is controlled over dbus. The
system supports many wifi connections. The user can remove and add a
connection.
If there are saved connections and wifi is currently disconnected and
connman is asked over dbus to do a scan it falls into the scan on channels
retrieved from the saved services.
So user sees only APs on these channels.
There is a commit which addressed a similar issue but when there is an
active connection
7f87a34f85f73585f3a5bc0e857144810b928513
There is a ticket https://01.org/jira/browse/CM-602 which describes similar
symptoms but a different root cause.
The patch forces wifi device do a simple scan if the scan is originated
over dbus. In this case wpa_supplicant will do a scan on all channels.
Best wishes, Volodymyr Ostap
2 years, 4 months
[PATCH 0/5] Add iptables IPv6 support
by Jussi Laakkonen
This patch set adds support for IPv6 iptables management into iptables.c.
Managing IPv6 iptables content differs only from the structure definition
parts so most of the IPv6 support is included into existing code.
For each iptables.c exposed function a type variable has been added, which
indicates the IP protocol type. Common AF_* definitions are used (AF_INET &
AF_INET6) as types.
Necessary changes for firewall-iptables.c and iptables-unit.c are applied.
Also a tool for testing ip6tables functionality is implemented as a copy of
the existing iptables-test.
NAT tests for IPv6 are not included into unit tests as IPv6 NAT functionality
is not implemented within this work.
Jussi Laakkonen (5):
iptables: Use xt_error_target when adding new rules and chains.
iptables: Replace ALIGN macro with XT_ALIGN macro.
iptables: Introduce IPv6 iptables management.
firewall: Adapt to iptables.c changes.
test: Add tests and test tool for IPv6 parts of iptables.c.
Makefile.am | 9 +-
configure.ac | 5 +
src/connman.h | 54 +-
src/firewall-iptables.c | 42 +-
src/iptables.c | 2223 ++++++++++++++++++++++++++++++++-------
tools/ip6tables-test.c | 163 +++
tools/iptables-test.c | 19 +-
tools/iptables-unit.c | 486 +++++++--
8 files changed, 2457 insertions(+), 544 deletions(-)
create mode 100644 tools/ip6tables-test.c
--
2.19.1
2 years, 4 months
[PATCH] iptables: Set protocol family in xtables setup.
by Jussi Laakkonen
This commit fixes the issue of not being able to set some IPv6 rules
after IPv4 rules with matches have been set (or the other way around).
The family for the matches has to be also updated when changing between
IP protocols.
---
src/iptables.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/iptables.c b/src/iptables.c
index 305a553f..a188f99a 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -3330,6 +3330,7 @@ static int current_type = -1;
static int setup_xtables(int type)
{
int err;
+ struct xtables_match *xt_m;
DBG("%d", type);
@@ -3351,6 +3352,13 @@ static int setup_xtables(int type)
}
if (!err) {
+ /*
+ * Set the match type, otherwise loading of matches in xtables
+ * will fail.
+ */
+ for (xt_m = xtables_matches; xt_m; xt_m = xt_m->next)
+ xt_m->family = type;
+
current_type = type;
} else {
connman_error("error initializing xtables");
--
2.19.1
2 years, 4 months
hidden ssid connection when service path is unknow
by Alexandre Leblanc
Hello everyone
I'm trying do develop a small wrapper around connmam mostly using dbus and python. Everything work fine yet.
Managing hidden network is a bit of an issue.
The wrapper will be use in an environment where there will be a lot of hidden network (not for security reason...)
and only the ssid Name will be known.
So how would one identity the right service to connect to ?
Using my wrapper I can already see hidden network path.
I already know that my agent will handle the ssid Name when a connection request is done.
Should I simply try connect to all of them ?
Thank you very much !
Alexandre Leblanc
Free Software Consultant | Montreal, Qc
Savoir-faire Linux
Office: (+ 1) 514 276-5468 ext.377
Confidentiality Message: This communication (including any files transmitted with it) is intended solely for the person or entity to whom it is addressed, and may contain confidential or privileged information.
The disclosure, distribution or copying of this message is strictly forbidden. Should you have received this communication in error, kindly contact the sender promptly, destroy any copies and delete this message from your computer system.
2 years, 4 months
Configuration file issues
by Nuno Gonçalves
Hi,
I've noticed 2 issues in the handling of the configuration file on Connman
1.36.
I have 2 ethernet devices at this device. I have not applied any
configuration so they default to DHCP on IPv4. Immutable is False for
both as expected.
I create a configuration file without a MAC address specified:
$ cat /var/lib/connman/010203040506.config
[service_config]
Type = ethernet
IPv4 = 192.168.1.107/255.255.255.0/192.168.1.1
After I commit this file both ethernet interfaces get the address
192.168.1.107 and they both display Immutable=True.
This could actually be expected, since I do not specify to which
interface I want my configuration to apply. But documentation says:
- MAC: MAC address of the interface where this setting should be applied.
The MAC address is optional and if it is missing, then the first found
interface is used.
So according to this the configuration should only apply to once interface.
The second issue happens when I remove /var/lib/connman/010203040506.config,
Connman at this time does not reset the interfaces to the default
configuration and instead they become unconfigured:
$ connmanctl services ethernet_(...1...)_cable
...
State = idle
Favorite = True
Immutable = False
AutoConnect = True
...
IPv4 = [ ]
IPv4.Configuration = [ ]
...
$ connmanctl services ethernet_(...2...)_cable
...
State = idle
Favorite = True
Immutable = False
AutoConnect = True
...
IPv4 = [ ]
IPv4.Configuration = [ ]
...
Thanks,
Nuno
2 years, 4 months
[PATCH 1/6] tethering: Add storage where tethering client can be registered
by Vasyl Vavrychuk
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
2 years, 4 months
Wifi connection make tether interface disappear (USB Gadget)
by Lao Hu
Hello,
An embedded device with ethernet, usb-otg and wifi is running connman.
1.- [OK] When the ethernet cable is plugged in, an IP (192.168.0.39) is
assigned to eth0.
2.- [OK] When the usb-otg is connected to the host, an IP (192.168.0.2) is
assigned to usb0 (wifi and ethernet are disconnected).
3.- [?] When the wifi is connected,tether disappear in the device (ifconfig
-a) and the system console show the following message:
Connected wifi_50338b6692d8_636173697461_managed_psk
...
tether: port 1(usb0) entered disabled state
device usb0 left promiscuous mode
tether: port 1(usb0) entered disabled state
About the item #3, I tried to find info related with this case, but not
success. Please, may I know if is possible to to have the device connected
to wifi (or ethernet) and the host connected to the device using usb0 at
the same time?
Perhaps, I'm missing some basic concepts, in that case, any comment or
suggestion will be appreciated as well.
Thanks
Lao Hu
---
cat /etc/connman/main.conf
[General]
PersistentTetheringMode=true
TetheringTechnologies=gadget
---
cat /var/lib/connman/settings
[global]
OfflineMode=false
Description=device network configuration
[Wired]
Enable=true
Tethering=false
[WiFi]
Enable=true
Tethering=false
[Bluetooth]
Enable=true
Tethering=false
[Gadget]
Enable=true
Tethering=true
[P2P]
Enable=false
Tethering=false
2 years, 4 months
[PATCH] wifi: implemented feature of tracking tethering clients
by Vasyl Vavrychuk
wpa_supplicant supports StaAuthorized StaDeauthorized D-Bus signal that
we handle and store information. Then stored information about connected
tethering clients is exposed via GetTetheringClients method and
TetheringClientsChanged signal of manager.
---
Makefile.am | 3 +-
client/commands.c | 27 ++++++++
client/tethering.c | 62 +++++++++++++++++++
client/tethering.h | 38 ++++++++++++
doc/manager-api.txt | 12 ++++
gsupplicant/gsupplicant.h | 4 ++
gsupplicant/supplicant.c | 64 +++++++++++++++++++
include/tethering.h | 36 +++++++++++
plugins/wifi.c | 29 +++++++++
src/connman.h | 3 +
src/manager.c | 24 ++++++++
src/tethering.c | 126 ++++++++++++++++++++++++++++++++++++++
12 files changed, 427 insertions(+), 1 deletion(-)
create mode 100644 client/tethering.c
create mode 100644 client/tethering.h
create mode 100644 include/tethering.h
diff --git a/Makefile.am b/Makefile.am
index d6dfbf1c..4614cb90 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
@@ -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..26d2c509 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -318,6 +318,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 +651,19 @@ 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)
+{
+ char *path;
+
+ 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 +2755,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..ce3688a4
--- /dev/null
+++ b/client/tethering.c
@@ -0,0 +1,62 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2014 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 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..c6b58de1
--- /dev/null
+++ b/client/tethering.h
@@ -0,0 +1,38 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2014 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 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 */
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index 2d2739ff..bfb07bd3 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
@@ -255,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/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index db61595b..bfb52db7 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -352,6 +352,10 @@ struct _GSupplicantCallbacks {
void (*network_changed) (GSupplicantNetwork *network,
const char *property);
void (*network_associated) (GSupplicantNetwork *network);
+ void (*sta_authorized) (GSupplicantInterface *interface,
+ const char *addr);
+ void (*sta_deauthorized) (GSupplicantInterface *interface,
+ const char *addr);
void (*peer_found) (GSupplicantPeer *peer);
void (*peer_lost) (GSupplicantPeer *peer);
void (*peer_changed) (GSupplicantPeer *peer,
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 0cb621b9..12391482 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -614,6 +614,30 @@ static void callback_network_associated(GSupplicantNetwork *network)
callbacks_pointer->network_associated(network);
}
+static void callback_sta_authorized(GSupplicantInterface *interface,
+ const char *addr)
+{
+ if (!callbacks_pointer)
+ return;
+
+ if (!callbacks_pointer->sta_authorized)
+ return;
+
+ callbacks_pointer->sta_authorized(interface, addr);
+}
+
+static void callback_sta_deauthorized(GSupplicantInterface *interface,
+ const char *addr)
+{
+ if (!callbacks_pointer)
+ return;
+
+ if (!callbacks_pointer->sta_deauthorized)
+ return;
+
+ callbacks_pointer->sta_deauthorized(interface, addr);
+}
+
static void callback_peer_found(GSupplicantPeer *peer)
{
if (!callbacks_pointer)
@@ -2731,6 +2755,44 @@ static void signal_network_removed(const char *path, DBusMessageIter *iter)
interface_network_removed(iter, interface);
}
+static void signal_sta_authorized(const char *path, DBusMessageIter *iter)
+{
+ GSupplicantInterface *interface;
+ DBusMessageIter array;
+ const char *addr = NULL;
+
+ SUPPLICANT_DBG("");
+
+ interface = g_hash_table_lookup(interface_table, path);
+ if (!interface)
+ return;
+
+ dbus_message_iter_get_basic(iter, &addr);
+ if (!addr)
+ return;
+
+ callback_sta_authorized(interface, addr);
+}
+
+static void signal_sta_deauthorized(const char *path, DBusMessageIter *iter)
+{
+ GSupplicantInterface *interface;
+ DBusMessageIter array;
+ const char *addr = NULL;
+
+ SUPPLICANT_DBG("");
+
+ interface = g_hash_table_lookup(interface_table, path);
+ if (!interface)
+ return;
+
+ dbus_message_iter_get_basic(iter, &addr);
+ if (!addr)
+ return;
+
+ callback_sta_deauthorized(interface, addr);
+}
+
static void signal_bss_changed(const char *path, DBusMessageIter *iter)
{
GSupplicantInterface *interface;
@@ -3505,6 +3567,8 @@ static struct {
{ SUPPLICANT_INTERFACE ".Interface", "BSSRemoved", signal_bss_removed },
{ SUPPLICANT_INTERFACE ".Interface", "NetworkAdded", signal_network_added },
{ SUPPLICANT_INTERFACE ".Interface", "NetworkRemoved", signal_network_removed },
+ { SUPPLICANT_INTERFACE ".Interface", "StaAuthorized", signal_sta_authorized },
+ { SUPPLICANT_INTERFACE ".Interface", "StaDeauthorized", signal_sta_deauthorized },
{ SUPPLICANT_INTERFACE ".BSS", "PropertiesChanged", signal_bss_changed },
diff --git a/include/tethering.h b/include/tethering.h
new file mode 100644
index 00000000..0d29b235
--- /dev/null
+++ b/include/tethering.h
@@ -0,0 +1,36 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007-2013 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
+ * 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/plugins/wifi.c b/plugins/wifi.c
index e437daeb..6fa20312 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -55,6 +55,7 @@
#include <connman/provision.h>
#include <connman/utsname.h>
#include <connman/machine.h>
+#include <connman/tethering.h>
#include <gsupplicant/gsupplicant.h>
@@ -2985,6 +2986,32 @@ static void network_associated(GSupplicantNetwork *network)
interface_state(interface);
}
+static void sta_authorized(GSupplicantInterface *interface,
+ const char *addr)
+{
+ struct wifi_data *wifi = g_supplicant_interface_get_data(interface);
+
+ DBG("wifi %p station %s authorized", wifi, addr);
+
+ if (!wifi || !wifi->tethering)
+ return;
+
+ __connman_tethering_client_register(addr);
+}
+
+static void sta_deauthorized(GSupplicantInterface *interface,
+ const char *addr)
+{
+ struct wifi_data *wifi = g_supplicant_interface_get_data(interface);
+
+ DBG("wifi %p station %s deauthorized", wifi, addr);
+
+ if (!wifi || !wifi->tethering)
+ return;
+
+ __connman_tethering_client_unregister(addr);
+}
+
static void apply_peer_services(GSupplicantPeer *peer,
struct connman_peer *connman_peer)
{
@@ -3205,6 +3232,8 @@ static const GSupplicantCallbacks callbacks = {
.network_removed = network_removed,
.network_changed = network_changed,
.network_associated = network_associated,
+ .sta_authorized = sta_authorized,
+ .sta_deauthorized = sta_deauthorized,
.peer_found = peer_found,
.peer_lost = peer_lost,
.peer_changed = peer_changed,
diff --git a/src/connman.h b/src/connman.h
index 13553833..dfcacc62 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -630,12 +630,15 @@ 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);
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 d15ce203..b2de863c 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 d222afca..61951075 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -61,6 +61,13 @@ static struct connman_ippool *dhcp_ippool = NULL;
static DBusConnection *connection;
static GHashTable *pn_hash;
+static GHashTable *clients_table = NULL;
+
+struct _clients_notify {
+ int id;
+ GHashTable *remove;
+} *clients_notify;
+
struct connman_private_network {
char *owner;
char *path;
@@ -181,6 +188,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 +320,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);
@@ -327,6 +348,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)
{
@@ -440,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;
@@ -529,6 +629,18 @@ 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);
+ client_added(addr);
+}
+
+void __connman_tethering_client_unregister(const char *addr)
+{
+ g_hash_table_remove(clients_table, g_strdup(addr));
+ client_removed(addr);
+}
+
int __connman_tethering_init(void)
{
DBG("");
@@ -542,6 +654,12 @@ 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);
+
+ 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;
}
@@ -562,5 +680,13 @@ void __connman_tethering_cleanup(void)
return;
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;
+
dbus_connection_unref(connection);
}
--
2.19.1
2 years, 5 months
Error with UDP server
by Doron Behar
I'm having a problem when I run connman only at home, I keep getting
this error repeatedly in the journal:
Oct 30 22:42:31 NUC connmand[404]: Error with UDP server fdc9:8a32:cbfb:0:16ae:dbff:fe55:f320
According to a reverse whois search, the server IPV6 address specified
in the message belongs to my ISP.
Additionally, I feel like at home my internet connection is much slower
then when I connect to my Android Hotspot WiFi.
Even if I configure this connection with IPV6 off the error persists.
It feels like a problem on my ISP's side but how can I debug this?
2 years, 5 months