From 95841fb56d70349b469b182e0aacf8bf2067e806 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 16 Jan 2015 16:43:14 +0100 Subject: [PATCH 01/37] Remove all the DODAG from the instance when the node is set as Root --- core/net/rpl/rpl-dag.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index cbbf0764a1..22af410882 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -253,6 +253,7 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id) rpl_dag_t *dag; rpl_instance_t *instance; uint8_t version; + int i; #if CETIC_6LBR version = nvm_data.rpl_version_id; @@ -263,19 +264,28 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id) #else version = RPL_LOLLIPOP_INIT; #endif - dag = get_dag(instance_id, dag_id); - if(dag != NULL) { - version = dag->version; - RPL_LOLLIPOP_INCREMENT(version); + instance = rpl_get_instance(instance_id); + if(instance != NULL) { + for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; ++i) { + dag = &instance->dag_table[i]; + if(dag->used) { + if(uip_ipaddr_cmp(&dag->dag_id, dag_id)) { + version = dag->version; + RPL_LOLLIPOP_INCREMENT(version); #if CETIC_6LBR nvm_data.rpl_version_id = version; store_nvm_config(); #endif - PRINTF("RPL: Dropping a joined DAG when setting this node as root"); - if(dag == dag->instance->current_dag) { - dag->instance->current_dag = NULL; + } + if(dag == dag->instance->current_dag) { + PRINTF("RPL: Dropping a joined DAG when setting this node as root"); + dag->instance->current_dag = NULL; + } else { + PRINTF("RPL: Dropping a DAG when setting this node as root"); + } + rpl_free_dag(dag); + } } - rpl_free_dag(dag); } dag = rpl_alloc_dag(instance_id, dag_id); From 33fccf76a6a96b24d3b74e6f9cddb42e0e6959eb Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 16 Jan 2015 16:43:31 +0100 Subject: [PATCH 02/37] Fix indentation --- core/net/rpl/rpl-dag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 22af410882..8430f4e769 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -273,8 +273,8 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id) version = dag->version; RPL_LOLLIPOP_INCREMENT(version); #if CETIC_6LBR - nvm_data.rpl_version_id = version; - store_nvm_config(); + nvm_data.rpl_version_id = version; + store_nvm_config(); #endif } if(dag == dag->instance->current_dag) { From 1c27755a11f4a648d471812c5335003100736942 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 16 Jan 2015 16:44:19 +0100 Subject: [PATCH 03/37] Do not delete instance when a new DODAG can not be created --- core/net/rpl/rpl-dag.c | 1 - 1 file changed, 1 deletion(-) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 8430f4e769..2cfa2ca049 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -522,7 +522,6 @@ rpl_alloc_dag(uint8_t instance_id, uip_ipaddr_t *dag_id) } RPL_STAT(rpl_stats.mem_overflows++); - rpl_free_instance(instance); return NULL; } /*---------------------------------------------------------------------------*/ From 678ed3033bab94e0bd90649ee7e20124933a9cf0 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 16 Jan 2015 16:45:51 +0100 Subject: [PATCH 04/37] Do not priotirize new packets in sicslowpan --- core/net/ipv6/sicslowpan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/net/ipv6/sicslowpan.c b/core/net/ipv6/sicslowpan.c index d4d9c1a866..f0e2492eeb 100644 --- a/core/net/ipv6/sicslowpan.c +++ b/core/net/ipv6/sicslowpan.c @@ -1676,7 +1676,7 @@ input(void) * We discard the previous packet, and start reassembling the new packet. * This lessens the negative impacts of too high SICSLOWPAN_REASS_MAXAGE. */ -#define PRIORITIZE_NEW_PACKETS 1 +#define PRIORITIZE_NEW_PACKETS 0 #if PRIORITIZE_NEW_PACKETS if(!is_fragment) { From 507a1b0b524819529d135e96f3b7374db8c0fb03 Mon Sep 17 00:00:00 2001 From: Maciej Wasilak Date: Fri, 19 Dec 2014 22:43:09 +0100 Subject: [PATCH 05/37] Set uip_ext_len to 0 after dropping packet --- core/net/ip/tcpip.c | 7 +++++++ core/net/ipv6/multicast/smrf.c | 3 +++ core/net/ipv6/uip-nd6.c | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/core/net/ip/tcpip.c b/core/net/ip/tcpip.c index 6d6b80a694..f2ac16a978 100644 --- a/core/net/ip/tcpip.c +++ b/core/net/ip/tcpip.c @@ -589,12 +589,14 @@ tcpip_ipv6_output(void) if(uip_len > UIP_LINK_MTU) { UIP_LOG("tcpip_ipv6_output: Packet to big"); uip_len = 0; + uip_ext_len = 0; return; } if(uip_is_addr_unspecified(&UIP_IP_BUF->destipaddr)){ UIP_LOG("tcpip_ipv6_output: Destination address unspecified"); uip_len = 0; + uip_ext_len = 0; return; } @@ -649,6 +651,7 @@ tcpip_ipv6_output(void) PRINTF("tcpip_ipv6_output: Destination off-link but no route\n"); #endif /* !UIP_FALLBACK_INTERFACE */ uip_len = 0; + uip_ext_len = 0; return; } @@ -698,6 +701,7 @@ tcpip_ipv6_output(void) #if UIP_CONF_IPV6_RPL if(rpl_update_header_final(nexthop)) { uip_len = 0; + uip_ext_len = 0; return; } #endif /* UIP_CONF_IPV6_RPL */ @@ -706,6 +710,7 @@ tcpip_ipv6_output(void) #if UIP_ND6_SEND_NA if((nbr = uip_ds6_nbr_add(nexthop, NULL, 0, NBR_INCOMPLETE)) == NULL) { uip_len = 0; + uip_ext_len = 0; return; } else { #if UIP_CONF_IPV6_QUEUE_PKT @@ -744,6 +749,7 @@ tcpip_ipv6_output(void) } #endif /*UIP_CONF_IPV6_QUEUE_PKT*/ uip_len = 0; + uip_ext_len = 0; return; } /* Send in parallel if we are running NUD (nbc state is either STALE, @@ -774,6 +780,7 @@ tcpip_ipv6_output(void) #endif /*UIP_CONF_IPV6_QUEUE_PKT*/ uip_len = 0; + uip_ext_len = 0; return; } return; diff --git a/core/net/ipv6/multicast/smrf.c b/core/net/ipv6/multicast/smrf.c index 8a80a41425..13abb48725 100644 --- a/core/net/ipv6/multicast/smrf.c +++ b/core/net/ipv6/multicast/smrf.c @@ -81,6 +81,9 @@ mcast_fwd(void *p) UIP_IP_BUF->ttl--; tcpip_output(NULL); uip_len = 0; +#if NETSTACK_CONF_WITH_IPV6 + uip_ext_len = 0; +#endif /*NETSTACK_CONF_WITH_IPV6*/ } /*---------------------------------------------------------------------------*/ static uint8_t diff --git a/core/net/ipv6/uip-nd6.c b/core/net/ipv6/uip-nd6.c index 9d0055e388..3e2f4639e1 100644 --- a/core/net/ipv6/uip-nd6.c +++ b/core/net/ipv6/uip-nd6.c @@ -356,6 +356,7 @@ ns_input(void) discard: uip_len = 0; + uip_ext_len = 0; return; } @@ -608,6 +609,7 @@ na_input(void) discard: uip_len = 0; + uip_ext_len = 0; return; } @@ -744,6 +746,7 @@ rs_input(void) discard: uip_len = 0; + uip_ext_len = 0; return; } @@ -1126,6 +1129,7 @@ ra_input(void) discard: uip_len = 0; + uip_ext_len = 0; return; } #endif /* !UIP_CONF_ROUTER */ From 7d7cd0059310e355f540cf153bbb5ba493516350 Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Fri, 24 Oct 2014 15:13:27 +0200 Subject: [PATCH 06/37] fixed so that trickle timer rpl config is updated at global repair --- core/net/rpl/rpl-dag.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 2cfa2ca049..4dacdf0dc8 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -1079,6 +1079,14 @@ global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio) remove_parents(dag, 0); dag->version = dio->version; + + /* copy parts of the configuration so that it propagates in the network */ + dag->instance->dio_intdoubl = dio->dag_intdoubl; + dag->instance->dio_intmin = dio->dag_intmin; + dag->instance->dio_redundancy = dio->dag_redund; + dag->instance->default_lifetime = dio->default_lifetime; + dag->instance->lifetime_unit = dio->lifetime_unit; + dag->instance->of->reset(dag); dag->min_rank = INFINITE_RANK; RPL_LOLLIPOP_INCREMENT(dag->instance->dtsn_out); From f680514bf7bba3a256a8cc173588852d52ba1c44 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 27 Mar 2015 16:08:00 +0100 Subject: [PATCH 07/37] Use debuild to create debian package --- examples/6lbr/Makefile | 15 +------ .../6lbr/{control-ipk => angstrom}/control | 0 .../6lbr/{control-ipk => angstrom}/postinst | 0 .../6lbr/{control-ipk => angstrom}/postrm | 0 examples/6lbr/{control-ipk => angstrom}/prerm | 0 examples/6lbr/control-deb/control | 8 ---- examples/6lbr/control-deb/postinst | 12 ------ examples/6lbr/control-deb/postrm | 6 --- examples/6lbr/control-deb/prerm | 8 ---- examples/6lbr/debian/changelog | 5 +++ examples/6lbr/debian/compat | 1 + examples/6lbr/debian/control | 13 +++++++ examples/6lbr/debian/copyright | 39 +++++++++++++++++++ examples/6lbr/debian/docs | 0 examples/6lbr/debian/rules | 21 ++++++++++ examples/6lbr/debian/source/format | 1 + 16 files changed, 81 insertions(+), 48 deletions(-) rename examples/6lbr/{control-ipk => angstrom}/control (100%) rename examples/6lbr/{control-ipk => angstrom}/postinst (100%) rename examples/6lbr/{control-ipk => angstrom}/postrm (100%) rename examples/6lbr/{control-ipk => angstrom}/prerm (100%) delete mode 100644 examples/6lbr/control-deb/control delete mode 100755 examples/6lbr/control-deb/postinst delete mode 100755 examples/6lbr/control-deb/postrm delete mode 100755 examples/6lbr/control-deb/prerm create mode 100644 examples/6lbr/debian/changelog create mode 100644 examples/6lbr/debian/compat create mode 100644 examples/6lbr/debian/control create mode 100644 examples/6lbr/debian/copyright create mode 100644 examples/6lbr/debian/docs create mode 100755 examples/6lbr/debian/rules create mode 100644 examples/6lbr/debian/source/format diff --git a/examples/6lbr/Makefile b/examples/6lbr/Makefile index ac685517a1..34bbcdcb1b 100644 --- a/examples/6lbr/Makefile +++ b/examples/6lbr/Makefile @@ -366,19 +366,6 @@ ifneq ($(PLUGINS_FILES),) install $(PLUGINS_FILES) /usr/lib/6lbr/plugins endif install tools/nvm_tool /usr/lib/6lbr/bin - update-rc.d 6lbr defaults - -rpi_deb: - rm -rf $(DEB) - cp -R package $(DEB) - cp -R control-deb $(DEB)/DEBIAN - mkdir -p $(DEB)/usr/lib/6lbr/bin - cp bin/* $(DEB)/usr/lib/6lbr/bin -ifneq ($(PLUGINS_FILES),) - cp $(PLUGINS_FILES) $(DEB)/usr/lib/6lbr/plugins -endif - cp tools/nvm_tool $(DEB)/usr/lib/6lbr/bin - dpkg --build $(DEB) . ipk: rm -rf $(IPK) @@ -391,7 +378,7 @@ ifneq ($(PLUGINS_FILES),) endif cp tools/nvm_tool $(IPK)/usr/lib/6lbr/bin cd $(IPK) && tar zcvf ../$(IPK)/data.tar.gz --exclude='*~' * - cd control-ipk && tar zcvfh ../$(IPK)/control.tar.gz --exclude='*~' * + cd angstrom && tar zcvfh ../$(IPK)/control.tar.gz --exclude='*~' * echo 2.0 > $(IPK)/debian-binary cd $(IPK) && ar rc ../cetic-6lbr_$(VERSION)-$(PKG_VERSION)_armv7a.ipk debian-binary data.tar.gz control.tar.gz diff --git a/examples/6lbr/control-ipk/control b/examples/6lbr/angstrom/control similarity index 100% rename from examples/6lbr/control-ipk/control rename to examples/6lbr/angstrom/control diff --git a/examples/6lbr/control-ipk/postinst b/examples/6lbr/angstrom/postinst similarity index 100% rename from examples/6lbr/control-ipk/postinst rename to examples/6lbr/angstrom/postinst diff --git a/examples/6lbr/control-ipk/postrm b/examples/6lbr/angstrom/postrm similarity index 100% rename from examples/6lbr/control-ipk/postrm rename to examples/6lbr/angstrom/postrm diff --git a/examples/6lbr/control-ipk/prerm b/examples/6lbr/angstrom/prerm similarity index 100% rename from examples/6lbr/control-ipk/prerm rename to examples/6lbr/angstrom/prerm diff --git a/examples/6lbr/control-deb/control b/examples/6lbr/control-deb/control deleted file mode 100644 index 412662e2f2..0000000000 --- a/examples/6lbr/control-deb/control +++ /dev/null @@ -1,8 +0,0 @@ -Package: cetic-6lbr -Version: 1.3.2 -Architecture: armhf -Maintainer: CETIC <6lbr@cetic.be> -Section: network -Priority: optional -Installed-Size: 350000 -Description: CETIC 6LoWPAN Border Router diff --git a/examples/6lbr/control-deb/postinst b/examples/6lbr/control-deb/postinst deleted file mode 100755 index 56fa25ad0a..0000000000 --- a/examples/6lbr/control-deb/postinst +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -e - -action="$1" - -if [ "$action" != configure ]; then - exit 0 -fi - -if [ -x "/etc/init.d/6lbr" ]; then - update-rc.d 6lbr defaults >/dev/null -fi diff --git a/examples/6lbr/control-deb/postrm b/examples/6lbr/control-deb/postrm deleted file mode 100755 index 6ebae0a984..0000000000 --- a/examples/6lbr/control-deb/postrm +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -e - -if [ "$1" = "purge" ] ; then - update-rc.d 6lbr remove >/dev/null -fi diff --git a/examples/6lbr/control-deb/prerm b/examples/6lbr/control-deb/prerm deleted file mode 100755 index d87f204332..0000000000 --- a/examples/6lbr/control-deb/prerm +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -if [ -x "/etc/init.d/6lbr" ]; then - invoke-rc.d 6lbr stop || exit $? -fi - - diff --git a/examples/6lbr/debian/changelog b/examples/6lbr/debian/changelog new file mode 100644 index 0000000000..bf5801d292 --- /dev/null +++ b/examples/6lbr/debian/changelog @@ -0,0 +1,5 @@ +cetic-6lbr (1.3.3) unstable; urgency=low + + * Initial Release. + + -- 6LBR Team <6lbr@cetic.be> Wed, 25 Mar 2015 13:27:37 +0000 diff --git a/examples/6lbr/debian/compat b/examples/6lbr/debian/compat new file mode 100644 index 0000000000..45a4fb75db --- /dev/null +++ b/examples/6lbr/debian/compat @@ -0,0 +1 @@ +8 diff --git a/examples/6lbr/debian/control b/examples/6lbr/debian/control new file mode 100644 index 0000000000..bd2d26ce31 --- /dev/null +++ b/examples/6lbr/debian/control @@ -0,0 +1,13 @@ +Source: cetic-6lbr +Section: network +Priority: extra +Maintainer: 6LBR Team <6lbr@cetic.be> +Build-Depends: debhelper (>= 8.0.0) +Standards-Version: 3.9.3 +Homepage: https://github.com/cetic/6lbr + +Package: cetic-6lbr +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: CETIC 6LoWPAN Border Router + CETIC 6LBR is an enhanced version of Contiki's 6LoWPAN Border Router solution. rIit provides network configuration and monitoring and support out of the box redundant and distributed operating modes. diff --git a/examples/6lbr/debian/copyright b/examples/6lbr/debian/copyright new file mode 100644 index 0000000000..53556d41fb --- /dev/null +++ b/examples/6lbr/debian/copyright @@ -0,0 +1,39 @@ +License: BSD-3-clause +CETIC-6LBR is licensed under the 3-clause BSD license. This license gives +everyone the right to use and distribute the code, either in binary or +source code format, as long as the copyright license is retained in +the source code. + +The copyright for different parts of the code is held by different +people and organizations, but the code is licensed under the same type +of license. The license text is: + + * Copyright (c) (Year), (Name of copyright holder) + * 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. + diff --git a/examples/6lbr/debian/docs b/examples/6lbr/debian/docs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/6lbr/debian/rules b/examples/6lbr/debian/rules new file mode 100755 index 0000000000..4456cf852c --- /dev/null +++ b/examples/6lbr/debian/rules @@ -0,0 +1,21 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +%: + dh $@ + +override_dh_auto_build: + make all_native + make plugins + make tools + +override_dh_installinit: + dh_installinit --onlyscripts --name 6lbr diff --git a/examples/6lbr/debian/source/format b/examples/6lbr/debian/source/format new file mode 100644 index 0000000000..89ae9db8f8 --- /dev/null +++ b/examples/6lbr/debian/source/format @@ -0,0 +1 @@ +3.0 (native) From a30daa53c5eeec30adacff32f41899b4ad49f703 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Wed, 25 Mar 2015 13:48:01 +0100 Subject: [PATCH 08/37] Check node existence first in add route notification in node-info --- examples/6lbr/apps/node-info/node-info.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/6lbr/apps/node-info/node-info.c b/examples/6lbr/apps/node-info/node-info.c index a2e5faea9f..d81c0cc7d4 100644 --- a/examples/6lbr/apps/node-info/node-info.c +++ b/examples/6lbr/apps/node-info/node-info.c @@ -50,8 +50,13 @@ node_info_route_notification_cb(int event, { if(event == UIP_DS6_NOTIFICATION_ROUTE_ADD) { node_info_t *node = NULL; - node = node_info_add(route); - node->last_seen = clock_time(); + node = node_info_lookup(route); + if(node == NULL) { + node = node_info_add(route); + } + if(node != NULL) { + node->last_seen = clock_time(); + } } else if(event == UIP_DS6_NOTIFICATION_ROUTE_RM) { node_info_rm(route); } From 81cbab73de6fde9dbcd20289de26e7764f6d2e57 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Wed, 1 Apr 2015 14:34:42 +0200 Subject: [PATCH 09/37] Allow more baudrates for slip-radio interface --- examples/6lbr/platform/native/slip-config.c | 156 ++++++++++++++++---- 1 file changed, 130 insertions(+), 26 deletions(-) diff --git a/examples/6lbr/platform/native/slip-config.c b/examples/6lbr/platform/native/slip-config.c index 53ad64b1d9..13876ca328 100644 --- a/examples/6lbr/platform/native/slip-config.c +++ b/examples/6lbr/platform/native/slip-config.c @@ -69,6 +69,45 @@ char const *slip_config_plugins = NULL; char const *ip_config_file_name = NULL; char const * node_config_file_name = NULL; +#if __APPLE__ +#ifndef B460800 +#define B460800 460800 +#endif +#ifndef B500000 +#define B500000 500000 +#endif +#ifndef B576000 +#define B576000 576000 +#endif +#ifndef B921600 +#define B921600 921600 +#endif +#ifndef B1000000 +#define B1000000 1000000 +#endif +#ifndef B1152000 +#define B1152000 1152000 +#endif +#ifndef B1500000 +#define B1500000 1500000 +#endif +#ifndef B2000000 +#define B2000000 2000000 +#endif +#ifndef B2500000 +#define B2500000 2500000 +#endif +#ifndef B3000000 +#define B3000000 3000000 +#endif +#ifndef B3500000 +#define B3500000 3500000 +#endif +#ifndef B4000000 +#define B4000000 4000000 +#endif +#endif + #ifndef BAUDRATE #define BAUDRATE B115200 #endif @@ -196,13 +235,8 @@ slip_config_handle_arguments(int argc, char **argv) fprintf(stderr, "usage: %s [options] ipaddress\n", prog); fprintf(stderr, "example: %s -L -v2 -s ttyUSB1\n", prog); fprintf(stderr, "Options are:\n"); -#ifdef linux - fprintf(stderr, - " -B baudrate 9600,19200,38400,57600,115200,921600 (default 115200)\n"); -#else fprintf(stderr, - " -B baudrate 9600,19200,38400,57600,115200 (default 115200)\n"); -#endif + " -B baudrate Slip-radio baudrate (default 115200)\n"); fprintf(stderr, " -H Hardware CTS/RTS flow control (default disabled)\n"); fprintf(stderr, @@ -242,26 +276,96 @@ slip_config_handle_arguments(int argc, char **argv) switch (baudrate) { case -2: break; /* Use default. */ - case 9600: - slip_config_b_rate = B9600; - break; - case 19200: - slip_config_b_rate = B19200; - break; - case 38400: - slip_config_b_rate = B38400; - break; - case 57600: - slip_config_b_rate = B57600; - break; - case 115200: - slip_config_b_rate = B115200; - break; -#ifdef linux - case 921600: - slip_config_b_rate = B921600; - break; -#endif + #ifdef B50 + case 50: slip_config_b_rate = B50; break; + #endif + #ifdef B75 + case 75: slip_config_b_rate = B75; break; + #endif + #ifdef B110 + case 110: slip_config_b_rate = B110; break; + #endif + #ifdef B134 + case 134: slip_config_b_rate = B134; break; + #endif + #ifdef B150 + case 150: slip_config_b_rate = B150; break; + #endif + #ifdef B200 + case 200: slip_config_b_rate = B200; break; + #endif + #ifdef B300 + case 300: slip_config_b_rate = B300; break; + #endif + #ifdef B600 + case 600: slip_config_b_rate = B600; break; + #endif + #ifdef B1200 + case 1200: slip_config_b_rate = B1200; break; + #endif + #ifdef B1800 + case 1800: slip_config_b_rate = B1800; break; + #endif + #ifdef B2400 + case 2400: slip_config_b_rate = B2400; break; + #endif + #ifdef B4800 + case 4800: slip_config_b_rate = B4800; break; + #endif + #ifdef B9600 + case 9600: slip_config_b_rate = B9600; break; + #endif + #ifdef B19200 + case 19200: slip_config_b_rate = B19200; break; + #endif + #ifdef B38400 + case 38400: slip_config_b_rate = B38400; break; + #endif + #ifdef B57600 + case 57600: slip_config_b_rate = B57600; break; + #endif + #ifdef B115200 + case 115200: slip_config_b_rate = B115200; break; + #endif + #ifdef B230400 + case 230400: slip_config_b_rate = B230400; break; + #endif + #ifdef B460800 + case 460800: slip_config_b_rate = B460800; break; + #endif + #ifdef B500000 + case 500000: slip_config_b_rate = B500000; break; + #endif + #ifdef B576000 + case 576000: slip_config_b_rate = B576000; break; + #endif + #ifdef B921600 + case 921600: slip_config_b_rate = B921600; break; + #endif + #ifdef B1000000 + case 1000000: slip_config_b_rate = B1000000; break; + #endif + #ifdef B1152000 + case 1152000: slip_config_b_rate = B1152000; break; + #endif + #ifdef B1500000 + case 1500000: slip_config_b_rate = B1500000; break; + #endif + #ifdef B2000000 + case 2000000: slip_config_b_rate = B2000000; break; + #endif + #ifdef B2500000 + case 2500000: slip_config_b_rate = B2500000; break; + #endif + #ifdef B3000000 + case 3000000: slip_config_b_rate = B3000000; break; + #endif + #ifdef B3500000 + case 3500000: slip_config_b_rate = B3500000; break; + #endif + #ifdef B4000000 + case 4000000: slip_config_b_rate = B4000000; break; + #endif default: err(1, "unknown baudrate %d", baudrate); break; From 76fa87d1d417630a750efd11e60084877eb6f2c5 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 17 Apr 2015 13:06:19 +0200 Subject: [PATCH 10/37] Force bridge mac address to eth0 mac address in example interface files --- .../6lbr/package/etc/6lbr/interfaces.dhcp.example | 11 ++++------- .../6lbr/package/etc/6lbr/interfaces.static.example | 12 ++++-------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/examples/6lbr/package/etc/6lbr/interfaces.dhcp.example b/examples/6lbr/package/etc/6lbr/interfaces.dhcp.example index 780b3cd2a3..95a5a69e26 100644 --- a/examples/6lbr/package/etc/6lbr/interfaces.dhcp.example +++ b/examples/6lbr/package/etc/6lbr/interfaces.dhcp.example @@ -7,16 +7,13 @@ address 0.0.0.0 auto br0 iface br0 inet dhcp - pre-up brctl addbr br0 - pre-up brctl addif br0 eth0 - pre-up ip addr flush dev eth0 + bridge_ports eth0 + bridge_stp off up echo 0 > /sys/devices/virtual/net/br0/bridge/multicast_snooping - post-down ip link set eth0 down - post-down ip link set br0 down - post-down brctl delif br0 eth0 - post-down brctl delbr br0 + post-up ip link set br0 address `ip link show eth0 | grep ether | awk '{print $2}'` allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf + iface default inet dhcp diff --git a/examples/6lbr/package/etc/6lbr/interfaces.static.example b/examples/6lbr/package/etc/6lbr/interfaces.static.example index 2d68bd935c..647805a06c 100644 --- a/examples/6lbr/package/etc/6lbr/interfaces.static.example +++ b/examples/6lbr/package/etc/6lbr/interfaces.static.example @@ -7,22 +7,18 @@ address 0.0.0.0 auto br0 iface br0 inet static - pre-up brctl addbr br0 - pre-up brctl addif br0 eth0 - pre-up ip addr flush dev eth0 + bridge_ports eth0 + bridge_stp off up echo 0 > /sys/devices/virtual/net/br0/bridge/multicast_snooping - post-down ip link set eth0 down - post-down ip link set br0 down - post-down brctl delif br0 eth0 - post-down brctl delbr br0 + post-up ip link set br0 address `ip link show eth0 | grep ether | awk '{print $2}'` address 192.168.2.100 netmask 255.255.255.0 network 192.168.2.0 broadcast 192.168.2.255 gateway 192.168.2.254 - allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf + iface default inet dhcp From d7be65234fb505e3ecb3681802c75a4daead5e31 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 17 Apr 2015 16:19:52 +0200 Subject: [PATCH 11/37] Fix webserver formatting --- examples/6lbr/apps/webserver/webserver.c | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/6lbr/apps/webserver/webserver.c b/examples/6lbr/apps/webserver/webserver.c index 9d514483f5..623008b431 100644 --- a/examples/6lbr/apps/webserver/webserver.c +++ b/examples/6lbr/apps/webserver/webserver.c @@ -487,7 +487,7 @@ PT_THREAD(generate_index(struct httpd_state *s)) #if WEBSERVER_CONF_FILESTATS static uint16_t numtimes; - add("
This page sent %u times", ++numtimes); + add("
This page sent %u times", ++numtimes); #endif #if WEBSERVER_CONF_LOADTIME @@ -537,14 +537,14 @@ PT_THREAD(generate_sensors(struct httpd_state *s)) if ( node_config_loaded ) { add("%s (", node_config_get_name(node_config_find_from_ip(&node_info_table[i].ipaddr))); ipaddr_add(&node_info_table[i].ipaddr); - add(")"); + add(")"); } else { ipaddr_add(&node_info_table[i].ipaddr); - add(""); + add(""); } #else ipaddr_add(&node_info_table[i].ipaddr); - add(""); + add(""); #endif if(0) { @@ -597,12 +597,12 @@ PT_THREAD(generate_sensors(struct httpd_state *s)) } SEND_STRING(&s->sout, buf); reset_buf(); - add("web"); - add("web"); + add("coap"); + add("]:5683\">coap"); if(node_info_table[i].messages_count > 0) { add("%d", node_info_table[i].sequence); #if CETIC_NODE_CONFIG @@ -633,7 +633,7 @@ PT_THREAD(generate_sensors(struct httpd_state *s)) add ("
" - "
"); + add("}\" alt=\"\" />"); SEND_STRING(&s->sout, buf); reset_buf(); @@ -695,7 +695,7 @@ PT_THREAD(generate_sensors(struct httpd_state *s)) #if WEBSERVER_CONF_FILESTATS static uint16_t numtimes; - add("
This page sent %u times", ++numtimes); + add("
This page sent %u times", ++numtimes); #endif #if WEBSERVER_CONF_LOADTIME @@ -820,7 +820,7 @@ PT_THREAD(generate_rpl(struct httpd_state *s)) #if WEBSERVER_CONF_FILESTATS static uint16_t numtimes; - add("
This page sent %u times", ++numtimes); + add("
This page sent %u times", ++numtimes); #endif #if WEBSERVER_CONF_LOADTIME @@ -1030,7 +1030,7 @@ PT_THREAD(generate_network(struct httpd_state *s)) #if WEBSERVER_CONF_FILESTATS static uint16_t numtimes; - add("
This page sent %u times", ++numtimes); + add("
This page sent %u times", ++numtimes); #endif #if WEBSERVER_CONF_LOADTIME @@ -1210,7 +1210,7 @@ PT_THREAD(generate_config(struct httpd_state *s)) #if WEBSERVER_CONF_FILESTATS static uint16_t numtimes; - add("
This page sent %u times", ++numtimes); + add("
This page sent %u times", ++numtimes); #endif #if WEBSERVER_CONF_LOADTIME From f41cc9222bcaf1248010675b56377897201d50b2 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Wed, 29 Apr 2015 22:04:46 +0200 Subject: [PATCH 12/37] Add support for non constant Ethernet padding --- examples/6lbr/6lbr/packet-filter.c | 17 +++++++++++++++++ examples/6lbr/platform/native/raw-tap-dev.c | 7 +------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/6lbr/6lbr/packet-filter.c b/examples/6lbr/6lbr/packet-filter.c index 15386a02c8..310a9410de 100644 --- a/examples/6lbr/6lbr/packet-filter.c +++ b/examples/6lbr/6lbr/packet-filter.c @@ -51,6 +51,9 @@ #include "nvm-config.h" #include "platform-init.h" #include "log-6lbr.h" +#if CONTIKI_TARGET_NATIVE +#include "slip-config.h" +#endif #include "eth-drv.h" @@ -233,6 +236,20 @@ eth_input(void) uip_len = 0; return; } + if((UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] + 40 < uip_len) { +#if CONTIKI_TARGET_NATIVE + if(ethernet_has_fcs) { + uip_len = (UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] + 40; + } else +#endif + { + LOG6LBR_PRINTF(PACKET, PF_IN, "eth_input: packet size different than reported in IPv6 header, %d vs %d\n", uip_len, (UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] + 40); + } + } else if((UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] + 40 > uip_len) { + LOG6LBR_PRINTF(PACKET, PF_IN, "eth_input: packet shorter than reported in IPv6 header, %d vs %d\n", uip_len, (UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] + 40); + uip_len = 0; + return; + } //Packet source Filtering //----------------------- /* IPv6 uses 33-33-xx-xx-xx-xx prefix for multicast ND stuff */ diff --git a/examples/6lbr/platform/native/raw-tap-dev.c b/examples/6lbr/platform/native/raw-tap-dev.c index f15d6023c4..cf9eb050f8 100644 --- a/examples/6lbr/platform/native/raw-tap-dev.c +++ b/examples/6lbr/platform/native/raw-tap-dev.c @@ -407,12 +407,7 @@ handle_fd(fd_set * rset, fd_set * wset) if(FD_ISSET(tunfd, rset)) { size = tun_input(tmp_tap_buf, sizeof(tmp_tap_buf)); - if(ethernet_has_fcs) { - //Remove extra data from packet capture - uip_len = size - ETHERNET_LLH_LEN - 4; - } else { - uip_len = size - ETHERNET_LLH_LEN; - } + uip_len = size - ETHERNET_LLH_LEN; memcpy(ll_header, tmp_tap_buf, ETHERNET_LLH_LEN); memcpy(uip_buf, tmp_tap_buf + ETHERNET_LLH_LEN, uip_len); eth_drv_input(); From ebf770743e815f4be8f825cc47e0cc84fe5c0aef Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Mon, 9 Mar 2015 19:41:25 +0100 Subject: [PATCH 13/37] Send the first NS attempt inside tcpip_ipv6_output() --- core/net/ip/tcpip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/net/ip/tcpip.c b/core/net/ip/tcpip.c index f2ac16a978..2e6661d640 100644 --- a/core/net/ip/tcpip.c +++ b/core/net/ip/tcpip.c @@ -734,7 +734,11 @@ tcpip_ipv6_output(void) stimer_set(&nbr->sendns, uip_ds6_if.retrans_timer / 1000); nbr->nscount = 1; + /* Send the first NS try from here (multicast destination IP address). */ } +#else /* UIP_ND6_SEND_NA */ + uip_len = 0; + return; #endif /* UIP_ND6_SEND_NA */ } else { #if UIP_ND6_SEND_NA @@ -783,7 +787,6 @@ tcpip_ipv6_output(void) uip_ext_len = 0; return; } - return; } /* Multicast IP destination address. */ tcpip_output(NULL); From 7d591c3724faf988c00f0045b059bb02007ca81d Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Tue, 5 May 2015 09:15:01 +0000 Subject: [PATCH 14/37] Add DESTDIR to install target and fix 6lbr startup script --- examples/6lbr/Makefile | 25 +++++++++++++------------ examples/6lbr/package/etc/init.d/6lbr | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/6lbr/Makefile b/examples/6lbr/Makefile index 34bbcdcb1b..03017151b8 100644 --- a/examples/6lbr/Makefile +++ b/examples/6lbr/Makefile @@ -350,22 +350,23 @@ VERSION=$(shell echo $(word 3,$(shell awk '/CETIC_6LBR_VERSION/' project-conf.h) DEB=6lbr-$(VERSION)-$(PKG_VERSION)-deb IPK=6lbr-$(VERSION)-$(PKG_VERSION)-ipk +DESTDIR= install: - install -d /etc/6lbr - cp -r package/etc/6lbr /etc - install -d /etc/init.d - install package/etc/init.d/* /etc/init.d - install -d /usr/bin - install package/usr/bin/* /usr/bin - install -d /usr/lib/6lbr - cp -r package/usr/lib/6lbr /usr/lib - install -d /usr/lib/6lbr/bin - install bin/* /usr/lib/6lbr/bin + install -d $(DESTDIR)/etc/6lbr + cp -r package/etc/6lbr $(DESTDIR)/etc + install -d $(DESTDIR)/etc/init.d + install package/etc/init.d/* $(DESTDIR)/etc/init.d + install -d $(DESTDIR)/usr/bin + install package/usr/bin/* $(DESTDIR)/usr/bin + install -d $(DESTDIR)/usr/lib/6lbr + cp -r package/usr/lib/6lbr $(DESTDIR)/usr/lib + install -d $(DESTDIR)/usr/lib/6lbr/bin + install bin/* $(DESTDIR)/usr/lib/6lbr/bin ifneq ($(PLUGINS_FILES),) - install $(PLUGINS_FILES) /usr/lib/6lbr/plugins + install $(PLUGINS_FILES) $(DESTDIR)/usr/lib/6lbr/plugins endif - install tools/nvm_tool /usr/lib/6lbr/bin + install tools/nvm_tool $(DESTDIR)/usr/lib/6lbr/bin ipk: rm -rf $(IPK) diff --git a/examples/6lbr/package/etc/init.d/6lbr b/examples/6lbr/package/etc/init.d/6lbr index 14afd90088..7ef0eff121 100755 --- a/examples/6lbr/package/etc/init.d/6lbr +++ b/examples/6lbr/package/etc/init.d/6lbr @@ -3,7 +3,7 @@ ### BEGIN INIT INFO # Provides: 6lbr # Required-Start: $network $remote_fs -# Required-Stop: +# Required-Stop: $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: 6LoWPAN Border Router From 28377c1dfc8f04e0f523a2f632271b54f898c5d8 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Wed, 6 May 2015 06:59:07 +0000 Subject: [PATCH 15/37] Add usb scanning workaround for BB --- examples/6lbr/package/usr/lib/6lbr/6lbr | 2 ++ examples/6lbr/package/usr/lib/6lbr/bb-scan-usb.sh | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 examples/6lbr/package/usr/lib/6lbr/bb-scan-usb.sh diff --git a/examples/6lbr/package/usr/lib/6lbr/6lbr b/examples/6lbr/package/usr/lib/6lbr/6lbr index 1ba1c02c09..9c2e121ac0 100755 --- a/examples/6lbr/package/usr/lib/6lbr/6lbr +++ b/examples/6lbr/package/usr/lib/6lbr/6lbr @@ -176,9 +176,11 @@ fi while ((1)); do if [ "$MODE" != 'RPL-ROOT' -a "$SOCK_RADIO" = "" ]; then + $SCAN_DEVICE while [ ! -e "$DEV_RADIO" ]; do echo "Waiting for $DEV_RADIO" sleep 10 + $SCAN_DEVICE done fi TIMESTAMP=`date`" : Starting 6LBR " diff --git a/examples/6lbr/package/usr/lib/6lbr/bb-scan-usb.sh b/examples/6lbr/package/usr/lib/6lbr/bb-scan-usb.sh new file mode 100755 index 0000000000..2bdfed0d4f --- /dev/null +++ b/examples/6lbr/package/usr/lib/6lbr/bb-scan-usb.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +echo "Reset and scan USB devices..." + +#Rebind USB controller +echo "usb1" > /sys/bus/usb/drivers/usb/unbind +sleep 1 +echo "usb1" > /sys/bus/usb/drivers/usb/bind +sleep 1 + +#Disable auto-suspend +echo "on" > /sys/bus/usb/devices/usb1/power/control + +#Force USB controller scan +cat /dev/bus/usb/001/001 > /dev/null From 6ca958aba2e7fbefe6f17df8b6724af1ff1e1562 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Wed, 6 May 2015 09:12:42 +0200 Subject: [PATCH 16/37] Update documentation --- examples/6lbr/package/etc/6lbr/6lbr.conf.example | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/6lbr/package/etc/6lbr/6lbr.conf.example b/examples/6lbr/package/etc/6lbr/6lbr.conf.example index bca61f701d..5548b54751 100644 --- a/examples/6lbr/package/etc/6lbr/6lbr.conf.example +++ b/examples/6lbr/package/etc/6lbr/6lbr.conf.example @@ -51,6 +51,11 @@ #ETH_JOIN_BRIDGE=1 +#Multicast snooping is broken in several versions of the Linux kernel, it drops +#multicast traffic after a while. + +#BRIDGE_DISABLE_SNOOPING=1 + ################################################################################ #SLIP Radio configuration # These parameters define the SLIP Radio device and the Baudrate to be used to From ac97c549fa0f85a50d823e29904579bf352dd7e7 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Wed, 6 May 2015 09:13:06 +0200 Subject: [PATCH 17/37] Add protection on MacOS-X --- examples/6lbr/package/etc/6lbr/ifup.d/20link | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/6lbr/package/etc/6lbr/ifup.d/20link b/examples/6lbr/package/etc/6lbr/ifup.d/20link index cdebed241a..37eac62c2b 100755 --- a/examples/6lbr/package/etc/6lbr/ifup.d/20link +++ b/examples/6lbr/package/etc/6lbr/ifup.d/20link @@ -32,9 +32,11 @@ case $OS in ifconfig $DEV link $DEV_TAP_MAC fi - #On MacOS 10.6, IPv6 stack is not always correctly started on tap device - ip6 -d $DEV - ip6 -u $DEV + if [ -x /usr/sbin/ip6 ]; then + #On MacOS 10.6, IPv6 stack is not always correctly started on tap device + ip6 -d $DEV + ip6 -u $DEV + fi ifconfig $DEV inet6 up ;; From f034d3cbfd08dbbf5aeccfb474b263fb1bea07fd Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Wed, 6 May 2015 10:22:07 +0200 Subject: [PATCH 18/37] Add forward compatibility in node-info --- examples/6lbr/apps/node-info/node-info.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/6lbr/apps/node-info/node-info.c b/examples/6lbr/apps/node-info/node-info.c index d81c0cc7d4..e0a6fd58f4 100644 --- a/examples/6lbr/apps/node-info/node-info.c +++ b/examples/6lbr/apps/node-info/node-info.c @@ -107,6 +107,10 @@ node_info_update(uip_ipaddr_t * ipaddr, char * info) if (*info == ' ') { info++; } + sep = index(info, '|'); + if (sep != NULL) { + *sep = 0; + } if (uiplib_ipaddrconv(info, &node->ip_parent) == 0) { uip_create_unspecified(&node->ip_parent); } From 0102f69ead0c3520fc46f86d7525f16e2bde5af6 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 24 Apr 2015 10:41:19 +0200 Subject: [PATCH 19/37] Check mac address message size --- examples/6lbr/platform/native/slip-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/6lbr/platform/native/slip-cmds.c b/examples/6lbr/platform/native/slip-cmds.c index 47fbb86f58..cfa23fb6cd 100644 --- a/examples/6lbr/platform/native/slip-cmds.c +++ b/examples/6lbr/platform/native/slip-cmds.c @@ -66,7 +66,7 @@ border_router_cmd_handler(const uint8_t * data, int len) if(data[0] == '!') { LOG6LBR_TRACE("Got configuration message of type %c\n", data[1]); if(0) { - } else if(data[1] == 'M' && command_context == CMD_CONTEXT_RADIO) { + } else if(data[1] == 'M' && command_context == CMD_CONTEXT_RADIO && len == 10) { LOG6LBR_DEBUG("Setting MAC address\n"); slip_got_mac(&data[2]); return 1; From 49aa5153f5fa27e19aec7c7623374d898815587c Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 7 May 2015 13:54:00 +0200 Subject: [PATCH 20/37] Split up install target --- examples/6lbr/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/6lbr/Makefile b/examples/6lbr/Makefile index 03017151b8..37b4a8dba7 100644 --- a/examples/6lbr/Makefile +++ b/examples/6lbr/Makefile @@ -363,10 +363,12 @@ install: cp -r package/usr/lib/6lbr $(DESTDIR)/usr/lib install -d $(DESTDIR)/usr/lib/6lbr/bin install bin/* $(DESTDIR)/usr/lib/6lbr/bin + install tools/nvm_tool $(DESTDIR)/usr/lib/6lbr/bin + +install_plugins: ifneq ($(PLUGINS_FILES),) install $(PLUGINS_FILES) $(DESTDIR)/usr/lib/6lbr/plugins endif - install tools/nvm_tool $(DESTDIR)/usr/lib/6lbr/bin ipk: rm -rf $(IPK) From 574eaffa77d8689f10caa6b3f620b41585891fbe Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 7 May 2015 14:01:38 +0200 Subject: [PATCH 21/37] Add documentation on SCAN_DEVICE --- examples/6lbr/package/etc/6lbr/6lbr.conf.beaglebone | 3 +++ examples/6lbr/package/etc/6lbr/6lbr.conf.example | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/examples/6lbr/package/etc/6lbr/6lbr.conf.beaglebone b/examples/6lbr/package/etc/6lbr/6lbr.conf.beaglebone index 921e75621c..5e09a0cc1e 100644 --- a/examples/6lbr/package/etc/6lbr/6lbr.conf.beaglebone +++ b/examples/6lbr/package/etc/6lbr/6lbr.conf.beaglebone @@ -20,4 +20,7 @@ RAW_ETH_FCS=1 DEV_RADIO=/dev/ttyUSB0 BAUDRATE=115200 +#Enable this line if radio device is not detected +#SCAN_DEVICE=/usr/lib/6lbr/bb-scan-usb.sh + LOG_LEVEL=3 #INFO and above only diff --git a/examples/6lbr/package/etc/6lbr/6lbr.conf.example b/examples/6lbr/package/etc/6lbr/6lbr.conf.example index 5548b54751..db5695fdea 100644 --- a/examples/6lbr/package/etc/6lbr/6lbr.conf.example +++ b/examples/6lbr/package/etc/6lbr/6lbr.conf.example @@ -71,6 +71,13 @@ #SLIP Radio baudrate #BAUDRATE=115200 +#Scan operation to be performed before checking the radio availability +#SCAN_DEVICE= + +#On BeagleBone, the USB Host does not always scan and detect properly the slip +#radio. +#SCAN_DEVICE=/usr/lib/6lbr/bb-scan-usb.sh + ################################################################################ #NVM File # The NVM file contains the user configuration, like the network prefixes, the From b13c95d783b060728bb297b84963fe31b9a15802 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 7 May 2015 14:02:23 +0200 Subject: [PATCH 22/37] Add interfaces example file for debian Beaglebone --- .../etc/6lbr/interfaces.beaglebone.example | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/6lbr/package/etc/6lbr/interfaces.beaglebone.example diff --git a/examples/6lbr/package/etc/6lbr/interfaces.beaglebone.example b/examples/6lbr/package/etc/6lbr/interfaces.beaglebone.example new file mode 100644 index 0000000000..8a407b81f2 --- /dev/null +++ b/examples/6lbr/package/etc/6lbr/interfaces.beaglebone.example @@ -0,0 +1,41 @@ +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +# The loopback network interface +auto lo +iface lo inet loopback + +# The primary network interface +#auto eth0 +#iface eth0 inet dhcp +# Example to keep MAC address between reboots +#hwaddress ether DE:AD:BE:EF:CA:FE + +# The secondary network interface +#auto eth1 +#iface eth1 inet dhcp + +iface eth0 inet static +address 0.0.0.0 + +auto br0 +iface br0 inet dhcp + bridge_ports eth0 + bridge_stp off + up echo 0 > /sys/devices/virtual/net/br0/bridge/multicast_snooping + post-up ip link set br0 address `ip link show eth0 | grep ether | awk '{print $2}'` + +# WiFi Example +#auto wlan0 +#iface wlan0 inet dhcp +# wpa-ssid "essid" +# wpa-psk "password" + +# Ethernet/RNDIS gadget (g_ether) +# ... or on host side, usbnet and random hwaddr +# Note on some boards, usb0 is automaticly setup with an init script +iface usb0 inet static + address 192.168.7.2 + netmask 255.255.255.0 + network 192.168.7.0 + gateway 192.168.7.1 From 68bc940db921532ba4392fa291b2ffb1811fe833 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Wed, 6 May 2015 13:17:42 +0200 Subject: [PATCH 23/37] Bump version to 1.3.3 --- examples/6lbr/angstrom/control | 2 +- examples/6lbr/project-conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/6lbr/angstrom/control b/examples/6lbr/angstrom/control index 6284f9791f..f558747c89 100644 --- a/examples/6lbr/angstrom/control +++ b/examples/6lbr/angstrom/control @@ -1,5 +1,5 @@ Package: cetic-6lbr -Version: 1.3.2 +Version: 1.3.3 Architecture: armv7a Maintainer: CETIC <6lbr@cetic.be> Section: network diff --git a/examples/6lbr/project-conf.h b/examples/6lbr/project-conf.h index d77ea29dcc..b962d48023 100644 --- a/examples/6lbr/project-conf.h +++ b/examples/6lbr/project-conf.h @@ -405,7 +405,7 @@ /*------------------------------------------------------------------*/ /* Do not change lines below */ -#define CETIC_6LBR_VERSION "1.3.2" +#define CETIC_6LBR_VERSION "1.3.3" #define CETIC_6LBR_ETH_EXT_A 0xFF #define CETIC_6LBR_ETH_EXT_B 0xFF From 3715b49b1121c0770f4a064753680cf315977ae9 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 8 May 2015 16:38:15 +0200 Subject: [PATCH 24/37] Update 1.3.3 changelog --- examples/6lbr/debian/changelog | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/6lbr/debian/changelog b/examples/6lbr/debian/changelog index bf5801d292..d839acc0d9 100644 --- a/examples/6lbr/debian/changelog +++ b/examples/6lbr/debian/changelog @@ -1,5 +1,19 @@ cetic-6lbr (1.3.3) unstable; urgency=low - * Initial Release. + * 6LoWPAN/RPL + Multi DODAG bugfixes + Support DAG parameter updates + Do not drop partially received segmented packets + * Slip-Radio + Better Z1 and CC2538 support + Check message format + Add more baud rates + * Network + Fix multicast snooping on bridge interface + Fix bridge hw address + Fix tap interface down issue + * BeagleBone + Add Debian support + Add USB scanning issue workaround - -- 6LBR Team <6lbr@cetic.be> Wed, 25 Mar 2015 13:27:37 +0000 + -- 6lbr-team <6lbr@cetic.be> Fri, 08 May 2015 12:23:54 +0000 From 4f7a1cd9240da51f93c33ad77a0b288acd35a1f1 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 8 May 2015 16:38:15 +0200 Subject: [PATCH 25/37] Update 1.4.0 changelog --- apps/tinydtls | 2 +- examples/6lbr/debian/changelog | 75 +++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/apps/tinydtls b/apps/tinydtls index 6c4757caea..a6fa96c9f6 160000 --- a/apps/tinydtls +++ b/apps/tinydtls @@ -1 +1 @@ -Subproject commit 6c4757caea14bedc4e398ea1a774040f2c351bc4 +Subproject commit a6fa96c9f6cf242660574f32794709ef39367770 diff --git a/examples/6lbr/debian/changelog b/examples/6lbr/debian/changelog index bf5801d292..6da08882fa 100644 --- a/examples/6lbr/debian/changelog +++ b/examples/6lbr/debian/changelog @@ -1,5 +1,76 @@ +cetic-6lbr (1.4.O) unstable; urgency=low + + * Features + Link layer Security + NAT 64 / Dual stack + RDNSS + DNS Forwarder + mDNS advertising + Static port mapping + Node Info (PRR, Hop Count, Parent Switch, ...) + * Platform + Zolertia Zoul/RE-Mote + OpenMote + CC26xx (experimental) + OpenWRT + * Network + 6lowpan context configuration (limited) + RPL stability bugfixes + Static route support + Tap/bridge interface autoconfiguration + RFC 4193 configuration script + * Updates + Rebased on Contiki 3.0 + TinyDTLS 1.9 + RFC CoAP + * Development + User plugins + Out of tree development + Modular webserver + New configuration file + * 6lbr-demo + Simple Core Interface library + CC26xx support + * Simple Core Interface library ([draft-ietf-core-interfaces](https://tools.ietf.org/html/draft-ietf-core-interfaces-03)) + Observe binding support + CoAP push binding support + Runtime configurable binding + Text, JSON, XML and SenML encoding + Linked list, batch and linked batch support + Simple Resource Directory client + IPSO Application Framework demo + LWM2M demo + * Bugfixes + Slip-Radio throughput improvements + Fix CRC when Adress overriding is enabled + CC2538DK alignment issues solved + Loss of connectivity in SmartBridge mode + Big Endian platform support + Multi-dodag bugfixes + Fix CSMA infinite retransmissions + Various webserver glitches fixed + Wrong month in logs fixed + LLSEC reboot workaround + Global DODAG id correction + + -- 6lbr-team <6lbr@cetic.be> Thu, 12 May 2016 16:32:25 +0200 + cetic-6lbr (1.3.3) unstable; urgency=low - * Initial Release. + * 6LoWPAN/RPL + Multi DODAG bugfixes + Support DAG parameter updates + Do not drop partially received segmented packets + * Slip-Radio + Better Z1 and CC2538 support + Check message format + Add more baud rates + * Network + Fix multicast snooping on bridge interface + Fix bridge hw address + Fix tap interface down issue + * BeagleBone + Add Debian support + Add USB scanning issue workaround - -- 6LBR Team <6lbr@cetic.be> Wed, 25 Mar 2015 13:27:37 +0000 + -- 6lbr-team <6lbr@cetic.be> Fri, 08 May 2015 12:23:54 +0000 From c33493fb84349022aade9ca4a735938cce8bcc2a Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 12 May 2016 16:40:51 +0200 Subject: [PATCH 26/37] Bump version to 1.4.0 --- examples/6lbr/angstrom/control | 2 +- examples/6lbr/project-conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/6lbr/angstrom/control b/examples/6lbr/angstrom/control index f558747c89..4a0023c722 100644 --- a/examples/6lbr/angstrom/control +++ b/examples/6lbr/angstrom/control @@ -1,5 +1,5 @@ Package: cetic-6lbr -Version: 1.3.3 +Version: 1.4.0 Architecture: armv7a Maintainer: CETIC <6lbr@cetic.be> Section: network diff --git a/examples/6lbr/project-conf.h b/examples/6lbr/project-conf.h index 20769dd0fb..0f9cb7b693 100644 --- a/examples/6lbr/project-conf.h +++ b/examples/6lbr/project-conf.h @@ -255,7 +255,7 @@ /*------------------------------------------------------------------*/ /* Do not change lines below */ -#define CETIC_6LBR_VERSION "1.4.x" +#define CETIC_6LBR_VERSION "1.4.0" #define CETIC_6LBR_ETH_EXT_A 0xFF #define CETIC_6LBR_ETH_EXT_B 0xFF From fc76af7480fc4ff82d48446a7623a2d4edad0603 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Fri, 13 May 2016 10:46:01 +0200 Subject: [PATCH 27/37] Update package creation rules --- examples/6lbr/debian/control | 7 ++++--- examples/6lbr/debian/rules | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/6lbr/debian/control b/examples/6lbr/debian/control index bd2d26ce31..214bf9d5e2 100644 --- a/examples/6lbr/debian/control +++ b/examples/6lbr/debian/control @@ -1,5 +1,5 @@ Source: cetic-6lbr -Section: network +Section: net Priority: extra Maintainer: 6LBR Team <6lbr@cetic.be> Build-Depends: debhelper (>= 8.0.0) @@ -8,6 +8,7 @@ Homepage: https://github.com/cetic/6lbr Package: cetic-6lbr Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} +Depends: ${shlibs:Depends}, ${misc:Depends}, bridge-utils Description: CETIC 6LoWPAN Border Router - CETIC 6LBR is an enhanced version of Contiki's 6LoWPAN Border Router solution. rIit provides network configuration and monitoring and support out of the box redundant and distributed operating modes. + CETIC 6LBR is an enhanced version of Contiki's 6LoWPAN Border Router solution. + It provides network configuration and monitoring, and supports out of the box redundant and distributed operating modes. diff --git a/examples/6lbr/debian/rules b/examples/6lbr/debian/rules index 4456cf852c..1d476de94f 100755 --- a/examples/6lbr/debian/rules +++ b/examples/6lbr/debian/rules @@ -13,9 +13,13 @@ export DH_VERBOSE=1 dh $@ override_dh_auto_build: - make all_native + make TARGET=native all make plugins make tools +# Add extra installation target for plugins +override_dh_auto_install: + dh_auto_install -- plugins-install + override_dh_installinit: dh_installinit --onlyscripts --name 6lbr From 58c673660f0943869ed48c56d727d095a9ea0c23 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Tue, 17 May 2016 14:33:49 +0200 Subject: [PATCH 28/37] Fix version in debian/changelog --- examples/6lbr/debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/6lbr/debian/changelog b/examples/6lbr/debian/changelog index 6da08882fa..68fd6da7f9 100644 --- a/examples/6lbr/debian/changelog +++ b/examples/6lbr/debian/changelog @@ -1,4 +1,4 @@ -cetic-6lbr (1.4.O) unstable; urgency=low +cetic-6lbr (1.4.0) unstable; urgency=low * Features Link layer Security From d71e0822ad1f6e69dab0d5f896bc0718cd8b0104 Mon Sep 17 00:00:00 2001 From: Emmanuel Nataf Date: Fri, 20 May 2016 12:14:14 +0200 Subject: [PATCH 29/37] Instance menu --- examples/6lbr/apps/6lbr-webserver/httpd-cgi.c | 21 +++++++++++++++++++ examples/6lbr/apps/6lbr-webserver/httpd-cgi.h | 2 ++ .../apps/6lbr-webserver/webserver-utils.c | 19 +++++++++++++++++ examples/6lbr/apps/6lbr-webserver/webserver.c | 2 ++ examples/6lbr/apps/6lbr-webserver/webserver.h | 1 + 5 files changed, 45 insertions(+) diff --git a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c index 153775f005..54cc47dd73 100644 --- a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c +++ b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c @@ -41,11 +41,27 @@ #include "httpd-cgi.h" #include "nvm-config.h" +static httpd_group_t *instances = NULL; static httpd_group_t *groups = NULL; static httpd_cgi_call_t *calls = NULL; static httpd_cgi_command_t *commands = NULL; /*---------------------------------------------------------------------------*/ void +httpd_instance_add(httpd_group_t *group) +{ + httpd_group_t *l; + + LOG6LBR_DEBUG("Adding instance : %s\n", group->title); + group->next = NULL; + if(instances == NULL) { + instances = group; + } else { + for(l = instances; l->next != NULL; l = l->next); + l->next = group; + } +} +/*---------------------------------------------------------------------------*/ +void httpd_group_add(httpd_group_t *group) { httpd_group_t *l; @@ -60,6 +76,11 @@ httpd_group_add(httpd_group_t *group) } } /*---------------------------------------------------------------------------*/ +httpd_group_t* httpd_instance_head(void) +{ + return instances; +} +/*---------------------------------------------------------------------------*/ httpd_group_t* httpd_group_head(void) { return groups; diff --git a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.h b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.h index cb63c174a3..b24310687f 100644 --- a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.h +++ b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.h @@ -79,8 +79,10 @@ typedef struct httpd_cgi_command httpd_cgi_command_t; #define HTTPD_CUSTOM_TOP 0x00000002 #define HTTPD_CUSTOM_BOTTOM 0x00000004 +void httpd_instance_add(httpd_group_t *group); void httpd_group_add(httpd_group_t *group); void httpd_group_add_page(httpd_group_t *group, httpd_cgi_call_t *c); +httpd_group_t* httpd_instance_head(void); httpd_group_t* httpd_group_head(void); void httpd_cgi_add(httpd_cgi_call_t *c); diff --git a/examples/6lbr/apps/6lbr-webserver/webserver-utils.c b/examples/6lbr/apps/6lbr-webserver/webserver-utils.c index 65f6e4b8ae..f57dc98c97 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver-utils.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver-utils.c @@ -220,8 +220,26 @@ key_conv(const char *str, uint8_t * key, int size) } /*---------------------------------------------------------------------------*/ static void +add_instances_menu(struct httpd_state *s) +{ + httpd_group_t *f; + for(f = httpd_instance_head(); f != NULL; f = f->next) { + add("
"); + if(s->script != NULL && f == s->script->group) { + add("%s", f->title); + } else { + add("%s", f->title, f->title); + } + add("
"); + } + +} +/*---------------------------------------------------------------------------*/ +static void add_menu(struct httpd_state *s) { + add_instances_menu(s); + add("
"); httpd_group_t *f; for(f = httpd_group_head(); f != NULL; f = f->next) { add("
"); @@ -232,6 +250,7 @@ add_menu(struct httpd_state *s) } add("
"); } + add("
"); } static void diff --git a/examples/6lbr/apps/6lbr-webserver/webserver.c b/examples/6lbr/apps/6lbr-webserver/webserver.c index 22558dda9b..bbb707f7e1 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver.c @@ -45,6 +45,7 @@ #include "nvm-config.h" #include "log-6lbr.h" +HTTPD_GROUP(instances_group, "Instances"); HTTPD_GROUP(main_group, "System"); HTTPD_GROUP(sensors_group, "Sensors"); HTTPD_GROUP(status_group, "Status"); @@ -101,6 +102,7 @@ webserver_init(void) { httpd_init(); + httpd_instance_add(&instances_group); httpd_group_add(&main_group); httpd_group_add(&sensors_group); httpd_group_add(&status_group); diff --git a/examples/6lbr/apps/6lbr-webserver/webserver.h b/examples/6lbr/apps/6lbr-webserver/webserver.h index ec8ee8e9c2..bb0e6a6062 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver.h +++ b/examples/6lbr/apps/6lbr-webserver/webserver.h @@ -39,6 +39,7 @@ #include "httpd-cgi.h" +HTTPD_GROUP_NAME(instances_group); HTTPD_GROUP_NAME(main_group); HTTPD_GROUP_NAME(sensors_group); HTTPD_GROUP_NAME(status_group); From 84b917e1399a5c58882548f247cf7011688b532d Mon Sep 17 00:00:00 2001 From: Emmanuel Nataf Date: Fri, 20 May 2016 14:58:07 +0200 Subject: [PATCH 30/37] Allow nvm data file to contain more that one RPL instance --- examples/6lbr/6lbr/nvm-config.c | 2 ++ examples/6lbr/6lbr/nvm-config.h | 2 ++ examples/6lbr/platform/native/native-nvm.c | 28 ++++++++++++++++++---- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/examples/6lbr/6lbr/nvm-config.c b/examples/6lbr/6lbr/nvm-config.c index 6e2adc4a97..b1ba6e652c 100644 --- a/examples/6lbr/6lbr/nvm-config.c +++ b/examples/6lbr/6lbr/nvm-config.c @@ -49,6 +49,8 @@ #include "nvm-itf.h" #include "log-6lbr.h" +nvm_data_t *nvms_data; +uint16_t rpl_instances; nvm_data_t nvm_data; /*---------------------------------------------------------------------------*/ diff --git a/examples/6lbr/6lbr/nvm-config.h b/examples/6lbr/6lbr/nvm-config.h index f6c676dfd3..aba1d3fd6e 100644 --- a/examples/6lbr/6lbr/nvm-config.h +++ b/examples/6lbr/6lbr/nvm-config.h @@ -39,7 +39,9 @@ #include "nvm-data.h" +extern nvm_data_t *nvms_data; extern nvm_data_t nvm_data; +extern uint16_t rpl_instances; void load_nvm_config(void); void store_nvm_config(void); diff --git a/examples/6lbr/platform/native/native-nvm.c b/examples/6lbr/platform/native/native-nvm.c index 1e37d9729c..03133dc485 100644 --- a/examples/6lbr/platform/native/native-nvm.c +++ b/examples/6lbr/platform/native/native-nvm.c @@ -41,6 +41,10 @@ #include #include #include +#include +#include +#include + #include "log-6lbr.h" #include "nvm-itf.h" @@ -53,13 +57,23 @@ char const *nvm_file = NULL; void nvm_data_read(void) -{ +{ LOG6LBR_DEBUG("Opening nvm file '%s'\n", nvm_file); memset(nvm_mem, 0xff, NVM_SIZE); int s = open(nvm_file, O_RDONLY); if(s > 0) { - if(read(s, nvm_mem, NVM_SIZE) < 0) { - LOG6LBR_ERROR("Failed to read NVM"); + struct stat buf_stat; + fstat(s,&buf_stat); + rpl_instances = 0; + rpl_instances = buf_stat.st_size / NVM_SIZE; + nvms_data = (nvm_data_t*)malloc(rpl_instances * sizeof(nvm_data)); + int i; + for(i=0;i 0) { - if(write(s, nvm_mem, NVM_SIZE) != NVM_SIZE) { - LOG6LBR_ERROR("Failed to write to NVM"); + int i; + for(i=0;i Date: Fri, 20 May 2016 16:43:15 +0200 Subject: [PATCH 31/37] Instances menus generation --- examples/6lbr/apps/6lbr-webserver/httpd-cgi.c | 26 ++++++++++++------- examples/6lbr/apps/6lbr-webserver/httpd-cgi.h | 8 +++++- examples/6lbr/apps/6lbr-webserver/webserver.c | 5 ++-- examples/6lbr/apps/6lbr-webserver/webserver.h | 2 +- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c index 54cc47dd73..aaba2eb18b 100644 --- a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c +++ b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c @@ -47,18 +47,26 @@ static httpd_cgi_call_t *calls = NULL; static httpd_cgi_command_t *commands = NULL; /*---------------------------------------------------------------------------*/ void -httpd_instance_add(httpd_group_t *group) +httpd_instances_add(void *dgroup, uint16_t nb) { - httpd_group_t *l; + httpd_group_t *group = (httpd_group_t *)malloc(nb * sizeof(httpd_group_t)); + - LOG6LBR_DEBUG("Adding instance : %s\n", group->title); - group->next = NULL; - if(instances == NULL) { - instances = group; - } else { - for(l = instances; l->next != NULL; l = l->next); - l->next = group; + int i; + char * instance; + for(i=0;i Date: Fri, 27 May 2016 15:49:28 +0200 Subject: [PATCH 32/37] Instance creation and recording --- examples/6lbr/6lbr/nvm-config.c | 2 +- examples/6lbr/6lbr/nvm-config.h | 2 +- examples/6lbr/apps/6lbr-webserver/httpd-cgi.c | 35 ++++++++++++------- examples/6lbr/apps/6lbr-webserver/httpd.c | 4 +-- .../apps/6lbr-webserver/webserver-config.c | 7 ++++ .../apps/6lbr-webserver/webserver-utils.c | 18 ++++++++-- examples/6lbr/apps/6lbr-webserver/webserver.c | 15 +++++++- examples/6lbr/cetic-6lbr.c | 13 ++++--- examples/6lbr/platform/native/native-nvm.c | 13 +++---- 9 files changed, 79 insertions(+), 30 deletions(-) diff --git a/examples/6lbr/6lbr/nvm-config.c b/examples/6lbr/6lbr/nvm-config.c index b1ba6e652c..4167abbf99 100644 --- a/examples/6lbr/6lbr/nvm-config.c +++ b/examples/6lbr/6lbr/nvm-config.c @@ -50,7 +50,7 @@ #include "log-6lbr.h" nvm_data_t *nvms_data; -uint16_t rpl_instances; +uint16_t rpl_instances, rpl_current_instance; nvm_data_t nvm_data; /*---------------------------------------------------------------------------*/ diff --git a/examples/6lbr/6lbr/nvm-config.h b/examples/6lbr/6lbr/nvm-config.h index aba1d3fd6e..9f6859b883 100644 --- a/examples/6lbr/6lbr/nvm-config.h +++ b/examples/6lbr/6lbr/nvm-config.h @@ -41,7 +41,7 @@ extern nvm_data_t *nvms_data; extern nvm_data_t nvm_data; -extern uint16_t rpl_instances; +extern uint16_t rpl_instances, rpl_current_instance; void load_nvm_config(void); void store_nvm_config(void); diff --git a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c index aaba2eb18b..ebe69a7985 100644 --- a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c +++ b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c @@ -49,22 +49,33 @@ static httpd_cgi_command_t *commands = NULL; void httpd_instances_add(void *dgroup, uint16_t nb) { - httpd_group_t *group = (httpd_group_t *)malloc(nb * sizeof(httpd_group_t)); + httpd_group_t *group = (httpd_group_t *)malloc(2 + nb * sizeof(httpd_group_t)); + group[0].title = (char*)malloc(sizeof(char)); + sprintf(group[0].title, "%c", '-'); + group[0].next = &group[1]; + group[1].title = (char*)malloc(sizeof(char)); + sprintf(group[1].title, "%c", '+'); - int i; - char * instance; - for(i=0;i 0){ + group[1].next = &group[2]; + int i; + char * instance; + for(i=0;iquery) { - LOG6LBR_6ADDR(DEBUG, &uip_conn->ripaddr, "Request for '%s?%s' from ", s->filename, s->query); + LOG6LBR_6ADDR(INFO, &uip_conn->ripaddr, "Request for '%s?%s' from ", s->filename, s->query); } else { - LOG6LBR_6ADDR(DEBUG, &uip_conn->ripaddr, "Request for '%s' from ", s->filename); + LOG6LBR_6ADDR(INFO, &uip_conn->ripaddr, "Request for '%s' from ", s->filename); } s->state = STATE_OUTPUT; diff --git a/examples/6lbr/apps/6lbr-webserver/webserver-config.c b/examples/6lbr/apps/6lbr-webserver/webserver-config.c index 984b0639f9..4d26a5d412 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver-config.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver-config.c @@ -511,6 +511,13 @@ update_config(const char *name, uint8_t *reboot_needed) } } if(do_update) { + int i,find=0; + for(i=0;i +#include + /*---------------------------------------------------------------------------*/ #define WEBSERVER_CONF_LOADTIME 1 @@ -222,23 +224,30 @@ key_conv(const char *str, uint8_t * key, int size) static void add_instances_menu(struct httpd_state *s) { + add("
"); httpd_group_t *f; for(f = httpd_instance_head(); f != NULL; f = f->next) { add("
"); if(s->script != NULL && f == s->script->group) { add("%s", f->title); } else { - add("%s", f->title, f->title); + if (strcmp(f->title, "+") == 0 || strcmp(f->title, "-") == 0) + add("%s", f->title, f->title); + else { + if (rpl_current_instance == atoi(f->title)) + add("%s", f->title); + else + add("%s", f->title, f->title); + } } add("
"); } - + add("
"); } /*---------------------------------------------------------------------------*/ static void add_menu(struct httpd_state *s) { - add_instances_menu(s); add("
"); httpd_group_t *f; for(f = httpd_group_head(); f != NULL; f = f->next) { @@ -289,6 +298,9 @@ PT_THREAD(generate_top(struct httpd_state *s)) add(BODY); SEND_STRING(&s->sout, buf); reset_buf(); + add_instances_menu(s); + SEND_STRING(&s->sout, buf); + reset_buf(); add_menu(s); SEND_STRING(&s->sout, buf); reset_buf(); diff --git a/examples/6lbr/apps/6lbr-webserver/webserver.c b/examples/6lbr/apps/6lbr-webserver/webserver.c index 55bb84379a..9c7fdd4c90 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver.c @@ -53,6 +53,12 @@ HTTPD_GROUP(config_group, "Configuration"); HTTPD_GROUP(statistics_group, "Statistics"); HTTPD_GROUP(admin_group, "Administration"); +HTTPD_CGI_CALL_NAME(webserver_instances) +HTTPD_CGI_CMD_NAME(webserver_instances_select_cmd) +HTTPD_CGI_CMD_NAME(webserver_instance_new_cmd) +/* +HTTPD_CGI_CALL_NAME(webserver_instances_rm) +*/ HTTPD_CGI_CALL_NAME(webserver_main) HTTPD_CGI_CALL_NAME(webserver_network) HTTPD_CGI_CMD_NAME(webserver_network_route_add_cmd) @@ -101,7 +107,6 @@ void webserver_init(void) { httpd_init(); - httpd_instances_add(&instances_group,rpl_instances); httpd_group_add(&main_group); @@ -111,6 +116,14 @@ webserver_init(void) httpd_group_add(&statistics_group); httpd_group_add(&admin_group); + + httpd_group_add_page(&instances_group, &webserver_instances); + httpd_cgi_command_add(&webserver_instances_select_cmd); + httpd_cgi_command_add(&webserver_instance_new_cmd); + /* + httpd_group_add_page(&webserver_instances, &webserver_instances_add); + httpd_group_add_page(&webserver_instances, &webserver_instances_rm); + */ httpd_group_add_page(&main_group, &webserver_main); httpd_group_add_page(&config_group, &webserver_config); #if CETIC_NODE_INFO diff --git a/examples/6lbr/cetic-6lbr.c b/examples/6lbr/cetic-6lbr.c index 0776a70c07..8d6998b332 100644 --- a/examples/6lbr/cetic-6lbr.c +++ b/examples/6lbr/cetic-6lbr.c @@ -459,7 +459,6 @@ PROCESS_THREAD(cetic_6lbr_process, ev, data) platform_init(); platform_load_config(CONFIG_LEVEL_LOAD); - #if !LOG6LBR_STATIC if(nvm_data.log_level != 0xFF) { Log6lbr_level = nvm_data.log_level; @@ -512,8 +511,11 @@ PROCESS_THREAD(cetic_6lbr_process, ev, data) #endif packet_filter_init(); - - cetic_6lbr_init(); + int i; + for(i=0;i 0) { @@ -66,33 +66,34 @@ nvm_data_read(void) fstat(s,&buf_stat); rpl_instances = 0; rpl_instances = buf_stat.st_size / NVM_SIZE; - nvms_data = (nvm_data_t*)malloc(rpl_instances * sizeof(nvm_data)); + nvms_data = (nvm_data_t*)malloc(rpl_instances * sizeof(nvm_data_t)); int i; for(i=0;i 0) { int i; for(i=0;i Date: Fri, 27 May 2016 15:51:22 +0200 Subject: [PATCH 33/37] Augments the number of RPL instance in contiki Add file to compile --- examples/6lbr/Makefile | 3 +++ examples/6lbr/apps/6lbr-webserver/Makefile.6lbr-webserver | 1 + 2 files changed, 4 insertions(+) diff --git a/examples/6lbr/Makefile b/examples/6lbr/Makefile index 6f112af5d8..5ff7904730 100644 --- a/examples/6lbr/Makefile +++ b/examples/6lbr/Makefile @@ -11,6 +11,8 @@ CETIC_6LBR_LEARN_RPL_MAC=1 CONTIKI_WITH_IPV6 = 1 +RPL_CONF_MAX_INSTANCES=10 + 6LBR?=. CONTIKI = $(6LBR)/../.. @@ -40,6 +42,7 @@ CFLAGS +=-DCETIC_6LBR_ROUTER=$(CETIC_6LBR_ROUTER) CFLAGS +=-DCETIC_6LBR_6LR=$(CETIC_6LBR_6LR) CFLAGS +=-DCETIC_6LBR_ONE_ITF=$(CETIC_6LBR_ONE_ITF) CFLAGS +=-DCETIC_6LBR_LEARN_RPL_MAC=$(CETIC_6LBR_LEARN_RPL_MAC) +CFLAGS +=-DRPL_CONF_MAX_INSTANCES=$(RPL_CONF_MAX_INSTANCES) CONTIKI_WITH_RPL ?= 1 WITH_IP64?=1 diff --git a/examples/6lbr/apps/6lbr-webserver/Makefile.6lbr-webserver b/examples/6lbr/apps/6lbr-webserver/Makefile.6lbr-webserver index 3cd69884b8..2dee7608ad 100644 --- a/examples/6lbr/apps/6lbr-webserver/Makefile.6lbr-webserver +++ b/examples/6lbr/apps/6lbr-webserver/Makefile.6lbr-webserver @@ -1,6 +1,7 @@ CFLAGS += -DWEBSERVER=1 6lbr-webserver_src = httpd.c httpd-cgi.c httpd-urlconv.c webserver.c webserver-utils.c \ webserver-main.c webserver-network.c \ + webserver-instances.c \ webserver-config.c webserver-statistics.c webserver-admin.c webserver-log.c ifeq ($(CONTIKI_WITH_RPL),1) From 65a0896fa8071f5ef210364d4860b3d3a752b8ff Mon Sep 17 00:00:00 2001 From: Manu Date: Fri, 27 May 2016 16:02:50 +0200 Subject: [PATCH 34/37] Forgetting one file --- .../apps/6lbr-webserver/webserver-instances.c | 596 ++++++++++++++++++ 1 file changed, 596 insertions(+) create mode 100644 examples/6lbr/apps/6lbr-webserver/webserver-instances.c diff --git a/examples/6lbr/apps/6lbr-webserver/webserver-instances.c b/examples/6lbr/apps/6lbr-webserver/webserver-instances.c new file mode 100644 index 0000000000..b7b86ad2fa --- /dev/null +++ b/examples/6lbr/apps/6lbr-webserver/webserver-instances.c @@ -0,0 +1,596 @@ +/* + * Copyright (c) 2013, CETIC. + * 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 + * 6LBR Web Server + * \author + * 6LBR Team <6lbr@cetic.be> + */ + +#define LOG6LBR_MODULE "WEB" + +#include + +#include "contiki.h" +#include "httpd.h" +#include "httpd-cgi.h" +#include "webserver-utils.h" + +#include "cetic-6lbr.h" +#include "node-info.h" +#include "log-6lbr.h" + +#include "nvm-config.h" + +#if CETIC_NODE_CONFIG +#include "node-config.h" +#endif + +nvm_data_t default_nvm_data; + +#define INPUT_FLAG(name, nvm_name, flag, text, on_text, off_text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
" \ + " "on_text"
", \ + (default_nvm_data.nvm_name & (flag)) != 0 ? "checked" : ""); \ + add(" "off_text"
", \ + (default_nvm_data.nvm_name & (flag)) == 0 ? "checked" : ""); \ + } else { \ + add(text " : %s
", (default_nvm_data.nvm_name & (flag)) != 0 ? on_text : off_text ); \ + } + +#define INPUT_FLAG_CB(name, nvm_name, flag, text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
" \ + " on ", \ + (default_nvm_data.nvm_name & (flag)) != 0 ? "checked" : ""); \ + add(" off
", \ + (default_nvm_data.nvm_name & (flag)) == 0 ? "checked" : ""); \ + } else { \ + add(text " : %s
", (default_nvm_data.nvm_name & (flag)) != 0 ? "on" : "off" ); \ + } + +#define INPUT_IPADDR(name, nvm_name, text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
"); \ + } else { \ + add(text " : "); \ + ipaddr_add_u8(default_nvm_data.nvm_name); \ + add("
"); \ + } + +#define INPUT_IP4ADDR(name, nvm_name, text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
"); \ + } else { \ + add(text " : "); \ + ip4addr_add_u8(default_nvm_data.nvm_name); \ + add("
"); \ + } + +#define INPUT_CONTEXT(name, nvm_name, text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
"); \ + } else { \ + add(text " : "); \ + ipaddr_add_u8(default_nvm_data.nvm_name); \ + add("
"); \ + } + +#define INPUT_INT(name, nvm_name, text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
", default_nvm_data.nvm_name); \ + } else { \ + add(text " : %d
", default_nvm_data.nvm_name); \ + } + +#define INPUT_HEX(name, nvm_name, text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
", default_nvm_data.nvm_name); \ + } else { \ + add(text " : %x
", default_nvm_data.nvm_name); \ + } + +#define INPUT_KEY(name, nvm_name, size, text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
"); \ + } else { \ + add(text " : ****
"); \ + } + +#define INPUT_STRING(name, nvm_name, size, text) \ + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { \ + add(text " :
", size, default_nvm_data.nvm_name); \ + } else { \ + add(text " : \"%s\"
", default_nvm_data.nvm_name); \ + } + +#define SELECT_OPTION(nvm_name, value, name) add("", value, default_nvm_data.nvm_name == value ? "selected" : "", name) + +static +PT_THREAD(generate_instances(struct httpd_state *s)) +{ + if(strcmp(s->query,"+") == 0) { + + check_nvm(&default_nvm_data, 1); + PSOCK_BEGIN(&s->sout); + + add("
"); + add("

WSN Network

"); +#if !CETIC_6LBR_ONE_ITF + add("

802.15.4 configuration

"); + INPUT_INT("channel", channel, "Channel"); +#if !CONTIKI_TARGET_NATIVE + INPUT_HEX("panid", pan_id, "PAN ID"); +#endif + SEND_STRING(&s->sout, buf); + reset_buf(); + + add("

802.15.4 Security

"); + add("Link-layer security :
"); + SEND_STRING(&s->sout, buf); + reset_buf(); + add("Link-layer security level :
"); + SEND_STRING(&s->sout, buf); + reset_buf(); + INPUT_KEY("psk", noncoresec_key, 16, "Pre-shared key"); + INPUT_FLAG_CB("sec_dis_ar", noncoresec_flags, CETIC_6LBR_NONCORESEC_DISABLE_ANTIREPLAY, "Disable anti-replay"); + INPUT_FLAG_CB("sec_ar_wa", noncoresec_flags, CETIC_6LBR_NONCORESEC_ANTIREPLAY_WORKAROUND, "Enable anti-replay workaround"); + SEND_STRING(&s->sout, buf); + reset_buf(); +#if CETIC_6LBR_MAC_WRAPPER + add("

MAC

"); + add("MAC Layer :
"); + SEND_STRING(&s->sout, buf); + reset_buf(); +#endif +#endif + + add("

IP configuration

"); +#if CETIC_6LBR_SMARTBRIDGE || CETIC_6LBR_TRANSPARENTBRIDGE + INPUT_FLAG_CB("wait_ra", mode, CETIC_MODE_WAIT_RA_MASK, "Network autoconfiguration"); + INPUT_IPADDR("wsn_pre", wsn_net_prefix, "Prefix"); + INPUT_INT("wsn_pre_len", wsn_net_prefix_len, "Prefix length"); + INPUT_IPADDR("eth_dft", eth_dft_router, "Default router"); + SEND_STRING(&s->sout, buf); + reset_buf(); +#elif CETIC_6LBR_ROUTER + INPUT_IPADDR("wsn_pre", wsn_net_prefix, "Prefix"); + INPUT_INT("wsn_pre_len", wsn_net_prefix_len, "Prefix length"); +#endif + INPUT_CONTEXT("wsn_context_0", wsn_6lowpan_context_0, "6LoPWAN context 0"); + INPUT_FLAG_CB("wsn_auto", mode, CETIC_MODE_WSN_AUTOCONF, "Address autoconfiguration"); + INPUT_IPADDR("wsn_addr", wsn_ip_addr, "Manual address"); + SEND_STRING(&s->sout, buf); + reset_buf(); + add("

