5 * Copyright (C) 2016 BMW Car IT GmbH.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include <linux/if_ether.h>
31 #define CONNMAN_API_SUBJECT_TO_CHANGE
32 #include <connman/plugin.h>
33 #include <connman/dbus.h>
34 #include <connman/network.h>
35 #include <connman/technology.h>
36 #include <connman/inet.h>
39 static DBusConnection *connection;
40 static GDBusClient *client;
41 static GDBusProxy *agent_proxy;
42 static GHashTable *adapters;
43 static GHashTable *devices;
44 static GHashTable *networks;
45 static bool agent_registered;
47 #define IWD_SERVICE "net.connman.iwd"
49 #define IWD_AGENT_MANAGER_INTERFACE "net.connman.iwd.AgentManager"
50 #define IWD_ADAPTER_INTERFACE "net.connman.iwd.Adapter"
51 #define IWD_DEVICE_INTERFACE "net.connman.iwd.Device"
52 #define IWD_NETWORK_INTERFACE "net.connman.iwd.Network"
54 #define IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
55 #define IWD_AGENT_ERROR_INTERFACE "net.connman.iwd.Agent.Error"
56 #define AGENT_PATH "/net/connman/iwd_agent"
75 struct connman_device *device;
86 struct iwd_device *iwdd;
87 struct connman_network *network;
90 static const char *proxy_get_string(GDBusProxy *proxy, const char *property)
95 if (!g_dbus_proxy_get_property(proxy, property, &iter))
98 dbus_message_iter_get_basic(&iter, &str);
103 static bool proxy_get_bool(GDBusProxy *proxy, const char *property)
105 DBusMessageIter iter;
108 if (!g_dbus_proxy_get_property(proxy, property, &iter))
111 dbus_message_iter_get_basic(&iter, &value);
116 static void address2ident(const char *address, char *ident)
120 for (i = 0; i < ETH_ALEN; i++) {
121 ident[i * 2] = address[i * 3];
122 ident[i * 2 + 1] = address[i * 3 + 1];
124 ident[ETH_ALEN * 2] = '\0';
127 static int cm_network_probe(struct connman_network *network)
132 g_hash_table_iter_init(&iter, networks);
134 while (g_hash_table_iter_next(&iter, &key, &value)) {
135 struct iwd_network *iwdn = value;
137 if (network == iwdn->network)
144 static void update_network_connected(struct iwd_network *iwdn)
146 struct iwd_device *iwdd;
149 iwdd = g_hash_table_lookup(devices, iwdn->device);
153 index = connman_inet_ifindex(iwdd->name);
157 DBG("interface name %s index %d", iwdd->name, index);
158 connman_network_set_index(iwdn->network, index);
159 connman_network_set_connected(iwdn->network, true);
162 static void update_network_disconnected(struct iwd_network *iwdn)
164 DBG("interface name %s", iwdn->name);
165 connman_network_set_connected(iwdn->network, false);
168 static void cm_network_connect_cb(DBusMessage *message, void *user_data)
170 const char *path = user_data;
171 struct iwd_network *iwdn;
173 iwdn = g_hash_table_lookup(networks, path);
177 if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
178 const char *dbus_error = dbus_message_get_error_name(message);
180 if (!strcmp(dbus_error, "net.connman.iwd.InProgress"))
183 DBG("%s connect failed: %s", path, dbus_error);
184 connman_network_set_error(iwdn->network,
185 CONNMAN_NETWORK_ERROR_CONNECT_FAIL);
189 update_network_connected(iwdn);
192 static int cm_network_connect(struct connman_network *network)
194 struct iwd_network *iwdn = connman_network_get_data(network);
199 if (!g_dbus_proxy_method_call(iwdn->proxy, "Connect",
200 NULL, cm_network_connect_cb,
201 g_strdup(iwdn->path), g_free))
204 connman_network_set_associating(iwdn->network, true);
209 static void cm_network_disconnect_cb(DBusMessage *message, void *user_data)
211 const char *path = user_data;
212 struct iwd_network *iwdn;
214 iwdn = g_hash_table_lookup(networks, path);
218 if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
219 const char *dbus_error = dbus_message_get_error_name(message);
221 if (!strcmp(dbus_error, "net.connman.iwd.NotConnected")) {
224 DBG("%s disconnect failed: %s", path, dbus_error);
230 * We end up in a tight loop in the error case. That is
231 * when we can't connect, bail out in cm_network_connect_cb() with
234 if (connman_network_get_connected(iwdn->network))
235 update_network_disconnected(iwdn);
238 static int cm_network_disconnect(struct connman_network *network)
240 struct iwd_network *iwdn = connman_network_get_data(network);
241 struct iwd_device *iwdd;
246 iwdd = g_hash_table_lookup(devices, iwdn->device);
250 if (!g_dbus_proxy_method_call(iwdd->proxy, "Disconnect",
251 NULL, cm_network_disconnect_cb, g_strdup(iwdn->path), g_free))
257 static struct connman_network_driver network_driver = {
259 .type = CONNMAN_NETWORK_TYPE_WIFI,
260 .probe = cm_network_probe,
261 .connect = cm_network_connect,
262 .disconnect = cm_network_disconnect,
265 static int cm_device_probe(struct connman_device *device)
270 g_hash_table_iter_init(&iter, devices);
272 while (g_hash_table_iter_next(&iter, &key, &value)) {
273 struct iwd_device *iwdd = value;
275 if (device == iwdd->device)
282 static void cm_device_remove(struct connman_device *device)
291 static void device_powered_cb(const DBusError *error, void *user_data)
293 struct dev_cb_data *cbd = user_data;
294 struct iwd_device *iwdd;
296 iwdd = g_hash_table_lookup(devices, cbd->path);
300 if (dbus_error_is_set(error)) {
301 connman_warn("WiFi device %s not enabled %s",
302 cbd->path, error->message);
306 connman_device_set_powered(iwdd->device, cbd->powered);
312 static int set_device_powered(struct connman_device *device, bool powered)
314 struct iwd_device *iwdd = connman_device_get_data(device);
315 dbus_bool_t device_powered = powered;
316 struct dev_cb_data *cbd;
318 if (proxy_get_bool(iwdd->proxy, "Powered"))
321 cbd = g_new(struct dev_cb_data, 1);
322 cbd->path = g_strdup(iwdd->path);
323 cbd->powered = powered;
325 g_dbus_proxy_set_property_basic(iwdd->proxy, "Powered",
326 DBUS_TYPE_BOOLEAN, &device_powered,
327 device_powered_cb, cbd, NULL);
332 static int cm_device_enable(struct connman_device *device)
334 return set_device_powered(device, true);
337 static int cm_device_disable(struct connman_device *device)
339 return set_device_powered(device, false);
342 static struct connman_device_driver device_driver = {
344 .type = CONNMAN_DEVICE_TYPE_WIFI,
345 .probe = cm_device_probe,
346 .remove = cm_device_remove,
347 .enable = cm_device_enable,
348 .disable = cm_device_disable,
351 static int cm_tech_probe(struct connman_technology *technology)
356 static void cm_tech_remove(struct connman_technology *technology)
360 static struct connman_technology_driver tech_driver = {
362 .type = CONNMAN_SERVICE_TYPE_WIFI,
363 .probe = cm_tech_probe,
364 .remove = cm_tech_remove,
367 static unsigned char calculate_strength(int strength)
372 * Network's maximum signal strength expressed in 100 * dBm.
373 * The value is the range of 0 (strongest signal) to -10000
376 * ConnMan expects it in the range from 100 (strongest) to 0
379 res = (unsigned char)((strength * -10000) / 100);
384 static void _update_signal_strength(const char *path, int16_t signal_strength)
386 struct iwd_network *iwdn;
388 iwdn = g_hash_table_lookup(networks, path);
395 connman_network_set_strength(iwdn->network,
396 calculate_strength(signal_strength));
399 static void ordered_networks_cb(DBusMessage *message, void *user_data)
401 DBusMessageIter array, entry;
405 if (!dbus_message_iter_init(message, &array))
408 if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
411 dbus_message_iter_recurse(&array, &entry);
412 while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRUCT) {
413 DBusMessageIter value;
414 const char *path, *name, *type;
415 int16_t signal_strength;
418 dbus_message_iter_recurse(&entry, &value);
420 dbus_message_iter_get_basic(&value, &path);
422 dbus_message_iter_next(&value);
423 dbus_message_iter_get_basic(&value, &name);
425 dbus_message_iter_next(&value);
426 dbus_message_iter_get_basic(&value, &signal_strength);
428 dbus_message_iter_next(&value);
429 dbus_message_iter_get_basic(&value, &type);
431 _update_signal_strength(path, signal_strength);
433 dbus_message_iter_next(&entry);
437 static void update_signal_strength(struct iwd_device *iwdd)
439 if (!g_dbus_proxy_method_call(iwdd->proxy,
440 "GetOrderedNetworks",
441 NULL, ordered_networks_cb,
443 DBG("GetOrderedNetworks() failed");
446 static const char *security_remap(const char *security)
448 if (!g_strcmp0(security, "open"))
450 else if (!g_strcmp0(security, "psk"))
452 else if (!g_strcmp0(security, "8021x"))
458 static char *create_identifier(const char *path, const char *security)
460 char *start, *end, *identifier;
461 char *_path = g_strdup(path);
464 * _path is something like
465 * /0/4/5363686970686f6c5f427573696e6573735f454150_8021x
467 start = strrchr(_path, '/');
469 end = strchr(start, '_');
473 * Create an ident which is identical to the corresponding
474 * wpa_supplicant identifier.
476 identifier = g_strdup_printf("%s_managed_%s", start,
477 security_remap(security));
483 static void add_network(const char *path, struct iwd_network *iwdn)
485 struct iwd_device *iwdd;
488 iwdd = g_hash_table_lookup(devices, iwdn->device);
492 identifier = create_identifier(path, iwdn->type);
493 iwdn->network = connman_network_create(identifier,
494 CONNMAN_NETWORK_TYPE_WIFI);
495 connman_network_set_data(iwdn->network, iwdn);
497 connman_network_set_name(iwdn->network, iwdn->name);
498 connman_network_set_blob(iwdn->network, "WiFi.SSID", iwdn->name,
500 connman_network_set_string(iwdn->network, "WiFi.Security",
502 connman_network_set_string(iwdn->network, "WiFi.Mode", "managed");
504 if (connman_device_add_network(iwdd->device, iwdn->network) < 0) {
505 connman_network_unref(iwdn->network);
506 iwdn->network = NULL;
511 connman_network_set_available(iwdn->network, true);
512 connman_network_set_group(iwdn->network, identifier);
517 static void remove_network(struct iwd_network *iwdn)
523 connman_device_remove_network(iwdn->iwdd->device,
526 connman_network_unref(iwdn->network);
527 iwdn->network = NULL;
530 static void add_device(const char *path, struct iwd_device *iwdd)
532 char ident[ETH_ALEN * 2 + 1];
534 iwdd->device = connman_device_create("wifi", CONNMAN_DEVICE_TYPE_WIFI);
538 connman_device_set_data(iwdd->device, iwdd);
540 address2ident(iwdd->address, ident);
541 connman_device_set_ident(iwdd->device, ident);
543 if (connman_device_register(iwdd->device) < 0) {
544 g_hash_table_remove(devices, path);
548 connman_device_set_powered(iwdd->device, iwdd->powered);
551 static void remove_device_networks(struct iwd_device *iwdd)
555 struct iwd_network *iwdn;
556 GSList *list, *nets = NULL;
558 g_hash_table_iter_init(&iter, networks);
560 while (g_hash_table_iter_next(&iter, &key, &value)) {
563 if (!strcmp(iwdd->path, iwdn->device))
564 nets = g_slist_prepend(nets, iwdn);
567 for (list = nets; list; list = list->next) {
569 g_hash_table_remove(networks, iwdn->path);
575 static void remove_device(struct iwd_device *iwdd)
580 remove_device_networks(iwdd);
581 connman_device_unregister(iwdd->device);
582 connman_device_unref(iwdd->device);
586 static void adapter_property_change(GDBusProxy *proxy, const char *name,
587 DBusMessageIter *iter, void *user_data)
589 struct iwd_adapter *adapter;
592 path = g_dbus_proxy_get_path(proxy);
593 adapter = g_hash_table_lookup(adapters, path);
597 if (!strcmp(name, "Powered")) {
600 dbus_message_iter_get_basic(iter, &powered);
601 adapter->powered = powered;
603 DBG("%p powered %d", path, adapter->powered);
607 static void device_property_change(GDBusProxy *proxy, const char *name,
608 DBusMessageIter *iter, void *user_data)
610 struct iwd_device *iwdd;
613 path = g_dbus_proxy_get_path(proxy);
614 iwdd = g_hash_table_lookup(devices, path);
618 if (!strcmp(name, "Name")) {
621 dbus_message_iter_get_basic(iter, &name);
623 iwdd->name = g_strdup(name);
625 DBG("%p name %s", path, iwdd->name);
626 } else if (!strcmp(name, "Powered")) {
629 dbus_message_iter_get_basic(iter, &powered);
630 iwdd->powered = powered;
632 DBG("%s powered %d", path, iwdd->powered);
633 } else if (!strcmp(name, "Scanning")) {
634 dbus_bool_t scanning;
636 dbus_message_iter_get_basic(iter, &scanning);
637 iwdd->scanning = scanning;
639 DBG("%s scanning %d", path, iwdd->scanning);
642 update_signal_strength(iwdd);
647 static void network_property_change(GDBusProxy *proxy, const char *name,
648 DBusMessageIter *iter, void *user_data)
650 struct iwd_network *iwdn;
653 path = g_dbus_proxy_get_path(proxy);
654 iwdn = g_hash_table_lookup(networks, path);
658 if (!strcmp(name, "Connected")) {
659 dbus_bool_t connected;
661 dbus_message_iter_get_basic(iter, &connected);
662 iwdn->connected = connected;
664 DBG("%s connected %d", path, iwdn->connected);
667 update_network_connected(iwdn);
669 update_network_disconnected(iwdn);
673 static void adapter_free(gpointer data)
675 struct iwd_adapter *iwda = data;
678 g_dbus_proxy_unref(iwda->proxy);
683 g_free(iwda->vendor);
688 static void device_free(gpointer data)
690 struct iwd_device *iwdd = data;
693 g_dbus_proxy_unref(iwdd->proxy);
700 g_free(iwdd->adapter);
702 g_free(iwdd->address);
706 static void network_free(gpointer data)
708 struct iwd_network *iwdn = data;
711 g_dbus_proxy_unref(iwdn->proxy);
715 remove_network(iwdn);
718 g_free(iwdn->device);
724 static void create_adapter(GDBusProxy *proxy)
726 const char *path = g_dbus_proxy_get_path(proxy);
727 struct iwd_adapter *iwda;
729 iwda = g_try_new0(struct iwd_adapter, 1);
732 connman_error("Out of memory creating IWD adapter");
736 iwda->path = g_strdup(path);
737 g_hash_table_replace(adapters, iwda->path, iwda);
739 iwda->proxy = g_dbus_proxy_ref(proxy);
742 connman_error("Cannot create IWD adapter watcher %s", path);
743 g_hash_table_remove(adapters, path);
747 iwda->vendor = g_strdup(proxy_get_string(proxy, "Vendor"));
748 iwda->model = g_strdup(proxy_get_string(proxy, "Model"));
749 iwda->powered = proxy_get_bool(proxy, "Powered");
751 DBG("%s vendor '%s' model '%s' powered %d", path, iwda->vendor,
752 iwda->model, iwda->powered);
754 g_dbus_proxy_set_property_watch(iwda->proxy,
755 adapter_property_change, NULL);
758 static void create_device(GDBusProxy *proxy)
760 const char *path = g_dbus_proxy_get_path(proxy);
761 struct iwd_device *iwdd;
763 iwdd = g_try_new0(struct iwd_device, 1);
766 connman_error("Out of memory creating IWD device");
770 iwdd->path = g_strdup(path);
771 g_hash_table_replace(devices, iwdd->path, iwdd);
773 iwdd->proxy = g_dbus_proxy_ref(proxy);
776 connman_error("Cannot create IWD device watcher %s", path);
777 g_hash_table_remove(devices, path);
781 iwdd->adapter = g_strdup(proxy_get_string(proxy, "Adapter"));
782 iwdd->name = g_strdup(proxy_get_string(proxy, "Name"));
783 iwdd->address = g_strdup(proxy_get_string(proxy, "Address"));
784 iwdd->powered = proxy_get_bool(proxy, "Powered");
785 iwdd->scanning = proxy_get_bool(proxy, "Scanning");
787 DBG("adapter %s name %s address %s powered %d scanning %d",
788 iwdd->adapter, iwdd->name, iwdd->address,
789 iwdd->powered, iwdd->scanning);
791 g_dbus_proxy_set_property_watch(iwdd->proxy,
792 device_property_change, NULL);
794 add_device(path, iwdd);
797 static void unregister_agent();
799 static DBusMessage *agent_release_method(DBusConnection *dbus_conn,
800 DBusMessage *message, void *user_data)
803 return g_dbus_create_reply(message, DBUS_TYPE_INVALID);
806 static DBusMessage *get_reply_on_error(DBusMessage *message, int error)
808 return g_dbus_create_error(message,
809 IWD_AGENT_ERROR_INTERFACE ".Failed", "Invalid parameters");
812 static DBusMessage *agent_request_passphrase(DBusConnection *dbus_conn,
813 DBusMessage *message,
816 struct iwd_network *iwdn;
817 DBusMessageIter iter;
818 const char *path, *passwd;
822 dbus_message_iter_init(message, &iter);
824 if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH)
825 return get_reply_on_error(message, EINVAL);
827 dbus_message_iter_get_basic(&iter, &path);
829 iwdn = g_hash_table_lookup(networks, path);
831 return get_reply_on_error(message, EINVAL);
833 passwd = connman_network_get_string(iwdn->network, "WiFi.Passphrase");
835 return g_dbus_create_reply(message, DBUS_TYPE_STRING, &passwd,
839 static DBusMessage *agent_cancel(DBusConnection *dbus_conn,
840 DBusMessage *message, void *user_data)
842 DBusMessageIter iter;
845 dbus_message_iter_init(message, &iter);
847 if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
848 return get_reply_on_error(message, EINVAL);
850 dbus_message_iter_get_basic(&iter, &reason);
852 DBG("cancel: %s", reason);
855 * We don't have to do anything here, because we asked the
856 * user upfront for the passphrase. So
857 * agent_request_passphrase() will always send a passphrase
861 return g_dbus_create_reply(message, DBUS_TYPE_INVALID);
864 static const GDBusMethodTable agent_methods[] = {
865 { GDBUS_METHOD("Release", NULL, NULL, agent_release_method) },
866 { GDBUS_METHOD("RequestPassphrase",
867 GDBUS_ARGS({ "path", "o" }),
868 GDBUS_ARGS({ "passphrase", "s" }),
869 agent_request_passphrase)},
870 { GDBUS_METHOD("Cancel",
871 GDBUS_ARGS({ "reason", "s" }),
872 NULL, agent_cancel) },
876 static void agent_register_builder(DBusMessageIter *iter, void *user_data)
878 const char *path = AGENT_PATH;
880 dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
884 static void register_agent(GDBusProxy *proxy)
886 if (!g_dbus_proxy_method_call(proxy,
888 agent_register_builder,
892 agent_proxy = g_dbus_proxy_ref(proxy);
895 static void unregister_agent()
900 g_dbus_proxy_method_call(agent_proxy,
902 agent_register_builder,
905 g_dbus_proxy_unref(agent_proxy);
909 static void iwd_is_present(DBusConnection *conn, void *user_data)
911 if (agent_registered)
914 if (!g_dbus_register_interface(connection, AGENT_PATH,
915 IWD_AGENT_INTERFACE, agent_methods,
916 NULL, NULL, NULL, NULL))
919 agent_registered = true;
922 static void iwd_is_out(DBusConnection *conn, void *user_data)
924 if (agent_registered) {
925 g_dbus_unregister_interface(connection,
926 AGENT_PATH, IWD_AGENT_INTERFACE);
927 agent_registered = false;
931 static void create_network(GDBusProxy *proxy)
933 const char *path = g_dbus_proxy_get_path(proxy);
934 struct iwd_network *iwdn;
936 iwdn = g_try_new0(struct iwd_network, 1);
939 connman_error("Out of memory creating IWD network");
943 iwdn->path = g_strdup(path);
944 g_hash_table_replace(networks, iwdn->path, iwdn);
946 iwdn->proxy = g_dbus_proxy_ref(proxy);
949 connman_error("Cannot create IWD network watcher %s", path);
950 g_hash_table_remove(networks, path);
954 iwdn->device = g_strdup(proxy_get_string(proxy, "Device"));
955 iwdn->name = g_strdup(proxy_get_string(proxy, "Name"));
956 iwdn->type = g_strdup(proxy_get_string(proxy, "Type"));
957 iwdn->connected = proxy_get_bool(proxy, "Connected");
959 DBG("device %s name '%s' type %s connected %d",
965 g_dbus_proxy_set_property_watch(iwdn->proxy,
966 network_property_change, NULL);
968 add_network(path, iwdn);
971 static void object_added(GDBusProxy *proxy, void *user_data)
973 const char *interface;
975 interface = g_dbus_proxy_get_interface(proxy);
977 connman_warn("Interface or proxy missing when adding "
982 DBG("%s %s", interface, g_dbus_proxy_get_path(proxy));
984 if (!strcmp(interface, IWD_AGENT_MANAGER_INTERFACE))
985 register_agent(proxy);
986 else if (!strcmp(interface, IWD_ADAPTER_INTERFACE))
987 create_adapter(proxy);
988 else if (!strcmp(interface, IWD_DEVICE_INTERFACE))
989 create_device(proxy);
990 else if (!strcmp(interface, IWD_NETWORK_INTERFACE))
991 create_network(proxy);
994 static void object_removed(GDBusProxy *proxy, void *user_data)
996 const char *interface, *path;
998 interface = g_dbus_proxy_get_interface(proxy);
1000 connman_warn("Interface or proxy missing when removing "
1005 path = g_dbus_proxy_get_path(proxy);
1006 DBG("%s %s", interface, path);
1008 if (!strcmp(interface, IWD_AGENT_MANAGER_INTERFACE))
1010 if (!strcmp(interface, IWD_ADAPTER_INTERFACE))
1011 g_hash_table_remove(adapters, path);
1012 else if (!strcmp(interface, IWD_DEVICE_INTERFACE))
1013 g_hash_table_remove(devices, path);
1014 else if (!strcmp(interface, IWD_NETWORK_INTERFACE))
1015 g_hash_table_remove(networks, path);
1018 static int iwd_init(void)
1020 connection = connman_dbus_get_connection();
1024 adapters = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1027 devices = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1030 networks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1033 if (connman_technology_driver_register(&tech_driver) < 0) {
1034 connman_warn("Failed to initialize technology for IWD");
1038 if (connman_device_driver_register(&device_driver) < 0) {
1039 connman_warn("Failed to initialize device driver for "
1041 connman_technology_driver_unregister(&tech_driver);
1045 if (connman_network_driver_register(&network_driver) < 0) {
1046 connman_technology_driver_unregister(&tech_driver);
1047 connman_device_driver_unregister(&device_driver);
1051 client = g_dbus_client_new(connection, IWD_SERVICE, IWD_PATH);
1053 connman_warn("Failed to initialize D-Bus client for "
1058 g_dbus_client_set_connect_watch(client, iwd_is_present, NULL);
1059 g_dbus_client_set_disconnect_watch(client, iwd_is_out, NULL);
1060 g_dbus_client_set_proxy_handlers(client, object_added, object_removed,
1067 g_hash_table_destroy(devices);
1070 g_hash_table_destroy(networks);
1073 g_hash_table_destroy(adapters);
1076 dbus_connection_unref(connection);
1081 static void iwd_exit(void)
1083 connman_network_driver_unregister(&network_driver);
1084 connman_device_driver_unregister(&device_driver);
1085 connman_technology_driver_unregister(&tech_driver);
1087 g_dbus_client_unref(client);
1089 g_hash_table_destroy(networks);
1090 g_hash_table_destroy(devices);
1091 g_hash_table_destroy(adapters);
1093 dbus_connection_unref(connection);
1096 CONNMAN_PLUGIN_DEFINE(iwd, "IWD plugin", VERSION,
1097 CONNMAN_PLUGIN_PRIORITY_DEFAULT, iwd_init, iwd_exit)