commit 4cfcb9c88d35dd58543733be035b33fdeb75071f
parent 800d57d0953034e2c96aa220241b8f48d00fe6e8
Author: Denis Kenzior <denkenz@gmail.com>
Date: Wed, 22 May 2019 10:00:12 -0500
network: Convert to use IWD_MODULE
Diffstat:
3 files changed, 44 insertions(+), 46 deletions(-)
diff --git a/src/iwd.h b/src/iwd.h
@@ -33,9 +33,6 @@ void netdev_exit(void);
void netdev_set_nl80211(struct l_genl_family *nl80211);
void netdev_shutdown(void);
-void network_init();
-void network_exit();
-
bool wsc_init(void);
bool wsc_exit();
diff --git a/src/main.c b/src/main.c
@@ -526,7 +526,6 @@ int main(int argc, char *argv[])
station_init();
wsc_init();
- network_init();
if (iwd_modules_init() < 0)
goto fail_modules;
@@ -538,7 +537,6 @@ int main(int argc, char *argv[])
fail_modules:
iwd_modules_exit();
- network_exit();
wsc_exit();
station_exit();
device_exit();
diff --git a/src/network.c b/src/network.c
@@ -1270,29 +1270,6 @@ static bool network_property_get_known_network(struct l_dbus *dbus,
return true;
}
-static void setup_network_interface(struct l_dbus_interface *interface)
-{
- l_dbus_interface_method(interface, "Connect", 0,
- network_connect,
- "", "");
-
- l_dbus_interface_property(interface, "Name", 0, "s",
- network_property_get_name, NULL);
-
- l_dbus_interface_property(interface, "Connected", 0, "b",
- network_property_is_connected,
- NULL);
-
- l_dbus_interface_property(interface, "Device", 0, "o",
- network_property_get_device, NULL);
-
- l_dbus_interface_property(interface, "Type", 0, "s",
- network_property_get_type, NULL);
-
- l_dbus_interface_property(interface, "KnownNetwork", 0, "o",
- network_property_get_known_network, NULL);
-}
-
bool network_register(struct network *network, const char *path)
{
if (!l_dbus_object_add_interface(dbus_get_bus(), path,
@@ -1341,24 +1318,6 @@ void network_remove(struct network *network, int reason)
l_free(network);
}
-void network_init()
-{
- if (!l_dbus_register_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE,
- setup_network_interface, NULL, false))
- l_error("Unable to register %s interface",
- IWD_NETWORK_INTERFACE);
-
- networks = l_queue_new();
-}
-
-void network_exit()
-{
- l_queue_destroy(networks, network_info_free);
- networks = NULL;
-
- l_dbus_unregister_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE);
-}
-
int network_rank_compare(const void *a, const void *b, void *user)
{
const struct network *new_network = a;
@@ -1473,3 +1432,47 @@ void network_info_forget_known(struct network_info *network)
else
network_info_free(network);
}
+
+static void setup_network_interface(struct l_dbus_interface *interface)
+{
+ l_dbus_interface_method(interface, "Connect", 0,
+ network_connect,
+ "", "");
+
+ l_dbus_interface_property(interface, "Name", 0, "s",
+ network_property_get_name, NULL);
+
+ l_dbus_interface_property(interface, "Connected", 0, "b",
+ network_property_is_connected,
+ NULL);
+
+ l_dbus_interface_property(interface, "Device", 0, "o",
+ network_property_get_device, NULL);
+
+ l_dbus_interface_property(interface, "Type", 0, "s",
+ network_property_get_type, NULL);
+
+ l_dbus_interface_property(interface, "KnownNetwork", 0, "o",
+ network_property_get_known_network, NULL);
+}
+
+static int network_init(void)
+{
+ if (!l_dbus_register_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE,
+ setup_network_interface, NULL, false))
+ l_error("Unable to register %s interface",
+ IWD_NETWORK_INTERFACE);
+
+ networks = l_queue_new();
+ return 0;
+}
+
+static void network_exit(void)
+{
+ l_queue_destroy(networks, network_info_free);
+ networks = NULL;
+
+ l_dbus_unregister_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE);
+}
+
+IWD_MODULE(network, network_init, network_exit)