Skip to content
Snippets Groups Projects
Commit a4358bfd authored by Hauke Petersen's avatar Hauke Petersen
Browse files

sys/auto-init: added mechanism to init network ifs

parent 56cce195
No related branches found
No related tags found
No related merge requests found
ifneq (,$(filter auto_init,$(USEMODULE)))
include $(RIOTBASE)/sys/auto_init/Makefile.include
endif
ifneq (,$(filter nomac,$(USEMODULE))) ifneq (,$(filter nomac,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
endif endif
......
...@@ -6,4 +6,6 @@ ifneq (,$(filter nomac,$(USEMODULE))) ...@@ -6,4 +6,6 @@ ifneq (,$(filter nomac,$(USEMODULE)))
INCLUDES += -I$(RIOTBASE)/sys/net/include/ INCLUDES += -I$(RIOTBASE)/sys/net/include/
endif endif
DIRS += $(AUTO_INIT_MODULES)
include $(RIOTBASE)/Makefile.base include $(RIOTBASE)/Makefile.base
# try to find the ng_netif auto init implementation in the application or in
# the board, respectively. If it is not found, nothing is called.
ifneq (,$(filter ng_netif,$(USEMODULE)))
ifneq (,$(wildcard $(APPDIR)/auto_init_ng_netif/*))
export AUTO_INIT_MODULES += $(APPDIR)/auto_init_ng_netif
export USEMODULE += auto_init_ng_netif
else
ifneq (,$(wildcard $(RIOTBOARD)/$(BOARD)/auto_init_ng_netif/*))
export AUTO_INIT_MODULES += $(RIOTBOARD)/$(BOARD)/auto_init_ng_netif
export USEMODULE += auto_init_ng_netif
endif
endif
endif
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* @file auto_init_c * @file auto_init_c
* @brief initializes any used module that has a trivial init function * @brief initializes any used module that has a trivial init function
* @author Oliver Hahm <oliver.hahm@inria.fr> * @author Oliver Hahm <oliver.hahm@inria.fr>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @} * @}
*/ */
#include <stdint.h> #include <stdint.h>
...@@ -304,4 +305,8 @@ void auto_init(void) ...@@ -304,4 +305,8 @@ void auto_init(void)
DEBUG("Auto init UDP module.\n"); DEBUG("Auto init UDP module.\n");
ng_udp_init(); ng_udp_init();
#endif #endif
#ifdef MODULE_AUTO_INIT_NG_NETIF
DEBUG("Auto init network interfaces.\n");
auto_init_ng_netif();
#endif
} }
/* /*
* Copyright (C) 2010 Freie Universität Berlin * Copyright (C) 2010,2015 Freie Universität Berlin
* Copyright (C) 2010 Kaspar Schleiser * Copyright (C) 2010 Kaspar Schleiser
* Copyright (C) 2013 INRIA * Copyright (C) 2013 INRIA
* *
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
* @{ * @{
* *
* @file auto_init.h * @file auto_init.h
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Oliver Hahm <oliver.hahm@inria.fr>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/ */
#ifndef AUTO_INIT_H #ifndef AUTO_INIT_H
...@@ -45,6 +49,22 @@ extern "C" { ...@@ -45,6 +49,22 @@ extern "C" {
*/ */
void auto_init(void); void auto_init(void);
/**
* @brief Initialize network interfaces and register them with ng_netif
*
* This function must be implemented in the board or in the application,
* in a subfolder that must be named auto_init_ng_netif
* This function is called under two conditions:
* 1. the ng_netif module is used (USEMODULE contains ng_netif)
* 2. the board or the application contains a subfolder called
* auto_init_ng_netif
* If the board and the application both contain the mentioned subfolder,
* the contents from the applications subfolder have a higher priority
* and will be compiled and linked, while the board's subfolder is then
* ignored.
*/
void auto_init_ng_netif(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment