2014-05-11 19:39:22 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2014-08-09 06:53:13 +02:00
|
|
|
#include <stdio.h>
|
2014-05-11 19:39:22 +02:00
|
|
|
#include <stdlib.h>
|
2018-05-03 21:45:26 +02:00
|
|
|
#include <errno.h>
|
2014-08-09 06:53:13 +02:00
|
|
|
#include <getopt.h>
|
2014-05-11 19:39:22 +02:00
|
|
|
#include <ell/ell.h>
|
2018-05-03 21:45:26 +02:00
|
|
|
#include "ell/key-private.h"
|
2014-05-11 19:39:22 +02:00
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
#include "linux/nl80211.h"
|
|
|
|
|
2016-05-12 04:59:03 +02:00
|
|
|
#include "src/iwd.h"
|
2014-06-21 20:51:26 +02:00
|
|
|
#include "src/netdev.h"
|
2016-05-05 19:13:45 +02:00
|
|
|
#include "src/device.h"
|
2014-07-29 21:25:01 +02:00
|
|
|
#include "src/wiphy.h"
|
2014-10-07 04:50:27 +02:00
|
|
|
#include "src/dbus.h"
|
2016-11-15 23:44:07 +01:00
|
|
|
#include "src/eap.h"
|
2015-09-29 02:51:40 +02:00
|
|
|
#include "src/eapol.h"
|
|
|
|
#include "src/scan.h"
|
|
|
|
#include "src/wsc.h"
|
2016-06-17 00:54:15 +02:00
|
|
|
#include "src/knownnetworks.h"
|
2016-07-02 16:42:39 +02:00
|
|
|
#include "src/rfkill.h"
|
2017-09-12 02:45:43 +02:00
|
|
|
#include "src/ap.h"
|
2017-11-22 23:34:38 +01:00
|
|
|
#include "src/plugin.h"
|
2017-11-29 18:24:46 +01:00
|
|
|
#include "src/simauth.h"
|
2018-07-17 23:16:02 +02:00
|
|
|
#include "src/adhoc.h"
|
2015-03-02 15:19:08 +01:00
|
|
|
|
2016-04-13 21:07:36 +02:00
|
|
|
#include "src/backtrace.h"
|
|
|
|
|
2016-11-02 22:04:37 +01:00
|
|
|
static struct l_settings *iwd_config;
|
2016-11-03 18:42:57 +01:00
|
|
|
static struct l_timeout *timeout;
|
2016-06-23 22:49:05 +02:00
|
|
|
static const char *interfaces;
|
|
|
|
static const char *nointerfaces;
|
2017-03-16 22:45:10 +01:00
|
|
|
static const char *phys;
|
|
|
|
static const char *nophys;
|
2016-11-02 22:04:37 +01:00
|
|
|
static const char *config_dir;
|
2017-11-22 23:34:38 +01:00
|
|
|
static const char *plugins;
|
|
|
|
static const char *noplugins;
|
2018-05-20 01:29:28 +02:00
|
|
|
static const char *debugopt;
|
2017-05-03 19:53:52 +02:00
|
|
|
static bool terminating;
|
2015-03-02 15:19:08 +01:00
|
|
|
|
|
|
|
static void main_loop_quit(struct l_timeout *timeout, void *user_data)
|
|
|
|
{
|
|
|
|
l_main_quit();
|
|
|
|
}
|
2014-05-21 06:44:13 +02:00
|
|
|
|
2017-05-03 19:53:51 +02:00
|
|
|
void iwd_shutdown(void)
|
|
|
|
{
|
2017-05-03 19:53:52 +02:00
|
|
|
if (terminating)
|
|
|
|
return;
|
|
|
|
|
|
|
|
terminating = true;
|
|
|
|
|
2017-05-03 19:53:51 +02:00
|
|
|
dbus_shutdown();
|
|
|
|
netdev_shutdown();
|
|
|
|
|
|
|
|
timeout = l_timeout_create(1, main_loop_quit, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2014-05-11 19:39:22 +02:00
|
|
|
static void signal_handler(struct l_signal *signal, uint32_t signo,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
switch (signo) {
|
|
|
|
case SIGINT:
|
|
|
|
case SIGTERM:
|
|
|
|
l_info("Terminate");
|
2017-05-03 19:53:51 +02:00
|
|
|
iwd_shutdown();
|
2014-05-11 19:39:22 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 22:04:37 +01:00
|
|
|
const struct l_settings *iwd_get_config(void)
|
|
|
|
{
|
|
|
|
return iwd_config;
|
|
|
|
}
|
|
|
|
|
2014-08-09 06:53:13 +02:00
|
|
|
static void usage(void)
|
|
|
|
{
|
|
|
|
printf("iwd - Wireless daemon\n"
|
|
|
|
"Usage:\n");
|
|
|
|
printf("\tiwd [options]\n");
|
|
|
|
printf("Options:\n"
|
2016-10-16 19:41:27 +02:00
|
|
|
"\t-B, --dbus-debug Enable D-Bus debugging\n"
|
2016-06-23 22:49:05 +02:00
|
|
|
"\t-i, --interfaces Interfaces to manage\n"
|
|
|
|
"\t-I, --nointerfaces Interfaces to ignore\n"
|
2017-03-16 22:45:10 +01:00
|
|
|
"\t-p, --phys Phys to manage\n"
|
|
|
|
"\t-P, --nophys Phys to ignore\n"
|
2016-11-02 22:04:37 +01:00
|
|
|
"\t-c, --config Configuration directory to use\n"
|
2017-11-22 23:34:38 +01:00
|
|
|
"\t-l, --plugin Plugins to include\n"
|
|
|
|
"\t-L, --noplugin Plugins to exclude\n"
|
2018-05-20 01:29:28 +02:00
|
|
|
"\t-d, --debug Enable debug output\n"
|
2014-08-09 06:53:13 +02:00
|
|
|
"\t-h, --help Show help options\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct option main_options[] = {
|
2016-06-23 22:49:05 +02:00
|
|
|
{ "dbus-debug", no_argument, NULL, 'B' },
|
|
|
|
{ "version", no_argument, NULL, 'v' },
|
|
|
|
{ "interfaces", required_argument, NULL, 'i' },
|
|
|
|
{ "nointerfaces", required_argument, NULL, 'I' },
|
2017-03-16 22:45:10 +01:00
|
|
|
{ "phys", required_argument, NULL, 'p' },
|
|
|
|
{ "nophys", required_argument, NULL, 'P' },
|
2016-11-02 22:04:37 +01:00
|
|
|
{ "config", required_argument, NULL, 'c' },
|
2017-11-22 23:34:38 +01:00
|
|
|
{ "plugin", required_argument, NULL, 'l' },
|
|
|
|
{ "noplugin", required_argument, NULL, 'L' },
|
2018-05-20 01:29:28 +02:00
|
|
|
{ "debug", optional_argument, NULL, 'd' },
|
2016-06-23 22:49:05 +02:00
|
|
|
{ "help", no_argument, NULL, 'h' },
|
2014-08-09 06:53:13 +02:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
static void do_debug(const char *str, void *user_data)
|
|
|
|
{
|
|
|
|
const char *prefix = user_data;
|
|
|
|
|
|
|
|
l_info("%s%s", prefix, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nl80211_appeared(void *user_data)
|
|
|
|
{
|
|
|
|
struct l_genl_family *nl80211 = user_data;
|
|
|
|
|
2017-05-03 19:53:52 +02:00
|
|
|
if (terminating)
|
|
|
|
return;
|
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
l_debug("Found nl80211 interface");
|
|
|
|
|
2017-03-16 22:45:10 +01:00
|
|
|
if (!wiphy_init(nl80211, phys, nophys))
|
2015-09-29 02:51:40 +02:00
|
|
|
l_error("Unable to init wiphy functionality");
|
|
|
|
|
2016-06-24 00:34:29 +02:00
|
|
|
if (!netdev_init(nl80211, interfaces, nointerfaces))
|
2016-06-01 21:58:51 +02:00
|
|
|
l_error("Unable to init netdev functionality");
|
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
if (!scan_init(nl80211))
|
|
|
|
l_error("Unable to init scan functionality");
|
|
|
|
|
|
|
|
if (!wsc_init(nl80211))
|
|
|
|
l_error("Unable to init WSC functionality");
|
2017-09-12 02:45:43 +02:00
|
|
|
|
|
|
|
ap_init(nl80211);
|
2015-09-29 02:51:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void nl80211_vanished(void *user_data)
|
|
|
|
{
|
|
|
|
l_debug("Lost nl80211 interface");
|
|
|
|
|
2017-09-12 02:45:43 +02:00
|
|
|
ap_exit();
|
2015-09-29 02:51:40 +02:00
|
|
|
wsc_exit();
|
|
|
|
scan_exit();
|
2016-06-01 21:58:51 +02:00
|
|
|
netdev_exit();
|
2015-09-29 02:51:40 +02:00
|
|
|
wiphy_exit();
|
|
|
|
}
|
|
|
|
|
2018-05-03 21:45:26 +02:00
|
|
|
static void print_koption(const void *key, void *value, void *user_data)
|
|
|
|
{
|
|
|
|
l_info("\t%s", (const char *) key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int check_crypto()
|
|
|
|
{
|
|
|
|
int r = 0;
|
|
|
|
struct l_hashmap *options = l_hashmap_string_new();
|
|
|
|
struct l_hashmap *optional = l_hashmap_string_new();
|
|
|
|
|
|
|
|
if (!l_checksum_is_supported(L_CHECKSUM_SHA1, true)) {
|
|
|
|
r = -ENOTSUP;
|
|
|
|
l_error("No HMAC(SHA1) support found");
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_USER_API_HASH", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_SHA1", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_HMAC", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_SHA1_SSSE3", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_checksum_is_supported(L_CHECKSUM_MD5, true)) {
|
|
|
|
r = -ENOTSUP;
|
|
|
|
l_error("No HMAC(MD5) support found");
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_USER_API_HASH", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_MD5", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_HMAC", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_checksum_cmac_aes_supported()) {
|
|
|
|
r = -ENOTSUP;
|
|
|
|
l_error("No CMAC(AES) support found");
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_USER_API_HASH", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_AES", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_CMAC", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_AES_X86_64", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_AES_NI_INTEL", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_checksum_is_supported(L_CHECKSUM_SHA256, true)) {
|
|
|
|
r = -ENOTSUP;
|
|
|
|
l_error("No HMAC(SHA256) support not found");
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_USER_API_HASH", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_HMAC", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_SHA256", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_SHA256_SSSE3", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_checksum_is_supported(L_CHECKSUM_SHA512, true)) {
|
|
|
|
l_warn("No HMAC(SHA512) support found, "
|
|
|
|
"certain TLS connections might fail");
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_SHA512", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_SHA512_SSSE3", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_ARC4)) {
|
|
|
|
r = -ENOTSUP;
|
|
|
|
l_error("RC4 support not found");
|
|
|
|
l_hashmap_insert(options,
|
|
|
|
"CONFIG_CRYPTO_USER_API_SKCIPHER", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_ARC4", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_ECB", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_DES) ||
|
|
|
|
!l_cipher_is_supported(L_CIPHER_DES3_EDE_CBC)) {
|
|
|
|
r = -ENOTSUP;
|
|
|
|
l_error("DES support not found");
|
|
|
|
l_hashmap_insert(options,
|
|
|
|
"CONFIG_CRYPTO_USER_API_SKCIPHER", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_DES", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_ECB", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_DES3_EDE_X86_64", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_AES)) {
|
|
|
|
r = -ENOTSUP;
|
|
|
|
l_error("AES support not found");
|
|
|
|
l_hashmap_insert(options,
|
|
|
|
"CONFIG_CRYPTO_USER_API_SKCIPHER", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_AES", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_ECB", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_AES_X86_64", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_AES_NI_INTEL", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_DES3_EDE_CBC)) {
|
|
|
|
l_warn("No CBC(DES3_EDE) support found, "
|
|
|
|
"certain TLS connections might fail");
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_DES", &r);
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_CBC", &r);
|
|
|
|
l_hashmap_insert(optional, "CONFIG_CRYPTO_DES3_EDE_X86_64", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_AES_CBC)) {
|
|
|
|
l_warn("No CBC(AES) support found, "
|
|
|
|
"WPS will not be available");
|
|
|
|
l_hashmap_insert(options, "CONFIG_CRYPTO_CBC", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_key_is_supported(L_KEY_FEATURE_DH)) {
|
|
|
|
l_warn("No Diffie-Hellman support found, "
|
|
|
|
"WPS will not be available");
|
|
|
|
l_hashmap_insert(options, "CONFIG_KEY_DH_OPERATIONS", &r);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l_hashmap_isempty(options))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
l_info("The following options are missing in the kernel:");
|
|
|
|
|
|
|
|
if (l_hashmap_remove(options, "CONFIG_CRYPTO_USER_API_HASH"))
|
|
|
|
l_info("\tCONFIG_CRYPTO_USER_API_HASH");
|
|
|
|
|
|
|
|
if (l_hashmap_remove(options, "CONFIG_CRYPTO_USER_API_SKCIPHER"))
|
|
|
|
l_info("\tCONFIG_CRYPTO_USER_API_SKCIPHER");
|
|
|
|
|
|
|
|
l_hashmap_foreach(options, print_koption, NULL);
|
|
|
|
|
|
|
|
l_info("The following optimized implementations might be available:");
|
|
|
|
l_hashmap_foreach(optional, print_koption, NULL);
|
|
|
|
|
|
|
|
done:
|
|
|
|
l_hashmap_destroy(options, NULL);
|
|
|
|
l_hashmap_destroy(optional, NULL);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-05-11 19:39:22 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2014-11-08 04:43:18 +01:00
|
|
|
bool enable_dbus_debug = false;
|
2014-05-11 19:39:22 +02:00
|
|
|
struct l_signal *signal;
|
|
|
|
sigset_t mask;
|
2014-05-21 06:44:13 +02:00
|
|
|
int exit_status;
|
2015-09-29 02:51:40 +02:00
|
|
|
struct l_genl *genl;
|
|
|
|
struct l_genl_family *nl80211;
|
2016-11-02 22:04:37 +01:00
|
|
|
char *config_path;
|
2016-11-15 23:44:07 +01:00
|
|
|
uint32_t eap_mtu;
|
2014-05-11 19:39:22 +02:00
|
|
|
|
2014-08-09 06:53:13 +02:00
|
|
|
for (;;) {
|
|
|
|
int opt;
|
|
|
|
|
2018-05-20 01:29:28 +02:00
|
|
|
opt = getopt_long(argc, argv, "Bi:I:p:P:c:vd::h",
|
2017-03-16 22:45:10 +01:00
|
|
|
main_options, NULL);
|
2014-08-09 06:53:13 +02:00
|
|
|
if (opt < 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (opt) {
|
2014-11-08 04:43:18 +01:00
|
|
|
case 'B':
|
|
|
|
enable_dbus_debug = true;
|
|
|
|
break;
|
2016-06-23 22:49:05 +02:00
|
|
|
case 'i':
|
|
|
|
interfaces = optarg;
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
nointerfaces = optarg;
|
|
|
|
break;
|
2017-03-16 22:45:10 +01:00
|
|
|
case 'p':
|
|
|
|
phys = optarg;
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
nophys = optarg;
|
|
|
|
break;
|
2014-08-09 06:53:13 +02:00
|
|
|
case 'v':
|
|
|
|
printf("%s\n", VERSION);
|
|
|
|
return EXIT_SUCCESS;
|
2016-11-02 22:04:37 +01:00
|
|
|
case 'c':
|
|
|
|
config_dir = optarg;
|
|
|
|
break;
|
2017-11-22 23:34:38 +01:00
|
|
|
case 'l':
|
|
|
|
plugins = optarg;
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
noplugins = optarg;
|
|
|
|
break;
|
2018-05-20 01:29:28 +02:00
|
|
|
case 'd':
|
|
|
|
if (optarg)
|
|
|
|
debugopt = optarg;
|
|
|
|
else if (argv[optind] && argv[optind][0] != '-')
|
|
|
|
debugopt = argv[optind++];
|
|
|
|
else
|
|
|
|
debugopt = "*";
|
|
|
|
break;
|
2014-08-09 06:53:13 +02:00
|
|
|
case 'h':
|
|
|
|
usage();
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
default:
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc - optind > 0) {
|
|
|
|
fprintf(stderr, "Invalid command line parameters\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2018-05-03 21:45:26 +02:00
|
|
|
l_log_set_stderr();
|
|
|
|
|
|
|
|
if (check_crypto() < 0)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2016-06-09 16:38:13 +02:00
|
|
|
if (!l_main_init())
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2014-05-11 19:39:22 +02:00
|
|
|
sigemptyset(&mask);
|
|
|
|
sigaddset(&mask, SIGINT);
|
|
|
|
sigaddset(&mask, SIGTERM);
|
|
|
|
|
|
|
|
signal = l_signal_create(&mask, signal_handler, NULL, NULL);
|
|
|
|
|
2018-05-20 01:29:28 +02:00
|
|
|
if (debugopt)
|
|
|
|
l_debug_enable(debugopt);
|
2014-05-11 19:39:22 +02:00
|
|
|
|
2016-04-13 21:07:36 +02:00
|
|
|
#ifdef __GLIBC__
|
2017-03-16 21:13:35 +01:00
|
|
|
__iwd_backtrace_init();
|
2016-04-13 21:07:36 +02:00
|
|
|
#endif
|
|
|
|
|
2014-05-11 19:39:22 +02:00
|
|
|
l_info("Wireless daemon version %s", VERSION);
|
|
|
|
|
2016-11-02 22:04:37 +01:00
|
|
|
if (!config_dir)
|
|
|
|
config_dir = CONFIGDIR;
|
|
|
|
|
2018-01-29 11:13:41 +01:00
|
|
|
config_path = l_strdup_printf("/%s/%s", config_dir, "main.conf");
|
2016-11-02 22:04:37 +01:00
|
|
|
|
|
|
|
iwd_config = l_settings_new();
|
|
|
|
|
|
|
|
if (!l_settings_load_from_file(iwd_config, config_path))
|
2018-01-29 11:24:52 +01:00
|
|
|
l_warn("Skipping optional configuration file %s", config_path);
|
2016-11-02 22:04:37 +01:00
|
|
|
|
|
|
|
l_free(config_path);
|
|
|
|
|
2016-10-16 19:41:27 +02:00
|
|
|
if (!dbus_init(enable_dbus_debug)) {
|
2014-10-07 04:50:27 +02:00
|
|
|
exit_status = EXIT_FAILURE;
|
2016-04-01 04:27:37 +02:00
|
|
|
goto done;
|
2014-10-07 04:50:27 +02:00
|
|
|
}
|
|
|
|
|
2017-11-29 18:24:46 +01:00
|
|
|
if (!sim_auth_init()) {
|
|
|
|
l_error("Failed to start sim auth module");
|
|
|
|
exit_status = EXIT_FAILURE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2017-11-22 23:34:38 +01:00
|
|
|
plugin_init(plugins, noplugins);
|
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
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);
|
|
|
|
|
2016-05-05 19:13:45 +02:00
|
|
|
if (!device_init()) {
|
|
|
|
exit_status = EXIT_FAILURE;
|
|
|
|
goto fail_device;
|
|
|
|
}
|
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
l_debug("Opening nl80211 interface");
|
|
|
|
|
|
|
|
nl80211 = l_genl_family_new(genl, NL80211_GENL_NAME);
|
|
|
|
if (!nl80211) {
|
|
|
|
l_error("Failed to open nl80211 interface");
|
2014-06-21 13:41:40 +02:00
|
|
|
exit_status = EXIT_FAILURE;
|
2015-09-29 02:51:40 +02:00
|
|
|
goto fail_nl80211;
|
2014-06-21 13:41:40 +02:00
|
|
|
}
|
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
l_genl_family_set_watches(nl80211, nl80211_appeared, nl80211_vanished,
|
|
|
|
nl80211, NULL);
|
|
|
|
|
2016-11-15 23:44:07 +01:00
|
|
|
if (!l_settings_get_uint(iwd_config, "EAP", "mtu", &eap_mtu))
|
|
|
|
eap_mtu = 1400; /* on WiFi the real MTU is around 2304 */
|
|
|
|
|
2018-04-02 20:47:44 +02:00
|
|
|
__eapol_set_config(iwd_config);
|
|
|
|
|
2018-07-17 23:16:02 +02:00
|
|
|
adhoc_init();
|
2016-11-15 23:44:07 +01:00
|
|
|
eap_init(eap_mtu);
|
2015-09-29 02:51:40 +02:00
|
|
|
eapol_init();
|
2015-06-22 22:08:12 +02:00
|
|
|
network_init();
|
2016-06-17 00:54:15 +02:00
|
|
|
known_networks_init();
|
2016-07-02 16:42:39 +02:00
|
|
|
rfkill_init();
|
2015-06-22 22:08:12 +02:00
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
exit_status = EXIT_SUCCESS;
|
2014-05-11 19:39:22 +02:00
|
|
|
l_main_run();
|
|
|
|
|
2016-07-02 16:42:39 +02:00
|
|
|
rfkill_exit();
|
2016-06-17 00:54:15 +02:00
|
|
|
known_networks_exit();
|
2015-06-22 22:08:12 +02:00
|
|
|
network_exit();
|
2018-07-17 23:16:02 +02:00
|
|
|
adhoc_exit();
|
2015-09-29 02:51:40 +02:00
|
|
|
eapol_exit();
|
2016-11-15 23:44:07 +01:00
|
|
|
eap_exit();
|
2017-11-22 23:34:38 +01:00
|
|
|
plugin_exit();
|
2017-11-29 18:24:46 +01:00
|
|
|
sim_auth_exit();
|
2015-09-29 02:51:40 +02:00
|
|
|
|
|
|
|
l_genl_family_unref(nl80211);
|
|
|
|
|
|
|
|
fail_nl80211:
|
2016-05-05 19:13:45 +02:00
|
|
|
device_exit();
|
|
|
|
|
|
|
|
fail_device:
|
2015-09-29 02:51:40 +02:00
|
|
|
l_genl_unref(genl);
|
|
|
|
|
|
|
|
fail_genl:
|
|
|
|
dbus_exit();
|
2014-05-21 06:44:13 +02:00
|
|
|
|
|
|
|
done:
|
2016-11-02 22:04:37 +01:00
|
|
|
l_settings_free(iwd_config);
|
|
|
|
|
2014-05-11 19:39:22 +02:00
|
|
|
l_signal_remove(signal);
|
2015-03-02 15:19:08 +01:00
|
|
|
l_timeout_remove(timeout);
|
2014-05-11 19:39:22 +02:00
|
|
|
|
2016-06-09 16:38:13 +02:00
|
|
|
l_main_exit();
|
|
|
|
|
2014-05-21 06:44:13 +02:00
|
|
|
return exit_status;
|
2014-05-11 19:39:22 +02:00
|
|
|
}
|