From: Daniel Wagner <[email protected]>
---
src/connman.h | 1 -
src/notifier.c | 5 -----
src/tethering.c | 28 +++++++++++++++++++++++++---
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/src/connman.h b/src/connman.h
index 02ff929..dd6724a 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -475,7 +475,6 @@ int __connman_tethering_init(void);
void __connman_tethering_cleanup(void);
const char *__connman_tethering_get_bridge(void);
-void __connman_tethering_update_interface(const char *interface);
void __connman_tethering_set_enabled(void);
void __connman_tethering_set_disabled(void);
diff --git a/src/notifier.c b/src/notifier.c
index 91b52ea..dedea95 100644
--- a/src/notifier.c
+++ b/src/notifier.c
@@ -197,15 +197,10 @@ static void technology_default(enum connman_service_type
type)
void __connman_notifier_default_changed(struct connman_service *service)
{
enum connman_service_type type = connman_service_get_type(service);
- char *interface;
GSList *list;
technology_default(type);
- interface = connman_service_get_interface(service);
- __connman_tethering_update_interface(interface);
- g_free(interface);
-
for (list = notifier_list; list; list = list->next) {
struct connman_notifier *notifier = list->data;
diff --git a/src/tethering.c b/src/tethering.c
index c240302..70c9177 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -319,8 +319,12 @@ void __connman_tethering_set_disabled(void)
DBG("tethering stopped");
}
-void __connman_tethering_update_interface(const char *interface)
+static void update_tethering_interface(struct connman_service *service)
{
+ char *interface;
+
+ interface = connman_service_get_interface(service);
+
DBG("interface %s", interface);
g_free(default_interface);
@@ -329,16 +333,19 @@ void __connman_tethering_update_interface(const char
*interface)
disable_nat(interface);
default_interface = NULL;
- return;
+ goto out;
}
default_interface = g_strdup(interface);
__sync_synchronize();
if (tethering_enabled == 0)
- return;
+ goto out;
enable_nat(interface);
+
+out:
+ g_free(interface);
}
static void setup_tun_interface(unsigned int flags, unsigned change,
@@ -537,8 +544,15 @@ int __connman_private_network_release(const char *path)
return 0;
}
+static struct connman_notifier tethering_notifier = {
+ .name = "tethering",
+ .default_changed = update_tethering_interface,
+};
+
int __connman_tethering_init(void)
{
+ int err;
+
DBG("");
tethering_enabled = 0;
@@ -547,6 +561,12 @@ int __connman_tethering_init(void)
if (connection == NULL)
return -EFAULT;
+ err = connman_notifier_register(&tethering_notifier);
+ if (err < 0) {
+ dbus_connection_unref(connection);
+ return err;
+ }
+
pn_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, remove_private_network);
@@ -565,6 +585,8 @@ void __connman_tethering_cleanup(void)
__connman_bridge_remove(BRIDGE_NAME);
}
+ connman_notifier_unregister(&tethering_notifier);
+
if (connection == NULL)
return;
--
1.7.9.48.g85da4d
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman