3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 10:39:23 +01:00

main: Rework initialization order

Group together all the configuration settings / reading code together
for more readability.

Initialize eap, eapol and rfkill before device
This commit is contained in:
Denis Kenzior 2018-08-17 23:32:30 -05:00
parent c5b19dc747
commit b3e937e11a

View File

@ -389,7 +389,6 @@ int main(int argc, char *argv[])
config_dir = CONFIGDIR; config_dir = CONFIGDIR;
config_path = l_strdup_printf("/%s/%s", config_dir, "main.conf"); config_path = l_strdup_printf("/%s/%s", config_dir, "main.conf");
iwd_config = l_settings_new(); iwd_config = l_settings_new();
if (!l_settings_load_from_file(iwd_config, config_path)) if (!l_settings_load_from_file(iwd_config, config_path))
@ -397,50 +396,47 @@ int main(int argc, char *argv[])
l_free(config_path); l_free(config_path);
__eapol_set_config(iwd_config);
if (!l_settings_get_uint(iwd_config, "EAP", "mtu", &eap_mtu))
eap_mtu = 1400; /* on WiFi the real MTU is around 2304 */
exit_status = EXIT_FAILURE;
if (!dbus_init(enable_dbus_debug)) { if (!dbus_init(enable_dbus_debug)) {
exit_status = EXIT_FAILURE; l_error("Failed to initialize D-Bus");
goto done; goto fail_dbus;
} }
genl = l_genl_new_default(); genl = l_genl_new_default();
if (!genl) { if (!genl) {
l_error("Failed to open generic netlink socket"); l_error("Failed to open generic netlink socket");
exit_status = EXIT_FAILURE;
goto fail_genl; goto fail_genl;
} }
if (getenv("IWD_GENL_DEBUG")) if (getenv("IWD_GENL_DEBUG"))
l_genl_set_debug(genl, do_debug, "[GENL] ", NULL); l_genl_set_debug(genl, do_debug, "[GENL] ", NULL);
if (!device_init()) {
exit_status = EXIT_FAILURE;
goto fail_device;
}
l_debug("Opening nl80211 interface");
nl80211 = l_genl_family_new(genl, NL80211_GENL_NAME); nl80211 = l_genl_family_new(genl, NL80211_GENL_NAME);
if (!nl80211) { if (!nl80211) {
l_error("Failed to open nl80211 interface"); l_error("Failed to open nl80211 interface");
exit_status = EXIT_FAILURE;
goto fail_nl80211; goto fail_nl80211;
} }
l_genl_family_set_watches(nl80211, nl80211_appeared, nl80211_vanished, l_genl_family_set_watches(nl80211, nl80211_appeared, nl80211_vanished,
nl80211, NULL); nl80211, NULL);
if (!l_settings_get_uint(iwd_config, "EAP", "mtu", &eap_mtu)) eap_init(eap_mtu);
eap_mtu = 1400; /* on WiFi the real MTU is around 2304 */ eapol_init();
rfkill_init();
__eapol_set_config(iwd_config); if (!device_init())
goto fail_device;
adhoc_init(); adhoc_init();
wsc_init(); wsc_init();
eap_init(eap_mtu);
eapol_init();
network_init(); network_init();
known_networks_init(); known_networks_init();
rfkill_init();
sim_auth_init(); sim_auth_init();
plugin_init(plugins, noplugins); plugin_init(plugins, noplugins);
@ -449,26 +445,22 @@ int main(int argc, char *argv[])
plugin_exit(); plugin_exit();
sim_auth_exit(); sim_auth_exit();
rfkill_exit();
known_networks_exit(); known_networks_exit();
network_exit(); network_exit();
eapol_exit();
eap_exit();
wsc_exit(); wsc_exit();
adhoc_exit(); adhoc_exit();
device_exit();
fail_device:
rfkill_exit();
eapol_exit();
eap_exit();
l_genl_family_unref(nl80211); l_genl_family_unref(nl80211);
fail_nl80211: fail_nl80211:
device_exit();
fail_device:
l_genl_unref(genl); l_genl_unref(genl);
fail_genl: fail_genl:
dbus_exit(); dbus_exit();
fail_dbus:
done:
l_settings_free(iwd_config); l_settings_free(iwd_config);
l_signal_remove(signal); l_signal_remove(signal);