Extra configuration

"); +#if CETIC_6LBR_SMARTBRIDGE + INPUT_FLAG_CB("smart_multi", mode, CETIC_MODE_SMART_MULTI_BR, "Multi-BR support"); +#endif + INPUT_IPADDR("dns", dns_server, "DNS server"); +#if CETIC_NODE_CONFIG + INPUT_FLAG_CB("nc_filter", global_flags, CETIC_GLOBAL_FILTER_NODES, "Filter nodes"); +#endif + SEND_STRING(&s->sout, buf); + reset_buf(); + + add("

Eth Network

"); +#if CETIC_6LBR_ROUTER + add("

IP configuration

"); + INPUT_IPADDR("eth_pre", eth_net_prefix, "Prefix"); + INPUT_INT("eth_pre_len", eth_net_prefix_len, "Prefix length"); + SEND_STRING(&s->sout, buf); + reset_buf(); + + INPUT_FLAG_CB("eth_auto", mode, CETIC_MODE_ETH_AUTOCONF, "Address autoconfiguration" ); + INPUT_IPADDR("eth_addr", eth_ip_addr, "Manual address"); + SEND_STRING(&s->sout, buf); + reset_buf(); + INPUT_IPADDR("eth_dft", eth_dft_router, "Peer router"); + SEND_STRING(&s->sout, buf); + reset_buf(); +#endif +#if CETIC_6LBR_IP64 + add("

