network: Convert to use IWD_MODULE
This commit is contained in:
parent
800d57d095
commit
4cfcb9c88d
|
@ -33,9 +33,6 @@ void netdev_exit(void);
|
||||||
void netdev_set_nl80211(struct l_genl_family *nl80211);
|
void netdev_set_nl80211(struct l_genl_family *nl80211);
|
||||||
void netdev_shutdown(void);
|
void netdev_shutdown(void);
|
||||||
|
|
||||||
void network_init();
|
|
||||||
void network_exit();
|
|
||||||
|
|
||||||
bool wsc_init(void);
|
bool wsc_init(void);
|
||||||
bool wsc_exit();
|
bool wsc_exit();
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
station_init();
|
station_init();
|
||||||
wsc_init();
|
wsc_init();
|
||||||
network_init();
|
|
||||||
|
|
||||||
if (iwd_modules_init() < 0)
|
if (iwd_modules_init() < 0)
|
||||||
goto fail_modules;
|
goto fail_modules;
|
||||||
|
@ -538,7 +537,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
fail_modules:
|
fail_modules:
|
||||||
iwd_modules_exit();
|
iwd_modules_exit();
|
||||||
network_exit();
|
|
||||||
wsc_exit();
|
wsc_exit();
|
||||||
station_exit();
|
station_exit();
|
||||||
device_exit();
|
device_exit();
|
||||||
|
|
|
@ -1270,29 +1270,6 @@ static bool network_property_get_known_network(struct l_dbus *dbus,
|
||||||
return true;
|
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)
|
bool network_register(struct network *network, const char *path)
|
||||||
{
|
{
|
||||||
if (!l_dbus_object_add_interface(dbus_get_bus(), 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);
|
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)
|
int network_rank_compare(const void *a, const void *b, void *user)
|
||||||
{
|
{
|
||||||
const struct network *new_network = a;
|
const struct network *new_network = a;
|
||||||
|
@ -1473,3 +1432,47 @@ void network_info_forget_known(struct network_info *network)
|
||||||
else
|
else
|
||||||
network_info_free(network);
|
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)
|
||||||
|
|
Loading…
Reference in New Issue