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
1 changed files with 20 additions and 28 deletions

View File

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