IP64

"); + INPUT_FLAG_CB("ip64", global_flags, CETIC_GLOBAL_IP64, "IP64" ); + INPUT_FLAG_CB("ip64_dhcp", eth_ip64_flags, CETIC_6LBR_IP64_DHCP, "DHCP" ); + INPUT_IP4ADDR("ip64_addr", eth_ip64_addr, "Address"); + SEND_STRING(&s->sout, buf); + reset_buf(); + INPUT_IP4ADDR("ip64_netmask", eth_ip64_netmask, "Netmask"); + INPUT_IP4ADDR("ip64_gateway", eth_ip64_gateway, "Gateway"); + INPUT_FLAG_CB("ip64_6052", eth_ip64_flags, CETIC_6LBR_IP64_RFC6052_PREFIX, "RFC 6052 prefix" ); + INPUT_FLAG_CB("ip64_port_map", eth_ip64_flags, CETIC_6LBR_IP64_SPECIAL_PORTS, "Static port mapping" ); + SEND_STRING(&s->sout, buf); + reset_buf(); +#endif +#if RESOLV_CONF_SUPPORTS_MDNS + add("

MDNS

"); + INPUT_FLAG_CB("mdns", global_flags, CETIC_GLOBAL_MDNS, "MDNS publishing" ); + INPUT_STRING("hostname", dns_host_name, NVM_DATA_DNS_HOST_NAME_SIZE, "Hostname"); +#if RESOLV_CONF_SUPPORTS_DNS_SD + INPUT_FLAG_CB("dns_sd", dns_flags, CETIC_6LBR_DNS_DNS_SD, "DNS-SD publishing" ); +#endif + SEND_STRING(&s->sout, buf); + reset_buf(); +#endif +#if CETIC_6LBR_ROUTER + add("

RA Daemon

"); + INPUT_FLAG("ra_daemon", mode, CETIC_MODE_ROUTER_RA_DAEMON, "RA Daemon", "active", "inactive"); + INPUT_INT("ra_lifetime", ra_router_lifetime, "Router lifetime"); + SEND_STRING(&s->sout, buf); + reset_buf(); + add("

RA

"); + INPUT_INT( "ra_max_interval", ra_max_interval, "Max interval"); + INPUT_INT( "ra_min_interval", ra_min_interval, "Min interval"); + INPUT_INT( "ra_min_delay", ra_min_delay, "Min delay"); + SEND_STRING(&s->sout, buf); + reset_buf(); + add("

RA Prefix

"); + INPUT_FLAG_CB( "ra_pio", ra_prefix_flags, CETIC_6LBR_MODE_SEND_PIO, "Send Prefix Information"); + INPUT_FLAG_CB( "ra_prefix_o", ra_prefix_flags, UIP_ND6_RA_FLAG_ONLINK, "Prefix on-link"); + INPUT_FLAG_CB( "ra_prefix_a", ra_prefix_flags, UIP_ND6_RA_FLAG_AUTONOMOUS, "Allow autoconfiguration"); + SEND_STRING(&s->sout, buf); + reset_buf(); + INPUT_INT( "ra_prefix_vtime", ra_prefix_vtime, "Prefix valid time"); + INPUT_INT( "ra_prefix_ptime", ra_prefix_ptime, "Prefix preferred time"); + add("
"); + SEND_STRING(&s->sout, buf); + reset_buf(); + add("

RA Route Information

"); + INPUT_FLAG_CB( "ra_rio_en", ra_rio_flags, CETIC_6LBR_MODE_SEND_RIO, "Include RIO"); + INPUT_INT( "ra_rio_lifetime", ra_rio_lifetime, "Route lifetime"); + add("
"); + SEND_STRING(&s->sout, buf); + reset_buf(); +#endif + +#if UIP_CONF_IPV6_RPL && (CETIC_6LBR_ROUTER || CETIC_6LBR_SMARTBRIDGE) + add("

RPL Configuration

"); + INPUT_INT( "rpl_instance_id", rpl_instance_id, "Instance ID"); + INPUT_FLAG_CB( "dodag_manual", rpl_config, CETIC_6LBR_MODE_MANUAL_DODAG, "Manual DODAG ID"); + INPUT_IPADDR("dodag_id", rpl_dodag_id, "DODAG ID"); + SEND_STRING(&s->sout, buf); + reset_buf(); + INPUT_FLAG_CB( "dodag_global", rpl_config, CETIC_6LBR_MODE_GLOBAL_DODAG, "Global DODAG ID"); + INPUT_INT( "rpl_preference", rpl_preference, "Preference"); + INPUT_INT( "rpl_dio_intdoubl", rpl_dio_intdoubl, "DIO interval doubling"); + INPUT_INT( "rpl_dio_intmin", rpl_dio_intmin, "DIO min interval"); + SEND_STRING(&s->sout, buf); + reset_buf(); + INPUT_INT( "rpl_dio_redundancy", rpl_dio_redundancy, "DIO redundancy"); + INPUT_INT( "rpl_min_hoprankinc", rpl_min_hoprankinc, "Min rank increment"); + INPUT_INT( "rpl_max_rankinc", rpl_max_rankinc, "Max rank increase"); + INPUT_INT( "rpl_default_lifetime", rpl_default_lifetime, "Route lifetime"); + INPUT_INT( "rpl_lifetime_unit", rpl_lifetime_unit, "Route lifetime unit"); + SEND_STRING(&s->sout, buf); + reset_buf(); +#endif + +#if CETIC_6LBR_ROUTER + add("

Packet filtering

