diff --git a/Makefile.include b/Makefile.include index b1344c18f..0c6cc679f 100644 --- a/Makefile.include +++ b/Makefile.include @@ -170,6 +170,9 @@ CONTIKI_SOURCEFILES += $(MODULES_SOURCES) # Include module-specific makefiles MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}} include $(MODULES_INCLUDES) +# Iterate once more: include the modules added from the previous include. +# Only works with one level of nested module inclusion. +include $(MODULES_INCLUDES) # C-include module-specific macros using -imacros MODULES_IMACROS = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/module-macros.h}} diff --git a/arch/platform/cooja/contiki-cooja-main.c b/arch/platform/cooja/contiki-cooja-main.c index d418e7039..53c8eb7d8 100644 --- a/arch/platform/cooja/contiki-cooja-main.c +++ b/arch/platform/cooja/contiki-cooja-main.c @@ -61,6 +61,7 @@ #include "dev/vib-sensor.h" #include "sys/node-id.h" +#include "services/rpl-border-router/rpl-border-router.h" #if BUILD_WITH_ORCHESTRA #include "orchestra.h" #endif /* BUILD_WITH_ORCHESTRA */ @@ -240,6 +241,9 @@ contiki_init() /* Start serial process */ serial_line_init(); +#if BUILD_WITH_RPL_BORDER_ROUTER + rpl_border_router_init(); +#endif /* BUILD_WITH_RPL_BORDER_ROUTER */ #if BUILD_WITH_ORCHESTRA orchestra_init(); #endif /* BUILD_WITH_ORCHESTRA */ diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index 3c2aae020..d8b14d5bd 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -2,12 +2,12 @@ CONTIKI_PROJECT = border-router all: $(CONTIKI_PROJECT) CONTIKI = ../.. +# Include RPL BR module +MODULES += os/services/rpl-border-router +# Include webserver module +MODULES_REL += webserver +# Include optional target-specific module include $(CONTIKI)/Makefile.identify-target - -ifneq ($(TARGET),native) - MODULES_REL += embedded -endif MODULES_REL += $(TARGET) -MODULES_REL += common include $(CONTIKI)/Makefile.include diff --git a/examples/rpl-border-router/border-router.c b/examples/rpl-border-router/border-router.c index 668b1d6dd..416d18093 100644 --- a/examples/rpl-border-router/border-router.c +++ b/examples/rpl-border-router/border-router.c @@ -46,8 +46,6 @@ PROCESS_THREAD(contiki_ng_br, ev, data) { PROCESS_BEGIN(); - PROCESS_NAME(border_router_process); - process_start(&border_router_process, NULL); #if BORDER_ROUTER_CONF_WEBSERVER PROCESS_NAME(webserver_nogui_process); process_start(&webserver_nogui_process, NULL); diff --git a/examples/rpl-border-router/project-conf.h b/examples/rpl-border-router/project-conf.h new file mode 100644 index 000000000..a2ffcc950 --- /dev/null +++ b/examples/rpl-border-router/project-conf.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ + +#ifndef WEBSERVER_CONF_CFS_CONNS +#define WEBSERVER_CONF_CFS_CONNS 2 +#endif + +#ifndef BORDER_ROUTER_CONF_WEBSERVER +#define BORDER_ROUTER_CONF_WEBSERVER 1 +#endif + +#if BORDER_ROUTER_CONF_WEBSERVER +#define UIP_CONF_TCP 1 +#endif + +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/rpl-border-router/common/httpd-simple.c b/examples/rpl-border-router/webserver/httpd-simple.c similarity index 100% rename from examples/rpl-border-router/common/httpd-simple.c rename to examples/rpl-border-router/webserver/httpd-simple.c diff --git a/examples/rpl-border-router/common/httpd-simple.h b/examples/rpl-border-router/webserver/httpd-simple.h similarity index 100% rename from examples/rpl-border-router/common/httpd-simple.h rename to examples/rpl-border-router/webserver/httpd-simple.h diff --git a/examples/rpl-border-router/common/webserver.c b/examples/rpl-border-router/webserver/webserver.c similarity index 100% rename from examples/rpl-border-router/common/webserver.c rename to examples/rpl-border-router/webserver/webserver.c diff --git a/os/contiki-main.c b/os/contiki-main.c index 62638c8a7..234b759ee 100644 --- a/os/contiki-main.c +++ b/os/contiki-main.c @@ -47,6 +47,7 @@ #include "sys/stack-check.h" #include "dev/watchdog.h" +#include "services/rpl-border-router/rpl-border-router.h" #include "services/orchestra/orchestra.h" #include "services/shell/serial-shell.h" @@ -110,6 +111,11 @@ main(void) platform_init_stage_three(); +#if BUILD_WITH_RPL_BORDER_ROUTER + rpl_border_router_init(); + LOG_DBG("With RPL Border Router\n"); +#endif /* BUILD_WITH_RPL_BORDER_ROUTER */ + #if BUILD_WITH_ORCHESTRA orchestra_init(); LOG_DBG("With Orchestra\n"); diff --git a/examples/rpl-border-router/embedded/Makefile.embedded b/os/services/rpl-border-router/embedded/Makefile.embedded similarity index 100% rename from examples/rpl-border-router/embedded/Makefile.embedded rename to os/services/rpl-border-router/embedded/Makefile.embedded diff --git a/examples/rpl-border-router/embedded/README.md b/os/services/rpl-border-router/embedded/README.md similarity index 100% rename from examples/rpl-border-router/embedded/README.md rename to os/services/rpl-border-router/embedded/README.md diff --git a/examples/rpl-border-router/embedded/border-router-embedded.c b/os/services/rpl-border-router/embedded/border-router-embedded.c similarity index 99% rename from examples/rpl-border-router/embedded/border-router-embedded.c rename to os/services/rpl-border-router/embedded/border-router-embedded.c index d1d8cdafc..8ec4bd49c 100644 --- a/examples/rpl-border-router/embedded/border-router-embedded.c +++ b/os/services/rpl-border-router/embedded/border-router-embedded.c @@ -39,7 +39,7 @@ #include "rpl.h" #include "dev/button-sensor.h" #include "dev/slip.h" -#include "border-router-common.h" +#include "rpl-border-router.h" /*---------------------------------------------------------------------------*/ /* Log configuration */ diff --git a/examples/rpl-border-router/embedded/slip-bridge.c b/os/services/rpl-border-router/embedded/slip-bridge.c similarity index 100% rename from examples/rpl-border-router/embedded/slip-bridge.c rename to os/services/rpl-border-router/embedded/slip-bridge.c diff --git a/examples/rpl-border-router/native/Makefile.native b/os/services/rpl-border-router/native/Makefile.native similarity index 100% rename from examples/rpl-border-router/native/Makefile.native rename to os/services/rpl-border-router/native/Makefile.native diff --git a/examples/rpl-border-router/native/README.md b/os/services/rpl-border-router/native/README.md similarity index 100% rename from examples/rpl-border-router/native/README.md rename to os/services/rpl-border-router/native/README.md diff --git a/examples/rpl-border-router/native/border-router-cmds.c b/os/services/rpl-border-router/native/border-router-cmds.c similarity index 100% rename from examples/rpl-border-router/native/border-router-cmds.c rename to os/services/rpl-border-router/native/border-router-cmds.c diff --git a/examples/rpl-border-router/native/border-router-cmds.h b/os/services/rpl-border-router/native/border-router-cmds.h similarity index 100% rename from examples/rpl-border-router/native/border-router-cmds.h rename to os/services/rpl-border-router/native/border-router-cmds.h diff --git a/examples/rpl-border-router/native/border-router-mac.c b/os/services/rpl-border-router/native/border-router-mac.c similarity index 100% rename from examples/rpl-border-router/native/border-router-mac.c rename to os/services/rpl-border-router/native/border-router-mac.c diff --git a/examples/rpl-border-router/native/border-router-native.c b/os/services/rpl-border-router/native/border-router-native.c similarity index 99% rename from examples/rpl-border-router/native/border-router-native.c rename to os/services/rpl-border-router/native/border-router-native.c index fd5e3cde7..07bd322c6 100644 --- a/examples/rpl-border-router/native/border-router-native.c +++ b/os/services/rpl-border-router/native/border-router-native.c @@ -41,7 +41,7 @@ #include "contiki.h" #include "contiki-net.h" #include "rpl.h" -#include "border-router-common.h" +#include "rpl-border-router.h" #include "cmd.h" #include "border-router.h" #include "border-router-cmds.h" diff --git a/examples/rpl-border-router/native/border-router.h b/os/services/rpl-border-router/native/border-router.h similarity index 100% rename from examples/rpl-border-router/native/border-router.h rename to os/services/rpl-border-router/native/border-router.h diff --git a/examples/rpl-border-router/native/module-macros.h b/os/services/rpl-border-router/native/module-macros.h similarity index 100% rename from examples/rpl-border-router/native/module-macros.h rename to os/services/rpl-border-router/native/module-macros.h diff --git a/examples/rpl-border-router/native/slip-config.c b/os/services/rpl-border-router/native/slip-config.c similarity index 100% rename from examples/rpl-border-router/native/slip-config.c rename to os/services/rpl-border-router/native/slip-config.c diff --git a/examples/rpl-border-router/native/slip-dev.c b/os/services/rpl-border-router/native/slip-dev.c similarity index 100% rename from examples/rpl-border-router/native/slip-dev.c rename to os/services/rpl-border-router/native/slip-dev.c diff --git a/examples/rpl-border-router/native/tun-bridge.c b/os/services/rpl-border-router/native/tun-bridge.c similarity index 100% rename from examples/rpl-border-router/native/tun-bridge.c rename to os/services/rpl-border-router/native/tun-bridge.c diff --git a/examples/rpl-border-router/common/border-router-common.c b/os/services/rpl-border-router/rpl-border-router.c similarity index 88% rename from examples/rpl-border-router/common/border-router-common.c rename to os/services/rpl-border-router/rpl-border-router.c index ba3288777..59426d7f9 100644 --- a/examples/rpl-border-router/common/border-router-common.c +++ b/os/services/rpl-border-router/rpl-border-router.c @@ -31,7 +31,7 @@ */ #include "contiki.h" -#include "border-router-common.h" +#include "rpl-border-router.h" #include "rpl-dag-root.h" /* Log configuration */ @@ -67,3 +67,11 @@ set_prefix_64(uip_ipaddr_t *prefix_64) rpl_dag_root_init(prefix_64, NULL); rpl_dag_root_init_dag_immediately(); } +/*---------------------------------------------------------------------------*/ +void +rpl_border_router_init(void) +{ + PROCESS_NAME(border_router_process); + process_start(&border_router_process, NULL); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/rpl-border-router/common/border-router-common.h b/os/services/rpl-border-router/rpl-border-router.h similarity index 98% rename from examples/rpl-border-router/common/border-router-common.h rename to os/services/rpl-border-router/rpl-border-router.h index 25d58aab0..50d66ad05 100644 --- a/examples/rpl-border-router/common/border-router-common.h +++ b/os/services/rpl-border-router/rpl-border-router.h @@ -36,5 +36,6 @@ extern uint8_t prefix_set; +void rpl_border_router_init(void); void print_local_addresses(void); void set_prefix_64(uip_ipaddr_t *prefix_64); diff --git a/examples/rpl-border-router/sky/slip-bridge-putchar.c b/os/services/rpl-border-router/sky/slip-bridge-putchar.c similarity index 100% rename from examples/rpl-border-router/sky/slip-bridge-putchar.c rename to os/services/rpl-border-router/sky/slip-bridge-putchar.c