diff --git a/.gitignore b/.gitignore index 035e0c7c5..74bef3888 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ *~ obj_* Makefile.target +Makefile.*.defines tools/doxygen/html patches-* tools/tunslip diff --git a/Makefile.include b/Makefile.include index bcddedca8..ec927b88b 100644 --- a/Makefile.include +++ b/Makefile.include @@ -8,7 +8,7 @@ endif # Setting this option is also important for tests on Cooja motes to check for warnings. WERROR ?= 1 -include $(CONTIKI)/Makefile.identify-target +include $(CONTIKI)/Makefile.identify-target ifeq ($(DEFINES),) -include Makefile.$(TARGET).defines @@ -57,7 +57,6 @@ MODULES += os os/net os/net/mac os/storage oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}} CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}} - PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}} # Provide way to create $(OBJECTDIR) if it has been removed by make clean @@ -169,13 +168,22 @@ else CFLAGS += -DUIP_CONF_IPV6_RPL=0 endif -ifdef MODULES - UNIQUEMODULES = $(call uniq,$(MODULES)) - MODULEDIRS = ${wildcard ${addprefix $(CONTIKI)/, $(UNIQUEMODULES)}} - MODULES_SOURCES = ${foreach d, $(MODULEDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}} - MODULES_INCLUDES = ${wildcard ${foreach d, $(MODULEDIRS), $(d)/Makefile.${notdir $(d)}}} - include $(MODULES_INCLUDES) - CONTIKI_SOURCEFILES += $(MODULES_SOURCES) +MODULEDIRS = $(MODULES_REL) ${wildcard ${addprefix $(CONTIKI)/, $(MODULES)}} +UNIQUEMODULES = $(call uniq,$(MODULEDIRS)) +MODULES_SOURCES = ${foreach d, $(MODULEDIRS), ${subst ${d}/,,${wildcard $(d)/*.c}}} +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}} +ifneq ($(MODULES_IMACROS),) + CFLAGS += ${foreach d, $(MODULES_IMACROS), -imacros $(d)} endif ### Verbosity control. Use make V=1 to get verbose builds. @@ -247,7 +255,6 @@ clean: -rm -f *~ *core core *.srec \ *.lst *.map \ *.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \ - *.ce *.co rm -rf $(CLEAN) -rm -rf $(OBJECTDIR) @@ -256,13 +263,6 @@ distclean: clean -include $(CONTIKI)/arch/platform/$(TARGET)/Makefile.customrules-$(TARGET) -ifndef CUSTOM_RULE_C_TO_CE -%.ce: %.c - $(TRACE_CC) - $(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@ - $(STRIP) --strip-unneeded -g -x $@ -endif - ifndef CUSTOM_RULE_C_TO_OBJECTDIR_O $(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) $(TRACE_CC) @@ -306,12 +306,6 @@ ifndef CUSTOM_RULE_C_TO_E $(Q)$(CC) $(CFLAGS) -E $< -o $@ endif -ifndef CUSTOM_RULE_C_TO_CO -%.co: %.c - $(TRACE_CC) - $(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@ -endif - ifndef AROPTS AROPTS = rcf endif @@ -327,7 +321,7 @@ ifndef LD endif ifndef CUSTOM_RULE_LINK -%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a +%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(TRACE_LD) $(Q)$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} \ ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ diff --git a/arch/cpu/arm/common/usb/Makefile.usb b/arch/cpu/arm/common/usb/Makefile.usb index 3286ca365..05266cf7b 100644 --- a/arch/cpu/arm/common/usb/Makefile.usb +++ b/arch/cpu/arm/common/usb/Makefile.usb @@ -6,7 +6,7 @@ endif STRUCTGEN = structgen -PROJECTDIRS += $(BUILTSRCDIR) +MODULES_REL += $(BUILTSRCDIR) USB_STRING_DESCRIPTORS ?= $(CONTIKI_CPU_ARM)/common/usb/cdc-acm/string-descriptors.xml diff --git a/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 b/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 index 8baf1651d..f5547fea0 100644 --- a/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 +++ b/arch/cpu/arm/cortex-m/cm3/Makefile.cm3 @@ -17,7 +17,9 @@ CPU_STARTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CPU_START_SOURCEFILES ### Compilation rules CUSTOM_RULE_LINK = 1 -%.elf: $(CPU_STARTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(LDSCRIPT) +.SECONDEXPANSION: + +%.elf: $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT) $(TRACE_LD) $(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -lm -o $@ diff --git a/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 b/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 index ca79428f1..78367b0eb 100644 --- a/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 +++ b/arch/cpu/arm/cortex-m/cm4/Makefile.cm4 @@ -6,8 +6,8 @@ LDFLAGS += -mcpu=cortex-m4 ### Compilation rules CUSTOM_RULE_LINK=1 -%.elf: $(TARGET_STARTFILES) %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(TARGET_LIBS) +%.elf: $(TARGET_STARTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(TARGET_LIBS) $(TRACE_LD) - $(Q)$(CC) $(LDFLAGS) ${filter %o %.co %.a,$^} -o $@ + $(Q)$(CC) $(LDFLAGS) ${filter %.o %.a,$^} -o $@ include $(CONTIKI)/arch/cpu/arm/cortex-m/Makefile.cortex-m diff --git a/arch/cpu/cc2538/Makefile.cc2538 b/arch/cpu/cc2538/Makefile.cc2538 index 18213ca74..c0a2bb2f0 100644 --- a/arch/cpu/cc2538/Makefile.cc2538 +++ b/arch/cpu/cc2538/Makefile.cc2538 @@ -36,8 +36,6 @@ CPU_START_SOURCEFILES = startup-gcc.c CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES) CONTIKI_SOURCEFILES += $(USB_SOURCEFILES) -.SECONDEXPANSION: - ### Always re-build ieee-addr.o in case the command line passes a new NODEID FORCE: diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c index a354fdd4b..cf1676570 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/ieee-mode.c @@ -209,7 +209,7 @@ static const output_config_t output_power[] = { #define OUTPUT_POWER_UNKNOWN 0xFFFF /* Default TX Power - position in output_power[] */ -const output_config_t *tx_power_current = &output_power[0]; +static const output_config_t *tx_power_current = &output_power[0]; /*---------------------------------------------------------------------------*/ static volatile int8_t last_rssi = 0; static volatile uint8_t last_corr_lqi = 0; diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index 61581f20a..f9f49e9a0 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -203,7 +203,7 @@ extern const prop_mode_tx_power_config_t TX_POWER_DRIVER[]; #define OUTPUT_POWER_UNKNOWN 0xFFFF /* Default TX Power - position in output_power[] */ -const prop_mode_tx_power_config_t *tx_power_current = &TX_POWER_DRIVER[1]; +static const prop_mode_tx_power_config_t *tx_power_current = &TX_POWER_DRIVER[1]; /*---------------------------------------------------------------------------*/ #ifdef PROP_MODE_CONF_LO_DIVIDER #define PROP_MODE_LO_DIVIDER PROP_MODE_CONF_LO_DIVIDER diff --git a/arch/cpu/msp430/Makefile.msp430 b/arch/cpu/msp430/Makefile.msp430 index f7267b694..ec8c33664 100644 --- a/arch/cpu/msp430/Makefile.msp430 +++ b/arch/cpu/msp430/Makefile.msp430 @@ -108,11 +108,6 @@ ifeq ($(HOST_OS),Windows) @$(FINALIZE_CYGWIN_DEPENDENCY) endif -CUSTOM_RULE_C_TO_CO = 1 -%.co: %.c - $(TRACE_CC) - $(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@ - AROPTS = -o else @@ -195,10 +190,6 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)} $(CC) $(CFLAGS) -c $< -o $@ $(STRIP) --strip-unneeded -g -x $@ -%.cm: %.co - $(LD) -i -r --unresolved-symbols=ignore-in-object-files -mmsp430x149 -o $@ $^ - $(STRIP) --strip-unneeded -g -x $@ - %-stripped.o: %.o $(STRIP) --strip-unneeded -g -x -o $@ $< @@ -206,7 +197,7 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)} mv $< $@ ifdef IAR -%.ihex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a +%.ihex: %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(LD) $(LDFLAGSNO) -Fintel-extended $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ else %.ihex: %.$(TARGET) diff --git a/arch/cpu/msp430/dev/uart0-putchar.c b/arch/cpu/msp430/dev/uart0-putchar.c index bf237695b..4c92f9160 100644 --- a/arch/cpu/msp430/dev/uart0-putchar.c +++ b/arch/cpu/msp430/dev/uart0-putchar.c @@ -1,9 +1,39 @@ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" #include "dev/uart0.h" -/* In case of IPv4: putchar() is defined by the SLIP driver */ +#include +/*---------------------------------------------------------------------------*/ +#define SLIP_END 0300 +#undef putchar +/*---------------------------------------------------------------------------*/ int putchar(int c) { +#if SLIP_ARCH_CONF_ENABLED + static char debug_frame = 0; + + if(!debug_frame) { /* Start of debug output */ + uart0_writeb(SLIP_END); + uart0_writeb('\r'); /* Type debug line == '\r' */ + debug_frame = 1; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ + + /* Need to also print '\n' because for example COOJA will not show + any output before line end */ uart0_writeb((char)c); + +#if SLIP_ARCH_CONF_ENABLED + /* + * Line buffered output, a newline marks the end of debug output and + * implicitly flushes debug output. + */ + if(c == '\n') { + uart0_writeb(SLIP_END); + debug_frame = 0; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ return c; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/dev/uart1-putchar.c b/arch/cpu/msp430/dev/uart1-putchar.c index 7623b435a..14146d9dc 100644 --- a/arch/cpu/msp430/dev/uart1-putchar.c +++ b/arch/cpu/msp430/dev/uart1-putchar.c @@ -1,9 +1,39 @@ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" #include "dev/uart1.h" -/* In case of IPv4: putchar() is defined by the SLIP driver */ +#include +/*---------------------------------------------------------------------------*/ +#define SLIP_END 0300 +#undef putchar +/*---------------------------------------------------------------------------*/ int putchar(int c) { +#if SLIP_ARCH_CONF_ENABLED + static char debug_frame = 0; + + if(!debug_frame) { /* Start of debug output */ + uart1_writeb(SLIP_END); + uart1_writeb('\r'); /* Type debug line == '\r' */ + debug_frame = 1; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ + + /* Need to also print '\n' because for example COOJA will not show + any output before line end */ uart1_writeb((char)c); + +#if SLIP_ARCH_CONF_ENABLED + /* + * Line buffered output, a newline marks the end of debug output and + * implicitly flushes debug output. + */ + if(c == '\n') { + uart1_writeb(SLIP_END); + debug_frame = 0; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ return c; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/msp430-conf.h b/arch/cpu/msp430/msp430-conf.h index ec4f49a55..f4f0da54c 100644 --- a/arch/cpu/msp430/msp430-conf.h +++ b/arch/cpu/msp430/msp430-conf.h @@ -1,30 +1,30 @@ /* * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. + * 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. + * 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. + * 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 MSP430_CONF_H_ @@ -42,6 +42,20 @@ #else #define MSP430_CPU_SPEED 2457600UL #endif + +#ifndef SLIP_ARCH_CONF_ENABLED +/* + * Determine whether we need SLIP + * This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT + * keep using SLIP + */ +#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT) +#define SLIP_ARCH_CONF_ENABLED 1 +#else +#define SLIP_ARCH_CONF_ENABLED 0 +#endif +#endif + /*---------------------------------------------------------------------------*/ #endif /* MSP430_CONF_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/nrf52832/Makefile.nrf52832 b/arch/cpu/nrf52832/Makefile.nrf52832 index 9f76177bb..567270834 100644 --- a/arch/cpu/nrf52832/Makefile.nrf52832 +++ b/arch/cpu/nrf52832/Makefile.nrf52832 @@ -178,6 +178,8 @@ vpath %.s $(ASM_PATHS) OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS) +CLEAN += nrf52832.a + TARGET_LIBS= nrf52832.a $(NRF52_SDK_ROOT)/components/iot/ble_6lowpan/lib/ble_6lowpan.a nrf52832.a: $(OBJECTS) diff --git a/arch/platform/cooja/Makefile.cooja b/arch/platform/cooja/Makefile.cooja index 9f41dbaad..853e7eaf5 100644 --- a/arch/platform/cooja/Makefile.cooja +++ b/arch/platform/cooja/Makefile.cooja @@ -38,7 +38,7 @@ endif ## QUICKSTART MAIN_OBJ = $(OBJECTDIR)/$(LIBNAME).o ARCHIVE = $(OBJECTDIR)/$(LIBNAME).a JNILIB = $(OBJECTDIR)/$(LIBNAME).$(TARGET) -CONTIKI_APP_OBJ = $(CONTIKI_APP).co +CONTIKI_APP_OBJ = $(CONTIKI_APP).o # Modules MODULES += os/net os/net/mac os/net/mac/framer diff --git a/arch/platform/cooja/contiki-cooja-main.c b/arch/platform/cooja/contiki-cooja-main.c index 39793d12c..53c8eb7d8 100644 --- a/arch/platform/cooja/contiki-cooja-main.c +++ b/arch/platform/cooja/contiki-cooja-main.c @@ -45,7 +45,6 @@ #include "sys/clock.h" #include "sys/etimer.h" #include "sys/cooja_mt.h" -#include "sys/autostart.h" #include "sys/log.h" #include "lib/random.h" @@ -62,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 */ @@ -241,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/arch/platform/jn516x/Makefile.jn516x b/arch/platform/jn516x/Makefile.jn516x index bb654ceb8..d7aa80992 100644 --- a/arch/platform/jn516x/Makefile.jn516x +++ b/arch/platform/jn516x/Makefile.jn516x @@ -236,7 +236,7 @@ ABS_APPLIBS = $(addsuffix _$(JENNIC_CHIP_FAMILY).a,$(addprefix $(COMPONENTS_BASE ifneq ($(wildcard $(SDK_BASE_DIR)/Components/Library/*),) # The SDK is fully installed, proceed to linking and objcopy to ready-to-upload .jn516x.bin file -%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(ABS_APPLIBS) +%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(ABS_APPLIBS) echo ${filter %.a,$^} $(Q)$(CC) -Wl,--gc-sections $(LDFLAGS) -T$(LINKCMD) -o $@ -Wl,--start-group \ $(patsubst /cygdrive/c/%,c:/%,${filter-out %.a,$^}) \ @@ -245,7 +245,7 @@ ifneq ($(wildcard $(SDK_BASE_DIR)/Components/Library/*),) $(OBJCOPY) -S -O binary $@ $@.bin else # The SDK does not include libraries, only build objects and libraries, skip linking -%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a +%.$(TARGET): %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a echo Creating empty $@ touch $@ endif diff --git a/arch/platform/jn516x/jn516x-def.h b/arch/platform/jn516x/jn516x-def.h index 357c255c0..4861d00b3 100644 --- a/arch/platform/jn516x/jn516x-def.h +++ b/arch/platform/jn516x/jn516x-def.h @@ -272,9 +272,14 @@ typedef uint32_t clock_time_t; /* Set this to zero only if we are using SLIP */ #ifndef SLIP_BRIDGE_CONF_NO_PUTCHAR -#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1 +#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT) +#define SLIP_BRIDGE_CONF_NO_PUTCHAR 0 +#else +#define SLIP_BRIDGE_CONF_NO_PUTCHAR 1 +#endif #endif /* SLIP_BRIDGE_CONF_NO_PUTCHAR */ + /* Extension of LED definitions from leds.h for various JN516x dev boards JN516x Dongle: LEDS_RED Red LED on dongle diff --git a/arch/platform/native/contiki-conf.h b/arch/platform/native/contiki-conf.h index c315b8e18..3a0329a82 100644 --- a/arch/platform/native/contiki-conf.h +++ b/arch/platform/native/contiki-conf.h @@ -67,9 +67,11 @@ typedef uint16_t u16_t; typedef uint32_t u32_t; typedef int32_t s32_t; -typedef unsigned short uip_stats_t; +typedef unsigned int uip_stats_t; +#ifndef UIP_CONF_BYTE_ORDER #define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN +#endif #if NETSTACK_CONF_WITH_IPV6 diff --git a/arch/platform/native/platform.c b/arch/platform/native/platform.c index 02fad921c..4d1a1421c 100644 --- a/arch/platform/native/platform.c +++ b/arch/platform/native/platform.c @@ -70,12 +70,44 @@ #define LOG_MODULE "Native" #define LOG_LEVEL LOG_LEVEL_MAIN +/*---------------------------------------------------------------------------*/ +/** + * \name Native Platform Configuration + * + * @{ + */ + +/* + * Defines the maximum number of file descriptors monitored by the platform + * main loop. + */ #ifdef SELECT_CONF_MAX #define SELECT_MAX SELECT_CONF_MAX #else #define SELECT_MAX 8 #endif +/* + * Defines the timeout (in msec) of the select operation if no monitored file + * descriptors becomes ready. + */ +#ifdef SELECT_CONF_TIMEOUT +#define SELECT_TIMEOUT SELECT_CONF_TIMEOUT +#else +#define SELECT_TIMEOUT 1000 +#endif + +/* + * Adds the STDIN file descriptor to the list of monitored file descriptors. + */ +#ifdef SELECT_CONF_STDIN +#define SELECT_STDIN SELECT_CONF_STDIN +#else +#define SELECT_STDIN 1 +#endif +/** @} */ +/*---------------------------------------------------------------------------*/ + static const struct select_callback *select_callback[SELECT_MAX]; static int select_max = 0; @@ -116,6 +148,7 @@ select_set_callback(int fd, const struct select_callback *callback) return 0; } /*---------------------------------------------------------------------------*/ +#if SELECT_STDIN static int stdin_set_fd(fd_set *rset, fd_set *wset) { @@ -135,6 +168,7 @@ stdin_handle_fd(fd_set *rset, fd_set *wset) const static struct select_callback stdin_fd = { stdin_set_fd, stdin_handle_fd }; +#endif /* SELECT_STDIN */ /*---------------------------------------------------------------------------*/ static void set_lladdr(void) @@ -240,7 +274,9 @@ platform_init_stage_three() void platform_main_loop() { +#if SELECT_STDIN select_set_callback(STDIN_FILENO, &stdin_fd); +#endif /* SELECT_STDIN */ while(1) { fd_set fdr; fd_set fdw; @@ -252,7 +288,7 @@ platform_main_loop() retval = process_run(); tv.tv_sec = 0; - tv.tv_usec = retval ? 1 : 1000; + tv.tv_usec = retval ? 1 : SELECT_TIMEOUT; FD_ZERO(&fdr); FD_ZERO(&fdw); diff --git a/arch/platform/sky/platform.c b/arch/platform/sky/platform.c index 5bbce5286..d71471340 100644 --- a/arch/platform/sky/platform.c +++ b/arch/platform/sky/platform.c @@ -51,7 +51,6 @@ #include "sys/node-id.h" #include "cfs-coffee-arch.h" #include "cfs/cfs-coffee.h" -#include "sys/autostart.h" #if DCOSYNCH_CONF_ENABLED static struct timer mgt_timer; diff --git a/arch/platform/srf06-cc26xx/contiki-conf.h b/arch/platform/srf06-cc26xx/contiki-conf.h index 07c8f285a..718efc3f6 100644 --- a/arch/platform/srf06-cc26xx/contiki-conf.h +++ b/arch/platform/srf06-cc26xx/contiki-conf.h @@ -70,12 +70,12 @@ /* Platform-specific define to signify sensor reading failure */ #define CC26XX_SENSOR_READING_ERROR 0x80000000 /*---------------------------------------------------------------------------*/ -/* board.h assumes that basic configuration is done */ -#include "board.h" -/*---------------------------------------------------------------------------*/ /* Include CPU-related configuration */ #include "cc13xx-cc26xx-conf.h" /*---------------------------------------------------------------------------*/ +/* board.h assumes that basic configuration is done */ +#include "board.h" +/*---------------------------------------------------------------------------*/ #endif /* CONTIKI_CONF_H */ /** @} */ diff --git a/examples/coap/Makefile b/examples/coap/Makefile index 1c8f2d21e..379ffb104 100644 --- a/examples/coap/Makefile +++ b/examples/coap/Makefile @@ -3,20 +3,12 @@ all: coap-example-server coap-example-client CONTIKI=../.. -# automatically build RESTful resources -REST_RESOURCES_DIR = ./resources -ifndef TARGET -REST_RESOURCES_FILES = $(notdir $(shell find $(REST_RESOURCES_DIR) -name '*.c')) -else -ifeq ($(TARGET), native) -REST_RESOURCES_FILES = $(notdir $(shell find $(REST_RESOURCES_DIR) -name '*.c')) -else -REST_RESOURCES_FILES = $(notdir $(shell find $(REST_RESOURCES_DIR) -name '*.c' ! -name 'res-plugtest*')) +# build RESTful resources +include $(CONTIKI)/Makefile.identify-target +ifeq ($(TARGET),native) + MODULES_REL += ./resources-plugtest endif -endif - -PROJECTDIRS += $(REST_RESOURCES_DIR) -PROJECT_SOURCEFILES += $(REST_RESOURCES_FILES) +MODULES_REL += ./resources # Include the CoAP implementation MODULES += os/net/app-layer/coap diff --git a/examples/coap/resources/res-plugtest-create1.c b/examples/coap/resources-plugtest/res-plugtest-create1.c similarity index 100% rename from examples/coap/resources/res-plugtest-create1.c rename to examples/coap/resources-plugtest/res-plugtest-create1.c diff --git a/examples/coap/resources/res-plugtest-create2.c b/examples/coap/resources-plugtest/res-plugtest-create2.c similarity index 100% rename from examples/coap/resources/res-plugtest-create2.c rename to examples/coap/resources-plugtest/res-plugtest-create2.c diff --git a/examples/coap/resources/res-plugtest-create3.c b/examples/coap/resources-plugtest/res-plugtest-create3.c similarity index 100% rename from examples/coap/resources/res-plugtest-create3.c rename to examples/coap/resources-plugtest/res-plugtest-create3.c diff --git a/examples/coap/resources/res-plugtest-large-create.c b/examples/coap/resources-plugtest/res-plugtest-large-create.c similarity index 100% rename from examples/coap/resources/res-plugtest-large-create.c rename to examples/coap/resources-plugtest/res-plugtest-large-create.c diff --git a/examples/coap/resources/res-plugtest-large-update.c b/examples/coap/resources-plugtest/res-plugtest-large-update.c similarity index 100% rename from examples/coap/resources/res-plugtest-large-update.c rename to examples/coap/resources-plugtest/res-plugtest-large-update.c diff --git a/examples/coap/resources/res-plugtest-large.c b/examples/coap/resources-plugtest/res-plugtest-large.c similarity index 100% rename from examples/coap/resources/res-plugtest-large.c rename to examples/coap/resources-plugtest/res-plugtest-large.c diff --git a/examples/coap/resources/res-plugtest-links.c b/examples/coap/resources-plugtest/res-plugtest-links.c similarity index 100% rename from examples/coap/resources/res-plugtest-links.c rename to examples/coap/resources-plugtest/res-plugtest-links.c diff --git a/examples/coap/resources/res-plugtest-locquery.c b/examples/coap/resources-plugtest/res-plugtest-locquery.c similarity index 100% rename from examples/coap/resources/res-plugtest-locquery.c rename to examples/coap/resources-plugtest/res-plugtest-locquery.c diff --git a/examples/coap/resources/res-plugtest-longpath.c b/examples/coap/resources-plugtest/res-plugtest-longpath.c similarity index 100% rename from examples/coap/resources/res-plugtest-longpath.c rename to examples/coap/resources-plugtest/res-plugtest-longpath.c diff --git a/examples/coap/resources/res-plugtest-multi.c b/examples/coap/resources-plugtest/res-plugtest-multi.c similarity index 100% rename from examples/coap/resources/res-plugtest-multi.c rename to examples/coap/resources-plugtest/res-plugtest-multi.c diff --git a/examples/coap/resources/res-plugtest-obs.c b/examples/coap/resources-plugtest/res-plugtest-obs.c similarity index 100% rename from examples/coap/resources/res-plugtest-obs.c rename to examples/coap/resources-plugtest/res-plugtest-obs.c diff --git a/examples/coap/resources/res-plugtest-path.c b/examples/coap/resources-plugtest/res-plugtest-path.c similarity index 100% rename from examples/coap/resources/res-plugtest-path.c rename to examples/coap/resources-plugtest/res-plugtest-path.c diff --git a/examples/coap/resources/res-plugtest-query.c b/examples/coap/resources-plugtest/res-plugtest-query.c similarity index 100% rename from examples/coap/resources/res-plugtest-query.c rename to examples/coap/resources-plugtest/res-plugtest-query.c diff --git a/examples/coap/resources/res-plugtest-separate.c b/examples/coap/resources-plugtest/res-plugtest-separate.c similarity index 100% rename from examples/coap/resources/res-plugtest-separate.c rename to examples/coap/resources-plugtest/res-plugtest-separate.c diff --git a/examples/coap/resources/res-plugtest-test.c b/examples/coap/resources-plugtest/res-plugtest-test.c similarity index 100% rename from examples/coap/resources/res-plugtest-test.c rename to examples/coap/resources-plugtest/res-plugtest-test.c diff --git a/examples/coap/resources/res-plugtest-validate.c b/examples/coap/resources-plugtest/res-plugtest-validate.c similarity index 100% rename from examples/coap/resources/res-plugtest-validate.c rename to examples/coap/resources-plugtest/res-plugtest-validate.c diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile b/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile index 88b4b0184..bc024b826 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/Makefile @@ -1,12 +1,6 @@ all: cc26xx-web-demo -REST_RESOURCES_DIR = ./resources - -REST_RESOURCES_FILES += res-leds.c res-toggle-leds.c res-device.c -REST_RESOURCES_FILES += res-sensors.c res-ble-advd.c res-net.c - -PROJECTDIRS += $(REST_RESOURCES_DIR) -PROJECT_SOURCEFILES += $(REST_RESOURCES_FILES) +MODULES_REL += ./resources PROJECT_SOURCEFILES += cetic-6lbr-client.c coap-server.c net-uart.c mqtt-client.c PROJECT_SOURCEFILES += httpd-simple.c diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile index 1b13ef3e0..1b39fbae3 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile @@ -8,8 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c +MODULES_REL += .. ../tools MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile index 9a393ff14..79a7e7f13 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile @@ -8,8 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c +MODULES_REL += .. ../tools MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile index 32231f636..a5887a8ef 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile @@ -8,8 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c +MODULES_REL += .. ../tools MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/node/Makefile b/examples/platform-specific/jn516x/rpl/node/Makefile index 37f6c7c79..83cd48869 100644 --- a/examples/platform-specific/jn516x/rpl/node/Makefile +++ b/examples/platform-specific/jn516x/rpl/node/Makefile @@ -6,7 +6,6 @@ TARGET ?= jn516x CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH -PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c +MODULES_REL += .. ../tools include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile index df37a89af..2e7e32585 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile @@ -5,8 +5,7 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../../.. -PROJECTDIRS += .. ../../tools -PROJECT_SOURCEFILES += rpl-tools.c +MODULES_REL += .. ../../tools MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap MODULES += os/services/orchestra os/lib/json diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile index 977210702..3884b9d30 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile @@ -5,8 +5,7 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../../.. -PROJECTDIRS += .. ../../tools -PROJECT_SOURCEFILES += rpl-tools.c +MODULES_REL += .. ../../tools MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile index c88fa5a2b..3773e04a5 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile @@ -7,8 +7,7 @@ CONTIKI=../../../../../.. PROJECT_SOURCEFILES += slip-bridge.c slip.c -PROJECTDIRS += .. ../../tools -PROJECT_SOURCEFILES += rpl-tools.c +MODULES_REL += .. ../../tools MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile index ca520969d..640495432 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile @@ -6,8 +6,7 @@ TARGET_WITH_UART1 = 1 CONTIKI=../../../../.. -PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c +MODULES_REL += .. ../tools MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/nrf52dk/coap-demo/Makefile b/examples/platform-specific/nrf52dk/coap-demo/Makefile index 6d9639da0..37b4cef4d 100644 --- a/examples/platform-specific/nrf52dk/coap-demo/Makefile +++ b/examples/platform-specific/nrf52dk/coap-demo/Makefile @@ -16,11 +16,7 @@ CFLAGS += -DDEVICE_NAME=\"nRF52-DK-CoAP-Server\" endif # automatically build RESTful resources -REST_RESOURCES_DIR = ./resources -REST_RESOURCES_FILES = $(notdir $(shell find $(REST_RESOURCES_DIR) -name '*.c' ! -name 'res-plugtest*')) - -PROJECTDIRS += $(REST_RESOURCES_DIR) -PROJECT_SOURCEFILES += $(REST_RESOURCES_FILES) +MODULES_REL += ./resources # REST Engine shall use Erbium CoAP implementation MODULES += os/net/app-layer/coap diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index 76c07cb8b..d8b14d5bd 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -1,21 +1,13 @@ -PROJECTDIRS += common -PREFIX ?= fd00::1/64 +CONTIKI_PROJECT = border-router +all: $(CONTIKI_PROJECT) CONTIKI = ../.. --include $(CONTIKI)/Makefile.identify-target - -all: border-router.$(TARGET) - -ifeq ($(TARGET),native) - SOURCES_DIR = native -else - SOURCES_DIR = embedded -endif - -include $(SOURCES_DIR)/Makefile - -PROJECTDIRS += $(SOURCES_DIR) -PROJECT_SOURCEFILES += httpd-simple.c webserver.c border-router-common.c -CFLAGS += -DPROJECT_CONF_PATH=\"$(SOURCES_DIR)/project-conf.h\" +# 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 +MODULES_REL += $(TARGET) include $(CONTIKI)/Makefile.include diff --git a/examples/rpl-border-router/border-router.c b/examples/rpl-border-router/border-router.c index 30b6d6150..416d18093 100644 --- a/examples/rpl-border-router/border-router.c +++ b/examples/rpl-border-router/border-router.c @@ -32,11 +32,26 @@ #include "contiki.h" -PROCESS_NAME(border_router_process); +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "RPL BR" +#define LOG_LEVEL LOG_LEVEL_INFO + +/* Declare and auto-start this file's process */ +PROCESS(contiki_ng_br, "Contiki-NG Border Router"); +AUTOSTART_PROCESSES(&contiki_ng_br); + +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(contiki_ng_br, ev, data) +{ + PROCESS_BEGIN(); #if BORDER_ROUTER_CONF_WEBSERVER -PROCESS_NAME(webserver_nogui_process); -AUTOSTART_PROCESSES(&border_router_process, &webserver_nogui_process); -#else /* BORDER_ROUTER_CONF_WEBSERVER */ -AUTOSTART_PROCESSES(&border_router_process); + PROCESS_NAME(webserver_nogui_process); + process_start(&webserver_nogui_process, NULL); #endif /* BORDER_ROUTER_CONF_WEBSERVER */ + + LOG_INFO("Contiki-NG Border Router started\n"); + + PROCESS_END(); +} diff --git a/examples/rpl-border-router/embedded/Makefile b/examples/rpl-border-router/embedded/Makefile deleted file mode 100644 index 5faba70c8..000000000 --- a/examples/rpl-border-router/embedded/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -### Optionally, the target can add its own Makefile, to do things like e.g. -### add more source files to the build or define make variables. --include $(SOURCES_DIR)/$(TARGET)/Makefile.$(TARGET) - -PROJECTDIRS += $(SOURCES_DIR)/$(TARGET) - -PROJECT_SOURCEFILES += slip-bridge.c border-router-embedded.c - -$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c - (cd $(CONTIKI)/tools && $(MAKE) tunslip6) - -connect-router: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 $(PREFIX) - -connect-router-cooja: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 $(PREFIX) diff --git a/examples/rpl-border-router/embedded/sky/Makefile.sky b/examples/rpl-border-router/embedded/sky/Makefile.sky deleted file mode 100644 index c3d097481..000000000 --- a/examples/rpl-border-router/embedded/sky/Makefile.sky +++ /dev/null @@ -1,3 +0,0 @@ -PROJECT_SOURCEFILES += slip-bridge-putchar.c - -CFLAGS += -DTARGET_CONF_PATH=\"target-conf.h\" diff --git a/examples/rpl-border-router/embedded/sky/slip-bridge-putchar.c b/examples/rpl-border-router/embedded/sky/slip-bridge-putchar.c deleted file mode 100644 index f7f501ba1..000000000 --- a/examples/rpl-border-router/embedded/sky/slip-bridge-putchar.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - * - */ -/*---------------------------------------------------------------------------*/ -#include "contiki.h" -#include "dev/slip.h" - -#include -/*---------------------------------------------------------------------------*/ -#define SLIP_END 0300 -#undef putchar -/*---------------------------------------------------------------------------*/ -int -putchar(int c) -{ - static char debug_frame = 0; - - if(!debug_frame) { /* Start of debug output */ - slip_arch_writeb(SLIP_END); - slip_arch_writeb('\r'); /* Type debug line == '\r' */ - debug_frame = 1; - } - - /* Need to also print '\n' because for example COOJA will not show - any output before line end */ - slip_arch_writeb((char)c); - - /* - * Line buffered output, a newline marks the end of debug output and - * implicitly flushes debug output. - */ - if(c == '\n') { - slip_arch_writeb(SLIP_END); - debug_frame = 0; - } - return c; -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/rpl-border-router/native/Makefile b/examples/rpl-border-router/native/Makefile deleted file mode 100644 index 30690df0f..000000000 --- a/examples/rpl-border-router/native/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -MODULES += os/services/slip-cmd - -PROJECT_SOURCEFILES += border-router-native.c -PROJECT_SOURCEFILES += border-router-cmds.c tun-bridge.c -PROJECT_SOURCEFILES += slip-config.c slip-dev.c border-router-mac.c - -MAKE_MAC = MAKE_MAC_OTHER -MAKE_NET = MAKE_NET_IPV6 - -connect-router: border-router.native - sudo ./border-router.native fd00::1/64 diff --git a/examples/rpl-border-router/embedded/project-conf.h b/examples/rpl-border-router/project-conf.h similarity index 79% rename from examples/rpl-border-router/embedded/project-conf.h rename to examples/rpl-border-router/project-conf.h index 30ef25b90..a2ffcc950 100644 --- a/examples/rpl-border-router/embedded/project-conf.h +++ b/examples/rpl-border-router/project-conf.h @@ -28,17 +28,8 @@ * */ -#ifndef PROJECT_ROUTER_CONF_H_ -#define PROJECT_ROUTER_CONF_H_ -/*---------------------------------------------------------------------------*/ -/* Include target-specific header */ -#ifdef TARGET_CONF_PATH -#include TARGET_CONF_PATH -#endif /* TARGET_CONF_PATH */ -/*---------------------------------------------------------------------------*/ -#ifndef UIP_FALLBACK_INTERFACE -#define UIP_FALLBACK_INTERFACE rpl_interface -#endif +#ifndef PROJECT_CONF_H_ +#define PROJECT_CONF_H_ #ifndef WEBSERVER_CONF_CFS_CONNS #define WEBSERVER_CONF_CFS_CONNS 2 @@ -52,4 +43,4 @@ #define UIP_CONF_TCP 1 #endif -#endif /* PROJECT_ROUTER_CONF_H_ */ +#endif /* PROJECT_CONF_H_ */ diff --git a/examples/rpl-border-router/embedded/sky/target-conf.h b/examples/rpl-border-router/sky/module-macros.h similarity index 89% rename from examples/rpl-border-router/embedded/sky/target-conf.h rename to examples/rpl-border-router/sky/module-macros.h index 70cdab319..f9c7b408c 100644 --- a/examples/rpl-border-router/embedded/sky/target-conf.h +++ b/examples/rpl-border-router/sky/module-macros.h @@ -29,13 +29,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -#ifndef TARGET_CONF_H_ -#define TARGET_CONF_H_ -/*---------------------------------------------------------------------------*/ /* Save some RAM and ROM */ #define QUEUEBUF_CONF_NUM 4 #define UIP_CONF_BUFFER_SIZE 140 #define BORDER_ROUTER_CONF_WEBSERVER 0 /*---------------------------------------------------------------------------*/ -#endif /* TARGET_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/examples/sensniff/Makefile b/examples/sensniff/Makefile index 2bb2549b1..a3c3286f2 100644 --- a/examples/sensniff/Makefile +++ b/examples/sensniff/Makefile @@ -2,13 +2,9 @@ CONTIKI_PROJECT = sensniff CONTIKI = ../.. PROJECT_SOURCEFILES += sensniff-mac.c netstack.c -PROJECTDIRS += pool $(TARGET) +MODULES_REL += pool $(TARGET) --include $(CONTIKI)/Makefile.identify-target - -### Optionally, the target can add its own Makefile, to do things like e.g. -### add more source files to the build or define make variables. --include $(TARGET)/Makefile.$(TARGET) +include $(CONTIKI)/Makefile.identify-target all: $(CONTIKI_PROJECT) diff --git a/examples/slip-radio/Makefile b/examples/slip-radio/Makefile index d59b5e240..3ab7bffa3 100644 --- a/examples/slip-radio/Makefile +++ b/examples/slip-radio/Makefile @@ -3,13 +3,9 @@ all: $(CONTIKI_PROJECT) MODULES += os/services/slip-cmd CONTIKI=../.. --include $(CONTIKI)/Makefile.identify-target +include $(CONTIKI)/Makefile.identify-target -### Optionally, the target can add its own Makefile, to do things like e.g. -### add more source files to the build or define make variables. --include $(TARGET)/Makefile.$(TARGET) - -PROJECTDIRS += $(TARGET) +MODULES_REL += $(TARGET) PROJECT_SOURCEFILES += slip-net.c # custom net layer, but with IPv6 enabled diff --git a/examples/slip-radio/project-conf.h b/examples/slip-radio/project-conf.h index 2f05bec5e..4283d0249 100644 --- a/examples/slip-radio/project-conf.h +++ b/examples/slip-radio/project-conf.h @@ -29,11 +29,7 @@ #ifndef PROJECT_CONF_H_ #define PROJECT_CONF_H_ -/*---------------------------------------------------------------------------*/ -/* Include target-specific header */ -#ifdef TARGET_CONF_PATH -#include TARGET_CONF_PATH -#endif /* TARGET_CONF_PATH */ + /*---------------------------------------------------------------------------*/ #define UIP_CONF_ROUTER 0 diff --git a/examples/slip-radio/sky/Makefile.sky b/examples/slip-radio/sky/Makefile.sky deleted file mode 100644 index 83a91472d..000000000 --- a/examples/slip-radio/sky/Makefile.sky +++ /dev/null @@ -1,4 +0,0 @@ -PROJECT_SOURCEFILES += slip-radio-cc2420.c slip-radio-sky-sensors.c -PROJECT_SOURCEFILES += slip-radio-putchar.c - -CFLAGS += -DTARGET_CONF_PATH=\"target-conf.h\" diff --git a/examples/slip-radio/sky/target-conf.h b/examples/slip-radio/sky/module-macros.h similarity index 89% rename from examples/slip-radio/sky/target-conf.h rename to examples/slip-radio/sky/module-macros.h index 08fa66512..cbf6a3827 100644 --- a/examples/slip-radio/sky/target-conf.h +++ b/examples/slip-radio/sky/module-macros.h @@ -29,9 +29,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -#ifndef TARGET_CONF_H_ -#define TARGET_CONF_H_ -/*---------------------------------------------------------------------------*/ #define QUEUEBUF_CONF_NUM 4 #define UIP_CONF_BUFFER_SIZE 140 @@ -39,5 +36,3 @@ #define SLIP_RADIO_CONF_SENSORS slip_radio_sky_sensors #define UART1_CONF_RX_WITH_DMA 1 /*---------------------------------------------------------------------------*/ -#endif /* TARGET_CONF_H_ */ -/*---------------------------------------------------------------------------*/ 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/os/lib/list.c b/os/lib/list.c index 401da617e..afa9df585 100644 --- a/os/lib/list.c +++ b/os/lib/list.c @@ -44,15 +44,14 @@ * \addtogroup list * @{ */ - +#include "contiki.h" #include "lib/list.h" -#define NULL 0 - +#include +/*---------------------------------------------------------------------------*/ struct list { struct list *next; }; - /*---------------------------------------------------------------------------*/ /** * Initialize a list. @@ -118,13 +117,13 @@ void * list_tail(list_t list) { struct list *l; - + if(*list == NULL) { return NULL; } - + for(l = *list; l->next != NULL; l = l->next); - + return l; } /*---------------------------------------------------------------------------*/ @@ -148,7 +147,7 @@ list_add(list_t list, void *item) list_remove(list, item); ((struct list *)item)->next = NULL; - + l = list_tail(list); if(l == NULL) { @@ -164,8 +163,6 @@ list_add(list_t list, void *item) void list_push(list_t list, void *item) { - /* struct list *l;*/ - /* Make sure not to add the same element twice */ list_remove(list, item); @@ -186,7 +183,7 @@ void * list_chop(list_t list) { struct list *l, *r; - + if(*list == NULL) { return NULL; } @@ -195,12 +192,12 @@ list_chop(list_t list) *list = NULL; return l; } - + for(l = *list; l->next->next != NULL; l = l->next); r = l->next; l->next = NULL; - + return r; } /*---------------------------------------------------------------------------*/ @@ -240,20 +237,20 @@ void list_remove(list_t list, void *item) { struct list *l, *r; - + if(*list == NULL) { return; } - + r = NULL; for(l = *list; l != NULL; l = l->next) { if(l == item) { if(r == NULL) { - /* First on list */ - *list = l->next; + /* First on list */ + *list = l->next; } else { - /* Not first on list */ - r->next = l->next; + /* Not first on list */ + r->next = l->next; } l->next = NULL; return; @@ -305,7 +302,7 @@ list_insert(list_t list, void *previtem, void *newitem) if(previtem == NULL) { list_push(list, newitem); } else { - + list_remove(list, newitem); ((struct list *)newitem)->next = ((struct list *)previtem)->next; ((struct list *)previtem)->next = newitem; } @@ -324,7 +321,7 @@ list_insert(list_t list, void *previtem, void *newitem) void * list_item_next(void *item) { - return item == NULL? NULL: ((struct list *)item)->next; + return item == NULL ? NULL : ((struct list *)item)->next; } /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/os/net/ipv6/uip-nd6.c b/os/net/ipv6/uip-nd6.c index 5c01de392..7881ed749 100644 --- a/os/net/ipv6/uip-nd6.c +++ b/os/net/ipv6/uip-nd6.c @@ -115,7 +115,7 @@ static uip_ds6_nbr_t *nbr; /** Pointer to a nbr cache entry*/ static uip_ds6_addr_t *addr; /** Pointer to an interface address */ #endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */ -#if UIP_ND6_SEND_NS || !UIP_CONF_ROUTER +#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */ #endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */ @@ -973,7 +973,7 @@ ra_input(void) default: LOG_DBG("Updating timer of prefix "); LOG_DBG_6ADDR(&prefix->ipaddr); - LOG_DBG_(" new value %lu\n", uip_ntohl(nd6_opt_prefix_info->validlt)); + LOG_DBG_(" new value %lu\n", (unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt)); stimer_set(&prefix->vlifetime, uip_ntohl(nd6_opt_prefix_info->validlt)); prefix->isinfinite = 0; @@ -999,7 +999,7 @@ ra_input(void) LOG_DBG("Updating timer of address "); LOG_DBG_6ADDR(&addr->ipaddr); LOG_DBG_(" new value %lu\n", - uip_ntohl(nd6_opt_prefix_info->validlt)); + (unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt)); stimer_set(&addr->vlifetime, uip_ntohl(nd6_opt_prefix_info->validlt)); } else { @@ -1027,18 +1027,16 @@ ra_input(void) break; #if UIP_ND6_RA_RDNSS case UIP_ND6_OPT_RDNSS: - if(UIP_ND6_RA_BUF->flags_reserved & (UIP_ND6_O_FLAG << 6)) { - LOG_DBG("Processing RDNSS option\n"); - uint8_t naddr = (UIP_ND6_OPT_RDNSS_BUF->len - 1) / 2; - uip_ipaddr_t *ip = (uip_ipaddr_t *)(&UIP_ND6_OPT_RDNSS_BUF->ip); - LOG_DBG("got %d nameservers\n", naddr); - while(naddr-- > 0) { - LOG_DBG("nameserver: "); - LOG_DBG_6ADDR(ip); - LOG_DBG_(" lifetime: %lx\n", uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime)); - uip_nameserver_update(ip, uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime)); - ip++; - } + LOG_DBG("Processing RDNSS option\n"); + uint8_t naddr = (UIP_ND6_OPT_RDNSS_BUF->len - 1) / 2; + uip_ipaddr_t *ip = (uip_ipaddr_t *)(&UIP_ND6_OPT_RDNSS_BUF->ip); + LOG_DBG("got %d nameservers\n", naddr); + while(naddr-- > 0) { + LOG_DBG("nameserver: "); + LOG_DBG_6ADDR(ip); + LOG_DBG_(" lifetime: %lx\n", (unsigned long)uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime)); + uip_nameserver_update(ip, uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime)); + ip++; } break; #endif /* UIP_ND6_RA_RDNSS */ diff --git a/os/net/ipv6/uip-nd6.h b/os/net/ipv6/uip-nd6.h index 43b989490..2c1e3226b 100644 --- a/os/net/ipv6/uip-nd6.h +++ b/os/net/ipv6/uip-nd6.h @@ -118,7 +118,7 @@ be added regardless of their reachability and liveness. */ #define UIP_ND6_MIN_RA_INTERVAL UIP_CONF_ND6_MIN_RA_INTERVAL #endif #define UIP_ND6_M_FLAG 0 -#define UIP_ND6_O_FLAG (UIP_ND6_RA_RDNSS || UIP_ND6_RA_DNSSL) +#define UIP_ND6_O_FLAG 0 #ifndef UIP_CONF_ROUTER_LIFETIME #define UIP_ND6_ROUTER_LIFETIME 3 * UIP_ND6_MAX_RA_INTERVAL #else diff --git a/os/net/rpl-classic/rpl-icmp6.c b/os/net/rpl-classic/rpl-icmp6.c index c5114fd14..6d9a2bca3 100644 --- a/os/net/rpl-classic/rpl-icmp6.c +++ b/os/net/rpl-classic/rpl-icmp6.c @@ -141,15 +141,23 @@ get_global_addr(uip_ipaddr_t *addr) { int i; int state; + uip_ipaddr_t *prefix = NULL; + uint8_t prefix_length = 0; + rpl_dag_t *dag = rpl_get_any_dag(); + + if(dag != NULL && dag->prefix_info.length != 0) { + prefix = &dag->prefix_info.prefix; + prefix_length = dag->prefix_info.length; + } for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; if(uip_ds6_if.addr_list[i].isused && - (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) { - if(!uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) { - memcpy(addr, &uip_ds6_if.addr_list[i].ipaddr, sizeof(uip_ipaddr_t)); - return 1; - } + state == ADDR_PREFERRED && + !uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr) && + (prefix == NULL || uip_ipaddr_prefixcmp(prefix, &uip_ds6_if.addr_list[i].ipaddr, prefix_length))) { + memcpy(addr, &uip_ds6_if.addr_list[i].ipaddr, sizeof(uip_ipaddr_t)); + return 1; } } return 0; diff --git a/os/net/rpl-lite/rpl.c b/os/net/rpl-lite/rpl.c index 76d49d562..29eca52b0 100644 --- a/os/net/rpl-lite/rpl.c +++ b/os/net/rpl-lite/rpl.c @@ -71,12 +71,20 @@ rpl_get_global_address(void) int i; uint8_t state; uip_ipaddr_t *ipaddr = NULL; + uip_ipaddr_t *prefix = NULL; + uint8_t prefix_length = 0; + + if(curr_instance.used && curr_instance.dag.prefix_info.length != 0) { + prefix = &curr_instance.dag.prefix_info.prefix; + prefix_length = curr_instance.dag.prefix_info.length; + } for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; if(uip_ds6_if.addr_list[i].isused && state == ADDR_PREFERRED && - !uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) { + !uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr) && + (prefix == NULL || uip_ipaddr_prefixcmp(prefix, &uip_ds6_if.addr_list[i].ipaddr, prefix_length))) { ipaddr = &uip_ds6_if.addr_list[i].ipaddr; } } diff --git a/os/services/rpl-border-router/Makefile.rpl-border-router b/os/services/rpl-border-router/Makefile.rpl-border-router new file mode 100644 index 000000000..61ba5fa59 --- /dev/null +++ b/os/services/rpl-border-router/Makefile.rpl-border-router @@ -0,0 +1,8 @@ +include $(CONTIKI)/Makefile.identify-target + +# Include either native or embedded BR +ifeq ($(TARGET),native) + MODULES += os/services/rpl-border-router/native +else + MODULES += os/services/rpl-border-router/embedded +endif diff --git a/os/services/rpl-border-router/embedded/Makefile.embedded b/os/services/rpl-border-router/embedded/Makefile.embedded new file mode 100644 index 000000000..c62f7df54 --- /dev/null +++ b/os/services/rpl-border-router/embedded/Makefile.embedded @@ -0,0 +1,9 @@ +$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c + (cd $(CONTIKI)/tools && $(MAKE) tunslip6) + +PREFIX ?= fd00::1/64 +connect-router: $(CONTIKI)/tools/tunslip6 + sudo $(CONTIKI)/tools/tunslip6 $(PREFIX) + +connect-router-cooja: $(CONTIKI)/tools/tunslip6 + sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 $(PREFIX) 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/os/services/rpl-border-router/module-macros.h b/os/services/rpl-border-router/module-macros.h new file mode 100644 index 000000000..f3fad0b9b --- /dev/null +++ b/os/services/rpl-border-router/module-macros.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017, RISE SICS + * 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. + * + */ + +#define BUILD_WITH_RPL_BORDER_ROUTER 1 +#define UIP_FALLBACK_INTERFACE rpl_interface diff --git a/os/services/rpl-border-router/native/Makefile.native b/os/services/rpl-border-router/native/Makefile.native new file mode 100644 index 000000000..62f7221a0 --- /dev/null +++ b/os/services/rpl-border-router/native/Makefile.native @@ -0,0 +1,8 @@ +MODULES += os/services/slip-cmd + +MAKE_MAC = MAKE_MAC_OTHER +MAKE_NET = MAKE_NET_IPV6 + +PREFIX ?= fd00::1/64 +connect-router: border-router.native + sudo ./border-router.native $(PREFIX) 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/project-conf.h b/os/services/rpl-border-router/native/module-macros.h similarity index 88% rename from examples/rpl-border-router/native/project-conf.h rename to os/services/rpl-border-router/native/module-macros.h index 841a31f67..6527738ad 100644 --- a/examples/rpl-border-router/native/project-conf.h +++ b/os/services/rpl-border-router/native/module-macros.h @@ -27,13 +27,6 @@ * SUCH DAMAGE. */ -#ifndef PROJECT_ROUTER_CONF_H_ -#define PROJECT_ROUTER_CONF_H_ - -#define BORDER_ROUTER_CONF_WEBSERVER 1 - -#define UIP_FALLBACK_INTERFACE rpl_interface - /* use a non-default network driver */ #define NETSTACK_CONF_NETWORK sicslowpan_driver @@ -42,14 +35,9 @@ #define SLIP_DEV_CONF_SEND_DELAY (CLOCK_SECOND / 32) -#define WEBSERVER_CONF_CFS_CONNS 2 - #define SERIALIZE_ATTRIBUTES 1 -#define UIP_CONF_TCP 1 #define CMD_CONF_OUTPUT border_router_cmd_output /* used by wpcap (see /cpu/native/net/wpcap-drv.c) */ #define SELECT_CALLBACK 1 - -#endif /* PROJECT_ROUTER_CONF_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/os/services/unit-test/example-test.c b/os/services/unit-test/example-test.c index b40dc525f..04192642f 100644 --- a/os/services/unit-test/example-test.c +++ b/os/services/unit-test/example-test.c @@ -37,12 +37,12 @@ #include "contiki.h" #include "unit-test.h" -/* Register two unit tests that will be executed by using +/* Register two unit tests that will be executed by using the UNIT_TEST_RUN macro. */ UNIT_TEST_REGISTER(arithmetic, "Arith ops"); UNIT_TEST_REGISTER(string, "String ops"); -/* arithmetic: Demonstrates a test that succeeds. The exit point will be +/* arithmetic: Demonstrates a test that succeeds. The exit point will be the line where UNIT_TEST_END is called. */ UNIT_TEST(arithmetic) { @@ -58,7 +58,7 @@ UNIT_TEST(arithmetic) UNIT_TEST_END(); } -/* string: Demonstrates a test that fails. The exit point will be +/* string: Demonstrates a test that fails. The exit point will be the line where the call to UNIT_TEST_ASSERT fails. */ UNIT_TEST(string) { @@ -72,7 +72,6 @@ UNIT_TEST(string) } PROCESS(test_process, "Unit testing"); -AUTOSTART_PROCESSES(&test_process); PROCESS_THREAD(test_process, ev, data) { diff --git a/os/sys/autostart.h b/os/sys/autostart.h index a2cd10eb7..8a671b363 100644 --- a/os/sys/autostart.h +++ b/os/sys/autostart.h @@ -44,13 +44,8 @@ #include "sys/process.h" #if ! CC_NO_VA_ARGS -#if AUTOSTART_ENABLE #define AUTOSTART_PROCESSES(...) \ struct process * const autostart_processes[] = {__VA_ARGS__, NULL} -#else /* AUTOSTART_ENABLE */ -#define AUTOSTART_PROCESSES(...) \ -extern int _dummy -#endif /* AUTOSTART_ENABLE */ #else #error "C compiler must support __VA_ARGS__ macro" #endif diff --git a/tests/00-doxygen/Makefile b/tests/00-doxygen/Makefile index a5dfac35b..3d99c5d00 100644 --- a/tests/00-doxygen/Makefile +++ b/tests/00-doxygen/Makefile @@ -30,15 +30,15 @@ DOCDIR=../../tools/doxygen all: clean summary doxygen: - @make -C $(DOCDIR) 2> doxygen.runerr > doxygen.runlog + @make -C $(DOCDIR) 2> doxygen.err > /dev/null summary: doxygen @( \ 1> summary; \ - if [ -s doxygen.runerr ] ; then \ + if [ -s doxygen.err ] ; then \ echo "Doxygen: TEST FAIL" | tee summary; \ echo "Errors:"; \ - cat doxygen.runerr; \ + cat doxygen.err; \ fi ; \ if [ -s $(DOCDIR)/doxygen.log ] ; then \ echo "Doxygen: TEST FAIL" | tee summary; \ @@ -49,10 +49,10 @@ summary: doxygen echo "Doxygen: TEST OK (no warning nor error)" | tee summary; \ fi ; \ ) - @rm doxygen.runlog doxygen.runerr + @rm doxygen.err @echo "========== Summary ==========" @cat summary clean: - @rm -f summary doxygen.runlog doxygen.runerr + @rm -f summary doxygen.err @make -C $(DOCDIR) clean diff --git a/tests/07-simulation-base/code-data-structures/test-data-structures.c b/tests/07-simulation-base/code-data-structures/test-data-structures.c index e682e43da..dc4d8bb5b 100644 --- a/tests/07-simulation-base/code-data-structures/test-data-structures.c +++ b/tests/07-simulation-base/code-data-structures/test-data-structures.c @@ -30,6 +30,7 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" +#include "lib/list.h" #include "lib/stack.h" #include "lib/queue.h" #include "lib/circular-list.h" @@ -65,6 +66,141 @@ print_test_report(const unit_test_t *utp) } } /*---------------------------------------------------------------------------*/ +UNIT_TEST_REGISTER(test_list, "Singly-linked list"); +UNIT_TEST(test_list) +{ + demo_struct_t *head, *tail; + + LIST(lst); + + UNIT_TEST_BEGIN(); + + memset(elements, 0, sizeof(elements)); + list_init(lst); + + /* Starts from empty */ + UNIT_TEST_ASSERT(list_head(lst) == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 0); + + /* + * Add an item. Should be head and tail + * 0 --> NULL + */ + list_add(lst, &elements[0]); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[0]); + UNIT_TEST_ASSERT(elements[0].next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 1); + + /* + * Add an item. Should become the new tail + * 0 --> 1 --> NULL + */ + list_add(lst, &elements[1]); + head = list_head(lst); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[1]); + UNIT_TEST_ASSERT(head->next == tail); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 2); + + /* + * Add after existing head + * 0 --> 2 --> 1 --> NULL + */ + head = list_head(lst); + list_insert(lst, head, &elements[2]); + head = list_head(lst); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[1]); + UNIT_TEST_ASSERT(head->next == &elements[2]); + UNIT_TEST_ASSERT(elements[2].next == tail); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 3); + + /* + * Add after existing head + * 0 --> 2 --> 1 --> 3 --> NULL + */ + tail = list_tail(lst); + list_insert(lst, tail, &elements[3]); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[3]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 4); + + /* + * Re-add item 2 using list_add + * 0 --> 1 --> 3 --> 2 --> NULL + */ + list_add(lst, &elements[2]); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[2]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 4); + + /* + * Re-add item 3 using list_insert + * 0 --> 1 --> 2 --> 3 --> NULL + */ + tail = list_tail(lst); + list_insert(lst, tail, &elements[3]); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[3]); + UNIT_TEST_ASSERT(elements[2].next == tail); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 4); + + /* + * Remove the tail + * 0 --> 1 --> 2 --> NULL + */ + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_chop(lst) == tail); + head = list_head(lst); + tail = list_tail(lst); + UNIT_TEST_ASSERT(tail == &elements[2]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 3); + + /* + * Remove an item in the middle + * 0 --> 2 --> NULL + */ + head = list_head(lst); + list_remove(lst, head->next); + head = list_head(lst); + tail = list_tail(lst); + UNIT_TEST_ASSERT(head->next == tail); + UNIT_TEST_ASSERT(list_head(lst) == &elements[0]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[2]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 2); + + /* + * Remove the head + * 2 --> NULL + */ + list_remove(lst, list_head(lst)); + tail = list_tail(lst); + UNIT_TEST_ASSERT(list_head(lst) == &elements[2]); + UNIT_TEST_ASSERT(list_tail(lst) == &elements[2]); + UNIT_TEST_ASSERT(tail->next == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 1); + + /* Ends empty */ + list_remove(lst, list_tail(lst)); + UNIT_TEST_ASSERT(list_head(lst) == NULL); + UNIT_TEST_ASSERT(list_length(lst) == 0); + + UNIT_TEST_END(); +} +/*---------------------------------------------------------------------------*/ UNIT_TEST_REGISTER(test_stack, "Stack Push/Pop"); UNIT_TEST(test_stack) { @@ -884,6 +1020,7 @@ PROCESS_THREAD(data_structure_test_process, ev, data) memset(elements, 0, sizeof(elements)); + UNIT_TEST_RUN(test_list); UNIT_TEST_RUN(test_stack); UNIT_TEST_RUN(test_queue); UNIT_TEST_RUN(test_csll); diff --git a/tests/17-tun-rpl-br/06-native-coap.sh b/tests/17-tun-rpl-br/06-native-coap.sh index a42424ee4..453d76e2e 100755 --- a/tests/17-tun-rpl-br/06-native-coap.sh +++ b/tests/17-tun-rpl-br/06-native-coap.sh @@ -44,7 +44,7 @@ sleep 2 pgrep hello-world | sudo xargs kill -9 if [ $TESTCOUNT -eq $OKCOUNT ] ; then - printf "%-40s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" > $BASENAME.testlog; + printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" > $BASENAME.testlog; else echo "==== make.log ====" ; cat make.log; echo "==== make.err ====" ; cat make.err; diff --git a/tests/Makefile.compile-test b/tests/Makefile.compile-test index 28904194d..6c7df5835 100644 --- a/tests/Makefile.compile-test +++ b/tests/Makefile.compile-test @@ -41,10 +41,10 @@ define dooneexample @echo -n Building example $(3): $(1) $(4) for target $(2) @((cd $(EXAMPLESDIR)/$(1); \ make $(4) TARGET=$(2) clean && make -j $(4) TARGET=$(2) WERROR=1) > \ - /dev/null 2>make.runerr && \ + /dev/null 2>make.err && \ (echo " -> OK" && printf "%-75s %-35s %-20s TEST OK\n" "$(1)" "$(4)" "$(2)" > $(3)-$(subst /,-,$(1))$(2).testlog) || \ - (echo " -> FAIL" && printf "%-75s %-35s %-20s TEST FAIL\n" "$(1)" "$(4)" "$(2)" > $(3)-$(subst /,-,$(1))$(2).testlog ; cat make.runerr)) -@rm -f make.runerr + (echo " -> FAIL" && printf "%-75s %-35s %-20s TEST FAIL\n" "$(1)" "$(4)" "$(2)" > $(3)-$(subst /,-,$(1))$(2).testlog ; cat make.err)) +@rm -f make.err endef define doexample diff --git a/tools/cooja b/tools/cooja index 1256b2999..c1a1b4fdc 160000 --- a/tools/cooja +++ b/tools/cooja @@ -1 +1 @@ -Subproject commit 1256b299930b57f4c1d5512f8e96aa22a327591c +Subproject commit c1a1b4fdc9329b6cf22a7740145f448841ac2254 diff --git a/tools/sky/uip6-bridge/Makefile b/tools/sky/uip6-bridge/Makefile index ce605851e..55da6798e 100644 --- a/tools/sky/uip6-bridge/Makefile +++ b/tools/sky/uip6-bridge/Makefile @@ -12,7 +12,7 @@ ifndef TARGET TARGET=sky endif -PROJECTDIRS = dev +MODULES_REL += dev PROJECT_SOURCEFILES = fakeuip.c sicslow_ethernet.c all: uip6-bridge-tap.sky