diff --git a/examples/native-border-router/Makefile.target b/examples/native-border-router/Makefile.target deleted file mode 100644 index 12b0e8c74db3e96910d9b5c09ed13a04e55e392d..0000000000000000000000000000000000000000 --- a/examples/native-border-router/Makefile.target +++ /dev/null @@ -1 +0,0 @@ -TARGET = native diff --git a/examples/platform-specific/jn516x/rpl/border-router/Makefile b/examples/platform-specific/jn516x/rpl/border-router/Makefile deleted file mode 100644 index 006055734ee4a2e1e60c6896a9996dd05cc519f0..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/rpl/border-router/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -CONTIKI_PROJECT = border-router -all: $(CONTIKI_PROJECT) - -TARGET ?= jn516x - -CONTIKI=../../../../.. - -MAKE_MAC = MAKE_MAC_TSCH -PROJECTDIRS += .. ../tools -PROJECT_SOURCEFILES += rpl-tools.c -PROJECT_SOURCEFILES += slip-bridge.c slip.c - -ifeq ($(PREFIX),) - PREFIX = fd00::1/64 -endif - -include $(CONTIKI)/Makefile.include - -#using XON/XOFF flow control -connect-router-sw: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -X -B 1000000 $(PREFIX) - -#using hw flow control -connect-router-hw: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -H -B 1000000 $(PREFIX) - -#using no flow control -connect-router-no: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -B 1000000 $(PREFIX) diff --git a/examples/platform-specific/jn516x/rpl/border-router/README.md b/examples/platform-specific/jn516x/rpl/border-router/README.md deleted file mode 100644 index c2af3f3b66d5eb08b76aa7e19027927547be2f0f..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/rpl/border-router/README.md +++ /dev/null @@ -1,10 +0,0 @@ -A RPL border router. -To indicate the hardware target for the border router, add one of the following -options in the command line: -If rpl-border-router runs on dongle: -JN516x_WITH_DONGLE=1 -If rpl-border-router runs on DR1174: -JN516x_WITH_DR1174=1 -If building for a new platform, first execute : make clean - -See ../README.md for more. \ No newline at end of file diff --git a/examples/platform-specific/jn516x/rpl/border-router/border-router.c b/examples/platform-specific/jn516x/rpl/border-router/border-router.c deleted file mode 100644 index 3e829b4cc6c2fd2f42a91345129efc92624f3574..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/rpl/border-router/border-router.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 file is part of the Contiki operating system. - * - */ - -#include "contiki.h" -#include "dev/slip.h" -#include "rpl.h" -#include "tools/rpl-tools.h" - -#define DEBUG DEBUG_PRINT -#include "net/ipv6/uip-debug.h" - -static uip_ipaddr_t prefix; -static uint8_t prefix_set; - -PROCESS(border_router_process, "Border router process"); - -AUTOSTART_PROCESSES(&border_router_process); - -/*---------------------------------------------------------------------------*/ -void -request_prefix(void) -{ - /* mess up uip_buf with a dirty request... */ - uip_buf[0] = '?'; - uip_buf[1] = 'P'; -/* uip_buf[2] = '\n'; */ - uip_len = 2; - slip_send(); - uip_len = 0; -} -/*---------------------------------------------------------------------------*/ -void -set_prefix_64(uip_ipaddr_t *prefix_64) -{ - memcpy(&prefix, prefix_64, 16); - prefix_set = 1; -} -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(border_router_process, ev, data) -{ - static struct etimer et; - - PROCESS_BEGIN(); - -/* While waiting for the prefix to be sent through the SLIP connection, the future - * border router can join an existing DAG as a parent or child, or acquire a default - * router that will later take precedence over the SLIP fallback interface. - * Prevent that by turning the radio off until we are initialized as a DAG root. - */ - prefix_set = 0; - - PROCESS_PAUSE(); - - PRINTF("RPL-Border router started\n"); - - /* Request prefix until it has been received */ - while(!prefix_set) { - etimer_set(&et, CLOCK_SECOND); - request_prefix(); - PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); - PRINTF("Waiting for prefix\n"); - } - - PRINTF("Obtained prefix: "); - uip_debug_ipaddr_print(&prefix); - PRINTF("\n"); - - rpl_tools_init(&prefix); - - /* Print out routing tables every minute */ - etimer_set(&et, CLOCK_SECOND * 60); - while(1) { - print_network_status(); - PROCESS_YIELD_UNTIL(etimer_expired(&et)); - etimer_reset(&et); - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/platform-specific/jn516x/rpl/border-router/project-conf.h b/examples/platform-specific/jn516x/rpl/border-router/project-conf.h deleted file mode 100644 index 2673d895e78ef317843a0f68bb65f98a51d810d4..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/rpl/border-router/project-conf.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2015, SICS Swedish ICT. - * 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. - * - */ - -/** - * \author Simon Duquennoy <simonduq@sics.se> - */ - -#ifndef BR_PROJECT_CONF_H_ -#define BR_PROJECT_CONF_H_ - -#ifndef UIP_FALLBACK_INTERFACE -#define UIP_FALLBACK_INTERFACE rpl_interface -#endif - -/* Needed for slip-bridge */ -#define SLIP_BRIDGE_CONF_NO_PUTCHAR 0 - -#include "../common-conf.h" - -#endif /* PROJECT_CONF_H_ */ diff --git a/examples/platform-specific/jn516x/rpl/border-router/slip-bridge.c b/examples/platform-specific/jn516x/rpl/border-router/slip-bridge.c deleted file mode 100644 index a4aff20e08bde9e05543fac47aaf7b5002de987d..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/rpl/border-router/slip-bridge.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2010, SICS Swedish ICT. - * 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. - * - */ - -/** - * \file - * Slip fallback interface - * \author - * Niclas Finne <nfi@sics.se> - * Joakim Eriksson <joakime@sics.se> - * Joel Hoglund <joel@sics.se> - * Nicolas Tsiftes <nvt@sics.se> - */ - -#include "net/ipv6/uip.h" -#include "net/ipv6/uip-ds6.h" -#include "dev/slip.h" -#if CONTIKI_TARGET_JN516X -#include "dev/uart0.h" -#else -#include "dev/uart1.h" -#endif -#include <string.h> - -#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) - -#define DEBUG DEBUG_NONE -#include "net/ipv6/uip-debug.h" - -void set_prefix_64(uip_ipaddr_t *); - -static uip_ipaddr_t last_sender; -/*---------------------------------------------------------------------------*/ -static void -slip_input_callback(void) -{ - PRINTF("SIN: %u\n", uip_len); - if(uip_buf[0] == '!') { - PRINTF("Got configuration message of type %c\n", uip_buf[1]); - uip_len = 0; - if(uip_buf[1] == 'P') { - uip_ipaddr_t prefix; - /* Here we set a prefix !!! */ - memset(&prefix, 0, 16); - memcpy(&prefix, &uip_buf[2], 8); - PRINTF("Setting prefix "); - PRINT6ADDR(&prefix); - PRINTF("\n"); - set_prefix_64(&prefix); - } - } else if(uip_buf[0] == '?') { - PRINTF("Got request message of type %c\n", uip_buf[1]); - if(uip_buf[1] == 'M') { - char *hexchar = "0123456789abcdef"; - int j; - /* this is just a test so far... just to see if it works */ - uip_buf[0] = '!'; - for(j = 0; j < 8; j++) { - uip_buf[2 + j * 2] = hexchar[uip_lladdr.addr[j] >> 4]; - uip_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15]; - } - uip_len = 18; - slip_send(); - } - uip_len = 0; - } - /* Save the last sender received over SLIP to avoid bouncing the - packet back if no route is found */ - uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr); -} -/*---------------------------------------------------------------------------*/ -static void -init(void) -{ - slip_arch_init(); - process_start(&slip_process, NULL); - slip_set_input_callback(slip_input_callback); -} -/*---------------------------------------------------------------------------*/ -static int -output(void) -{ - if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) { - /* Do not bounce packets back over SLIP if the packet was received - over SLIP */ - PRINTF("slip-bridge: Destination off-link but no route src="); - PRINT6ADDR(&UIP_IP_BUF->srcipaddr); - PRINTF(" dst="); - PRINT6ADDR(&UIP_IP_BUF->destipaddr); - PRINTF("\n"); - } else { - PRINTF("SUT: %u\n", uip_len); - slip_send(); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -#if !SLIP_BRIDGE_CONF_NO_PUTCHAR -#undef putchar -int -putchar(int c) -{ -#define SLIP_END 0300 - 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; -} -#endif -/*---------------------------------------------------------------------------*/ -const struct uip_fallback_interface rpl_interface = { - init, output -}; -/*---------------------------------------------------------------------------*/ diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/Makefile b/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/Makefile deleted file mode 100644 index 41c732ba2f2dc893fadc369d8191f2162b01541f..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -CONTIKI_PROJECT=border-router - -TARGET ?= jn516x -JN516x_WITH_DONGLE = 1 -CONTIKI=../../../../../.. - -PROJECT_SOURCEFILES += slip-bridge.c slip.c - -PROJECTDIRS += .. ../../tools -PROJECT_SOURCEFILES += rpl-tools.c - -MAKE_MAC = MAKE_MAC_TSCH -MODULES += os/net/app-layer/coap -MODULES += os/services/orchestra os/lib/json - -all: $(CONTIKI_PROJECT) -include $(CONTIKI)/Makefile.include - -ifeq ($(PREFIX),) - PREFIX = bbbb::1/64 -endif - -#no flow control -connect-router: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -v1 -B 1000000 $(PREFIX) - -#using XON/XOFF flow control -connect-router-sw: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -v1 -X -B 1000000 $(PREFIX) - -#using hw flow control -connect-router-hw: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -v1 -H -B 1000000 $(PREFIX) - -#using no flow control -connect-router-no: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -v1 -B 1000000 $(PREFIX) - -connect-router-cooja: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 $(PREFIX) diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/README.md b/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/README.md deleted file mode 100644 index da1bc21ff8be9e9c6336204dd7ca821d4375eb63..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/README.md +++ /dev/null @@ -1,2 +0,0 @@ -rpl-border-router has been configured and tested to run on a JN5168-dongle in combination -with the NXP IoT Gateway. This requires the baud rate to be configured on 230400Bd. diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/border-router.c b/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/border-router.c deleted file mode 100644 index df329a50874aa115b7695c9826d3424abda2439f..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/border-router.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 file is part of the Contiki operating system. - * - */ -/** - * \file - * border-router - * \author - * Niclas Finne <nfi@sics.se> - * Joakim Eriksson <joakime@sics.se> - * Nicolas Tsiftes <nvt@sics.se> - */ - -#include "contiki.h" -#include "contiki-lib.h" -#include "contiki-net.h" -#include "net/ipv6/uip.h" -#include "net/ipv6/uip-ds6.h" -#include "rpl.h" -#include "simple-udp.h" -#include "net/mac/tsch/tsch.h" -#include "net/mac/tsch/tsch-schedule.h" -#include "net/netstack.h" -#include "dev/slip.h" -#include "rpl-tools.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#define DEBUG DEBUG_NONE -#include "net/ipv6/uip-debug.h" - -static uip_ipaddr_t prefix; -static uint8_t prefix_set; - -PROCESS(border_router_process, "Border router process"); - -AUTOSTART_PROCESSES(&border_router_process); -/*---------------------------------------------------------------------------*/ -void -request_prefix(void) -{ - /* mess up uip_buf with a dirty request... */ - uip_buf[0] = '?'; - uip_buf[1] = 'P'; - uip_len = 2; - slip_send(); - uip_len = 0; -} -/*---------------------------------------------------------------------------*/ -void -set_prefix_64(uip_ipaddr_t *prefix_64) -{ - memcpy(&prefix, prefix_64, 16); - prefix_set = 1; -} -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(border_router_process, ev, data) -{ - static struct etimer et; - - PROCESS_BEGIN(); - -/* While waiting for the prefix to be sent through the SLIP connection, the future - * border router can join an existing DAG as a parent or child, or acquire a default - * router that will later take precedence over the SLIP fallback interface. - * Prevent that by turning the radio off until we are initialized as a DAG root. - */ - prefix_set = 0; - - PROCESS_PAUSE(); - - PRINTF("RPL-Border router started\n"); - - - /* Request prefix until it has been received */ - while(!prefix_set) { - etimer_set(&et, CLOCK_SECOND); - request_prefix(); - PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); - PRINTF("Waiting for prefix\n"); - } - - PRINTF("Obtained prefix: "); - uip_debug_ipaddr_print(&prefix); - PRINTF("\n"); - - rpl_tools_init(&prefix); - - etimer_set(&et, CLOCK_SECOND * 60); - while(1) { - print_network_status(); - PROCESS_YIELD_UNTIL(etimer_expired(&et)); - etimer_reset(&et); - } - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/slip-bridge.c b/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/slip-bridge.c deleted file mode 100644 index 8201bf0f751ae72890707cb7b5322bce70d984e1..0000000000000000000000000000000000000000 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/slip-bridge.c +++ /dev/null @@ -1,160 +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. - * - */ - -/** - * \file - * Slip fallback interface - * \author - * Niclas Finne <nfi@sics.se> - * Joakim Eriksson <joakime@sics.se> - * Joel Hoglund <joel@sics.se> - * Nicolas Tsiftes <nvt@sics.se> - */ - -#include "net/ipv6/uip.h" -#include "net/ipv6/uip-ds6.h" -#include "dev/slip.h" -#if CONTIKI_TARGET_JN516X -#include "dev/uart0.h" -#else -#include "dev/uart1.h" -#endif -#include <string.h> - -#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) - -#define DEBUG DEBUG_NONE -#include "net/ipv6/uip-debug.h" - -void set_prefix_64(uip_ipaddr_t *); - -static uip_ipaddr_t last_sender; -/*---------------------------------------------------------------------------*/ -static void -slip_input_callback(void) -{ - PRINTF("SIN: %u\n", uip_len); - if(uip_buf[0] == '!') { - PRINTF("Got configuration message of type %c\n", uip_buf[1]); - uip_len = 0; - if(uip_buf[1] == 'P') { - uip_ipaddr_t prefix; - /* Here we set a prefix !!! */ - memset(&prefix, 0, 16); - memcpy(&prefix, &uip_buf[2], 8); - PRINTF("Setting prefix "); - PRINT6ADDR(&prefix); - PRINTF("\n"); - set_prefix_64(&prefix); - } - } else if (uip_buf[0] == '?') { - PRINTF("Got request message of type %c\n", uip_buf[1]); - if(uip_buf[1] == 'M') { - char* hexchar = "0123456789abcdef"; - int j; - /* this is just a test so far... just to see if it works */ - uip_buf[0] = '!'; - for(j = 0; j < 8; j++) { - uip_buf[2 + j * 2] = hexchar[uip_lladdr.addr[j] >> 4]; - uip_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15]; - } - uip_len = 18; - slip_send(); - - } - uip_len = 0; - } - /* Save the last sender received over SLIP to avoid bouncing the - packet back if no route is found */ - uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr); -} -/*---------------------------------------------------------------------------*/ -static void -init(void) -{ - slip_arch_init(); - process_start(&slip_process, NULL); - slip_set_input_callback(slip_input_callback); -} -/*---------------------------------------------------------------------------*/ -static int -output(void) -{ - if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) { - /* Do not bounce packets back over SLIP if the packet was received - over SLIP */ - PRINTF("slip-bridge: Destination off-link but no route src="); - PRINT6ADDR(&UIP_IP_BUF->srcipaddr); - PRINTF(" dst="); - PRINT6ADDR(&UIP_IP_BUF->destipaddr); - PRINTF("\n"); - } else { - PRINTF("SUT: %u\n", uip_len); - slip_send(); - printf("\n"); - } - return 0; -} - -/*---------------------------------------------------------------------------*/ -#if !SLIP_BRIDGE_CONF_NO_PUTCHAR -#undef putchar -int -putchar(int c) -{ -#define SLIP_END 0300 - 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; -} -#endif -/*---------------------------------------------------------------------------*/ -const struct uip_fallback_interface rpl_interface = { - init, output -}; -/*---------------------------------------------------------------------------*/ diff --git a/examples/rpl-border-router/Makefile b/examples/rpl-border-router/Makefile index 2f02a031e2f479651efb8b06a072be80b965846f..22d8d743f699a312e2e8b514ddc930b802fdaddd 100644 --- a/examples/rpl-border-router/Makefile +++ b/examples/rpl-border-router/Makefile @@ -1,21 +1,29 @@ -CONTIKI_PROJECT=border-router -all: $(CONTIKI_PROJECT) +PROJECTDIRS += common CONTIKI=../.. -PROJECT_SOURCEFILES += slip-bridge.c httpd-simple.c +-include $(CONTIKI)/Makefile.identify-target -ifeq ($(PREFIX),) - PREFIX = fd00::1/64 +all: border-router.$(TARGET) + +ifeq ($(TARGET),native) + SOURCES_DIR = native +else + SOURCES_DIR = embedded endif -include $(CONTIKI)/Makefile.include +include $(SOURCES_DIR)/Makefile + +PROJECTDIRS += $(SOURCES_DIR) +CFLAGS += -DPROJECT_CONF_PATH=\"$(SOURCES_DIR)/project-conf.h\" -$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c - (cd $(CONTIKI)/tools && $(MAKE) tunslip6) +border-router.$(TARGET): $(SOURCES_DIR)/border-router.$(TARGET) + cp $< $@ -connect-router: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 $(PREFIX) +CLEAN += border-router.$(TARGET) $(SOURCES_DIR)/border-router.$(TARGET) -connect-router-cooja: $(CONTIKI)/tools/tunslip6 - sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 $(PREFIX) +ifeq ($(PREFIX),) + PREFIX = fd00::1/64 +endif + +include $(CONTIKI)/Makefile.include diff --git a/examples/native-border-router/httpd-simple.c b/examples/rpl-border-router/common/httpd-simple.c similarity index 100% rename from examples/native-border-router/httpd-simple.c rename to examples/rpl-border-router/common/httpd-simple.c diff --git a/examples/native-border-router/httpd-simple.h b/examples/rpl-border-router/common/httpd-simple.h similarity index 100% rename from examples/native-border-router/httpd-simple.h rename to examples/rpl-border-router/common/httpd-simple.h diff --git a/examples/rpl-border-router/embedded/Makefile b/examples/rpl-border-router/embedded/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..5a7b1cd554ee4dc9b66b216ebc0238587095be01 --- /dev/null +++ b/examples/rpl-border-router/embedded/Makefile @@ -0,0 +1,16 @@ +### 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 httpd-simple.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/border-router.c b/examples/rpl-border-router/embedded/border-router.c similarity index 93% rename from examples/rpl-border-router/border-router.c rename to examples/rpl-border-router/embedded/border-router.c index c6a812d93594bb489acb3f1c745cd5e957869980..a6ecb065e0afa09839c4ca95b8823fb7e6acdef4 100644 --- a/examples/rpl-border-router/border-router.c +++ b/examples/rpl-border-router/embedded/border-router.c @@ -51,20 +51,23 @@ #include "net/netstack.h" #include "dev/button-sensor.h" #include "dev/slip.h" - +#include "net/ipv6/uip-debug.h" +/*---------------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> - -#define DEBUG DEBUG_NONE -#include "net/ipv6/uip-debug.h" - +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "BR" +#define LOG_LEVEL LOG_LEVEL_INFO +/*---------------------------------------------------------------------------*/ static uip_ipaddr_t prefix; static uint8_t prefix_set; - +/*---------------------------------------------------------------------------*/ PROCESS(border_router_process, "Border router process"); - +/*---------------------------------------------------------------------------*/ #if BORDER_ROUTER_CONF_WEBSERVER /* Use simple webserver with only one page for minimum footprint. * Multiple connections can result in interleaved tcp segments since @@ -352,14 +355,13 @@ print_local_addresses(void) int i; uint8_t state; - PRINTA("Server IPv6 addresses:\n"); + LOG_INFO("Server IPv6 addresses:\n"); 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)) { - PRINTA(" "); - uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr); - PRINTA("\n"); + LOG_INFO_6ADDR(&uip_ds6_if.addr_list[i].ipaddr); + LOG_INFO_("\n"); } } } @@ -402,15 +404,18 @@ PROCESS_THREAD(border_router_process, ev, data) SENSORS_ACTIVATE(button_sensor); - PRINTF("RPL-Border router started\n"); + LOG_INFO("RPL-Border router started\n"); /* Request prefix until it has been received */ while(!prefix_set) { etimer_set(&et, CLOCK_SECOND); request_prefix(); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + LOG_INFO("Waiting for prefix\n"); } + NETSTACK_MAC.on(); + #if DEBUG || 1 print_local_addresses(); #endif @@ -418,7 +423,7 @@ PROCESS_THREAD(border_router_process, ev, data) while(1) { PROCESS_YIELD(); if (ev == sensors_event && data == &button_sensor) { - PRINTF("Initiating global repair\n"); + LOG_INFO("Initiating global repair\n"); #if UIP_CONF_IPV6_RPL_LITE rpl_global_repair(); #else diff --git a/examples/rpl-border-router/project-conf.h b/examples/rpl-border-router/embedded/project-conf.h similarity index 87% rename from examples/rpl-border-router/project-conf.h rename to examples/rpl-border-router/embedded/project-conf.h index 32703ce4531b66f17845d1e75e89728e94818e2e..b67d39e5643e98669cdb006badabec37dd29569a 100644 --- a/examples/rpl-border-router/project-conf.h +++ b/examples/rpl-border-router/embedded/project-conf.h @@ -30,7 +30,12 @@ #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 diff --git a/examples/rpl-border-router/embedded/sky/Makefile.sky b/examples/rpl-border-router/embedded/sky/Makefile.sky new file mode 100644 index 0000000000000000000000000000000000000000..c3d097481e048de9f0dc7efa3c0c1bb06bfe2d67 --- /dev/null +++ b/examples/rpl-border-router/embedded/sky/Makefile.sky @@ -0,0 +1,3 @@ +PROJECT_SOURCEFILES += slip-bridge-putchar.c + +CFLAGS += -DTARGET_CONF_PATH=\"target-conf.h\" diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/project-conf.h b/examples/rpl-border-router/embedded/sky/slip-bridge-putchar.c similarity index 61% rename from examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/project-conf.h rename to examples/rpl-border-router/embedded/sky/slip-bridge-putchar.c index 52f716c41d01ac0346de6b8090ab7e6fec1ff87b..f7f501ba1951b610dbbff90f93422b1e4a35c4ab 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/project-conf.h +++ b/examples/rpl-border-router/embedded/sky/slip-bridge-putchar.c @@ -27,21 +27,38 @@ * SUCH DAMAGE. * */ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" +#include "dev/slip.h" -#ifndef BR_PROJECT_ROUTER_CONF_H_ -#define BR_PROJECT_ROUTER_CONF_H_ +#include <string.h> +/*---------------------------------------------------------------------------*/ +#define SLIP_END 0300 +#undef putchar +/*---------------------------------------------------------------------------*/ +int +putchar(int c) +{ + static char debug_frame = 0; -#ifndef UIP_FALLBACK_INTERFACE -#define UIP_FALLBACK_INTERFACE rpl_interface -#endif + if(!debug_frame) { /* Start of debug output */ + slip_arch_writeb(SLIP_END); + slip_arch_writeb('\r'); /* Type debug line == '\r' */ + debug_frame = 1; + } -#define UIP_CONF_TCP 0 + /* Need to also print '\n' because for example COOJA will not show + any output before line end */ + slip_arch_writeb((char)c); -/* Needed for slip-bridge */ -#define SLIP_BRIDGE_CONF_NO_PUTCHAR 0 - -#define UART_BAUD_RATE UART_RATE_230400 - -#include "../../common-conf.h" - -#endif /* PROJECT_ROUTER_CONF_H_ */ + /* + * 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/embedded/sky/target-conf.h b/examples/rpl-border-router/embedded/sky/target-conf.h new file mode 100644 index 0000000000000000000000000000000000000000..3b0b0fcd4dda89a1bde80e52c15e8be9595ae2e6 --- /dev/null +++ b/examples/rpl-border-router/embedded/sky/target-conf.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, George Oikonomou - http://www.spd.gr + * 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 copyright holder 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDER 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 TARGET_CONF_H_ +#define TARGET_CONF_H_ +/*---------------------------------------------------------------------------*/ +#define QUEUEBUF_CONF_NUM 4 +#define UIP_CONF_BUFFER_SIZE 140 +/*---------------------------------------------------------------------------*/ +#endif /* TARGET_CONF_H_ */ +/*---------------------------------------------------------------------------*/ diff --git a/examples/rpl-border-router/slip-bridge.c b/examples/rpl-border-router/embedded/slip-bridge.c similarity index 74% rename from examples/rpl-border-router/slip-bridge.c rename to examples/rpl-border-router/embedded/slip-bridge.c index 17460f35429e4186243b575f347d6644d2e8a0ef..abf95dfa8d96bf675bb5ae2b1cdd6f97f4d993b7 100644 --- a/examples/rpl-border-router/slip-bridge.c +++ b/examples/rpl-border-router/embedded/slip-bridge.c @@ -37,17 +37,19 @@ * Joel Hoglund <joel@sics.se> * Nicolas Tsiftes <nvt@sics.se> */ - +/*---------------------------------------------------------------------------*/ #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" #include "dev/slip.h" #include <string.h> - +/*---------------------------------------------------------------------------*/ #define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) - -#define DEBUG DEBUG_PRINT -#include "net/ipv6/uip-debug.h" - +/*---------------------------------------------------------------------------*/ +/* Log configuration */ +#include "sys/log.h" +#define LOG_MODULE "SLIP" +#define LOG_LEVEL LOG_LEVEL_NONE +/*---------------------------------------------------------------------------*/ void set_prefix_64(uip_ipaddr_t *); static uip_ipaddr_t last_sender; @@ -55,24 +57,24 @@ static uip_ipaddr_t last_sender; static void slip_input_callback(void) { - // PRINTF("SIN: %u\n", uip_len); + LOG_DBG("SIN: %u\n", uip_len); if(uip_buf[0] == '!') { - PRINTF("Got configuration message of type %c\n", uip_buf[1]); + LOG_INFO("Got configuration message of type %c\n", uip_buf[1]); uip_clear_buf(); if(uip_buf[1] == 'P') { uip_ipaddr_t prefix; /* Here we set a prefix !!! */ memset(&prefix, 0, 16); memcpy(&prefix, &uip_buf[2], 8); - PRINTF("Setting prefix "); - PRINT6ADDR(&prefix); - PRINTF("\n"); + LOG_INFO("Setting prefix "); + LOG_INFO_6ADDR(&prefix); + LOG_INFO_("\n"); set_prefix_64(&prefix); } - } else if (uip_buf[0] == '?') { - PRINTF("Got request message of type %c\n", uip_buf[1]); + } else if(uip_buf[0] == '?') { + LOG_INFO("Got request message of type %c\n", uip_buf[1]); if(uip_buf[1] == 'M') { - char* hexchar = "0123456789abcdef"; + char *hexchar = "0123456789abcdef"; int j; /* this is just a test so far... just to see if it works */ uip_buf[0] = '!'; @@ -82,7 +84,6 @@ slip_input_callback(void) } uip_len = 18; slip_send(); - } uip_clear_buf(); } @@ -105,48 +106,17 @@ output(void) if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) { /* Do not bounce packets back over SLIP if the packet was received over SLIP */ - PRINTF("slip-bridge: Destination off-link but no route src="); - PRINT6ADDR(&UIP_IP_BUF->srcipaddr); - PRINTF(" dst="); - PRINT6ADDR(&UIP_IP_BUF->destipaddr); - PRINTF("\n"); + LOG_ERR("slip-bridge: Destination off-link but no route src="); + LOG_ERR_6ADDR(&UIP_IP_BUF->srcipaddr); + LOG_ERR_(" dst="); + LOG_ERR_6ADDR(&UIP_IP_BUF->destipaddr); + LOG_ERR_("\n"); } else { - // PRINTF("SUT: %u\n", uip_len); + LOG_DBG("SUT: %u\n", uip_len); slip_send(); } return 0; } - -/*---------------------------------------------------------------------------*/ -#if !SLIP_BRIDGE_CONF_NO_PUTCHAR -#undef putchar -int -putchar(int c) -{ -#define SLIP_END 0300 - 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; -} -#endif /*---------------------------------------------------------------------------*/ const struct uip_fallback_interface rpl_interface = { init, output diff --git a/examples/rpl-border-router/httpd-simple.c b/examples/rpl-border-router/httpd-simple.c deleted file mode 100644 index 7a6ad75007679e24e872d5c39b4d3fc429250019..0000000000000000000000000000000000000000 --- a/examples/rpl-border-router/httpd-simple.c +++ /dev/null @@ -1,261 +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. - * - */ - -/** - * \file - * A simple web server forwarding page generation to a protothread - * \author - * Adam Dunkels <adam@sics.se> - * Niclas Finne <nfi@sics.se> - * Joakim Eriksson <joakime@sics.se> - */ - -#include <stdio.h> -#include <string.h> - -#include "contiki-net.h" - -//#include "urlconv.h" - -#include "httpd-simple.h" -#define webserver_log_file(...) -#define webserver_log(...) - -#ifndef WEBSERVER_CONF_CFS_CONNS -#define CONNS UIP_TCP_CONNS -#else /* WEBSERVER_CONF_CFS_CONNS */ -#define CONNS WEBSERVER_CONF_CFS_CONNS -#endif /* WEBSERVER_CONF_CFS_CONNS */ - -#ifndef WEBSERVER_CONF_CFS_URLCONV -#define URLCONV 0 -#else /* WEBSERVER_CONF_CFS_URLCONV */ -#define URLCONV WEBSERVER_CONF_CFS_URLCONV -#endif /* WEBSERVER_CONF_CFS_URLCONV */ - -#define STATE_WAITING 0 -#define STATE_OUTPUT 1 - -MEMB(conns, struct httpd_state, CONNS); - -#define ISO_nl 0x0a -#define ISO_space 0x20 -#define ISO_period 0x2e -#define ISO_slash 0x2f - -/*---------------------------------------------------------------------------*/ -static const char *NOT_FOUND = "<html><body bgcolor=\"white\">" -"<center>" -"<h1>404 - file not found</h1>" -"</center>" -"</body>" -"</html>"; -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(send_string(struct httpd_state *s, const char *str)) -{ - PSOCK_BEGIN(&s->sout); - - SEND_STRING(&s->sout, str); - - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -const char http_content_type_html[] = "Content-type: text/html\r\n\r\n"; -static -PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr)) -{ - /* char *ptr; */ - - PSOCK_BEGIN(&s->sout); - - SEND_STRING(&s->sout, statushdr); - - /* ptr = strrchr(s->filename, ISO_period); */ - /* if(ptr == NULL) { */ - /* s->ptr = http_content_type_plain; */ - /* } else if(strcmp(http_html, ptr) == 0) { */ - /* s->ptr = http_content_type_html; */ - /* } else if(strcmp(http_css, ptr) == 0) { */ - /* s->ptr = http_content_type_css; */ - /* } else if(strcmp(http_png, ptr) == 0) { */ - /* s->ptr = http_content_type_png; */ - /* } else if(strcmp(http_gif, ptr) == 0) { */ - /* s->ptr = http_content_type_gif; */ - /* } else if(strcmp(http_jpg, ptr) == 0) { */ - /* s->ptr = http_content_type_jpg; */ - /* } else { */ - /* s->ptr = http_content_type_binary; */ - /* } */ - /* SEND_STRING(&s->sout, s->ptr); */ - SEND_STRING(&s->sout, http_content_type_html); - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -const char http_header_200[] = "HTTP/1.0 200 OK\r\nServer: Contiki/2.4 http://www.sics.se/contiki/\r\nConnection: close\r\n"; -const char http_header_404[] = "HTTP/1.0 404 Not found\r\nServer: Contiki/2.4 http://www.sics.se/contiki/\r\nConnection: close\r\n"; -static -PT_THREAD(handle_output(struct httpd_state *s)) -{ - PT_BEGIN(&s->outputpt); - - s->script = NULL; - s->script = httpd_simple_get_script(&s->filename[1]); - if(s->script == NULL) { - strncpy(s->filename, "/notfound.html", sizeof(s->filename)); - PT_WAIT_THREAD(&s->outputpt, - send_headers(s, http_header_404)); - PT_WAIT_THREAD(&s->outputpt, - send_string(s, NOT_FOUND)); - uip_close(); - webserver_log_file(&uip_conn->ripaddr, "404 - not found"); - PT_EXIT(&s->outputpt); - } else { - PT_WAIT_THREAD(&s->outputpt, - send_headers(s, http_header_200)); - PT_WAIT_THREAD(&s->outputpt, s->script(s)); - } - s->script = NULL; - PSOCK_CLOSE(&s->sout); - PT_END(&s->outputpt); -} -/*---------------------------------------------------------------------------*/ -const char http_get[] = "GET "; -const char http_index_html[] = "/index.html"; -//const char http_referer[] = "Referer:" -static -PT_THREAD(handle_input(struct httpd_state *s)) -{ - PSOCK_BEGIN(&s->sin); - - PSOCK_READTO(&s->sin, ISO_space); - - if(strncmp(s->inputbuf, http_get, 4) != 0) { - PSOCK_CLOSE_EXIT(&s->sin); - } - PSOCK_READTO(&s->sin, ISO_space); - - if(s->inputbuf[0] != ISO_slash) { - PSOCK_CLOSE_EXIT(&s->sin); - } - -#if URLCONV - s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; - urlconv_tofilename(s->filename, s->inputbuf, sizeof(s->filename)); -#else /* URLCONV */ - if(s->inputbuf[1] == ISO_space) { - strncpy(s->filename, http_index_html, sizeof(s->filename)); - } else { - s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; - strncpy(s->filename, s->inputbuf, sizeof(s->filename)); - } -#endif /* URLCONV */ - - webserver_log_file(&uip_conn->ripaddr, s->filename); - - s->state = STATE_OUTPUT; - - while(1) { - PSOCK_READTO(&s->sin, ISO_nl); -#if 0 - if(strncmp(s->inputbuf, http_referer, 8) == 0) { - s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0; - webserver_log(s->inputbuf); - } -#endif - } - - PSOCK_END(&s->sin); -} -/*---------------------------------------------------------------------------*/ -static void -handle_connection(struct httpd_state *s) -{ - handle_input(s); - if(s->state == STATE_OUTPUT) { - handle_output(s); - } -} - -/*---------------------------------------------------------------------------*/ -void -httpd_appcall(void *state) -{ - struct httpd_state *s = (struct httpd_state *)state; - - if(uip_closed() || uip_aborted() || uip_timedout()) { - if(s != NULL) { - s->script = NULL; - memb_free(&conns, s); - } - } else if(uip_connected()) { - s = (struct httpd_state *)memb_alloc(&conns); - if(s == NULL) { - uip_abort(); - webserver_log_file(&uip_conn->ripaddr, "reset (no memory block)"); - return; - } - tcp_markconn(uip_conn, s); - PSOCK_INIT(&s->sin, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1); - PSOCK_INIT(&s->sout, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1); - PT_INIT(&s->outputpt); - s->script = NULL; - s->state = STATE_WAITING; - timer_set(&s->timer, CLOCK_SECOND * 10); - handle_connection(s); - } else if(s != NULL) { - if(uip_poll()) { - if(timer_expired(&s->timer)) { - uip_abort(); - s->script = NULL; - memb_free(&conns, s); - webserver_log_file(&uip_conn->ripaddr, "reset (timeout)"); - } - } else { - timer_restart(&s->timer); - } - handle_connection(s); - } else { - uip_abort(); - } -} - -/*---------------------------------------------------------------------------*/ -void -httpd_init(void) -{ - - tcp_listen(UIP_HTONS(80)); - memb_init(&conns); -#if URLCONV - urlconv_init(); -#endif /* URLCONV */ -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/rpl-border-router/httpd-simple.h b/examples/rpl-border-router/httpd-simple.h deleted file mode 100644 index a16dbd99ea815b33a21a41715ae0c743894e9380..0000000000000000000000000000000000000000 --- a/examples/rpl-border-router/httpd-simple.h +++ /dev/null @@ -1,74 +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. - * - */ - -/** - * \file - * A simple webserver - * \author - * Adam Dunkels <adam@sics.se> - * Niclas Finne <nfi@sics.se> - * Joakim Eriksson <joakime@sics.se> - */ - -#ifndef HTTPD_SIMPLE_H_ -#define HTTPD_SIMPLE_H_ - -#include "contiki-net.h" - -/* The current internal border router webserver ignores the requested file name */ -/* and needs no per-connection output buffer, so save some RAM */ -#ifndef WEBSERVER_CONF_CFS_PATHLEN -#define HTTPD_PATHLEN 2 -#else /* WEBSERVER_CONF_CFS_CONNS */ -#define HTTPD_PATHLEN WEBSERVER_CONF_CFS_PATHLEN -#endif /* WEBSERVER_CONF_CFS_CONNS */ - -struct httpd_state; -typedef char (* httpd_simple_script_t)(struct httpd_state *s); - -struct httpd_state { - struct timer timer; - struct psock sin, sout; - struct pt outputpt; - char inputbuf[HTTPD_PATHLEN + 24]; -/*char outputbuf[UIP_TCP_MSS]; */ - char filename[HTTPD_PATHLEN]; - httpd_simple_script_t script; - char state; -}; - -void httpd_init(void); -void httpd_appcall(void *state); - -httpd_simple_script_t httpd_simple_get_script(const char *name); - -#define SEND_STRING(s, str) PSOCK_SEND(s, (uint8_t *)str, strlen(str)) - -#endif /* HTTPD_SIMPLE_H_ */ diff --git a/examples/native-border-router/Makefile b/examples/rpl-border-router/native/Makefile similarity index 74% rename from examples/native-border-router/Makefile rename to examples/rpl-border-router/native/Makefile index d61b29f6e01deeb7a4f1e8c3e8a53b21de0bb2bf..53b5759e79efbc2071b825f2922ee41a19545eac 100644 --- a/examples/native-border-router/Makefile +++ b/examples/rpl-border-router/native/Makefile @@ -1,15 +1,10 @@ -CONTIKI_PROJECT=border-router -all: $(CONTIKI_PROJECT) MODULES += os/services/slip-cmd -CONTIKI=../.. - PROJECT_SOURCEFILES += border-router-cmds.c tun-bridge.c httpd-simple.c PROJECT_SOURCEFILES += slip-config.c slip-dev.c border-router-mac.c MAKE_MAC = MAKE_MAC_OTHER MAKE_NET = MAKE_NET_IPV6 -include $(CONTIKI)/Makefile.include connect-router: border-router.native sudo ./border-router.native fd00::1/64 diff --git a/examples/native-border-router/README.md b/examples/rpl-border-router/native/README.md similarity index 100% rename from examples/native-border-router/README.md rename to examples/rpl-border-router/native/README.md diff --git a/examples/native-border-router/border-router-cmds.c b/examples/rpl-border-router/native/border-router-cmds.c similarity index 100% rename from examples/native-border-router/border-router-cmds.c rename to examples/rpl-border-router/native/border-router-cmds.c diff --git a/examples/native-border-router/border-router-cmds.h b/examples/rpl-border-router/native/border-router-cmds.h similarity index 100% rename from examples/native-border-router/border-router-cmds.h rename to examples/rpl-border-router/native/border-router-cmds.h diff --git a/examples/native-border-router/border-router-mac.c b/examples/rpl-border-router/native/border-router-mac.c similarity index 100% rename from examples/native-border-router/border-router-mac.c rename to examples/rpl-border-router/native/border-router-mac.c diff --git a/examples/native-border-router/border-router.c b/examples/rpl-border-router/native/border-router.c similarity index 100% rename from examples/native-border-router/border-router.c rename to examples/rpl-border-router/native/border-router.c diff --git a/examples/native-border-router/border-router.h b/examples/rpl-border-router/native/border-router.h similarity index 100% rename from examples/native-border-router/border-router.h rename to examples/rpl-border-router/native/border-router.h diff --git a/examples/native-border-router/project-conf.h b/examples/rpl-border-router/native/project-conf.h similarity index 100% rename from examples/native-border-router/project-conf.h rename to examples/rpl-border-router/native/project-conf.h diff --git a/examples/native-border-router/slip-config.c b/examples/rpl-border-router/native/slip-config.c similarity index 100% rename from examples/native-border-router/slip-config.c rename to examples/rpl-border-router/native/slip-config.c diff --git a/examples/native-border-router/slip-dev.c b/examples/rpl-border-router/native/slip-dev.c similarity index 100% rename from examples/native-border-router/slip-dev.c rename to examples/rpl-border-router/native/slip-dev.c diff --git a/examples/native-border-router/tun-bridge.c b/examples/rpl-border-router/native/tun-bridge.c similarity index 100% rename from examples/native-border-router/tun-bridge.c rename to examples/rpl-border-router/native/tun-bridge.c diff --git a/tests/01-compile-base/Makefile b/tests/01-compile-base/Makefile index 5fa09d2e53975c8ac2dff53ef3b0f05525389adf..77cc30005270ecd5500a58ef403417491626bb86 100644 --- a/tests/01-compile-base/Makefile +++ b/tests/01-compile-base/Makefile @@ -8,7 +8,8 @@ storage/eeprom-test/native \ multicast/sky \ libs/logging/native \ rpl-udp/sky \ -native-border-router/native \ +rpl-border-router/native \ +rpl-border-router/sky \ slip-radio/sky \ TOOLS= diff --git a/tests/02-compile-arm-ports/Makefile b/tests/02-compile-arm-ports/Makefile index 4a1395c56137d1a13fe8eee8e401eb52ea2ed325..172769621aac38b3d55b36243183ddd386242f3f 100644 --- a/tests/02-compile-arm-ports/Makefile +++ b/tests/02-compile-arm-ports/Makefile @@ -13,6 +13,8 @@ platform-specific/cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=launchpad/cc1350 \ platform-specific/cc26xx/very-sleepy-demo/srf06-cc26xx \ hello-world/cc2538dk \ rpl-border-router/cc2538dk \ +rpl-border-router/srf06-cc26xx:BOARD=launchpad/cc2650 \ +rpl-border-router/zoul \ rpl-udp/cc2538dk \ coap-example/cc2538dk \ slip-radio/cc2538dk \ diff --git a/tests/03-compile-nxp-ports/Makefile b/tests/03-compile-nxp-ports/Makefile index 782ca92d23be54c6a28617d42fa96b4ce03da103..b1fdd9ea698cdc4ccd52d0a7005b6256165112c9 100644 --- a/tests/03-compile-nxp-ports/Makefile +++ b/tests/03-compile-nxp-ports/Makefile @@ -5,17 +5,16 @@ TOOLSDIR=../../tools EXAMPLES = \ hello-world/jn516x \ platform-specific/jn516x/dr1175-sensors/jn516x \ -platform-specific/jn516x/rpl/border-router/jn516x \ platform-specific/jn516x/rpl/node/jn516x \ platform-specific/jn516x/rpl/coap-dongle-node/jn516x \ platform-specific/jn516x/rpl/coap-dr1175-node/jn516x \ platform-specific/jn516x/rpl/coap-dr1199-node/jn516x \ platform-specific/jn516x/tsch/simple-sensor-network/node/jn516x \ platform-specific/jn516x/tsch/tx-power-verification/node/jn516x \ -platform-specific/jn516x/tsch/simple-sensor-network/rpl-border-router/jn516x \ platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/jn516x \ platform-specific/jn516x/tsch/uart1-test-node/jn516x \ sensniff/jn516x \ +rpl-border-router/jn516x \ 6tisch/simple-node/jn516x \ 6tisch/simple-node/jn516x:MAKE_WITH_ORCHESTRA=1 \ 6tisch/simple-node/jn516x:MAKE_WITH_SECURITY=1 \