1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c

69 lines
2.2 KiB
C
Raw Normal View History

2016-05-14 12:46:14 +02:00
/*
* Copyright (C) 2016 Cenk Gündoğan <cenk.guendogan@haw-hamburg.de>
2016-05-14 12:46:14 +02:00
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*
*/
/*
2018-06-01 13:19:39 +02:00
* @ingroup net_gnrc_rpl
2016-05-14 12:46:14 +02:00
* @{
*
* @file
* @brief Auto initialization for gnrc_rpl
*
* @author Cenk Gündoğan <cenk.guendogan@haw-hamburg.de>
2016-05-14 12:46:14 +02:00
*/
#ifdef MODULE_AUTO_INIT_GNRC_RPL
#include "log.h"
2016-05-14 12:46:14 +02:00
#include "net/gnrc.h"
#include "net/gnrc/rpl.h"
2020-10-22 11:35:22 +02:00
#define ENABLE_DEBUG 0
2016-05-14 12:46:14 +02:00
#include "debug.h"
void auto_init_gnrc_rpl(void)
{
if (gnrc_netif_highlander() || gnrc_netif_numof() == 1) {
gnrc_netif_t *netif = gnrc_netif_iter(NULL);
if (netif == NULL) {
/* XXX this is just a work-around ideally this would happen with
* an `up` event of the interface */
LOG_INFO("Unable to auto-initialize RPL. No interfaces found.\n");
return;
}
DEBUG("auto_init_gnrc_rpl: initializing RPL on interface %" PRIkernel_pid "\n",
netif->pid);
gnrc_rpl_init(netif->pid);
return;
}
else if (CONFIG_GNRC_RPL_DEFAULT_NETIF != KERNEL_PID_UNDEF) {
if (gnrc_netif_get_by_pid(CONFIG_GNRC_RPL_DEFAULT_NETIF) != NULL) {
DEBUG("auto_init_gnrc_rpl: initializing RPL on interface %" PRIkernel_pid "\n",
(kernel_pid_t) CONFIG_GNRC_RPL_DEFAULT_NETIF);
gnrc_rpl_init(CONFIG_GNRC_RPL_DEFAULT_NETIF);
return;
}
/* XXX this is just a work-around ideally this would happen with
* an `up` event of the CONFIG_GNRC_RPL_DEFAULT_NETIF */
DEBUG("auto_init_gnrc_rpl: could not initialize RPL on interface %" PRIkernel_pid" - "
"interface does not exist\n", (kernel_pid_t) CONFIG_GNRC_RPL_DEFAULT_NETIF);
2016-05-14 12:46:14 +02:00
return;
}
else {
/* XXX this is just a work-around ideally this should be defined in some
* run-time interface configuration */
DEBUG("auto_init_gnrc_rpl: please specify an interface "
"by setting CONFIG_GNRC_RPL_DEFAULT_NETIF\n");
}
2016-05-14 12:46:14 +02:00
}
#else
typedef int dont_be_pedantic;
#endif /* MODULE_AUTO_INIT_GNRC_RPL */
/** @} */