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
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ell/ell.h>
|
|
|
|
|
2014-05-21 06:44:13 +02:00
|
|
|
#include "src/kdbus.h"
|
|
|
|
|
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");
|
|
|
|
l_main_quit();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct l_signal *signal;
|
|
|
|
sigset_t mask;
|
2014-05-21 06:44:13 +02:00
|
|
|
char *bus_name;
|
|
|
|
int exit_status;
|
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);
|
|
|
|
|
|
|
|
l_log_set_stderr();
|
2014-05-21 06:44:13 +02:00
|
|
|
l_debug_enable("*");
|
2014-05-11 19:39:22 +02:00
|
|
|
|
|
|
|
l_info("Wireless daemon version %s", VERSION);
|
|
|
|
|
2014-05-21 06:44:13 +02:00
|
|
|
if (!kdbus_create_bus()) {
|
|
|
|
exit_status = EXIT_FAILURE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_name = kdbus_lookup_bus();
|
|
|
|
if (!bus_name) {
|
|
|
|
exit_status = EXIT_FAILURE;
|
|
|
|
goto destroy;
|
|
|
|
}
|
|
|
|
|
|
|
|
l_debug("Bus location: %s", bus_name);
|
2014-05-11 19:39:22 +02:00
|
|
|
|
2014-05-21 08:07:49 +02:00
|
|
|
if (!kdbus_open_bus(bus_name, "net.connman.iwd", "iwd")) {
|
|
|
|
exit_status = EXIT_FAILURE;
|
|
|
|
goto destroy;
|
|
|
|
}
|
|
|
|
|
2014-06-21 13:41:40 +02:00
|
|
|
if (!netdev_init()) {
|
|
|
|
exit_status = EXIT_FAILURE;
|
|
|
|
goto destroy;
|
|
|
|
}
|
|
|
|
|
2014-05-11 19:39:22 +02:00
|
|
|
l_main_run();
|
|
|
|
|
2014-06-21 13:41:40 +02:00
|
|
|
netdev_exit();
|
|
|
|
|
2014-05-21 06:44:13 +02:00
|
|
|
exit_status = EXIT_SUCCESS;
|
|
|
|
|
2014-05-21 08:07:49 +02:00
|
|
|
destroy:
|
2014-05-21 06:44:13 +02:00
|
|
|
l_free(bus_name);
|
|
|
|
|
|
|
|
kdbus_destroy_bus();
|
|
|
|
|
|
|
|
done:
|
2014-05-11 19:39:22 +02:00
|
|
|
l_signal_remove(signal);
|
|
|
|
|
2014-05-21 06:44:13 +02:00
|
|
|
return exit_status;
|
2014-05-11 19:39:22 +02:00
|
|
|
}
|