"); + INPUT_FLAG("rewrite", mode, CETIC_MODE_REWRITE_ADDR_MASK, "Address rewrite", "enabled", "disabled"); +#endif + if ((default_nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { + add("
"); + } + SEND_STRING(&s->sout, buf); + reset_buf(); + + PSOCK_END(&s->sout); + } + else if (strcmp(s->query,"-") == 0){ + + } + +} + +/*---------------------------------------------------------------------------*/ + +#define UPDATE_FLAG(name, nvm_name, flag, reboot) \ +else if(strcmp(param, name) == 0) { \ + if(strcmp(value, "0") == 0) { \ + nvm_data.nvm_name &= ~(flag); \ + *reboot_needed |= (reboot); \ + } else if(strcmp(value, "1") == 0) { \ + nvm_data.nvm_name |= (flag); \ + *reboot_needed |= (reboot); \ + } else { \ + LOG6LBR_WARN("Invalid value for %s : '%s'\n", param, value); \ + do_update = 0; \ + } \ +} +#define UPDATE_INT(name, nvm_name, reboot) \ + else if(strcmp(param, name) == 0) { \ + nvm_data.nvm_name = atoi(value); \ + *reboot_needed |= (reboot); \ + } + +#define UPDATE_HEX(name, nvm_name, reboot) \ + else if(strcmp(param, name) == 0) { \ + nvm_data.nvm_name = strtoul(value, NULL, 16); \ + *reboot_needed |= (reboot); \ + } + +#define UPDATE_IPADDR(name, nvm_name, reboot) \ + else if(strcmp(param, name) == 0) { \ + if(uiplib_ipaddrconv(value, &loc_fipaddr)) { \ + memcpy(&nvm_data.nvm_name, &loc_fipaddr.u8, \ + sizeof(nvm_data.nvm_name)); \ + *reboot_needed |= (reboot); \ + } else { \ + LOG6LBR_WARN("Invalid value for %s : '%s'\n", param, value); \ + do_update = 0; \ + } \ + } + +#define UPDATE_IP4ADDR(name, nvm_name, reboot) \ + else if(strcmp(param, name) == 0) { \ + if(uiplib_ip4addrconv(value, &loc_fip4addr)) { \ + memcpy(&nvm_data.nvm_name, &loc_fip4addr.u8, \ + sizeof(nvm_data.nvm_name)); \ + *reboot_needed |= (reboot); \ + } else { \ + LOG6LBR_WARN("Invalid value for %s : '%s'\n", param, value); \ + do_update = 0; \ + } \ + } + +#define UPDATE_KEY(name, nvm_name, size, reboot) \ + else if(strcmp(param, name) == 0) { \ + uint8_t tmp_key[size]; \ + if(key_conv(value, tmp_key, size)) { \ + memcpy(&nvm_data.nvm_name, tmp_key, \ + sizeof(nvm_data.nvm_name)); \ + *reboot_needed |= (reboot); \ + } else { \ + LOG6LBR_WARN("Invalid value for %s : '%s'\n", param, value); \ + do_update = 0; \ + } \ + } + +#define UPDATE_STRING(name, nvm_name, size, reboot) \ + else if(strcmp(param, name) == 0) { \ + strncpy((char *)nvm_data.nvm_name, value, size); \ + *reboot_needed |= (reboot); \ + } + +static int +update_config(const char *name, uint8_t *reboot_needed) +{ + const char *ptr = name; + char *next; + uint8_t do_update = 1; + uip_ipaddr_t loc_fipaddr; +#if CETIC_6LBR_IP64 + uip_ip4addr_t loc_fip4addr; +#endif + + *reboot_needed = 0; + + while(*ptr) { + const char *param = ptr; + + next = index(ptr, '='); + if(!next) + break; + *next = 0; + ptr = next + 1; + const char *value = ptr; + + next = index(ptr, '&'); + if(next) { + *next = 0; + ptr = next + 1; + } else { + ptr += strlen(ptr); + } + + LOG6LBR_DEBUG("Got param: '%s' = '%s'\n", param, value); + if (0) { + } + UPDATE_FLAG("smart_multi", mode, CETIC_MODE_SMART_MULTI_BR, 1) + UPDATE_FLAG("wait_ra", mode, CETIC_MODE_WAIT_RA_MASK, 1) + UPDATE_INT("channel", channel, 1) + UPDATE_HEX("panid", pan_id, 1) +#if CETIC_6LBR_MAC_WRAPPER + UPDATE_INT("mac", mac_layer, 1) +#endif + UPDATE_INT("llsec", security_layer, 1) + UPDATE_INT("llsec_level", security_level, 1) + UPDATE_KEY("psk", noncoresec_key, 16, 1) + UPDATE_FLAG( "sec_dis_ar", noncoresec_flags, CETIC_6LBR_NONCORESEC_DISABLE_ANTIREPLAY, 1) + UPDATE_FLAG( "sec_ar_wa", noncoresec_flags, CETIC_6LBR_NONCORESEC_ANTIREPLAY_WORKAROUND, 1) + UPDATE_IPADDR("wsn_pre", wsn_net_prefix, 1) + UPDATE_INT("wsn_pre_len", wsn_net_prefix_len, 1) + UPDATE_IPADDR("wsn_context_0", wsn_6lowpan_context_0, 1) + UPDATE_FLAG("wsn_auto", mode, CETIC_MODE_WSN_AUTOCONF, 1) + UPDATE_IPADDR("wsn_addr", wsn_ip_addr, 1) + UPDATE_IPADDR("dns", dns_server, 1) + UPDATE_IPADDR("eth_pre", eth_net_prefix, 1) + UPDATE_INT("eth_pre_len", eth_net_prefix_len, 1) + UPDATE_FLAG("eth_auto", mode, CETIC_MODE_ETH_AUTOCONF, 1) + UPDATE_IPADDR("eth_addr", eth_ip_addr, 1) + UPDATE_IPADDR("eth_dft", eth_dft_router, 1) + UPDATE_FLAG("ra_daemon", mode, CETIC_MODE_ROUTER_RA_DAEMON, 1) + UPDATE_FLAG("rewrite", mode, CETIC_MODE_REWRITE_ADDR_MASK, 1) +#if CETIC_6LBR_IP64 + UPDATE_FLAG("ip64", global_flags, CETIC_GLOBAL_IP64, 1) + UPDATE_FLAG("ip64_dhcp", eth_ip64_flags, CETIC_6LBR_IP64_DHCP, 1) + UPDATE_IP4ADDR("ip64_addr", eth_ip64_addr, 1) + UPDATE_IP4ADDR("ip64_netmask", eth_ip64_netmask, 1) + UPDATE_IP4ADDR("ip64_gateway", eth_ip64_gateway, 1) + UPDATE_FLAG("ip64_port_map", eth_ip64_flags, CETIC_6LBR_IP64_SPECIAL_PORTS, 1) + UPDATE_FLAG("ip64_6052", eth_ip64_flags, CETIC_6LBR_IP64_RFC6052_PREFIX, 1) +#endif +#if RESOLV_CONF_SUPPORTS_MDNS + UPDATE_FLAG("mdns", global_flags, CETIC_GLOBAL_MDNS, 1) + UPDATE_STRING("hostname", dns_host_name, NVM_DATA_DNS_HOST_NAME_SIZE, 1) +#if RESOLV_CONF_SUPPORTS_DNS_SD + UPDATE_FLAG("dns_sd", dns_flags, CETIC_6LBR_DNS_DNS_SD, 1) +#endif +#endif +#if CETIC_NODE_CONFIG + UPDATE_FLAG("nc_filter", global_flags, CETIC_GLOBAL_FILTER_NODES, 1) +#endif + UPDATE_INT( "ra_lifetime", ra_router_lifetime, 1) + UPDATE_INT( "ra_max_interval", ra_max_interval, 1) + UPDATE_INT( "ra_min_interval", ra_min_interval, 1) + UPDATE_INT( "ra_min_delay", ra_min_delay, 1) + + UPDATE_FLAG( "ra_pio", ra_prefix_flags, CETIC_6LBR_MODE_SEND_PIO, 1) + UPDATE_FLAG( "ra_prefix_o", ra_prefix_flags, UIP_ND6_RA_FLAG_ONLINK, 1) + UPDATE_FLAG( "ra_prefix_a", ra_prefix_flags, UIP_ND6_RA_FLAG_AUTONOMOUS, 1) + UPDATE_INT( "ra_prefix_vtime", ra_prefix_vtime, 1) + UPDATE_INT( "ra_prefix_ptime", ra_prefix_ptime, 1) + + UPDATE_FLAG( "ra_rio_en", ra_rio_flags, CETIC_6LBR_MODE_SEND_RIO, 1) + UPDATE_INT( "ra_rio_lifetime", ra_rio_lifetime, 1) + + UPDATE_INT( "rpl_instance_id", rpl_instance_id, 1) + UPDATE_FLAG("dodag_manual", rpl_config, CETIC_6LBR_MODE_MANUAL_DODAG, 1) + UPDATE_FLAG("dodag_global", rpl_config, CETIC_6LBR_MODE_GLOBAL_DODAG, 1) + UPDATE_IPADDR("dodag_id", rpl_dodag_id, 1) + UPDATE_INT( "rpl_preference", rpl_preference, 1) + UPDATE_INT( "rpl_dio_intdoubl", rpl_dio_intdoubl, 1) + UPDATE_INT( "rpl_dio_intmin", rpl_dio_intmin, 1) + UPDATE_INT( "rpl_dio_redundancy", rpl_dio_redundancy, 1) + UPDATE_INT( "rpl_default_lifetime", rpl_default_lifetime, 1) + UPDATE_INT( "rpl_min_hoprankinc", rpl_min_hoprankinc, 1) + UPDATE_INT( "rpl_max_rankinc", rpl_max_rankinc, 1) + UPDATE_INT( "rpl_lifetime_unit", rpl_lifetime_unit, 1) + +#if !LOG6LBR_STATIC + UPDATE_INT( "log_level", log_level, 0) + UPDATE_HEX( "log_services", log_services, 0) +#endif + else { + LOG6LBR_WARN("Unknown parameter '%s'\n", param); + do_update=0; + } + } + if(do_update) { + //store_nvm_config(); +#if !LOG6LBR_STATIC + if(nvm_data.log_level != 0xFF) { + Log6lbr_level = nvm_data.log_level; + Log6lbr_services = nvm_data.log_services; + } +#endif + } + return do_update; +} +static httpd_cgi_call_t * +webserver_instance_new(struct httpd_state *s) +{ + uint8_t reboot_needed = 0; + webserver_result_title = "Configuration"; + + check_nvm(&default_nvm_data, 1); + nvm_data_t tmp_nvm_data = nvm_data; + nvm_data = default_nvm_data; + + if(!s->query || update_config(s->query, &reboot_needed)) { + rpl_instances++; + nvm_data_t * new_nvms_data = (nvm_data_t*)malloc(rpl_instances * sizeof(nvm_data_t)); + memcpy(new_nvms_data, nvms_data, (rpl_instances - 1) * sizeof(nvm_data_t)); + memcpy(&new_nvms_data[rpl_instances-1], &nvm_data, sizeof(nvm_data_t)); + nvms_data = new_nvms_data; + store_nvm_config(); + if(!reboot_needed) { + webserver_result_text = "Configuration updated"; + } else { + cetic_6lbr_restart_type = CETIC_6LBR_RESTART; + webserver_result_text = "Configuration updated, restarting BR..."; + webserver_result_refresh = 15; + process_post(&cetic_6lbr_process, cetic_6lbr_restart_event, NULL); + } + } else { + webserver_result_text = "Configuration invalid"; + } + return &webserver_result_page; +} + +static httpd_cgi_call_t * +webserver_instances_selection(struct httpd_state *s) +{ + int instance_id = atoi(s->query); + if(instance_id){ + int i=0; + while(nvms_data[i].rpl_instance_id != instance_id) + i++; + nvm_data = nvms_data[i]; + rpl_current_instance = instance_id; + webserver_result_title = "Instance selection"; + char rt[35] = "Instance number "; + strcat(rt, s->query); + strcat(rt, " selectioned"); + webserver_result_text = (char*)malloc(35*sizeof(char)); + strcpy(webserver_result_text, rt); + webserver_result_refresh = 1; + return &webserver_result_page; + } + webserver_result_title = "Instance selection ERROR"; + char rt[30] = "Unknow instance number :"; + strcat(rt, s->query); + webserver_result_text = (char*)malloc(30*sizeof(char)); + strcpy(webserver_result_text, rt); + webserver_result_refresh = 1; + return &webserver_result_page; +} + + +HTTPD_CGI_CALL_NAME(webserver_instances); +HTTPD_CGI_CALL(webserver_instances, "instances_mgmt", "Instance Management", generate_instances, 0); +HTTPD_CGI_CMD(webserver_instance_new_cmd, "instance_new", webserver_instance_new,0); +HTTPD_CGI_CMD(webserver_instances_select_cmd, "select", webserver_instances_selection,0); From 92b45f2175f7ac2e8b024736ef60f895a094f04f Mon Sep 17 00:00:00 2001 From: Emmanuel Nataf Date: Fri, 27 May 2016 18:44:55 +0200 Subject: [PATCH 35/37] RPL Instance suppression --- examples/6lbr/apps/6lbr-webserver/httpd-cgi.c | 5 +- .../apps/6lbr-webserver/webserver-instances.c | 69 ++++++++++++++++++- examples/6lbr/apps/6lbr-webserver/webserver.c | 6 +- 3 files changed, 71 insertions(+), 9 deletions(-) diff --git a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c index ebe69a7985..8c4ed8a59d 100644 --- a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c +++ b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c @@ -36,6 +36,7 @@ #include #include +#include #include "contiki-net.h" #include "httpd-cgi.h" @@ -51,10 +52,10 @@ httpd_instances_add(void *dgroup, uint16_t nb) { httpd_group_t *group = (httpd_group_t *)malloc(2 + nb * sizeof(httpd_group_t)); - group[0].title = (char*)malloc(sizeof(char)); + group[0].title = (char*)malloc(2*sizeof(char)); sprintf(group[0].title, "%c", '-'); group[0].next = &group[1]; - group[1].title = (char*)malloc(sizeof(char)); + group[1].title = (char*)malloc(2*sizeof(char)); sprintf(group[1].title, "%c", '+'); if(nb > 0){ diff --git a/examples/6lbr/apps/6lbr-webserver/webserver-instances.c b/examples/6lbr/apps/6lbr-webserver/webserver-instances.c index b7b86ad2fa..c79fd425b9 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver-instances.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver-instances.c @@ -330,9 +330,16 @@ PT_THREAD(generate_instances(struct httpd_state *s)) PSOCK_END(&s->sout); } else if (strcmp(s->query,"-") == 0){ - + PSOCK_BEGIN(&s->sout); + add("
"); + add("

Deleting the RPL instance number :

"); + add("

",rpl_current_instance); + add("
"); + add("
or choice other menu to cancel
"); + SEND_STRING(&s->sout, buf); + reset_buf(); + PSOCK_END(&s->sout); } - } /*---------------------------------------------------------------------------*/ @@ -545,6 +552,7 @@ webserver_instance_new(struct httpd_state *s) nvm_data_t * new_nvms_data = (nvm_data_t*)malloc(rpl_instances * sizeof(nvm_data_t)); memcpy(new_nvms_data, nvms_data, (rpl_instances - 1) * sizeof(nvm_data_t)); memcpy(&new_nvms_data[rpl_instances-1], &nvm_data, sizeof(nvm_data_t)); + free(nvms_data); nvms_data = new_nvms_data; store_nvm_config(); if(!reboot_needed) { @@ -561,11 +569,65 @@ webserver_instance_new(struct httpd_state *s) return &webserver_result_page; } +static httpd_cgi_call_t * +webserver_instance_rm(struct httpd_state *s) +{ + + const char *ptr = s->query; + char *next; + + while(*ptr) { + const char *param = ptr; + + next = index(ptr, '='); + if(!next) + break; + *next = 0; + ptr = next + 1; + const char *value = ptr; + + next = index(ptr, '&'); + if(next) { + *next = 0; + ptr = next + 1; + } else { + ptr += strlen(ptr); + } + + LOG6LBR_DEBUG("Got param: '%s' = '%s'\n", param, value); + + int instance_id = atoi(value); + webserver_result_title = "Configuration"; + if(instance_id>0){ + int i=0; + rpl_instances--; + nvm_data_t * new_nvms_data = (nvm_data_t*)malloc(rpl_instances * sizeof(nvm_data_t)); + for(i=0;iquery); + strcat(rt, " deleted"); + webserver_result_text = (char*)malloc(35*sizeof(char)); + strcpy(webserver_result_text, rt); + webserver_result_refresh = 15; + process_post(&cetic_6lbr_process, cetic_6lbr_restart_event, NULL); + return &webserver_result_page; + } + } +} + + static httpd_cgi_call_t * webserver_instances_selection(struct httpd_state *s) { int instance_id = atoi(s->query); - if(instance_id){ + if(instance_id>0){ int i=0; while(nvms_data[i].rpl_instance_id != instance_id) i++; @@ -593,4 +655,5 @@ webserver_instances_selection(struct httpd_state *s) HTTPD_CGI_CALL_NAME(webserver_instances); HTTPD_CGI_CALL(webserver_instances, "instances_mgmt", "Instance Management", generate_instances, 0); HTTPD_CGI_CMD(webserver_instance_new_cmd, "instance_new", webserver_instance_new,0); +HTTPD_CGI_CMD(webserver_instance_rm_cmd, "instance_rm", webserver_instance_rm,0); HTTPD_CGI_CMD(webserver_instances_select_cmd, "select", webserver_instances_selection,0); diff --git a/examples/6lbr/apps/6lbr-webserver/webserver.c b/examples/6lbr/apps/6lbr-webserver/webserver.c index 9c7fdd4c90..8d372e02b3 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver.c @@ -55,6 +55,7 @@ HTTPD_GROUP(admin_group, "Administration"); HTTPD_CGI_CALL_NAME(webserver_instances) HTTPD_CGI_CMD_NAME(webserver_instances_select_cmd) +HTTPD_CGI_CMD_NAME(webserver_instance_rm_cmd) HTTPD_CGI_CMD_NAME(webserver_instance_new_cmd) /* HTTPD_CGI_CALL_NAME(webserver_instances_rm) @@ -119,11 +120,8 @@ webserver_init(void) httpd_group_add_page(&instances_group, &webserver_instances); httpd_cgi_command_add(&webserver_instances_select_cmd); + httpd_cgi_command_add(&webserver_instance_rm_cmd); httpd_cgi_command_add(&webserver_instance_new_cmd); - /* - httpd_group_add_page(&webserver_instances, &webserver_instances_add); - httpd_group_add_page(&webserver_instances, &webserver_instances_rm); - */ httpd_group_add_page(&main_group, &webserver_main); httpd_group_add_page(&config_group, &webserver_config); #if CETIC_NODE_INFO From 6dfc1dcf47a2c88a3462d7a051099a5d3d6f16e5 Mon Sep 17 00:00:00 2001 From: Manu Date: Mon, 30 May 2016 11:37:05 +0200 Subject: [PATCH 36/37] Shows sensors and status/RPL info of the current RPL instance --- .../apps/6lbr-webserver/webserver-network.c | 77 ++-- .../6lbr/apps/6lbr-webserver/webserver-rpl.c | 96 ++--- .../apps/6lbr-webserver/webserver-sensors.c | 399 ++++++++++-------- 3 files changed, 306 insertions(+), 266 deletions(-) diff --git a/examples/6lbr/apps/6lbr-webserver/webserver-network.c b/examples/6lbr/apps/6lbr-webserver/webserver-network.c index 55d928fe76..ba82dc3ded 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver-network.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver-network.c @@ -87,34 +87,34 @@ PT_THREAD(generate_network(struct httpd_state *s)) if(uip_ds6_if.addr_list[i].isused) { ipaddr_add(&uip_ds6_if.addr_list[i].ipaddr); char flag; - + if(uip_ds6_if.addr_list[i].state == ADDR_TENTATIVE) { - flag = 'T'; + flag = 'T'; } else if(uip_ds6_if.addr_list[i].state == ADDR_PREFERRED) { - flag = 'P'; + flag = 'P'; } else { - flag = '?'; + flag = '?'; } add(" %c", flag); if(uip_ds6_if.addr_list[i].type == ADDR_MANUAL) { - flag = 'M'; + flag = 'M'; } else if(uip_ds6_if.addr_list[i].type == ADDR_DHCP) { - flag = 'D'; + flag = 'D'; } else if(uip_ds6_if.addr_list[i].type == ADDR_AUTOCONF) { - flag = 'A'; + flag = 'A'; } else { - flag = '?'; + flag = '?'; } add(" %c", flag); if(!uip_ds6_if.addr_list[i].isinfinite) { - add(" %u s", stimer_remaining(&uip_ds6_if.addr_list[i].vlifetime)); + add(" %u s", stimer_remaining(&uip_ds6_if.addr_list[i].vlifetime)); } add("\n"); SEND_STRING(&s->sout, buf); reset_buf(); } } - + add("

