mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
netdev: Rework netdev_init/exit
This commit is contained in:
parent
b3e937e11a
commit
da52bcd109
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#define uninitialized_var(x) x = x
|
#define uninitialized_var(x) x = x
|
||||||
|
|
||||||
|
struct l_genl_family;
|
||||||
struct device;
|
struct device;
|
||||||
|
|
||||||
typedef void (*iwd_device_foreach_func)(struct device *, void *data);
|
typedef void (*iwd_device_foreach_func)(struct device *, void *data);
|
||||||
@ -32,6 +33,11 @@ const struct l_settings *iwd_get_config(void);
|
|||||||
|
|
||||||
void iwd_shutdown(void);
|
void iwd_shutdown(void);
|
||||||
|
|
||||||
|
bool netdev_init(const char *whitelist, const char *blacklist);
|
||||||
|
void netdev_exit(void);
|
||||||
|
void netdev_set_nl80211(struct l_genl_family *nl80211);
|
||||||
|
void netdev_shutdown(void);
|
||||||
|
|
||||||
void network_init();
|
void network_init();
|
||||||
void network_exit();
|
void network_exit();
|
||||||
|
|
||||||
|
10
src/main.c
10
src/main.c
@ -34,7 +34,6 @@
|
|||||||
#include "linux/nl80211.h"
|
#include "linux/nl80211.h"
|
||||||
|
|
||||||
#include "src/iwd.h"
|
#include "src/iwd.h"
|
||||||
#include "src/netdev.h"
|
|
||||||
#include "src/wiphy.h"
|
#include "src/wiphy.h"
|
||||||
#include "src/dbus.h"
|
#include "src/dbus.h"
|
||||||
#include "src/eap.h"
|
#include "src/eap.h"
|
||||||
@ -147,8 +146,7 @@ static void nl80211_appeared(void *user_data)
|
|||||||
if (!wiphy_init(nl80211, phys, nophys))
|
if (!wiphy_init(nl80211, phys, nophys))
|
||||||
l_error("Unable to init wiphy functionality");
|
l_error("Unable to init wiphy functionality");
|
||||||
|
|
||||||
if (!netdev_init(nl80211, interfaces, nointerfaces))
|
netdev_set_nl80211(nl80211);
|
||||||
l_error("Unable to init netdev functionality");
|
|
||||||
|
|
||||||
if (!scan_init(nl80211))
|
if (!scan_init(nl80211))
|
||||||
l_error("Unable to init scan functionality");
|
l_error("Unable to init scan functionality");
|
||||||
@ -162,7 +160,6 @@ static void nl80211_vanished(void *user_data)
|
|||||||
|
|
||||||
ap_exit();
|
ap_exit();
|
||||||
scan_exit();
|
scan_exit();
|
||||||
netdev_exit();
|
|
||||||
wiphy_exit();
|
wiphy_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,6 +427,9 @@ int main(int argc, char *argv[])
|
|||||||
eapol_init();
|
eapol_init();
|
||||||
rfkill_init();
|
rfkill_init();
|
||||||
|
|
||||||
|
if (!netdev_init(interfaces, nointerfaces))
|
||||||
|
goto fail_netdev;
|
||||||
|
|
||||||
if (!device_init())
|
if (!device_init())
|
||||||
goto fail_device;
|
goto fail_device;
|
||||||
|
|
||||||
@ -451,6 +451,8 @@ int main(int argc, char *argv[])
|
|||||||
adhoc_exit();
|
adhoc_exit();
|
||||||
device_exit();
|
device_exit();
|
||||||
fail_device:
|
fail_device:
|
||||||
|
netdev_exit();
|
||||||
|
fail_netdev:
|
||||||
rfkill_exit();
|
rfkill_exit();
|
||||||
eapol_exit();
|
eapol_exit();
|
||||||
eap_exit();
|
eap_exit();
|
||||||
|
48
src/netdev.c
48
src/netdev.c
@ -4552,12 +4552,8 @@ bool netdev_station_watch_remove(struct netdev *netdev, uint32_t id)
|
|||||||
return watchlist_remove(&netdev->station_watches, id);
|
return watchlist_remove(&netdev->station_watches, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool netdev_init(struct l_genl_family *in,
|
bool netdev_init(const char *whitelist, const char *blacklist)
|
||||||
const char *whitelist, const char *blacklist)
|
|
||||||
{
|
{
|
||||||
struct l_genl_msg *msg;
|
|
||||||
struct l_genl *genl = l_genl_family_get_genl(in);
|
|
||||||
|
|
||||||
if (rtnl)
|
if (rtnl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -4581,6 +4577,27 @@ bool netdev_init(struct l_genl_family *in,
|
|||||||
|
|
||||||
netdev_list = l_queue_new();
|
netdev_list = l_queue_new();
|
||||||
|
|
||||||
|
__handshake_set_install_tk_func(netdev_set_tk);
|
||||||
|
__handshake_set_install_gtk_func(netdev_set_gtk);
|
||||||
|
__handshake_set_install_igtk_func(netdev_set_igtk);
|
||||||
|
|
||||||
|
__eapol_set_rekey_offload_func(netdev_set_rekey_offload);
|
||||||
|
__eapol_set_tx_packet_func(netdev_control_port_frame);
|
||||||
|
|
||||||
|
if (whitelist)
|
||||||
|
whitelist_filter = l_strsplit(whitelist, ',');
|
||||||
|
|
||||||
|
if (blacklist)
|
||||||
|
blacklist_filter = l_strsplit(blacklist, ',');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void netdev_set_nl80211(struct l_genl_family *in)
|
||||||
|
{
|
||||||
|
struct l_genl_msg *msg;
|
||||||
|
struct l_genl *genl = l_genl_family_get_genl(in);
|
||||||
|
|
||||||
nl80211 = in;
|
nl80211 = in;
|
||||||
|
|
||||||
if (!l_genl_family_register(nl80211, "config", netdev_config_notify,
|
if (!l_genl_family_register(nl80211, "config", netdev_config_notify,
|
||||||
@ -4599,27 +4616,12 @@ bool netdev_init(struct l_genl_family *in,
|
|||||||
if (!l_genl_set_unicast_handler(genl, netdev_unicast_notify,
|
if (!l_genl_set_unicast_handler(genl, netdev_unicast_notify,
|
||||||
NULL, NULL))
|
NULL, NULL))
|
||||||
l_error("Registering for unicast notification failed");
|
l_error("Registering for unicast notification failed");
|
||||||
|
|
||||||
__handshake_set_install_tk_func(netdev_set_tk);
|
|
||||||
__handshake_set_install_gtk_func(netdev_set_gtk);
|
|
||||||
__handshake_set_install_igtk_func(netdev_set_igtk);
|
|
||||||
|
|
||||||
__eapol_set_rekey_offload_func(netdev_set_rekey_offload);
|
|
||||||
__eapol_set_tx_packet_func(netdev_control_port_frame);
|
|
||||||
|
|
||||||
if (whitelist)
|
|
||||||
whitelist_filter = l_strsplit(whitelist, ',');
|
|
||||||
|
|
||||||
if (blacklist)
|
|
||||||
blacklist_filter = l_strsplit(blacklist, ',');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool netdev_exit(void)
|
void netdev_exit(void)
|
||||||
{
|
{
|
||||||
if (!rtnl)
|
if (!rtnl)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
l_strfreev(whitelist_filter);
|
l_strfreev(whitelist_filter);
|
||||||
l_strfreev(blacklist_filter);
|
l_strfreev(blacklist_filter);
|
||||||
@ -4629,8 +4631,6 @@ bool netdev_exit(void)
|
|||||||
l_debug("Closing route netlink socket");
|
l_debug("Closing route netlink socket");
|
||||||
l_netlink_destroy(rtnl);
|
l_netlink_destroy(rtnl);
|
||||||
rtnl = NULL;
|
rtnl = NULL;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void netdev_shutdown(void)
|
void netdev_shutdown(void)
|
||||||
|
@ -175,8 +175,3 @@ uint32_t netdev_station_watch_add(struct netdev *netdev,
|
|||||||
netdev_station_watch_func_t func, void *user_data);
|
netdev_station_watch_func_t func, void *user_data);
|
||||||
|
|
||||||
bool netdev_station_watch_remove(struct netdev *netdev, uint32_t id);
|
bool netdev_station_watch_remove(struct netdev *netdev, uint32_t id);
|
||||||
|
|
||||||
bool netdev_init(struct l_genl_family *in,
|
|
||||||
const char *whitelist, const char *blacklist);
|
|
||||||
bool netdev_exit(void);
|
|
||||||
void netdev_shutdown(void);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user