1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #13628 from jia200x/pr/gnrc_rpl_macro

gnrc_rpl: add default value to GNRC_RPL_DEFAULT_NETIF
This commit is contained in:
Leandro Lanzieri 2020-03-13 15:47:13 +01:00 committed by GitHub
commit d281d4843f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 26 deletions

View File

@ -487,6 +487,13 @@ extern netstats_rpl_t gnrc_rpl_netstats;
#define GNRC_RPL_PARENT_TIMEOUT_DIS_RETRIES (3)
#endif
/**
* @brief Default network interface for GNRC RPL
*/
#ifndef GNRC_RPL_DEFAULT_NETIF
#define GNRC_RPL_DEFAULT_NETIF (KERNEL_PID_UNDEF)
#endif
/**
* @brief Initialization of the RPL thread.
*

View File

@ -28,35 +28,37 @@
void auto_init_gnrc_rpl(void)
{
#if (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;
#elif defined(GNRC_RPL_DEFAULT_NETIF)
if (gnrc_netif_get_by_pid(GNRC_RPL_DEFAULT_NETIF) != NULL) {
if (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",
GNRC_RPL_DEFAULT_NETIF);
gnrc_rpl_init(GNRC_RPL_DEFAULT_NETIF);
netif->pid);
gnrc_rpl_init(netif->pid);
return;
}
/* XXX this is just a work-around ideally this would happen with
* an `up` event of the GNRC_RPL_DEFAULT_NETIF */
DEBUG("auto_init_gnrc_rpl: could not initialize RPL on interface %" PRIkernel_pid" - "
"interface does not exist\n", GNRC_RPL_DEFAULT_NETIF);
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 GNRC_RPL_DEFAULT_NETIF\n");
#endif
else if (GNRC_RPL_DEFAULT_NETIF != KERNEL_PID_UNDEF) {
if (gnrc_netif_get_by_pid(GNRC_RPL_DEFAULT_NETIF) != NULL) {
DEBUG("auto_init_gnrc_rpl: initializing RPL on interface %" PRIkernel_pid "\n",
(kernel_pid_t) GNRC_RPL_DEFAULT_NETIF);
gnrc_rpl_init(GNRC_RPL_DEFAULT_NETIF);
return;
}
/* XXX this is just a work-around ideally this would happen with
* an `up` event of the 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) GNRC_RPL_DEFAULT_NETIF);
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 GNRC_RPL_DEFAULT_NETIF\n");
}
}
#else
typedef int dont_be_pedantic;