Prefixes

");
   for(i = 0; i < UIP_DS6_PREFIX_NB; i++) {
     if(uip_ds6_prefix_list[i].isused) {
@@ -122,11 +122,11 @@ PT_THREAD(generate_network(struct httpd_state *s))
       add(" ");
 #if UIP_CONF_ROUTER
       if(uip_ds6_prefix_list[i].advertise) {
-        add("A");
+	add("A");
       }
 #else
       if(uip_ds6_prefix_list[i].isinfinite) {
-        add("I");
+	add("I");
       }
 #endif
       add("\n");
@@ -134,7 +134,7 @@ PT_THREAD(generate_network(struct httpd_state *s))
   }
   SEND_STRING(&s->sout, buf);
   reset_buf();
-
+  
 #if CETIC_6LBR_IP64
   if((nvm_data.global_flags & CETIC_GLOBAL_IP64) != 0) {
     add("

IP64

");
@@ -149,11 +149,11 @@ PT_THREAD(generate_network(struct httpd_state *s))
       ip4addr_add(ip64_get_draddr());
       add("
"); if((nvm_data.eth_ip64_flags & CETIC_6LBR_IP64_DHCP) != 0) { - extern struct ip64_dhcpc_state *ip64_dhcp_state; - add("DHCP Server : "); - ip4addr_add_u8(ip64_dhcp_state->serverid); - add("
"); - add("DHCP lease time : %d s
", uip_ntohs(ip64_dhcp_state->lease_time[0])*65536ul + uip_ntohs(ip64_dhcp_state->lease_time[1])); + extern struct ip64_dhcpc_state *ip64_dhcp_state; + add("DHCP Server : "); + ip4addr_add_u8(ip64_dhcp_state->serverid); + add("
"); + add("DHCP lease time : %d s
", uip_ntohs(ip64_dhcp_state->lease_time[0])*65536ul + uip_ntohs(ip64_dhcp_state->lease_time[1])); } } else { add("Waiting configuration
"); @@ -162,13 +162,13 @@ PT_THREAD(generate_network(struct httpd_state *s)) reset_buf(); } #endif - + add("

Neighbors

");
-
+  
   for(nbr = nbr_table_head(ds6_neighbors);
       nbr != NULL;
       nbr = nbr_table_next(ds6_neighbors, nbr)) {
-
+    
     if ((nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) {
       add("[ipaddr);
@@ -188,7 +188,7 @@ PT_THREAD(generate_network(struct httpd_state *s))
     SEND_STRING(&s->sout, buf);
     reset_buf();
   }
-
+      
   add("

Routes

");
   SEND_STRING(&s->sout, buf);
   reset_buf();
@@ -228,9 +228,9 @@ PT_THREAD(generate_network(struct httpd_state *s))
     SEND_STRING(&s->sout, buf);
     reset_buf();
   }
-
+  
   add("

Default Routers

");
-
+  
   for(dr = uip_ds6_defrt_list_head(); dr != NULL; dr = list_item_next(r)) {
     ipaddr_add(&dr->ipaddr);
     if(!dr->isinfinite) {
@@ -240,21 +240,21 @@ PT_THREAD(generate_network(struct httpd_state *s))
     SEND_STRING(&s->sout, buf);
     reset_buf();
   }
-
+  
 #if UIP_CONF_DS6_ROUTE_INFORMATION
   add("

Route info

");
   for(i = 0; i < UIP_DS6_ROUTE_INFO_NB; i++) {
     if(uip_ds6_route_info_list[i].isused) {
       ipaddr_add(&uip_ds6_route_info_list[i].ipaddr);
       add("/%u (%x) %us\n", uip_ds6_route_info_list[i].length,
-          uip_ds6_route_info_list[i].flags,
-          uip_ds6_route_info_list[i].lifetime);
+	  uip_ds6_route_info_list[i].flags,
+	  uip_ds6_route_info_list[i].lifetime);
     }
   }
   SEND_STRING(&s->sout, buf);
   reset_buf();
 #endif
-
+  
   add("

DNS server

");
   //Note: Currently we assume only one DNS server
   uip_ipaddr_t * dns = uip_nameserver_get(0);
@@ -264,33 +264,33 @@ PT_THREAD(generate_network(struct httpd_state *s))
   }
   SEND_STRING(&s->sout, buf);
   reset_buf();
-
+  
 #if CETIC_6LBR_IP64
   if((nvm_data.global_flags & CETIC_GLOBAL_IP64) != 0) {
     add("

IP64 connections mapping

");
     static struct ip64_addrmap_entry *m;
     for(m = ip64_addrmap_list();
-        m != NULL;
-        m = list_item_next(m)) {
+	m != NULL;
+	m = list_item_next(m)) {
       if(timer_expired(&m->timer)) continue;
       ipaddr_add(&m->ip6addr);
       add("%%%d (%d)", m->ip6port, m->protocol);
       if(m->ip6to4 && m->ip4to6) {
-        add(" <-> ");
+	add(" <-> ");
       } else if(m->ip6to4) {
-        add(" -> ");
+	add(" -> ");
       } else {
-        add(" <- ");
+	add(" <- ");
       }
       ip4addr_add(&m->ip4addr);
       add("%%%d : %d (%x) %us\n", m->ip4port, m->mapped_port,
-          m->flags, (m->timer.interval - (clock_time() - m->timer.start)) / CLOCK_SECOND);
+	  m->flags, (m->timer.interval - (clock_time() - m->timer.start)) / CLOCK_SECOND);
       SEND_STRING(&s->sout, buf);
       reset_buf();
     }
   }
 #endif
-
+  
 #if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
   add("

6LoWPAN Prefix contexts

");
   for(i = 0; i < SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS; i++) {
@@ -304,12 +304,12 @@ PT_THREAD(generate_network(struct httpd_state *s))
   SEND_STRING(&s->sout, buf);
   reset_buf();
 #endif
-
+  
 #if CETIC_6LBR_TRANSPARENTBRIDGE
   add("

HW Prefixes cache

");
   for(i = 0; i < prefixCounter; i++) {
     add("%02x:%02x:%02x\n", prefixBuffer[i][0], prefixBuffer[i][1],
-        prefixBuffer[i][2]);
+	prefixBuffer[i][2]);
   }
   SEND_STRING(&s->sout, buf);
   add("

"); @@ -317,6 +317,7 @@ PT_THREAD(generate_network(struct httpd_state *s)) #endif PSOCK_END(&s->sout); } + static void add_network_cases(const uint8_t state) { diff --git a/examples/6lbr/apps/6lbr-webserver/webserver-rpl.c b/examples/6lbr/apps/6lbr-webserver/webserver-rpl.c index 810f06c9b6..22d1a85917 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver-rpl.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver-rpl.c @@ -65,55 +65,57 @@ PT_THREAD(generate_rpl(struct httpd_state *s)) reset_buf(); for(i = 0; i < RPL_MAX_INSTANCES; ++i) { if(instance_table[i].used) { - add("

Instance %d

", instance_table[i].instance_id); - for(j = 0; j < RPL_MAX_DAG_PER_INSTANCE; ++j) { - if(instance_table[i].dag_table[j].used) { - add("

DODAG %d

", j); - add("DODAG ID : "); - ipaddr_add(&instance_table[i].dag_table[j].dag_id); - SEND_STRING(&s->sout, buf); - reset_buf(); - add("
Version : %d", instance_table[i].dag_table[j].version); - add("
Grounded : %s", - instance_table[i].dag_table[j].grounded ? "Yes" : "No"); - add("
Preference : %d", - instance_table[i].dag_table[j].preference); - add("
Mode of Operation : %u", instance_table[i].mop); - add("
Objective Function Code Point : %u", - instance_table[i].of->ocp); - add("
Joined : %s", - instance_table[i].dag_table[j].joined ? "Yes" : "No"); - add("
Rank : %d", instance_table[i].dag_table[j].rank); - add("
"); - SEND_STRING(&s->sout, buf); - reset_buf(); - add("
Current DIO Interval [%u-%u] : %u", - instance_table[i].dio_intmin, - instance_table[i].dio_intmin + instance_table[i].dio_intdoubl, - instance_table[i].dio_intcurrent); - if(instance_table[i].dio_send) { - add("
Next DIO : %u", (etimer_expiration_time(&instance_table[i].dio_timer.etimer) - clock_time()) / CLOCK_SECOND ); - add("
Next Interval : %u", (etimer_expiration_time(&instance_table[i].dio_timer.etimer) + instance_table[i].dio_next_delay - clock_time()) / CLOCK_SECOND ); - } else { - add("
Next DIO : -"); - add("
Next Interval : %u", (etimer_expiration_time(&instance_table[i].dio_timer.etimer) - clock_time()) / CLOCK_SECOND); - } - if (instance_table[i].dio_redundancy > 0) { - add("
DIO suppression : %s (%u >= %u)", (instance_table[i].dio_counter >= instance_table[i].dio_redundancy ? "Yes" : "No"), instance_table[i].dio_counter, instance_table[i].dio_redundancy); - } else { - add("
DIO suppression : Disabled"); - } - add("
"); + if(instance_table[i].instance_id == rpl_current_instance){ + add("

Instance %d

", instance_table[i].instance_id); + for(j = 0; j < RPL_MAX_DAG_PER_INSTANCE; ++j) { + if(instance_table[i].dag_table[j].used) { + add("

DODAG %d

", j); + add("DODAG ID : "); + ipaddr_add(&instance_table[i].dag_table[j].dag_id); + SEND_STRING(&s->sout, buf); + reset_buf(); + add("
Version : %d", instance_table[i].dag_table[j].version); + add("
Grounded : %s", + instance_table[i].dag_table[j].grounded ? "Yes" : "No"); + add("
Preference : %d", + instance_table[i].dag_table[j].preference); + add("
Mode of Operation : %u", instance_table[i].mop); + add("
Objective Function Code Point : %u", + instance_table[i].of->ocp); + add("
Joined : %s", + instance_table[i].dag_table[j].joined ? "Yes" : "No"); + add("
Rank : %d", instance_table[i].dag_table[j].rank); + add("
"); + SEND_STRING(&s->sout, buf); + reset_buf(); + add("
Current DIO Interval [%u-%u] : %u", + instance_table[i].dio_intmin, + instance_table[i].dio_intmin + instance_table[i].dio_intdoubl, + instance_table[i].dio_intcurrent); + if(instance_table[i].dio_send) { + add("
Next DIO : %u", (etimer_expiration_time(&instance_table[i].dio_timer.etimer) - clock_time()) / CLOCK_SECOND ); + add("
Next Interval : %u", (etimer_expiration_time(&instance_table[i].dio_timer.etimer) + instance_table[i].dio_next_delay - clock_time()) / CLOCK_SECOND ); + } else { + add("
Next DIO : -"); + add("
Next Interval : %u", (etimer_expiration_time(&instance_table[i].dio_timer.etimer) - clock_time()) / CLOCK_SECOND); + } + if (instance_table[i].dio_redundancy > 0) { + add("
DIO suppression : %s (%u >= %u)", (instance_table[i].dio_counter >= instance_table[i].dio_redundancy ? "Yes" : "No"), instance_table[i].dio_counter, instance_table[i].dio_redundancy); + } else { + add("
DIO suppression : Disabled"); + } + add("
"); #if RPL_CONF_STATS - add("DIO intervals : %d
", instance_table[i].dio_totint); - add("Sent DIO : %d
", instance_table[i].dio_totsend); - add("Received DIO : %d
", instance_table[i].dio_totrecv); - add("
"); + add("DIO intervals : %d
", instance_table[i].dio_totint); + add("Sent DIO : %d
", instance_table[i].dio_totsend); + add("Received DIO : %d
", instance_table[i].dio_totrecv); + add("
"); #endif - SEND_STRING(&s->sout, buf); - reset_buf(); - } - } + SEND_STRING(&s->sout, buf); + reset_buf(); + } + } + } } } if ((nvm_data.global_flags & CETIC_GLOBAL_DISABLE_CONFIG) == 0) { diff --git a/examples/6lbr/apps/6lbr-webserver/webserver-sensors.c b/examples/6lbr/apps/6lbr-webserver/webserver-sensors.c index 006503e16e..c5404cacc7 100644 --- a/examples/6lbr/apps/6lbr-webserver/webserver-sensors.c +++ b/examples/6lbr/apps/6lbr-webserver/webserver-sensors.c @@ -94,121 +94,129 @@ PT_THREAD(generate_sensors_info(struct httpd_state *s)) reset_buf(); for(i = 0; i < UIP_DS6_ROUTE_NB; i++) { - if(node_info_table[i].isused) { - add(""); - add("
state.dag; + if(dag->instance->instance_id == rpl_current_instance){ + + if(node_info_table[i].isused) { + add(""); + add("%s (", node_config_get_name(node_config_find_by_ip(&node_info_table[i].ipaddr))); - ipaddr_add(&node_info_table[i].ipaddr); - add(")"); - } else + if ( node_config_loaded ) { + add("\">%s (", node_config_get_name(node_config_find_by_ip(&node_info_table[i].ipaddr))); + ipaddr_add(&node_info_table[i].ipaddr); + add(")"); + } else #endif - { - add("\">"); - ipaddr_add(&node_info_table[i].ipaddr); - add(""); - } - - if(0) { - } else if(node_info_table[i].ipaddr.u8[8] == 0x02 - && node_info_table[i].ipaddr.u8[9] == 0x12 - && (node_info_table[i].ipaddr.u8[10] == 0x74 || - node_info_table[i].ipaddr.u8[10] == 0x75)) { - add("Moteiv Telos"); - } else if(node_info_table[i].ipaddr.u8[8] == 0x02 - && node_info_table[i].ipaddr.u8[9] == 0x1A - && node_info_table[i].ipaddr.u8[10] == 0x4C) { - add("Crossbow Sky"); - } else if(node_info_table[i].ipaddr.u8[8] == 0xC3 - && node_info_table[i].ipaddr.u8[9] == 0x0C - && node_info_table[i].ipaddr.u8[10] == 0x00) { - add("Zolertia Z1"); - } else if(node_info_table[i].ipaddr.u8[8] == 0x02 - && node_info_table[i].ipaddr.u8[9] == 0x80 - && node_info_table[i].ipaddr.u8[10] == 0xE1) { - add("STMicro"); - } else if(node_info_table[i].ipaddr.u8[8] == 0x02 - && node_info_table[i].ipaddr.u8[9] == 0x12 - && node_info_table[i].ipaddr.u8[10] == 0x4B) { - add("TI"); - } else if(node_info_table[i].ipaddr.u8[8] == 0x02 - && node_info_table[i].ipaddr.u8[9] == 0x50 - && node_info_table[i].ipaddr.u8[10] == 0xC2 - && node_info_table[i].ipaddr.u8[11] == 0xA8 - && (node_info_table[i].ipaddr.u8[12] & 0XF0) == 0xC0) { - add("Redwire Econotag I"); - } else if(node_info_table[i].ipaddr.u8[8] == 0x02 - && node_info_table[i].ipaddr.u8[9] == 0x05 - && node_info_table[i].ipaddr.u8[10] == 0x0C - && node_info_table[i].ipaddr.u8[11] == 0x2A - && node_info_table[i].ipaddr.u8[12] == 0x8C) { - add("Redwire Econotag I"); - } else if(node_info_table[i].ipaddr.u8[8] == 0xEE - && node_info_table[i].ipaddr.u8[9] == 0x47 - && node_info_table[i].ipaddr.u8[10] == 0x3C) { - if(node_info_table[i].ipaddr.u8[11] == 0x4D - && node_info_table[i].ipaddr.u8[12] == 0x12) { - add("Redwire M12"); - } else { - add("Redwire Unknown"); - } - } else if((node_info_table[i].ipaddr.u8[8] & 0x02) == 0) { - add("User defined"); - } else { - add("Unknown"); - } - SEND_STRING(&s->sout, buf); - reset_buf(); + { + add("\">"); + ipaddr_add(&node_info_table[i].ipaddr); + add(""); + } + + if(0) { + } else if(node_info_table[i].ipaddr.u8[8] == 0x02 + && node_info_table[i].ipaddr.u8[9] == 0x12 + && (node_info_table[i].ipaddr.u8[10] == 0x74 || + node_info_table[i].ipaddr.u8[10] == 0x75)) { + add("Moteiv Telos"); + } else if(node_info_table[i].ipaddr.u8[8] == 0x02 + && node_info_table[i].ipaddr.u8[9] == 0x1A + && node_info_table[i].ipaddr.u8[10] == 0x4C) { + add("Crossbow Sky"); + } else if(node_info_table[i].ipaddr.u8[8] == 0xC3 + && node_info_table[i].ipaddr.u8[9] == 0x0C + && node_info_table[i].ipaddr.u8[10] == 0x00) { + add("Zolertia Z1"); + } else if(node_info_table[i].ipaddr.u8[8] == 0x02 + && node_info_table[i].ipaddr.u8[9] == 0x80 + && node_info_table[i].ipaddr.u8[10] == 0xE1) { + add("STMicro"); + } else if(node_info_table[i].ipaddr.u8[8] == 0x02 + && node_info_table[i].ipaddr.u8[9] == 0x12 + && node_info_table[i].ipaddr.u8[10] == 0x4B) { + add("TI"); + } else if(node_info_table[i].ipaddr.u8[8] == 0x02 + && node_info_table[i].ipaddr.u8[9] == 0x50 + && node_info_table[i].ipaddr.u8[10] == 0xC2 + && node_info_table[i].ipaddr.u8[11] == 0xA8 + && (node_info_table[i].ipaddr.u8[12] & 0XF0) == 0xC0) { + add("Redwire Econotag I"); + } else if(node_info_table[i].ipaddr.u8[8] == 0x02 + && node_info_table[i].ipaddr.u8[9] == 0x05 + && node_info_table[i].ipaddr.u8[10] == 0x0C + && node_info_table[i].ipaddr.u8[11] == 0x2A + && node_info_table[i].ipaddr.u8[12] == 0x8C) { + add("Redwire Econotag I"); + } else if(node_info_table[i].ipaddr.u8[8] == 0xEE + && node_info_table[i].ipaddr.u8[9] == 0x47 + && node_info_table[i].ipaddr.u8[10] == 0x3C) { + if(node_info_table[i].ipaddr.u8[11] == 0x4D + && node_info_table[i].ipaddr.u8[12] == 0x12) { + add("Redwire M12"); + } else { + add("Redwire Unknown"); + } + } else if((node_info_table[i].ipaddr.u8[8] & 0x02) == 0) { + add("User defined"); + } else { + add("Unknown"); + } + SEND_STRING(&s->sout, buf); + reset_buf(); #if CETIC_6LBR_IP64 && CETIC_NODE_CONFIG - if(ip64_addr_is_ip64(&UIP_IP_BUF->srcipaddr)) { - node_config_t * config = node_config_find_by_ip(&node_info_table[i].ipaddr); - if(config && (nvm_data.eth_ip64_flags & CETIC_6LBR_IP64_SPECIAL_PORTS) != 0) { - add("web", config->http_port); - add("coap", config->coap_port); - } else { - add(""); - } - } else + if(ip64_addr_is_ip64(&UIP_IP_BUF->srcipaddr)) { + node_config_t * config = node_config_find_by_ip(&node_info_table[i].ipaddr); + if(config && (nvm_data.eth_ip64_flags & CETIC_6LBR_IP64_SPECIAL_PORTS) != 0) { + add("web", config->http_port); + add("coap", config->coap_port); + } else { + add(""); + } + } else #endif - { - add("web"); - add("coap"); - } - if(node_info_table[i].messages_received > 0) { - add(""); + { + add("web"); + add("coap"); + } + if(node_info_table[i].messages_received > 0) { + add(""); #if CETIC_NODE_CONFIG_HAS_NAME - if (node_config_loaded) { - add("%s (", node_config_get_name(node_config_find_by_ip(&node_info_table[i].ip_parent))); - ipaddr_add(&node_info_table[i].ip_parent); - add(")"); - } else { - ipaddr_add(&node_info_table[i].ip_parent); - } + if (node_config_loaded) { + add("%s (", node_config_get_name(node_config_find_by_ip(&node_info_table[i].ip_parent))); + ipaddr_add(&node_info_table[i].ip_parent); + add(")"); + } else { + ipaddr_add(&node_info_table[i].ip_parent); + } #else - ipaddr_add(&node_info_table[i].ip_parent); + ipaddr_add(&node_info_table[i].ip_parent); #endif - add(""); - add("%.1f%%", 100.0 * (node_info_table[i].messages_sent - node_info_table[i].up_messages_lost)/node_info_table[i].messages_sent); - add("%.1f%%", 100.0 * (node_info_table[i].messages_sent - node_info_table[i].down_messages_lost)/node_info_table[i].messages_sent); - } else { - add(""); + add(""); + add("%.1f%%", 100.0 * (node_info_table[i].messages_sent - node_info_table[i].up_messages_lost)/node_info_table[i].messages_sent); + add("%.1f%%", 100.0 * (node_info_table[i].messages_sent - node_info_table[i].down_messages_lost)/node_info_table[i].messages_sent); + } else { + add(""); + } + add("%d", + (clock_time() - node_info_table[i].last_seen) / CLOCK_SECOND); + add("%s", node_info_table[i].has_route ? "OK" : "NR"); + add(""); + SEND_STRING(&s->sout, buf); + reset_buf(); + } } - add("%d", - (clock_time() - node_info_table[i].last_seen) / CLOCK_SECOND); - add("%s", node_info_table[i].has_route ? "OK" : "NR"); - add(""); - SEND_STRING(&s->sout, buf); - reset_buf(); } } add("
"); @@ -287,42 +295,50 @@ PT_THREAD(generate_sensors_tree(struct httpd_state *s)) #endif for(i = 0; i < UIP_DS6_ROUTE_NB; i++) { if(node_info_table[i].isused) { - if(! uip_is_addr_unspecified(&node_info_table[i].ip_parent)) { + + uip_ds6_route_t * ds6_r = uip_ds6_route_lookup(&node_info_table[i].ipaddr); + if(ds6_r){ + rpl_dag_t * dag = (rpl_dag_t*)ds6_r->state.dag; + if(dag->instance->instance_id == rpl_current_instance){ + + if(! uip_is_addr_unspecified(&node_info_table[i].ip_parent)) { #if CETIC_NODE_CONFIG_HAS_NAME - node_config_t * node_config = node_config_find_by_ip(&node_info_table[i].ipaddr); - node_config_t * parent_node_config = node_config_find_by_ip(&node_info_table[i].ip_parent); - if ( node_config ) { - if ( parent_node_config ) { - add("%%22%s%%22->%%22%s%%22;", - node_config_get_name(node_config), - node_config_get_name(parent_node_config)); - } else { - add("%%22%s%%22->%%22%04hx%%22;", - node_config_get_name(node_config), - (node_info_table[i].ip_parent.u8[14] << 8) + - node_info_table[i].ip_parent.u8[15]); - } - } else { - if (parent_node_config) { - add("%%22%04hx%%22->%%22%s%%22;", - (node_info_table[i].ipaddr.u8[14] << 8) + - node_info_table[i].ipaddr.u8[15], - node_config_get_name(parent_node_config)); - } else { - add("%%22%04hx%%22->%%22%04hx%%22;", - (node_info_table[i].ipaddr.u8[14] << 8) + - node_info_table[i].ipaddr.u8[15], - (node_info_table[i].ip_parent.u8[14] << 8) + - node_info_table[i].ip_parent.u8[15]); - } - } + node_config_t * node_config = node_config_find_by_ip(&node_info_table[i].ipaddr); + node_config_t * parent_node_config = node_config_find_by_ip(&node_info_table[i].ip_parent); + if ( node_config ) { + if ( parent_node_config ) { + add("%%22%s%%22->%%22%s%%22;", + node_config_get_name(node_config), + node_config_get_name(parent_node_config)); + } else { + add("%%22%s%%22->%%22%04hx%%22;", + node_config_get_name(node_config), + (node_info_table[i].ip_parent.u8[14] << 8) + + node_info_table[i].ip_parent.u8[15]); + } + } else { + if (parent_node_config) { + add("%%22%04hx%%22->%%22%s%%22;", + (node_info_table[i].ipaddr.u8[14] << 8) + + node_info_table[i].ipaddr.u8[15], + node_config_get_name(parent_node_config)); + } else { + add("%%22%04hx%%22->%%22%04hx%%22;", + (node_info_table[i].ipaddr.u8[14] << 8) + + node_info_table[i].ipaddr.u8[15], + (node_info_table[i].ip_parent.u8[14] << 8) + + node_info_table[i].ip_parent.u8[15]); + } + } #else - add("%%22%04hx%%22->%%22%04hx%%22;", - (node_info_table[i].ipaddr.u8[14] << 8) + - node_info_table[i].ipaddr.u8[15], - (node_info_table[i].ip_parent.u8[14] << 8) + - node_info_table[i].ip_parent.u8[15]); + add("%%22%04hx%%22->%%22%04hx%%22;", + (node_info_table[i].ipaddr.u8[14] << 8) + + node_info_table[i].ipaddr.u8[15], + (node_info_table[i].ip_parent.u8[14] << 8) + + node_info_table[i].ip_parent.u8[15]); #endif + } + } } } } @@ -343,24 +359,32 @@ PT_THREAD(generate_sensors_prr(struct httpd_state *s)) add("['Sensor', 'IP', 'PRR Up', 'PRR Down'],"); for(i = 0; i < UIP_DS6_ROUTE_NB; i++) { if(node_info_table[i].isused && node_info_table[i].messages_sent > 0 && node_info_table[i].replies_sent > 0) { - float prr_up = 100.0 * (node_info_table[i].messages_sent - node_info_table[i].up_messages_lost)/node_info_table[i].messages_sent; - float prr_down = 100.0 * (node_info_table[i].replies_sent - node_info_table[i].down_messages_lost)/node_info_table[i].replies_sent; + + uip_ds6_route_t * ds6_r = uip_ds6_route_lookup(&node_info_table[i].ipaddr); + if(ds6_r){ + rpl_dag_t * dag = (rpl_dag_t*)ds6_r->state.dag; + if(dag->instance->instance_id == rpl_current_instance){ + + float prr_up = 100.0 * (node_info_table[i].messages_sent - node_info_table[i].up_messages_lost)/node_info_table[i].messages_sent; + float prr_down = 100.0 * (node_info_table[i].replies_sent - node_info_table[i].down_messages_lost)/node_info_table[i].replies_sent; #if CETIC_NODE_CONFIG_HAS_NAME - if (node_config_loaded) { - node_config_t * node_config = node_config_find_by_ip(&node_info_table[i].ipaddr); - add("[\"%s\",", node_config_get_name(node_config)); - } else + if (node_config_loaded) { + node_config_t * node_config = node_config_find_by_ip(&node_info_table[i].ipaddr); + add("[\"%s\",", node_config_get_name(node_config)); + } else #endif - { - add("[\""); - ipaddr_add(&node_info_table[i].ipaddr); - add("\","); + { + add("[\""); + ipaddr_add(&node_info_table[i].ipaddr); + add("\","); + } + add("\""); + ipaddr_add(&node_info_table[i].ipaddr); + add("\",%.1f,%.1f],", prr_up, prr_down); + SEND_STRING(&s->sout, buf); + reset_buf(); + } } - add("\""); - ipaddr_add(&node_info_table[i].ipaddr); - add("\",%.1f,%.1f],", prr_up, prr_down); - SEND_STRING(&s->sout, buf); - reset_buf(); } } add("]);var options={vAxis:{minValue: 0,maxValue: 100},legend:{position: \"none\"}};"); @@ -382,22 +406,29 @@ PT_THREAD(generate_sensors_parent_switch(struct httpd_state *s)) add("['Sensor', 'IP', 'Parent switch'],"); for(i = 0; i < UIP_DS6_ROUTE_NB; i++) { if(node_info_table[i].isused && node_info_table[i].messages_sent > 0) { + + uip_ds6_route_t * ds6_r = uip_ds6_route_lookup(&node_info_table[i].ipaddr); + if(ds6_r){ + rpl_dag_t * dag = (rpl_dag_t*)ds6_r->state.dag; + if(dag->instance->instance_id == rpl_current_instance){ #if CETIC_NODE_CONFIG_HAS_NAME - if (node_config_loaded) { - node_config_t * node_config = node_config_find_by_ip(&node_info_table[i].ipaddr); - add("[\"%s\",", node_config_get_name(node_config)); - } else + if (node_config_loaded) { + node_config_t * node_config = node_config_find_by_ip(&node_info_table[i].ipaddr); + add("[\"%s\",", node_config_get_name(node_config)); + } else #endif - { - add("[\""); - ipaddr_add(&node_info_table[i].ipaddr); - add("\","); + { + add("[\""); + ipaddr_add(&node_info_table[i].ipaddr); + add("\","); + } + add("\""); + ipaddr_add(&node_info_table[i].ipaddr); + add("\",%d],", node_info_table[i].parent_switch); + SEND_STRING(&s->sout, buf); + reset_buf(); + } } - add("\""); - ipaddr_add(&node_info_table[i].ipaddr); - add("\",%d],", node_info_table[i].parent_switch); - SEND_STRING(&s->sout, buf); - reset_buf(); } } add("]);var options={vAxis:{minValue: 0},legend:{position: \"none\"}};"); @@ -419,22 +450,28 @@ PT_THREAD(generate_sensors_hop_count(struct httpd_state *s)) add("['Sensor', 'IP', 'Hop count'],"); for(i = 0; i < UIP_DS6_ROUTE_NB; i++) { if(node_info_table[i].isused && node_info_table[i].messages_sent > 0) { + uip_ds6_route_t * ds6_r = uip_ds6_route_lookup(&node_info_table[i].ipaddr); + if(ds6_r){ + rpl_dag_t * dag = (rpl_dag_t*)ds6_r->state.dag; + if(dag->instance->instance_id == rpl_current_instance){ #if CETIC_NODE_CONFIG_HAS_NAME - if (node_config_loaded) { - node_config_t * node_config = node_config_find_by_ip(&node_info_table[i].ipaddr); - add("[\"%s\",", node_config_get_name(node_config)); - } else + if (node_config_loaded) { + node_config_t * node_config = node_config_find_by_ip(&node_info_table[i].ipaddr); + add("[\"%s\",", node_config_get_name(node_config)); + } else #endif - { - add("[\""); - ipaddr_add(&node_info_table[i].ipaddr); - add("\","); + { + add("[\""); + ipaddr_add(&node_info_table[i].ipaddr); + add("\","); + } + add("\""); + ipaddr_add(&node_info_table[i].ipaddr); + add("\",%d],", node_info_table[i].hop_count); + SEND_STRING(&s->sout, buf); + reset_buf(); + } } - add("\""); - ipaddr_add(&node_info_table[i].ipaddr); - add("\",%d],", node_info_table[i].hop_count); - SEND_STRING(&s->sout, buf); - reset_buf(); } } add("]);var options={vAxis:{minValue: 0},legend:{position: \"none\"}};"); From 715eff37815f19ca71de82ccbe09f0aa85b1a5a3 Mon Sep 17 00:00:00 2001 From: Manu Date: Tue, 31 May 2016 12:53:36 +0200 Subject: [PATCH 37/37] Case of 0 RPL instance and lookup before loop in rio --- examples/6lbr/6lbr/rio.c | 28 +++++++++++-------- examples/6lbr/apps/6lbr-webserver/httpd-cgi.c | 25 +++++++++++------ examples/6lbr/cetic-6lbr.c | 21 ++++++++++---- examples/6lbr/platform/native/native-config.c | 2 +- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/examples/6lbr/6lbr/rio.c b/examples/6lbr/6lbr/rio.c index 43b2a43968..2dc6cd091f 100644 --- a/examples/6lbr/6lbr/rio.c +++ b/examples/6lbr/6lbr/rio.c @@ -59,18 +59,22 @@ uip_ds6_route_info_add(uip_ipaddr_t * ipaddr, uint8_t ipaddrlen, if(uip_ds6_list_loop ((uip_ds6_element_t *) uip_ds6_route_info_list, UIP_DS6_ROUTE_INFO_NB, sizeof(uip_ds6_route_info_t), ipaddr, ipaddrlen, - (uip_ds6_element_t **) & locrtinfo) == FREESPACE) { - locrtinfo->isused = 1; - uip_ipaddr_copy(&locrtinfo->ipaddr, ipaddr); - locrtinfo->length = ipaddrlen; - locrtinfo->flags = flags; - locrtinfo->lifetime = rlifetime; - LOG6LBR_6ADDR(DEBUG, &locrtinfo->ipaddr, "Adding route information: length=%u, flags=%x, route lifetime=%lu, dest=", - ipaddrlen, flags, rlifetime); - return locrtinfo; - } else { - LOG6LBR_ERROR("No more space in route information list\n"); - } + (uip_ds6_element_t **) & locrtinfo) != FOUND) + if(uip_ds6_list_loop + ((uip_ds6_element_t *) uip_ds6_route_info_list, UIP_DS6_ROUTE_INFO_NB, + sizeof(uip_ds6_route_info_t), ipaddr, ipaddrlen, + (uip_ds6_element_t **) & locrtinfo) == FREESPACE) { + locrtinfo->isused = 1; + uip_ipaddr_copy(&locrtinfo->ipaddr, ipaddr); + locrtinfo->length = ipaddrlen; + locrtinfo->flags = flags; + locrtinfo->lifetime = rlifetime; + LOG6LBR_6ADDR(DEBUG, &locrtinfo->ipaddr, "Adding route information: length=%u, flags=%x, route lifetime=%lu, dest=", + ipaddrlen, flags, rlifetime); + return locrtinfo; + } else { + LOG6LBR_ERROR("No more space in route information list\n"); + } return NULL; } diff --git a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c index 8c4ed8a59d..98ad8d31ea 100644 --- a/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c +++ b/examples/6lbr/apps/6lbr-webserver/httpd-cgi.c @@ -50,13 +50,23 @@ static httpd_cgi_command_t *commands = NULL; void httpd_instances_add(void *dgroup, uint16_t nb) { - httpd_group_t *group = (httpd_group_t *)malloc(2 + nb * sizeof(httpd_group_t)); + httpd_group_t *group; + if(nb > 0){ + group = (httpd_group_t *)malloc(2 + nb * sizeof(httpd_group_t)); + + group[0].title = (char*)malloc(2*sizeof(char)); + sprintf(group[0].title, "%c", '-'); + group[0].next = &group[1]; + group[1].title = (char*)malloc(2*sizeof(char)); + sprintf(group[1].title, "%c", '+'); + } + else { + group = (httpd_group_t *)malloc(sizeof(httpd_group_t)); - group[0].title = (char*)malloc(2*sizeof(char)); - sprintf(group[0].title, "%c", '-'); - group[0].next = &group[1]; - group[1].title = (char*)malloc(2*sizeof(char)); - sprintf(group[1].title, "%c", '+'); + group[0].title = (char*)malloc(2*sizeof(char)); + sprintf(group[0].title, "%c", '+'); + group[0].next = NULL; + } if(nb > 0){ group[1].next = &group[2]; @@ -74,9 +84,6 @@ httpd_instances_add(void *dgroup, uint16_t nb) group[nb+1].title = instance; group[nb+1].next = NULL; } - else { - group[1].next = NULL; - } instances = &group[0]; } diff --git a/examples/6lbr/cetic-6lbr.c b/examples/6lbr/cetic-6lbr.c index 8d6998b332..ef9c91c76c 100644 --- a/examples/6lbr/cetic-6lbr.c +++ b/examples/6lbr/cetic-6lbr.c @@ -511,9 +511,15 @@ PROCESS_THREAD(cetic_6lbr_process, ev, data) #endif packet_filter_init(); - int i; - for(i=0;i 0){ + int i; + for(i=0;i 0){ + int i; + for(i=0;i