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);
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;
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);
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,
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;
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);
__connman_bridge_remove(BRIDGE_NAME);
}
+ connman_notifier_unregister(&tethering_notifier);
+
if (connection == NULL)
return;