Merge branch 'develop' into contrib/nightly-runs

This commit is contained in:
George Oikonomou 2018-09-10 09:10:02 +01:00 committed by GitHub
commit 83dd2ff10e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 1326 additions and 739 deletions

3
.gitmodules vendored
View File

@ -19,3 +19,6 @@
[submodule "tests/18-coap-lwm2m/example-lwm2m-standalone"]
path = tests/18-coap-lwm2m/example-lwm2m-standalone
url = https://github.com/contiki-ng/example-lwm2m-standalone.git
[submodule "tools/motelist"]
path = tools/motelist
url = https://github.com/contiki-ng/motelist

View File

@ -1,41 +1,30 @@
Contiki-NG 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.
Copyright (c) (Year), (Name of copyright holder)
All rights reserved.
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:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
```
/*
* 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.
*/
```
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.

View File

@ -9,7 +9,10 @@
Contiki-NG is an open-source, cross-platform operating system for Next-Generation IoT devices. It focuses on dependable (secure and reliable) low-power communication and standard protocols, such as IPv6/6LoWPAN, 6TiSCH, RPL, and CoAP. Contiki-NG comes with extensive documentation, tutorials, a roadmap, release cycle, and well-defined development flow for smooth integration of community contributions.
Unless excplicitly stated otherwise, Contiki-NG sources are distributed under
the terms of the [3-clause BSD license](LICENSE.md).
the terms of the [3-clause BSD license](LICENSE.md). 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.
Contiki-NG started as a fork of the Contiki OS and retains some of its original features.

View File

@ -9,10 +9,13 @@ SIZE = arm-none-eabi-size
SREC_CAT = srec_cat
CFLAGS += -mthumb -mabi=aapcs -mlittle-endian
CFLAGS += -Werror -Wall
CFLAGS += -Wall
CFLAGS += -std=c99
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fshort-enums -fomit-frame-pointer -fno-builtin
ifeq ($(WERROR),1)
CFLAGS += -Werror
endif
LDFLAGS += -mthumb -mlittle-endian

View File

@ -1,6 +1,12 @@
CPU_ABS_PATH = arch/cpu/cc26xx-cc13xx
TI_XXWARE = $(CONTIKI_CPU)/$(TI_XXWARE_PATH)
ifeq (,$(wildcard $(TI_XXWARE)))
$(warning $(TI_XXWARE) does not exist.)
$(warning Did you run 'git submodule update --init' ?)
$(error "")
endif
### cc26xxware sources under driverlib will be added to the MODULES list
TI_XXWARE_SRC = $(CPU_ABS_PATH)/$(TI_XXWARE_PATH)/driverlib

View File

@ -71,7 +71,9 @@
#endif /* CPU_FAMILY_CC13XX */
#if CC13XX_CONF_PROP_MODE
#ifndef NETSTACK_CONF_RADIO
#define NETSTACK_CONF_RADIO prop_mode_driver
#endif /* NETSTACK_CONF_RADIO */
/* Channels count from 0 upwards in IEEE 802.15.4g */
#ifndef IEEE802154_CONF_DEFAULT_CHANNEL

View File

@ -78,6 +78,19 @@ typedef unsigned int uip_stats_t;
#define NETSTACK_CONF_LINUXRADIO_DEV "wpan0"
/* configure network size and density */
#ifndef NETSTACK_MAX_ROUTE_ENTRIES
#define NETSTACK_MAX_ROUTE_ENTRIES 300
#endif /* NETSTACK_MAX_ROUTE_ENTRIES */
#ifndef NBR_TABLE_CONF_MAX_NEIGHBORS
#define NBR_TABLE_CONF_MAX_NEIGHBORS 300
#endif /* NBR_TABLE_CONF_MAX_NEIGHBORS */
/* configure queues */
#ifndef QUEUEBUF_CONF_NUM
#define QUEUEBUF_CONF_NUM 64
#endif /* QUEUEBUF_CONF_NUM */
#define UIP_CONF_IPV6_QUEUE_PKT 1
#define UIP_ARCH_IPCHKSUM 1

View File

@ -108,7 +108,7 @@ print_cell_list(const uint8_t *cell_list, uint16_t cell_list_len)
uint16_t i;
sf_simple_cell_t cell;
for(i = 0; i < (cell_list_len / sizeof(cell)); i++) {
for(i = 0; i < cell_list_len; i += sizeof(cell)) {
read_cell(&cell_list[i], &cell);
PRINTF("%u ", cell.timeslot_offset);
}
@ -132,7 +132,7 @@ add_links_to_schedule(const linkaddr_t *peer_addr, uint8_t link_option,
return;
}
for(i = 0; i < (cell_list_len / sizeof(cell)); i++) {
for(i = 0; i < cell_list_len; i += sizeof(cell)) {
read_cell(&cell_list[i], &cell);
if(cell.timeslot_offset == 0xffff) {
continue;
@ -166,7 +166,7 @@ remove_links_to_schedule(const uint8_t *cell_list, uint16_t cell_list_len)
return;
}
for(i = 0; i < (cell_list_len / sizeof(cell)); i++) {
for(i = 0; i < cell_list_len; i += sizeof(cell)) {
read_cell(&cell_list[i], &cell);
if(cell.timeslot_offset == 0xffff) {
continue;
@ -335,7 +335,7 @@ delete_req_input(const uint8_t *body, uint16_t body_len,
if(num_cells > 0 && cell_list_len > 0) {
/* ensure before delete */
for(i = 0, removed_link = 0; i < (cell_list_len / sizeof(cell)); i++) {
for(i = 0, removed_link = 0; i < cell_list_len; i += sizeof(cell)) {
read_cell(&cell_list[i], &cell);
if(tsch_schedule_get_link_by_timeslot(slotframe,
cell.timeslot_offset) != NULL) {

View File

@ -64,7 +64,7 @@
#define LWM2M_QUEUE_MODE_CONF_INCLUDE_DYNAMIC_ADAPTATION 1
#define LWM2M_QUEUE_MODE_CONF_DEFAULT_CLIENT_AWAKE_TIME 2000
#define LWM2M_QUEUE_MODE_CONF_DEFAULT_CLIENT_SLEEP_TIME 10000
#define LWM2M_QUEUE_MODE_CONF_DEFAULT_DYNAMIC_ADAPTATION_FLAG 1
#define LWM2M_QUEUE_MODE_OBJECT_CONF_ENABLED 0 */
#define LWM2M_QUEUE_MODE_CONF_DEFAULT_DYNAMIC_ADAPTATION_FLAG 0
#define LWM2M_QUEUE_MODE_OBJECT_CONF_ENABLED 1 */
#endif /* PROJECT_CONF_H_ */

View File

@ -493,6 +493,7 @@ publish(void)
int len;
int remaining = APP_BUFFER_SIZE;
int i;
char def_rt_str[64];
seq_nr_value++;
@ -519,7 +520,6 @@ publish(void)
buf_ptr += len;
/* Put our Default route's string representation in a buffer */
char def_rt_str[64];
memset(def_rt_str, 0, sizeof(def_rt_str));
ipaddr_sprintf(def_rt_str, sizeof(def_rt_str), uip_ds6_defrt_choose());

View File

@ -60,37 +60,36 @@
void
coap_blocking_request_callback(void *callback_data, coap_message_t *response)
{
coap_request_state_t *state = (coap_request_state_t *)callback_data;
coap_blocking_request_state_t *blocking_state = (coap_blocking_request_state_t *)callback_data;
state->response = response;
process_poll(state->process);
blocking_state->state.response = response;
process_poll(blocking_state->process);
}
/*---------------------------------------------------------------------------*/
PT_THREAD(coap_blocking_request
(coap_request_state_t *state, process_event_t ev,
(coap_blocking_request_state_t *blocking_state, process_event_t ev,
coap_endpoint_t *remote_ep,
coap_message_t *request,
coap_blocking_response_handler_t request_callback))
{
PT_BEGIN(&state->pt);
/* Before PT_BEGIN in order to not be a local variable in the PT_Thread and maintain it */
coap_request_state_t *state = &blocking_state->state;
static uint32_t res_block;
static uint8_t more;
static uint8_t block_error;
PT_BEGIN(&blocking_state->pt);
state->block_num = 0;
state->response = NULL;
state->process = PROCESS_CURRENT();
blocking_state->process = PROCESS_CURRENT();
more = 0;
res_block = 0;
block_error = 0;
state->more = 0;
state->res_block = 0;
state->block_error = 0;
do {
request->mid = coap_get_mid();
if((state->transaction = coap_new_transaction(request->mid, remote_ep))) {
state->transaction->callback = coap_blocking_request_callback;
state->transaction->callback_data = state;
state->transaction->callback_data = blocking_state;
if(state->block_num > 0) {
coap_set_header_block2(request, state->block_num, 0,
@ -104,33 +103,46 @@ PT_THREAD(coap_blocking_request
coap_send_transaction(state->transaction);
LOG_DBG("Requested #%"PRIu32" (MID %u)\n", state->block_num, request->mid);
PT_YIELD_UNTIL(&state->pt, ev == PROCESS_EVENT_POLL);
PT_YIELD_UNTIL(&blocking_state->pt, ev == PROCESS_EVENT_POLL);
if(!state->response) {
LOG_WARN("Server not responding\n");
PT_EXIT(&state->pt);
state->status = COAP_REQUEST_STATUS_TIMEOUT;
PT_EXIT(&blocking_state->pt);
}
coap_get_header_block2(state->response, &res_block, &more, NULL, NULL);
coap_get_header_block2(state->response, &state->res_block, &state->more, NULL, NULL);
LOG_DBG("Received #%"PRIu32"%s (%u bytes)\n", res_block, more ? "+" : "",
LOG_DBG("Received #%"PRIu32"%s (%u bytes)\n", state->res_block, state->more ? "+" : "",
state->response->payload_len);
if(state->more) {
state->status = COAP_REQUEST_STATUS_MORE;
} else {
state->status = COAP_REQUEST_STATUS_RESPONSE;
}
if(res_block == state->block_num) {
if(state->res_block == state->block_num) {
request_callback(state->response);
++(state->block_num);
} else {
LOG_WARN("WRONG BLOCK %"PRIu32"/%"PRIu32"\n",
res_block, state->block_num);
++block_error;
state->res_block, state->block_num);
++(state->block_error);
}
} else {
LOG_WARN("Could not allocate transaction buffer");
PT_EXIT(&state->pt);
PT_EXIT(&blocking_state->pt);
}
} while(more && block_error < COAP_MAX_ATTEMPTS);
} while(state->more && (state->block_error) < COAP_MAX_ATTEMPTS);
PT_END(&state->pt);
if((state->block_error) >= COAP_MAX_ATTEMPTS) {
/* failure - now we give up */
state->status = COAP_REQUEST_STATUS_BLOCK_ERROR;
} else {
/* No more blocks, request finished */
state->status = COAP_REQUEST_STATUS_FINISHED;
}
PT_END(&blocking_state->pt);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -39,31 +39,30 @@
#include "sys/pt.h"
#include "coap-transactions.h"
#include "coap-request-state.h"
/*---------------------------------------------------------------------------*/
/*- Client Part -------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
typedef struct coap_request_state {
typedef struct coap_blocking_request_state {
coap_request_state_t state;
struct pt pt;
struct process *process;
coap_transaction_t *transaction;
coap_message_t *response;
uint32_t block_num;
} coap_request_state_t;
} coap_blocking_request_state_t;
typedef void (* coap_blocking_response_handler_t)(coap_message_t *response);
PT_THREAD(coap_blocking_request
(coap_request_state_t *state, process_event_t ev,
(coap_blocking_request_state_t *blocking_state, process_event_t ev,
coap_endpoint_t *remote,
coap_message_t *request,
coap_blocking_response_handler_t request_callback));
#define COAP_BLOCKING_REQUEST(server_endpoint, request, chunk_handler) \
{ \
static coap_request_state_t request_state; \
PT_SPAWN(process_pt, &request_state.pt, \
coap_blocking_request(&request_state, ev, \
static coap_blocking_request_state_t blocking_state; \
PT_SPAWN(process_pt, &blocking_state.pt, \
coap_blocking_request(&blocking_state, ev, \
server_endpoint, \
request, chunk_handler) \
); \

View File

@ -54,19 +54,13 @@
#define LOG_MODULE "coap"
#define LOG_LEVEL LOG_LEVEL_COAP
/* These should go into the state struct so that we can have multiple
requests */
static uint32_t res_block;
static uint8_t more;
static uint8_t block_error;
static void coap_request_callback(void *callback_data, coap_message_t *response);
/*---------------------------------------------------------------------------*/
static int
progress_request(coap_request_state_t *state) {
progress_request(coap_callback_request_state_t *callback_state) {
coap_request_state_t *state = &callback_state->state;
coap_message_t *request = state->request;
request->mid = coap_get_mid();
if((state->transaction =
@ -93,7 +87,9 @@ progress_request(coap_request_state_t *state) {
static void
coap_request_callback(void *callback_data, coap_message_t *response)
{
coap_request_state_t *state = (coap_request_state_t *)callback_data;
coap_callback_request_state_t *callback_state = (coap_callback_request_state_t*)callback_data;
coap_request_state_t *state = &callback_state->state;
uint32_t res_block1;
state->response = response;
@ -102,58 +98,70 @@ coap_request_callback(void *callback_data, coap_message_t *response)
if(!state->response) {
LOG_WARN("Server not responding giving up...\n");
state->callback(state);
state->status = COAP_REQUEST_STATUS_TIMEOUT;
callback_state->callback(callback_state);
return;
}
/* Got a response */
coap_get_header_block2(state->response, &res_block, &more, NULL, NULL);
coap_get_header_block2(state->response, &state->res_block, &state->more, NULL, NULL);
coap_get_header_block1(state->response, &res_block1, NULL, NULL, NULL);
LOG_DBG("Received #%lu%s B1:%lu (%u bytes)\n",
(unsigned long)res_block, (unsigned)more ? "+" : "",
(unsigned long)state->res_block, (unsigned)state->more ? "+" : "",
(unsigned long)res_block1,
state->response->payload_len);
if(res_block == state->block_num) {
if(state->res_block == state->block_num) {
/* Call the callback function as we have more data */
state->callback(state);
if(state->more) {
state->status = COAP_REQUEST_STATUS_MORE;
} else {
state->status = COAP_REQUEST_STATUS_RESPONSE;
}
callback_state->callback(callback_state);
/* this is only for counting BLOCK2 blocks.*/
++(state->block_num);
} else {
LOG_WARN("WRONG BLOCK %"PRIu32"/%"PRIu32"\n", res_block, state->block_num);
++block_error;
LOG_WARN("WRONG BLOCK %"PRIu32"/%"PRIu32"\n", state->res_block, state->block_num);
++(state->block_error);
}
if(more && block_error < COAP_MAX_ATTEMPTS) {
progress_request(state);
if(state->more) {
if((state->block_error) < COAP_MAX_ATTEMPTS) {
progress_request(callback_state);
} else {
/* failure - now we give up and notify the callback */
state->status = COAP_REQUEST_STATUS_BLOCK_ERROR;
callback_state->callback(callback_state);
}
} else {
/* failure - now we give up and notify the callback */
/* No more blocks, finish and notify the callback */
state->status = COAP_REQUEST_STATUS_FINISHED;
state->response = NULL;
state->callback(state);
callback_state->callback(callback_state);
}
}
/*---------------------------------------------------------------------------*/
int
coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
coap_send_request(coap_callback_request_state_t *callback_state, coap_endpoint_t *endpoint,
coap_message_t *request,
void (*callback)(coap_request_state_t *state))
void (*callback)(coap_callback_request_state_t *callback_state))
{
/* can we have these variables shared between multiple requests? */
/* ripped from blocking request */
more = 0;
res_block = 0;
block_error = 0;
coap_request_state_t *state = &callback_state->state;
state->more = 0;
state->res_block = 0;
state->block_error = 0;
state->block_num = 0;
state->response = NULL;
state->request = request;
state->remote_endpoint = endpoint;
state->callback = callback;
callback_state->callback = callback;
return progress_request(state);
return progress_request(callback_state);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -47,35 +47,30 @@
#include "coap-engine.h"
#include "coap-transactions.h"
#include "coap-request-state.h"
#include "sys/cc.h"
/*---------------------------------------------------------------------------*/
/*- Client Part -------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
typedef struct coap_request_state coap_request_state_t;
typedef struct coap_callback_request_state coap_callback_request_state_t;
struct coap_request_state {
coap_transaction_t *transaction;
coap_message_t *response;
coap_message_t *request;
coap_endpoint_t *remote_endpoint;
uint32_t block_num;
void *user_data;
coap_timer_t coap_timer;
void (*callback)(coap_request_state_t *state);
struct coap_callback_request_state {
coap_request_state_t state;
void (*callback)(coap_callback_request_state_t *state);
};
/**
* \brief Send a CoAP request to a remote endpoint
* \param state The state to handle the CoAP request
* \param callback_state The callback state to handle the CoAP request
* \param endpoint The destination endpoint
* \param request The request to be sent
* \param callback callback to execute when the response arrives or the timeout expires
* \return 1 if there is a transaction available to send, 0 otherwise
*/
int coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
int coap_send_request(coap_callback_request_state_t *callback_state, coap_endpoint_t *endpoint,
coap_message_t *request,
void (*callback)(coap_request_state_t *state));
void (*callback)(coap_callback_request_state_t *callback_state));
#endif /* COAP_CALLBACK_API_H_ */
/** @} */

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2018, RISE SICS AB.
* 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 HOLDER 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.
*/
/**
* \addtogroup coap
* @{
*/
/**
* \file
* Common request state for all the APIs
* \author
* Carlos Gonzalo Peces <carlosgp143@gmail.com>
*/
#ifndef COAP_REQUEST_STATE_H_
#define COAP_REQUEST_STATE_H_
typedef enum {
COAP_REQUEST_STATUS_RESPONSE, /* Response received and no more blocks */
COAP_REQUEST_STATUS_MORE, /* Response received and there are more blocks */
COAP_REQUEST_STATUS_FINISHED, /* Request finished */
COAP_REQUEST_STATUS_TIMEOUT, /* Request Timeout after all retransmissions */
COAP_REQUEST_STATUS_BLOCK_ERROR /* Blocks in wrong order */
} coap_request_status_t;
typedef struct coap_request_state {
coap_transaction_t *transaction;
coap_message_t *response;
coap_message_t *request;
coap_endpoint_t *remote_endpoint;
uint32_t block_num;
uint32_t res_block;
uint8_t more;
uint8_t block_error;
void *user_data;
coap_request_status_t status;
} coap_request_state_t;
#endif /* COAP_REQUEST_STATE_H_ */
/** @} */

View File

@ -98,12 +98,11 @@ coap_send_transaction(coap_transaction_t *t)
{
LOG_DBG("Sending transaction %u\n", t->mid);
coap_sendto(&t->endpoint, t->message, t->message_len);
if(COAP_TYPE_CON ==
((COAP_HEADER_TYPE_MASK & t->message[0]) >> COAP_HEADER_TYPE_POSITION)) {
if(t->retrans_counter < COAP_MAX_RETRANSMIT) {
if(t->retrans_counter <= COAP_MAX_RETRANSMIT) {
/* not timed out yet */
coap_sendto(&t->endpoint, t->message, t->message_len);
LOG_DBG("Keeping transaction %u\n", t->mid);
if(t->retrans_counter == 0) {
@ -138,6 +137,7 @@ coap_send_transaction(coap_transaction_t *t)
}
}
} else {
coap_sendto(&t->endpoint, t->message, t->message_len);
coap_clear_transaction(t);
}
}

View File

@ -49,6 +49,7 @@
#include "contiki.h"
#include "net/ipv6/uip-udp-packet.h"
#include "net/ipv6/uiplib.h"
#include "net/routing/routing.h"
#include "coap.h"
#include "coap-engine.h"
#include "coap-endpoint.h"
@ -58,10 +59,6 @@
#include "coap-keystore.h"
#include "coap-keystore-simple.h"
#if UIP_CONF_IPV6_RPL
#include "rpl.h"
#endif /* UIP_CONF_IPV6_RPL */
/* Log configuration */
#include "coap-log.h"
#define LOG_MODULE "coap-uip"
@ -260,13 +257,12 @@ coap_endpoint_is_secure(const coap_endpoint_t *ep)
int
coap_endpoint_is_connected(const coap_endpoint_t *ep)
{
#if UIP_CONF_IPV6_RPL
#ifndef CONTIKI_TARGET_NATIVE
if(rpl_get_any_dag() == NULL) {
if(!uip_is_addr_linklocal(&ep->ipaddr)
&& NETSTACK_ROUTING.node_is_reachable() == 0) {
return 0;
}
#endif
#endif /* UIP_CONF_IPV6_RPL */
#ifdef WITH_DTLS
if(ep != NULL && ep->secure != 0) {

View File

@ -1017,7 +1017,8 @@ newdata(void)
namemapptr->state = STATE_DONE;
#if RESOLV_SUPPORTS_RECORD_EXPIRATION
namemapptr->expiration = ans->ttl[1] + (ans->ttl[0] << 8);
namemapptr->expiration = (uint32_t) uip_ntohs(ans->ttl[0]) << 16 |
(uint32_t) uip_ntohs(ans->ttl[1]);
namemapptr->expiration += clock_seconds();
#endif /* RESOLV_SUPPORTS_RECORD_EXPIRATION */

View File

@ -253,10 +253,6 @@ uip_icmp6_error_output(uint8_t type, uint8_t code, uint32_t param) {
void
uip_icmp6_send(const uip_ipaddr_t *dest, int type, int code, int payload_len)
{
LOG_INFO("Sending ICMPv6 packet to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO_(", type %u, code %u, len %u\n", type, code, payload_len);
UIP_IP_BUF->vtc = 0x60;
UIP_IP_BUF->tcflow = 0;
UIP_IP_BUF->flow = 0;
@ -279,6 +275,10 @@ uip_icmp6_send(const uip_ipaddr_t *dest, int type, int code, int payload_len)
UIP_STAT(++uip_stat.icmp.sent);
UIP_STAT(++uip_stat.ip.sent);
LOG_INFO("Sending ICMPv6 packet to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO_(", type %u, code %u, len %u\n", type, code, payload_len);
tcpip_ipv6_output();
}
/*---------------------------------------------------------------------------*/

View File

@ -109,7 +109,9 @@ timesync_learn_drift_ticks(uint32_t time_delta_asn, int32_t drift_ticks)
TSCH_LOG_ADD(tsch_log_message,
snprintf(log->message, sizeof(log->message),
"drift %ld", tsch_adaptive_timesync_get_drift_ppm()));
"drift %ld ppm (min/max delta seen: %"PRId32"/%"PRId32")",
tsch_adaptive_timesync_get_drift_ppm(),
min_drift_seen, max_drift_seen));
}
/*---------------------------------------------------------------------------*/
/* Either reset or update the neighbor's drift */
@ -136,6 +138,8 @@ tsch_timesync_update(struct tsch_neighbor *n, uint16_t time_delta_asn, int32_t d
compensated_ticks += drift_correction;
}
}
min_drift_seen = MIN(drift_correction, min_drift_seen);
max_drift_seen = MAX(drift_correction, max_drift_seen);
}
/*---------------------------------------------------------------------------*/
/* Error-accumulation free compensation algorithm */

View File

@ -171,6 +171,45 @@ tsch_schedule_get_link_by_handle(uint16_t handle)
return NULL;
}
/*---------------------------------------------------------------------------*/
static const char *
print_link_options(uint16_t link_options)
{
static char buffer[20];
unsigned length;
buffer[0] = '\0';
if(link_options & LINK_OPTION_TX) {
strcat(buffer, "Tx|");
}
if(link_options & LINK_OPTION_RX) {
strcat(buffer, "Rx|");
}
if(link_options & LINK_OPTION_SHARED) {
strcat(buffer, "Sh|");
}
length = strlen(buffer);
if(length > 0) {
buffer[length - 1] = '\0';
}
return buffer;
}
/*---------------------------------------------------------------------------*/
static const char *
print_link_type(uint16_t link_type)
{
switch(link_type) {
case LINK_TYPE_NORMAL:
return "NORMAL";
case LINK_TYPE_ADVERTISING:
return "ADV";
case LINK_TYPE_ADVERTISING_ONLY:
return "ADV_ONLY";
default:
return "?";
}
}
/*---------------------------------------------------------------------------*/
/* Adds a link to a slotframe, return a pointer to it (NULL if failure) */
struct tsch_link *
tsch_schedule_add_link(struct tsch_slotframe *slotframe,
@ -218,8 +257,10 @@ tsch_schedule_add_link(struct tsch_slotframe *slotframe,
}
linkaddr_copy(&l->addr, address);
LOG_INFO("add_link %u %u %u %u %u ",
slotframe->handle, link_options, link_type, timeslot, channel_offset);
LOG_INFO("add_link sf=%u opt=%s type=%s ts=%u ch=%u addr=",
slotframe->handle,
print_link_options(link_options),
print_link_type(link_type), timeslot, channel_offset);
LOG_INFO_LLADDR(address);
LOG_INFO_("\n");
/* Release the lock before we update the neighbor (will take the lock) */
@ -260,8 +301,10 @@ tsch_schedule_remove_link(struct tsch_slotframe *slotframe, struct tsch_link *l)
if(l == current_link) {
current_link = NULL;
}
LOG_INFO("remove_link %u %u %u %u ",
slotframe->handle, l->link_options, l->timeslot, l->channel_offset);
LOG_INFO("remove_link sf=%u opt=%s type=%s ts=%u ch=%u addr=",
slotframe->handle,
print_link_options(l->link_options),
print_link_type(l->link_type), l->timeslot, l->channel_offset);
LOG_INFO_LLADDR(&l->addr);
LOG_INFO_("\n");

View File

@ -53,6 +53,10 @@
#include <stdio.h>
#include <string.h>
#if LLSEC802154_ENABLED && !LLSEC802154_USES_EXPLICIT_KEYS
#error LLSEC802154_ENABLED set but LLSEC802154_USES_EXPLICIT_KEYS unset
#endif /* LLSEC802154_ENABLED */
/* The two keys K1 and K2 from 6TiSCH minimal configuration
* K1: well-known, used for EBs
* K2: secret, used for data and ACK

View File

@ -54,10 +54,6 @@
* - set LLSEC802154_CONF_USES_EXPLICIT_KEYS
* */
#if LLSEC802154_ENABLED && !LLSEC802154_USES_EXPLICIT_KEYS
#error LLSEC802154_ENABLED set but LLSEC802154_USES_EXPLICIT_KEYS unset
#endif /* LLSEC802154_ENABLED */
/* K1, defined in 6TiSCH minimal, is well-known (offers no security) and used for EBs only */
#ifdef TSCH_SECURITY_CONF_K1
#define TSCH_SECURITY_K1 TSCH_SECURITY_CONF_K1

View File

@ -160,6 +160,8 @@ static struct ctimer keepalive_timer;
unsigned long tx_count;
unsigned long rx_count;
unsigned long sync_count;
int32_t min_drift_seen;
int32_t max_drift_seen;
/* TSCH processes and protothreads */
PT_THREAD(tsch_scan(struct pt *pt));
@ -648,6 +650,8 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
tx_count = 0;
rx_count = 0;
sync_count = 0;
min_drift_seen = 0;
max_drift_seen = 0;
/* Start sending keep-alives now that tsch_is_associated is set */
tsch_schedule_keepalive();

View File

@ -175,6 +175,8 @@ extern rtimer_clock_t tsch_timing[tsch_ts_elements_count];
extern unsigned long tx_count;
extern unsigned long rx_count;
extern unsigned long sync_count;
extern int32_t min_drift_seen;
extern int32_t max_drift_seen;
/* TSCH processes */
PROCESS_NAME(tsch_process);

View File

@ -36,10 +36,12 @@
#include "net/routing/rpl-classic/rpl-private.h"
#include "net/ipv6/uip-ds6-route.h"
#include "sys/log.h"
#include <string.h>
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
/*---------------------------------------------------------------------------*/
static void
@ -47,7 +49,6 @@ set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
{
static uip_ipaddr_t root_ipaddr;
int i;
uint8_t state;
/* Assign a unique local address (RFC4193,
http://tools.ietf.org/html/rfc4193). */
@ -64,13 +65,17 @@ set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
uip_ds6_addr_add(&root_ipaddr, 0, ADDR_AUTOCONF);
printf("IPv6 addresses: ");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr);
printf("\n");
if(LOG_DBG_ENABLED) {
uint8_t state;
LOG_DBG("IPv6 addresses: ");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
LOG_DBG_6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
LOG_DBG_("\n");
}
}
}
}
@ -126,14 +131,14 @@ rpl_dag_root_start(void)
uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
rpl_set_prefix(dag, &prefix, 64);
PRINTF("rpl_dag_root_set_prefix_dag: created a new RPL dag\n");
LOG_INFO("root_set_prefix: created a new RPL dag\n");
return 0;
} else {
PRINTF("rpl_dag_root_set_prefix_dag: failed to create a new RPL DAG\n");
LOG_ERR("root_set_prefix: failed to create a new RPL DAG\n");
return -1;
}
} else {
PRINTF("rpl_dag_root_set_prefix_dag: failed to create a new RPL DAG, no preferred IP address found\n");
LOG_ERR("root_set_prefix_dag: failed to create a new RPL DAG, no preferred IP address found\n");
return -2;
}
}

View File

@ -56,12 +56,13 @@
#include "lib/list.h"
#include "lib/memb.h"
#include "sys/ctimer.h"
#include "sys/log.h"
#include <limits.h>
#include <string.h>
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
/* A configurable function called after every RPL parent switch */
#ifdef RPL_CALLBACK_PARENT_SWITCH
@ -233,19 +234,19 @@ static void
rpl_set_preferred_parent(rpl_dag_t *dag, rpl_parent_t *p)
{
if(dag != NULL && dag->preferred_parent != p) {
PRINTF("RPL: rpl_set_preferred_parent ");
LOG_INFO("rpl_set_preferred_parent ");
if(p != NULL) {
PRINT6ADDR(rpl_parent_get_ipaddr(p));
LOG_INFO_6ADDR(rpl_parent_get_ipaddr(p));
} else {
PRINTF("NULL");
LOG_INFO_("NULL");
}
PRINTF(" used to be ");
LOG_INFO_(" used to be ");
if(dag->preferred_parent != NULL) {
PRINT6ADDR(rpl_parent_get_ipaddr(dag->preferred_parent));
LOG_INFO_6ADDR(rpl_parent_get_ipaddr(dag->preferred_parent));
} else {
PRINTF("NULL");
LOG_INFO_("NULL");
}
PRINTF("\n");
LOG_INFO_("\n");
#ifdef RPL_CALLBACK_PARENT_SWITCH
RPL_CALLBACK_PARENT_SWITCH(dag->preferred_parent, p);
@ -281,8 +282,7 @@ remove_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
{
rpl_parent_t *p;
PRINTF("RPL: Removing parents (minimum rank %u)\n",
minimum_rank);
LOG_INFO("Removing parents (minimum rank %u)\n", minimum_rank);
p = nbr_table_head(rpl_parents);
while(p != NULL) {
@ -298,8 +298,7 @@ nullify_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
{
rpl_parent_t *p;
PRINTF("RPL: Nullifying parents (minimum rank %u)\n",
minimum_rank);
LOG_INFO("Nullifying parents (minimum rank %u)\n", minimum_rank);
p = nbr_table_head(rpl_parents);
while(p != NULL) {
@ -371,11 +370,11 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
RPL_LOLLIPOP_INCREMENT(version);
}
if(dag == dag->instance->current_dag) {
PRINTF("RPL: Dropping a joined DAG when setting this node as root");
LOG_INFO("Dropping a joined DAG when setting this node as root\n");
rpl_set_default_route(instance, NULL);
dag->instance->current_dag = NULL;
} else {
PRINTF("RPL: Dropping a DAG when setting this node as root");
LOG_INFO("Dropping a DAG when setting this node as root\n");
}
rpl_free_dag(dag);
}
@ -384,7 +383,7 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
dag = rpl_alloc_dag(instance_id, dag_id);
if(dag == NULL) {
PRINTF("RPL: Failed to allocate a DAG\n");
LOG_ERR("Failed to allocate a DAG\n");
return NULL;
}
@ -397,7 +396,7 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
instance->mop = RPL_MOP_DEFAULT;
instance->of = rpl_find_of(RPL_OF_OCP);
if(instance->of == NULL) {
PRINTF("RPL: OF with OCP %u not supported\n", RPL_OF_OCP);
LOG_WARN("OF with OCP %u not supported\n", RPL_OF_OCP);
return NULL;
}
@ -433,11 +432,11 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
instance->of->update_metric_container(instance);
default_instance = instance;
PRINTF("RPL: Node set to be a DAG root with DAG ID ");
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
LOG_INFO("Node set to be a DAG root with DAG ID ");
LOG_INFO_6ADDR(&dag->dag_id);
LOG_INFO_("\n");
ANNOTATE("#A root=%u\n", dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
LOG_ANNOTATE("#A root=%u\n", dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
rpl_reset_dio_timer(instance);
@ -452,14 +451,14 @@ rpl_repair_root(uint8_t instance_id)
instance = rpl_get_instance(instance_id);
if(instance == NULL ||
instance->current_dag->rank != ROOT_RANK(instance)) {
PRINTF("RPL: rpl_repair_root triggered but not root\n");
LOG_WARN("rpl_repair_root triggered but not root\n");
return 0;
}
RPL_STAT(rpl_stats.root_repairs++);
RPL_LOLLIPOP_INCREMENT(instance->current_dag->version);
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
PRINTF("RPL: rpl_repair_root initiating global repair with version %d\n", instance->current_dag->version);
LOG_INFO("rpl_repair_root initiating global repair with version %d\n", instance->current_dag->version);
rpl_reset_dio_timer(instance);
return 1;
}
@ -490,9 +489,9 @@ check_prefix(rpl_prefix_t *last_prefix, rpl_prefix_t *new_prefix)
set_ip_from_prefix(&ipaddr, last_prefix);
rep = uip_ds6_addr_lookup(&ipaddr);
if(rep != NULL) {
PRINTF("RPL: removing global IP address ");
PRINT6ADDR(&ipaddr);
PRINTF("\n");
LOG_DBG("removing global IP address ");
LOG_DBG_6ADDR(&ipaddr);
LOG_DBG_("\n");
uip_ds6_addr_rm(rep);
}
}
@ -500,9 +499,9 @@ check_prefix(rpl_prefix_t *last_prefix, rpl_prefix_t *new_prefix)
if(new_prefix != NULL) {
set_ip_from_prefix(&ipaddr, new_prefix);
if(uip_ds6_addr_lookup(&ipaddr) == NULL) {
PRINTF("RPL: adding global IP address ");
PRINT6ADDR(&ipaddr);
PRINTF("\n");
LOG_DBG("adding global IP address ");
LOG_DBG_6ADDR(&ipaddr);
LOG_DBG_("\n");
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
}
}
@ -524,15 +523,15 @@ rpl_set_prefix(rpl_dag_t *dag, uip_ipaddr_t *prefix, unsigned len)
memcpy(&dag->prefix_info.prefix, prefix, (len + 7) / 8);
dag->prefix_info.length = len;
dag->prefix_info.flags = UIP_ND6_RA_FLAG_AUTONOMOUS;
PRINTF("RPL: Prefix set - will announce this in DIOs\n");
LOG_INFO("Prefix set - will announce this in DIOs\n");
if(dag->rank != ROOT_RANK(dag->instance)) {
/* Autoconfigure an address if this node does not already have an address
with this prefix. Otherwise, update the prefix */
if(last_len == 0) {
PRINTF("rpl_set_prefix - prefix NULL\n");
LOG_INFO("rpl_set_prefix - prefix NULL\n");
check_prefix(NULL, &dag->prefix_info);
} else {
PRINTF("rpl_set_prefix - prefix NON-NULL\n");
LOG_INFO("rpl_set_prefix - prefix NON-NULL\n");
check_prefix(&last_prefix, &dag->prefix_info);
}
}
@ -543,17 +542,17 @@ int
rpl_set_default_route(rpl_instance_t *instance, uip_ipaddr_t *from)
{
if(instance->def_route != NULL) {
PRINTF("RPL: Removing default route through ");
PRINT6ADDR(&instance->def_route->ipaddr);
PRINTF("\n");
LOG_DBG("Removing default route through ");
LOG_DBG_6ADDR(&instance->def_route->ipaddr);
LOG_DBG_("\n");
uip_ds6_defrt_rm(instance->def_route);
instance->def_route = NULL;
}
if(from != NULL) {
PRINTF("RPL: Adding default route through ");
PRINT6ADDR(from);
PRINTF("\n");
LOG_DBG("Adding default route through ");
LOG_DBG_6ADDR(from);
LOG_DBG("\n");
instance->def_route = uip_ds6_defrt_add(from,
RPL_DEFAULT_ROUTE_INFINITE_LIFETIME ? 0 : RPL_LIFETIME(instance, instance->default_lifetime));
if(instance->def_route == NULL) {
@ -632,7 +631,7 @@ rpl_free_instance(rpl_instance_t *instance)
rpl_dag_t *dag;
rpl_dag_t *end;
PRINTF("RPL: Leaving the instance %u\n", instance->instance_id);
LOG_INFO("Leaving the instance %u\n", instance->instance_id);
/* Remove any DAG inside this instance */
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DAG_PER_INSTANCE; dag < end; ++dag) {
@ -661,9 +660,9 @@ void
rpl_free_dag(rpl_dag_t *dag)
{
if(dag->joined) {
PRINTF("RPL: Leaving the DAG ");
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
LOG_INFO("Leaving the DAG ");
LOG_INFO_6ADDR(&dag->dag_id);
LOG_INFO_("\n");
dag->joined = 0;
/* Remove routes installed by DAOs. */
@ -693,15 +692,15 @@ rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
* Typically, the parent is added upon receiving a DIO. */
const uip_lladdr_t *lladdr = uip_ds6_nbr_lladdr_from_ipaddr(addr);
PRINTF("RPL: rpl_add_parent lladdr %p ", lladdr);
PRINT6ADDR(addr);
PRINTF("\n");
LOG_DBG("rpl_add_parent lladdr %p ", lladdr);
LOG_DBG_6ADDR(addr);
LOG_DBG_("\n");
if(lladdr != NULL) {
/* Add parent in rpl_parents - again this is due to DIO */
p = nbr_table_add_lladdr(rpl_parents, (linkaddr_t *)lladdr,
NBR_TABLE_REASON_RPL_DIO, dio);
if(p == NULL) {
PRINTF("RPL: rpl_add_parent p NULL\n");
LOG_DBG("rpl_add_parent p NULL\n");
} else {
p->dag = dag;
p->rank = dio->rank;
@ -792,9 +791,9 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
rpl_remove_routes(instance->current_dag);
}
PRINTF("RPL: New preferred DAG: ");
PRINT6ADDR(&best_dag->dag_id);
PRINTF("\n");
LOG_INFO("New preferred DAG: ");
LOG_INFO_6ADDR(&best_dag->dag_id);
LOG_INFO_("\n");
if(best_dag->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {
check_prefix(&instance->current_dag->prefix_info, &best_dag->prefix_info);
@ -817,7 +816,7 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
}
if(!acceptable_rank(best_dag, best_dag->rank)) {
PRINTF("RPL: New rank unacceptable!\n");
LOG_WARN("New rank unacceptable!\n");
rpl_set_preferred_parent(instance->current_dag, NULL);
if(RPL_IS_STORING(instance) && last_parent != NULL) {
/* Send a No-Path DAO to the removed preferred parent. */
@ -828,7 +827,7 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
if(best_dag->preferred_parent != last_parent) {
rpl_set_default_route(instance, rpl_parent_get_ipaddr(best_dag->preferred_parent));
PRINTF("RPL: Changed preferred parent, rank changed from %u to %u\n",
LOG_INFO("Changed preferred parent, rank changed from %u to %u\n",
(unsigned)old_rank, best_dag->rank);
RPL_STAT(rpl_stats.parent_switch++);
if(RPL_IS_STORING(instance)) {
@ -843,11 +842,11 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
/* The DAO parent set changed - schedule a DAO transmission. */
rpl_schedule_dao(instance);
rpl_reset_dio_timer(instance);
#if DEBUG
rpl_print_neighbor_list();
#endif
if(LOG_DBG_ENABLED) {
rpl_print_neighbor_list();
}
} else if(best_dag->rank != old_rank) {
PRINTF("RPL: Preferred parent update, rank changed from %u to %u\n",
LOG_DBG("RPL: Preferred parent update, rank changed from %u to %u\n",
(unsigned)old_rank, best_dag->rank);
}
return best_dag;
@ -871,7 +870,7 @@ best_parent(rpl_dag_t *dag, int fresh_only)
/* Exclude parents from other DAGs or announcing an infinite rank */
if(p->dag != dag || p->rank == RPL_INFINITE_RANK || p->rank < ROOT_RANK(dag->instance)) {
if(p->rank < ROOT_RANK(dag->instance)) {
PRINTF("RPL: Parent has invalid rank\n");
LOG_WARN("Parent has invalid rank\n");
}
continue;
}
@ -939,9 +938,9 @@ rpl_select_parent(rpl_dag_t *dag)
void
rpl_remove_parent(rpl_parent_t *parent)
{
PRINTF("RPL: Removing parent ");
PRINT6ADDR(rpl_parent_get_ipaddr(parent));
PRINTF("\n");
LOG_INFO("Removing parent ");
LOG_INFO_6ADDR(rpl_parent_get_ipaddr(parent));
LOG_INFO_("\n");
rpl_nullify_parent(parent);
@ -958,9 +957,9 @@ rpl_nullify_parent(rpl_parent_t *parent)
dag->rank = RPL_INFINITE_RANK;
if(dag->joined) {
if(dag->instance->def_route != NULL) {
PRINTF("RPL: Removing default route ");
PRINT6ADDR(rpl_parent_get_ipaddr(parent));
PRINTF("\n");
LOG_DBG("Removing default route ");
LOG_DBG_6ADDR(rpl_parent_get_ipaddr(parent));
LOG_DBG_("\n");
uip_ds6_defrt_rm(dag->instance->def_route);
dag->instance->def_route = NULL;
}
@ -974,9 +973,9 @@ rpl_nullify_parent(rpl_parent_t *parent)
}
}
PRINTF("RPL: Nullifying parent ");
PRINT6ADDR(rpl_parent_get_ipaddr(parent));
PRINTF("\n");
LOG_INFO("Nullifying parent ");
LOG_INFO_6ADDR(rpl_parent_get_ipaddr(parent));
LOG_INFO_("\n");
}
/*---------------------------------------------------------------------------*/
void
@ -986,10 +985,10 @@ rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent)
rpl_set_preferred_parent(dag_src, NULL);
dag_src->rank = RPL_INFINITE_RANK;
if(dag_src->joined && dag_src->instance->def_route != NULL) {
PRINTF("RPL: Removing default route ");
PRINT6ADDR(rpl_parent_get_ipaddr(parent));
PRINTF("\n");
PRINTF("rpl_move_parent\n");
LOG_DBG("Removing default route ");
LOG_DBG_6ADDR(rpl_parent_get_ipaddr(parent));
LOG_DBG_("\n");
LOG_DBG("rpl_move_parent\n");
uip_ds6_defrt_rm(dag_src->instance->def_route);
dag_src->instance->def_route = NULL;
}
@ -1000,9 +999,9 @@ rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent)
}
}
PRINTF("RPL: Moving parent ");
PRINT6ADDR(rpl_parent_get_ipaddr(parent));
PRINTF("\n");
LOG_INFO("Moving parent ");
LOG_INFO_6ADDR(rpl_parent_get_ipaddr(parent));
LOG_INFO_("\n");
parent->dag = dag_dst;
}
@ -1100,7 +1099,7 @@ rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio)
if((!RPL_WITH_NON_STORING && dio->mop == RPL_MOP_NON_STORING)
|| (!RPL_WITH_STORING && (dio->mop == RPL_MOP_STORING_NO_MULTICAST
|| dio->mop == RPL_MOP_STORING_MULTICAST))) {
PRINTF("RPL: DIO advertising a non-supported MOP %u\n", dio->mop);
LOG_WARN("DIO advertising a non-supported MOP %u\n", dio->mop);
return;
}
@ -1108,30 +1107,30 @@ rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio)
objective code point of the DIO. */
of = rpl_find_of(dio->ocp);
if(of == NULL) {
PRINTF("RPL: DIO for DAG instance %u does not specify a supported OF: %u\n",
LOG_WARN("DIO for DAG instance %u does not specify a supported OF: %u\n",
dio->instance_id, dio->ocp);
return;
}
dag = rpl_alloc_dag(dio->instance_id, &dio->dag_id);
if(dag == NULL) {
PRINTF("RPL: Failed to allocate a DAG object!\n");
LOG_ERR("Failed to allocate a DAG object!\n");
return;
}
instance = dag->instance;
p = rpl_add_parent(dag, dio, from);
PRINTF("RPL: Adding ");
PRINT6ADDR(from);
PRINTF(" as a parent: ");
LOG_DBG("Adding ");
LOG_DBG_6ADDR(from);
LOG_DBG_(" as a parent: ");
if(p == NULL) {
PRINTF("failed\n");
LOG_DBG_("failed\n");
instance->used = 0;
return;
}
p->dtsn = dio->dtsn;
PRINTF("succeeded\n");
LOG_DBG_("succeeded\n");
/* Autoconfigure an address if this node does not already have an address
with this prefix. */
@ -1177,12 +1176,12 @@ rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio)
default_instance = instance;
}
PRINTF("RPL: Joined DAG with instance ID %u, rank %hu, DAG ID ",
LOG_INFO("Joined DAG with instance ID %u, rank %hu, DAG ID ",
dio->instance_id, dag->rank);
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
LOG_INFO_6ADDR(&dag->dag_id);
LOG_INFO_("\n");
ANNOTATE("#A join=%u\n", dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
LOG_ANNOTATE("#A join=%u\n", dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
rpl_reset_dio_timer(instance);
rpl_set_default_route(instance, from);
@ -1190,7 +1189,7 @@ rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio)
if(instance->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
rpl_schedule_dao(instance);
} else {
PRINTF("RPL: The DIO does not meet the prerequisites for sending a DAO\n");
LOG_WARN("The DIO does not meet the prerequisites for sending a DAO\n");
}
instance->of->reset(dag);
@ -1208,7 +1207,7 @@ rpl_add_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
dag = rpl_alloc_dag(dio->instance_id, &dio->dag_id);
if(dag == NULL) {
PRINTF("RPL: Failed to allocate a DAG object!\n");
LOG_ERR("Failed to allocate a DAG object!\n");
return NULL;
}
@ -1216,16 +1215,16 @@ rpl_add_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
previous_dag = find_parent_dag(instance, from);
if(previous_dag == NULL) {
PRINTF("RPL: Adding ");
PRINT6ADDR(from);
PRINTF(" as a parent: ");
LOG_DBG("Adding ");
LOG_DBG_6ADDR(from);
LOG_DBG_(" as a parent: ");
p = rpl_add_parent(dag, dio, from);
if(p == NULL) {
PRINTF("failed\n");
LOG_DBG_("failed\n");
dag->used = 0;
return NULL;
}
PRINTF("succeeded\n");
LOG_DBG_("succeeded\n");
} else {
p = rpl_find_parent(previous_dag, from);
if(p != NULL) {
@ -1246,7 +1245,7 @@ rpl_add_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
instance->dio_redundancy != dio->dag_redund ||
instance->default_lifetime != dio->default_lifetime ||
instance->lifetime_unit != dio->lifetime_unit) {
PRINTF("RPL: DIO for DAG instance %u incompatible with previous DIO\n",
LOG_WARN("DIO for DAG instance %u incompatible with previous DIO\n",
dio->instance_id);
rpl_remove_parent(p);
dag->used = 0;
@ -1267,12 +1266,12 @@ rpl_add_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
dag->rank = rpl_rank_via_parent(p);
dag->min_rank = dag->rank; /* So far this is the lowest rank we know of. */
PRINTF("RPL: Joined DAG with instance ID %u, rank %hu, DAG ID ",
LOG_INFO("Joined DAG with instance ID %u, rank %hu, DAG ID ",
dio->instance_id, dag->rank);
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
LOG_INFO_6ADDR(&dag->dag_id);
LOG_INFO_("\n");
ANNOTATE("#A join=%u\n", dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
LOG_ANNOTATE("#A join=%u\n", dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
rpl_process_parent_event(instance, p);
p->dtsn = dio->dtsn;
@ -1303,16 +1302,16 @@ global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio)
p = rpl_add_parent(dag, dio, from);
if(p == NULL) {
PRINTF("RPL: Failed to add a parent during the global repair\n");
LOG_ERR("Failed to add a parent during the global repair\n");
dag->rank = RPL_INFINITE_RANK;
} else {
dag->rank = rpl_rank_via_parent(p);
dag->min_rank = dag->rank;
PRINTF("RPL: rpl_process_parent_event global repair\n");
LOG_DBG("rpl_process_parent_event global repair\n");
rpl_process_parent_event(dag->instance, p);
}
PRINTF("RPL: Participating in a global repair (version=%u, rank=%hu)\n",
LOG_DBG("Participating in a global repair (version=%u, rank=%hu)\n",
dag->version, dag->rank);
RPL_STAT(rpl_stats.global_repairs++);
@ -1325,10 +1324,10 @@ rpl_local_repair(rpl_instance_t *instance)
int i;
if(instance == NULL) {
PRINTF("RPL: local repair requested for instance NULL\n");
LOG_WARN("local repair requested for instance NULL\n");
return;
}
PRINTF("RPL: Starting a local instance repair\n");
LOG_INFO("Starting a local instance repair\n");
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; i++) {
if(instance->dag_table[i].used) {
instance->dag_table[i].rank = RPL_INFINITE_RANK;
@ -1367,9 +1366,9 @@ rpl_recalculate_ranks(void)
while(p != NULL) {
if(p->dag != NULL && p->dag->instance && (p->flags & RPL_PARENT_FLAG_UPDATED)) {
p->flags &= ~RPL_PARENT_FLAG_UPDATED;
PRINTF("RPL: rpl_process_parent_event recalculate_ranks\n");
LOG_DBG("rpl_process_parent_event recalculate_ranks\n");
if(!rpl_process_parent_event(p->dag->instance, p)) {
PRINTF("RPL: A parent was dropped\n");
LOG_DBG("A parent was dropped\n");
}
}
p = nbr_table_next(rpl_parents, p);
@ -1382,26 +1381,26 @@ rpl_process_parent_event(rpl_instance_t *instance, rpl_parent_t *p)
int return_value;
rpl_parent_t *last_parent = instance->current_dag->preferred_parent;
#if DEBUG
rpl_rank_t old_rank;
old_rank = instance->current_dag->rank;
#endif /* DEBUG */
#if LOG_DBG_ENABLED
rpl_rank_t old_rank;
old_rank = instance->current_dag->rank;
#endif /* LOG_DBG_ENABLED */
return_value = 1;
if(RPL_IS_STORING(instance)
&& uip_ds6_route_is_nexthop(rpl_parent_get_ipaddr(p))
&& !rpl_parent_is_reachable(p) && instance->mop > RPL_MOP_NON_STORING) {
PRINTF("RPL: Unacceptable link %u, removing routes via: ", rpl_get_parent_link_metric(p));
PRINT6ADDR(rpl_parent_get_ipaddr(p));
PRINTF("\n");
LOG_WARN("Unacceptable link %u, removing routes via: ", rpl_get_parent_link_metric(p));
LOG_WARN_6ADDR(rpl_parent_get_ipaddr(p));
LOG_WARN_("\n");
rpl_remove_routes_by_nexthop(rpl_parent_get_ipaddr(p), p->dag);
}
if(!acceptable_rank(p->dag, p->rank)) {
/* The candidate parent is no longer valid: the rank increase resulting
from the choice of it as a parent would be too high. */
PRINTF("RPL: Unacceptable rank %u (Current min %u, MaxRankInc %u)\n", (unsigned)p->rank,
LOG_WARN("Unacceptable rank %u (Current min %u, MaxRankInc %u)\n", (unsigned)p->rank,
p->dag->min_rank, p->dag->instance->max_rankinc);
rpl_nullify_parent(p);
if(p != instance->current_dag->preferred_parent) {
@ -1414,26 +1413,26 @@ rpl_process_parent_event(rpl_instance_t *instance, rpl_parent_t *p)
if(rpl_select_dag(instance, p) == NULL) {
if(last_parent != NULL) {
/* No suitable parent anymore; trigger a local repair. */
PRINTF("RPL: No parents found in any DAG\n");
LOG_ERR("No parents found in any DAG\n");
rpl_local_repair(instance);
return 0;
}
}
#if DEBUG
#if LOG_DBG_ENABLED
if(DAG_RANK(old_rank, instance) != DAG_RANK(instance->current_dag->rank, instance)) {
PRINTF("RPL: Moving in the instance from rank %hu to %hu\n",
LOG_INFO("Moving in the instance from rank %hu to %hu\n",
DAG_RANK(old_rank, instance), DAG_RANK(instance->current_dag->rank, instance));
if(instance->current_dag->rank != RPL_INFINITE_RANK) {
PRINTF("RPL: The preferred parent is ");
PRINT6ADDR(rpl_parent_get_ipaddr(instance->current_dag->preferred_parent));
PRINTF(" (rank %u)\n",
LOG_DBG("The preferred parent is ");
LOG_DBG_6ADDR(rpl_parent_get_ipaddr(instance->current_dag->preferred_parent));
LOG_DBG_(" (rank %u)\n",
(unsigned)DAG_RANK(instance->current_dag->preferred_parent->rank, instance));
} else {
PRINTF("RPL: We don't have any parent");
LOG_WARN("We don't have any parent");
}
}
#endif /* DEBUG */
#endif /* LOG_DBG_ENABLED */
return return_value;
}
@ -1443,9 +1442,9 @@ add_nbr_from_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
{
/* add this to the neighbor cache if not already there */
if(rpl_icmp6_update_nbr_table(from, NBR_TABLE_REASON_RPL_DIO, dio) == NULL) {
PRINTF("RPL: Out of memory, dropping DIO from ");
PRINT6ADDR(from);
PRINTF("\n");
LOG_ERR("Out of memory, dropping DIO from ");
LOG_ERR_6ADDR(from);
LOG_ERR_("\n");
return 0;
}
return 1;
@ -1465,7 +1464,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
#else
if(dio->mop != RPL_MOP_DEFAULT) {
#endif
PRINTF("RPL: Ignoring a DIO with an unsupported MOP: %d\n", dio->mop);
LOG_ERR("Ignoring a DIO with an unsupported MOP: %d\n", dio->mop);
return;
}
@ -1475,15 +1474,15 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
if(dag != NULL && instance != NULL) {
if(lollipop_greater_than(dio->version, dag->version)) {
if(dag->rank == ROOT_RANK(instance)) {
PRINTF("RPL: Root received inconsistent DIO version number (current: %u, received: %u)\n", dag->version, dio->version);
LOG_WARN("Root received inconsistent DIO version number (current: %u, received: %u)\n", dag->version, dio->version);
dag->version = dio->version;
RPL_LOLLIPOP_INCREMENT(dag->version);
rpl_reset_dio_timer(instance);
} else {
PRINTF("RPL: Global repair\n");
LOG_DBG("Global repair\n");
if(dio->prefix_info.length != 0) {
if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {
PRINTF("RPL: Prefix announced in DIO\n");
LOG_DBG("Prefix announced in DIO\n");
rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);
}
}
@ -1494,7 +1493,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
if(lollipop_greater_than(dag->version, dio->version)) {
/* The DIO sender is on an older version of the DAG. */
PRINTF("RPL: old version received => inconsistency detected\n");
LOG_WARN("old version received => inconsistency detected\n");
if(dag->joined) {
rpl_reset_dio_timer(instance);
return;
@ -1503,41 +1502,41 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
}
if(instance == NULL) {
PRINTF("RPL: New instance detected (ID=%u): Joining...\n", dio->instance_id);
LOG_INFO("New instance detected (ID=%u): Joining...\n", dio->instance_id);
if(add_nbr_from_dio(from, dio)) {
rpl_join_instance(from, dio);
} else {
PRINTF("RPL: Not joining since could not add parent\n");
LOG_WARN("Not joining since could not add parent\n");
}
return;
}
if(instance->current_dag->rank == ROOT_RANK(instance) && instance->current_dag != dag) {
PRINTF("RPL: Root ignored DIO for different DAG\n");
LOG_WARN("Root ignored DIO for different DAG\n");
return;
}
if(dag == NULL) {
#if RPL_MAX_DAG_PER_INSTANCE > 1
PRINTF("RPL: Adding new DAG to known instance.\n");
LOG_INFO("Adding new DAG to known instance.\n");
if(!add_nbr_from_dio(from, dio)) {
PRINTF("RPL: Could not add new DAG, could not add parent\n");
LOG_WARN("Could not add new DAG, could not add parent\n");
return;
}
dag = rpl_add_dag(from, dio);
if(dag == NULL) {
PRINTF("RPL: Failed to add DAG.\n");
LOG_WARN("Failed to add DAG.\n");
return;
}
#else /* RPL_MAX_DAG_PER_INSTANCE > 1 */
PRINTF("RPL: Only one instance supported.\n");
LOG_WARN("Only one instance supported.\n");
return;
#endif /* RPL_MAX_DAG_PER_INSTANCE > 1 */
}
if(dio->rank < ROOT_RANK(instance)) {
PRINTF("RPL: Ignoring DIO with too low rank: %u\n",
LOG_INFO("Ignoring DIO with too low rank: %u\n",
(unsigned)dio->rank);
return;
}
@ -1545,13 +1544,13 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
/* Prefix Information Option treated to add new prefix */
if(dio->prefix_info.length != 0) {
if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {
PRINTF("RPL: Prefix announced in DIO\n");
LOG_DBG("Prefix announced in DIO\n");
rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);
}
}
if(!add_nbr_from_dio(from, dio)) {
PRINTF("RPL: Could not add parent based on DIO\n");
LOG_WARN("Could not add parent based on DIO\n");
return;
}
@ -1564,9 +1563,9 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
/* The DIO comes from a valid DAG, we can refresh its lifetime */
dag->lifetime = (1UL << (instance->dio_intmin + instance->dio_intdoubl)) * RPL_DAG_LIFETIME / 1000;
PRINTF("Set dag ");
PRINT6ADDR(&dag->dag_id);
PRINTF(" lifetime to %ld\n", dag->lifetime);
LOG_INFO("Set dag ");
LOG_INFO_6ADDR(&dag->dag_id);
LOG_INFO_(" lifetime to %ld\n", (long int) dag->lifetime);
/*
* At this point, we know that this DIO pertains to a DAG that
@ -1582,14 +1581,14 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
/* Add the DIO sender as a candidate parent. */
p = rpl_add_parent(dag, dio, from);
if(p == NULL) {
PRINTF("RPL: Failed to add a new parent (");
PRINT6ADDR(from);
PRINTF(")\n");
LOG_WARN("Failed to add a new parent (");
LOG_WARN_6ADDR(from);
LOG_WARN_(")\n");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
LOG_INFO("New candidate parent with rank %u: ", (unsigned)p->rank);
LOG_INFO_6ADDR(from);
LOG_INFO_("\n");
} else {
p = rpl_find_parent(previous_dag, from);
if(p != NULL) {
@ -1598,7 +1597,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
}
} else {
if(p->rank == dio->rank) {
PRINTF("RPL: Received consistent DIO\n");
LOG_WARN("Received consistent DIO\n");
if(dag->joined) {
instance->dio_counter++;
}
@ -1614,11 +1613,11 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
/* Parent info has been updated, trigger rank recalculation */
p->flags |= RPL_PARENT_FLAG_UPDATED;
PRINTF("RPL: preferred DAG ");
PRINT6ADDR(&instance->current_dag->dag_id);
PRINTF(", rank %u, min_rank %u, ",
LOG_INFO("preferred DAG ");
LOG_INFO_6ADDR(&instance->current_dag->dag_id);
LOG_INFO_(", rank %u, min_rank %u, ",
instance->current_dag->rank, instance->current_dag->min_rank);
PRINTF("parent rank %u, link metric %u\n",
LOG_INFO_("parent rank %u, link metric %u\n",
p->rank, rpl_get_parent_link_metric(p));
/* We have allocated a candidate parent; process the DIO further. */
@ -1627,7 +1626,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
#endif /* RPL_WITH_MC */
if(rpl_process_parent_event(instance, p) == 0) {
PRINTF("RPL: The candidate parent is rejected\n");
LOG_WARN("The candidate parent is rejected\n");
return;
}

View File

@ -52,8 +52,10 @@
#include "net/routing/rpl-classic/rpl-private.h"
#include "net/packetbuf.h"
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#include "sys/log.h"
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
#include <limits.h>
#include <string.h>
@ -83,7 +85,7 @@ rpl_ext_header_hbh_update(int uip_ext_opt_offset)
|| UIP_EXT_HDR_OPT_RPL_BUF->opt_type != UIP_EXT_HDR_OPT_RPL
|| UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) {
PRINTF("RPL: Hop-by-hop extension header has wrong size or type (%u %u %u)\n",
LOG_ERR("Hop-by-hop extension header has wrong size or type (%u %u %u)\n",
UIP_HBHO_BUF->len,
UIP_EXT_HDR_OPT_RPL_BUF->opt_type,
UIP_EXT_HDR_OPT_RPL_BUF->opt_len);
@ -92,13 +94,13 @@ rpl_ext_header_hbh_update(int uip_ext_opt_offset)
instance = rpl_get_instance(UIP_EXT_HDR_OPT_RPL_BUF->instance);
if(instance == NULL) {
PRINTF("RPL: Unknown instance: %u\n",
LOG_ERR("Unknown instance: %u\n",
UIP_EXT_HDR_OPT_RPL_BUF->instance);
return 0;
}
if(UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_FWD_ERR) {
PRINTF("RPL: Forward error!\n");
LOG_ERR("Forward error!\n");
/* We should try to repair it by removing the neighbor that caused
the packet to be forwareded in the first place. We drop any
routes that go through the neighbor that sent the packet to
@ -117,7 +119,7 @@ rpl_ext_header_hbh_update(int uip_ext_opt_offset)
}
if(!instance->current_dag->joined) {
PRINTF("RPL: No DAG in the instance\n");
LOG_ERR("No DAG in the instance\n");
return 0;
}
down = 0;
@ -142,14 +144,14 @@ rpl_ext_header_hbh_update(int uip_ext_opt_offset)
sender_closer = sender_rank < instance->current_dag->rank;
PRINTF("RPL: Packet going %s, sender closer %d (%d < %d)\n", down == 1 ? "down" : "up",
LOG_DBG("Packet going %s, sender closer %d (%d < %d)\n", down == 1 ? "down" : "up",
sender_closer,
sender_rank,
instance->current_dag->rank
);
if((down && !sender_closer) || (!down && sender_closer)) {
PRINTF("RPL: Loop detected - senderrank: %d my-rank: %d sender_closer: %d\n",
LOG_WARN("Loop detected - senderrank: %d my-rank: %d sender_closer: %d\n",
sender_rank, instance->current_dag->rank,
sender_closer);
/* Attempt to repair the loop by sending a unicast DIO back to the sender
@ -160,18 +162,18 @@ rpl_ext_header_hbh_update(int uip_ext_opt_offset)
}
if(UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_RANK_ERR) {
RPL_STAT(rpl_stats.loop_errors++);
PRINTF("RPL: Rank error signalled in RPL option!\n");
LOG_ERR(" Rank error signalled in RPL option!\n");
/* Packet must be dropped and dio trickle timer reset, see RFC6550 - 11.2.2.2 */
rpl_reset_dio_timer(instance);
return 0;
}
PRINTF("RPL: Single error tolerated\n");
LOG_WARN("Single error tolerated\n");
RPL_STAT(rpl_stats.loop_warnings++);
UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_RANK_ERR;
return 1;
}
PRINTF("RPL: Rank OK\n");
LOG_DBG("Rank OK\n");
return 1;
}
/*---------------------------------------------------------------------------*/
@ -281,7 +283,7 @@ rpl_ext_header_srh_update(void)
path_len = ((ext_len - padding - RPL_RH_LEN - RPL_SRH_LEN - (16 - cmpre)) / (16 - cmpri)) + 1;
(void)path_len;
PRINTF("RPL: read SRH, path len %u, segments left %u, Cmpri %u, Cmpre %u, ext len %u (padding %u)\n",
LOG_DBG("read SRH, path len %u, segments left %u, Cmpri %u, Cmpre %u, ext len %u (padding %u)\n",
path_len, segments_left, cmpri, cmpre, ext_len, padding);
if(segments_left == 0) {
@ -303,9 +305,9 @@ rpl_ext_header_srh_update(void)
/* Update segments left field */
UIP_RH_BUF->seg_left--;
PRINTF("RPL: SRH next hop ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
LOG_INFO("SRH next hop ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO_("\n");
}
uip_ext_len = last_uip_ext_len;
return 1;
@ -346,9 +348,9 @@ insert_srh_header(void)
rpl_dag_t *dag;
uip_ipaddr_t node_addr;
PRINTF("RPL: SRH creating source routing header with destination ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" \n");
LOG_INFO("SRH creating source routing header with destination ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO_("\n");
/* Construct source route. We do not do this recursively to keep the runtime stack usage constant. */
@ -356,7 +358,7 @@ insert_srh_header(void)
dag = rpl_get_dag(&UIP_IP_BUF->destipaddr);
if(dag == NULL) {
PRINTF("RPL: SRH DAG not found\n");
LOG_ERR("SRH DAG not found\n");
return 0;
}
@ -368,12 +370,12 @@ insert_srh_header(void)
root_node = uip_sr_get_node(dag, &dag->dag_id);
if(root_node == NULL) {
PRINTF("RPL: SRH root node not found\n");
LOG_ERR("SRH root node not found\n");
return 0;
}
if(!uip_sr_is_addr_reachable(dag, &UIP_IP_BUF->destipaddr)) {
PRINTF("RPL: SRH no path found to destination\n");
LOG_ERR("SRH no path found to destination\n");
return 0;
}
@ -385,7 +387,7 @@ insert_srh_header(void)
cmpre = 15;
if(node == root_node) {
PRINTF("RPL: SRH no need to insert SRH\n");
LOG_DBG("SRH no need to insert SRH\n");
return 1;
}
@ -397,9 +399,9 @@ insert_srh_header(void)
cmpri = MIN(cmpri, count_matching_bytes(&node_addr, &UIP_IP_BUF->destipaddr, 16));
cmpre = cmpri;
PRINTF("RPL: SRH Hop ");
PRINT6ADDR(&node_addr);
PRINTF("\n");
LOG_DBG("SRH Hop ");
LOG_DBG_6ADDR(&node_addr);
LOG_DBG_("\n");
node = node->parent;
path_len++;
}
@ -412,12 +414,12 @@ insert_srh_header(void)
padding = ext_len % 8 == 0 ? 0 : (8 - (ext_len % 8));
ext_len += padding;
PRINTF("RPL: SRH Path len: %u, ComprI %u, ComprE %u, ext len %u (padding %u)\n",
LOG_DBG("SRH Path len: %u, ComprI %u, ComprE %u, ext len %u (padding %u)\n",
path_len, cmpri, cmpre, ext_len, padding);
/* Check if there is enough space to store the extension header */
if(uip_len + ext_len > UIP_BUFSIZE - UIP_LLH_LEN) {
PRINTF("RPL: Packet too long: impossible to add source routing header (%u bytes)\n", ext_len);
LOG_ERR("Packet too long: impossible to add source routing header (%u bytes)\n", ext_len);
return 0;
}
@ -486,7 +488,7 @@ update_hbh_header(void)
if(UIP_HBHO_BUF->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|| UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) {
PRINTF("RPL: Hop-by-hop extension header has wrong size (%u %u)\n",
LOG_ERR("Hop-by-hop extension header has wrong size (%u %u)\n",
UIP_EXT_HDR_OPT_RPL_BUF->opt_len,
uip_ext_len);
return 0; /* Drop */
@ -494,12 +496,12 @@ update_hbh_header(void)
instance = rpl_get_instance(UIP_EXT_HDR_OPT_RPL_BUF->instance);
if(instance == NULL || !instance->used || !instance->current_dag->joined) {
PRINTF("RPL: Unable to add/update hop-by-hop extension header: incorrect instance\n");
LOG_ERR("Unable to add/update hop-by-hop extension header: incorrect instance\n");
uip_ext_len = last_uip_ext_len;
return 0; /* Drop */
}
PRINTF("RPL: Updating RPL option\n");
LOG_INFO("Updating RPL option\n");
/* Update sender rank and instance, will update flags next */
UIP_EXT_HDR_OPT_RPL_BUF->senderrank = UIP_HTONS(instance->current_dag->rank);
UIP_EXT_HDR_OPT_RPL_BUF->instance = instance->instance_id;
@ -512,10 +514,10 @@ update_hbh_header(void)
if((UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_DOWN)) {
if(uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr) == NULL) {
UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_FWD_ERR;
PRINTF("RPL forwarding error\n");
LOG_WARN("RPL forwarding error\n");
/* We should send back the packet to the originating parent,
but it is not feasible yet, so we send a No-Path DAO instead */
PRINTF("RPL generate No-Path DAO\n");
LOG_WARN("RPL generate No-Path DAO\n");
parent = rpl_get_parent((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
if(parent != NULL) {
dao_output_target(parent, &UIP_IP_BUF->destipaddr, RPL_ZERO_LIFETIME);
@ -531,11 +533,11 @@ update_hbh_header(void)
/* No route was found, so this packet will go towards the RPL
root. If so, we should not set the down flag. */
UIP_EXT_HDR_OPT_RPL_BUF->flags &= ~RPL_HDR_OPT_DOWN;
PRINTF("RPL option going up\n");
LOG_DBG("RPL option going up\n");
} else {
/* A DAO route was found so we set the down flag. */
UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_DOWN;
PRINTF("RPL option going down\n");
LOG_DBG("RPL option going down\n");
}
}
}
@ -557,9 +559,9 @@ insert_hbh_header(const rpl_instance_t *instance)
uip_ext_opt_offset = 2;
/* Insert hop-by-hop header */
PRINTF("RPL: Creating hop-by-hop option\n");
LOG_DBG("Creating hop-by-hop option\n");
if(uip_len + RPL_HOP_BY_HOP_LEN > UIP_BUFSIZE - UIP_LLH_LEN) {
PRINTF("RPL: Packet too long: impossible to add hop-by-hop option\n");
LOG_ERR("Packet too long: impossible to add hop-by-hop option\n");
uip_ext_len = last_uip_ext_len;
return 0;
}
@ -619,7 +621,7 @@ rpl_ext_header_remove(void)
if(UIP_IP_BUF->len[1] > temp_len) {
UIP_IP_BUF->len[0]--;
}
PRINTF("RPL: Removing RPL extension header (type %u, len %u)\n", *uip_next_hdr, rpl_ext_hdr_len);
LOG_DBG("Removing RPL extension header (type %u, len %u)\n", *uip_next_hdr, rpl_ext_hdr_len);
memmove(UIP_EXT_BUF, ((uint8_t *)UIP_EXT_BUF) + rpl_ext_hdr_len, uip_len - UIP_IPH_LEN);
} else {
uip_next_hdr = &UIP_EXT_BUF->next;

View File

@ -56,12 +56,13 @@
#include "net/ipv6/multicast/uip-mcast6.h"
#include "random.h"
#include "sys/log.h"
#include <limits.h>
#include <string.h>
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
/*---------------------------------------------------------------------------*/
#define RPL_DIO_GROUNDED 0x80
@ -201,11 +202,11 @@ rpl_icmp6_update_nbr_table(uip_ipaddr_t *from, nbr_table_reason_t reason, void *
if((nbr = uip_ds6_nbr_add(from, (uip_lladdr_t *)
packetbuf_addr(PACKETBUF_ADDR_SENDER),
0, NBR_REACHABLE, reason, data)) != NULL) {
PRINTF("RPL: Neighbor added to neighbor cache ");
PRINT6ADDR(from);
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("\n");
LOG_INFO("Neighbor added to neighbor cache ");
LOG_INFO_6ADDR(from);
LOG_INFO_(", ");
LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
LOG_INFO_("\n");
}
}
@ -219,31 +220,31 @@ dis_input(void)
rpl_instance_t *end;
/* DAG Information Solicitation */
PRINTF("RPL: Received a DIS from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
LOG_INFO("Received a DIS from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO_("\n");
for(instance = &instance_table[0], end = instance + RPL_MAX_INSTANCES;
instance < end; ++instance) {
if(instance->used == 1) {
if(uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
#if RPL_LEAF_ONLY
PRINTF("RPL: LEAF ONLY Multicast DIS will NOT reset DIO timer\n");
LOG_INFO("LEAF ONLY Multicast DIS will NOT reset DIO timer\n");
#else /* !RPL_LEAF_ONLY */
PRINTF("RPL: Multicast DIS => reset DIO timer\n");
LOG_DBG("Multicast DIS => reset DIO timer\n");
rpl_reset_dio_timer(instance);
#endif /* !RPL_LEAF_ONLY */
} else {
/* Check if this neighbor should be added according to the policy. */
if(rpl_icmp6_update_nbr_table(&UIP_IP_BUF->srcipaddr,
NBR_TABLE_REASON_RPL_DIS, NULL) == NULL) {
PRINTF("RPL: Out of Memory, not sending unicast DIO, DIS from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("\n");
LOG_ERR("Out of Memory, not sending unicast DIO, DIS from ");
LOG_ERR_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_ERR_(", ");
LOG_ERR_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
LOG_ERR_("\n");
} else {
PRINTF("RPL: Unicast DIS, reply to sender\n");
LOG_DBG("Unicast DIS, reply to sender\n");
dio_output(instance, &UIP_IP_BUF->srcipaddr);
}
/* } */
@ -276,9 +277,9 @@ dis_output(uip_ipaddr_t *addr)
addr = &tmpaddr;
}
PRINTF("RPL: Sending a DIS to ");
PRINT6ADDR(addr);
PRINTF("\n");
LOG_INFO("Sending a DIS to ");
LOG_INFO_6ADDR(addr);
LOG_INFO_("\n");
uip_icmp6_send(addr, ICMP6_RPL, RPL_CODE_DIS, 2);
}
@ -309,9 +310,9 @@ dio_input(void)
uip_ipaddr_copy(&from, &UIP_IP_BUF->srcipaddr);
/* DAG Information Object */
PRINTF("RPL: Received a DIO from ");
PRINT6ADDR(&from);
PRINTF("\n");
LOG_INFO("Received a DIO from ");
LOG_INFO_6ADDR(&from);
LOG_INFO_("\n");
buffer_length = uip_len - uip_l3_icmp_hdr_len;
@ -324,7 +325,7 @@ dio_input(void)
dio.rank = get16(buffer, i);
i += 2;
PRINTF("RPL: Incoming DIO (id, ver, rank) = (%u,%u,%u)\n",
LOG_DBG("Incoming DIO (id, ver, rank) = (%u,%u,%u)\n",
(unsigned)dio.instance_id,
(unsigned)dio.version,
(unsigned)dio.rank);
@ -340,9 +341,9 @@ dio_input(void)
memcpy(&dio.dag_id, buffer + i, sizeof(dio.dag_id));
i += sizeof(dio.dag_id);
PRINTF("RPL: Incoming DIO (dag_id, pref) = (");
PRINT6ADDR(&dio.dag_id);
PRINTF(", %u)\n", dio.preference);
LOG_DBG("Incoming DIO (dag_id, pref) = (");
LOG_DBG_6ADDR(&dio.dag_id);
LOG_DBG_(", %u)\n", dio.preference);
/* Check if there are any DIO suboptions. */
for(; i < buffer_length; i += len) {
@ -355,17 +356,17 @@ dio_input(void)
}
if(len + i > buffer_length) {
PRINTF("RPL: Invalid DIO packet\n");
LOG_WARN("Invalid DIO packet\n");
RPL_STAT(rpl_stats.malformed_msgs++);
goto discard;
}
PRINTF("RPL: DIO option %u, length: %u\n", subopt_type, len - 2);
LOG_DBG("Incoming DIO (option, length) = (%u, %u)\n", subopt_type, len - 2);
switch(subopt_type) {
case RPL_OPTION_DAG_METRIC_CONTAINER:
if(len < 6) {
PRINTF("RPL: Invalid DAG MC, len = %d\n", len);
LOG_WARN("Invalid DAG MC, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
goto discard;
}
@ -381,7 +382,7 @@ dio_input(void)
} else if(dio.mc.type == RPL_DAG_MC_ETX) {
dio.mc.obj.etx = get16(buffer, i + 6);
PRINTF("RPL: DAG MC: type %u, flags %u, aggr %u, prec %u, length %u, ETX %u\n",
LOG_DBG("DAG MC: type %u, flags %u, aggr %u, prec %u, length %u, ETX %u\n",
(unsigned)dio.mc.type,
(unsigned)dio.mc.flags,
(unsigned)dio.mc.aggr,
@ -392,13 +393,13 @@ dio_input(void)
dio.mc.obj.energy.flags = buffer[i + 6];
dio.mc.obj.energy.energy_est = buffer[i + 7];
} else {
PRINTF("RPL: Unhandled DAG MC type: %u\n", (unsigned)dio.mc.type);
LOG_WARN("Unhandled DAG MC type: %u\n", (unsigned)dio.mc.type);
goto discard;
}
break;
case RPL_OPTION_ROUTE_INFO:
if(len < 9) {
PRINTF("RPL: Invalid destination prefix option, len = %d\n", len);
LOG_WARN("Invalid destination prefix option, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
goto discard;
}
@ -410,11 +411,11 @@ dio_input(void)
if(((dio.destination_prefix.length + 7) / 8) + 8 <= len &&
dio.destination_prefix.length <= 128) {
PRINTF("RPL: Copying destination prefix\n");
LOG_INFO("Copying destination prefix\n");
memcpy(&dio.destination_prefix.prefix, &buffer[i + 8],
(dio.destination_prefix.length + 7) / 8);
} else {
PRINTF("RPL: Invalid route info option, len = %d\n", len);
LOG_WARN("Invalid route info option, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
goto discard;
}
@ -422,7 +423,7 @@ dio_input(void)
break;
case RPL_OPTION_DAG_CONF:
if(len != 16) {
PRINTF("RPL: Invalid DAG configuration option, len = %d\n", len);
LOG_WARN("Invalid DAG configuration option, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
goto discard;
}
@ -437,14 +438,14 @@ dio_input(void)
/* buffer + 12 is reserved */
dio.default_lifetime = buffer[i + 13];
dio.lifetime_unit = get16(buffer, i + 14);
PRINTF("RPL: DAG conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n",
LOG_INFO("DAG conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n",
dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund,
dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp,
dio.default_lifetime, dio.lifetime_unit);
break;
case RPL_OPTION_PREFIX_INFO:
if(len != 32) {
PRINTF("RPL: Invalid DAG prefix info, len != 32\n");
LOG_WARN("Invalid DAG prefix info, len != 32\n");
RPL_STAT(rpl_stats.malformed_msgs++);
goto discard;
}
@ -454,11 +455,11 @@ dio_input(void)
/* preferred lifetime stored in lifetime */
dio.prefix_info.lifetime = get32(buffer, i + 8);
/* 32-bit reserved at i + 12 */
PRINTF("RPL: Copying prefix information\n");
LOG_INFO("Copying prefix information\n");
memcpy(&dio.prefix_info.prefix, &buffer[i + 16], 16);
break;
default:
PRINTF("RPL: Unsupported suboption type in DIO: %u\n",
LOG_WARN("Unsupported suboption type in DIO: %u\n",
(unsigned)subopt_type);
}
}
@ -488,7 +489,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
/* In leaf mode, we only send DIO messages as unicasts in response to
unicast DIS messages. */
if(uc_addr == NULL) {
PRINTF("RPL: LEAF ONLY have multicast addr: skip dio_output\n");
LOG_DBG("LEAF ONLY have multicast addr: skip dio_output\n");
return;
}
#endif /* RPL_LEAF_ONLY */
@ -502,7 +503,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
is_root = (dag->rank == ROOT_RANK(instance));
#if RPL_LEAF_ONLY
PRINTF("RPL: LEAF ONLY DIO rank set to RPL_INFINITE_RANK\n");
LOG_DBG("LEAF ONLY DIO rank set to RPL_INFINITE_RANK\n");
set16(buffer, pos, RPL_INFINITE_RANK);
#else /* RPL_LEAF_ONLY */
set16(buffer, pos, dag->rank);
@ -553,7 +554,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
buffer[pos++] = instance->mc.obj.energy.flags;
buffer[pos++] = instance->mc.obj.energy.energy_est;
} else {
PRINTF("RPL: Unable to send DIO because of unhandled DAG MC type %u\n",
LOG_ERR("Unable to send DIO because of unhandled DAG MC type %u\n",
(unsigned)instance->mc.type);
return;
}
@ -593,37 +594,38 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
pos += 4;
memcpy(&buffer[pos], &dag->prefix_info.prefix, 16);
pos += 16;
PRINTF("RPL: Sending prefix info in DIO for ");
PRINT6ADDR(&dag->prefix_info.prefix);
PRINTF("\n");
LOG_DBG("Sending prefix info in DIO for ");
LOG_DBG_6ADDR(&dag->prefix_info.prefix);
LOG_DBG_("\n");
} else {
PRINTF("RPL: No prefix to announce (len %d)\n",
LOG_DBG("No prefix to announce (len %d)\n",
dag->prefix_info.length);
}
#if RPL_LEAF_ONLY
#if (DEBUG) & DEBUG_PRINT
if(uc_addr == NULL) {
PRINTF("RPL: LEAF ONLY sending unicast-DIO from multicast-DIO\n");
if(LOG_DBG_ENABLED) {
if(uc_addr == NULL) {
LOG_DBG("LEAF ONLY sending unicast-DIO from multicast-DIO\n");
}
}
#endif /* DEBUG_PRINT */
PRINTF("RPL: Sending unicast-DIO with rank %u to ",
LOG_INFO("Sending unicast-DIO with rank %u to ",
(unsigned)dag->rank);
PRINT6ADDR(uc_addr);
PRINTF("\n");
LOG_INFO_6ADDR(uc_addr);
LOG_INFO_("\n");
uip_icmp6_send(uc_addr, ICMP6_RPL, RPL_CODE_DIO, pos);
#else /* RPL_LEAF_ONLY */
/* Unicast requests get unicast replies! */
if(uc_addr == NULL) {
PRINTF("RPL: Sending a multicast-DIO with rank %u\n",
LOG_INFO("Sending a multicast-DIO with rank %u\n",
(unsigned)instance->current_dag->rank);
uip_create_linklocal_rplnodes_mcast(&addr);
uip_icmp6_send(&addr, ICMP6_RPL, RPL_CODE_DIO, pos);
} else {
PRINTF("RPL: Sending unicast-DIO with rank %u to ",
LOG_INFO("Sending unicast-DIO with rank %u to ",
(unsigned)instance->current_dag->rank);
PRINT6ADDR(uc_addr);
PRINTF("\n");
LOG_INFO_6ADDR(uc_addr);
LOG_INFO_("\n");
uip_icmp6_send(uc_addr, ICMP6_RPL, RPL_CODE_DIO, pos);
}
#endif /* RPL_LEAF_ONLY */
@ -685,7 +687,7 @@ dao_input_storing(void)
/* Is the DAG ID present? */
if(flags & RPL_DAO_D_FLAG) {
if(memcmp(&dag->dag_id, &buffer[pos], sizeof(dag->dag_id))) {
PRINTF("RPL: Ignoring a DAO for a DAG different from ours\n");
LOG_INFO("Ignoring a DAO for a DAG different from ours\n");
return;
}
pos += 16;
@ -695,10 +697,10 @@ dao_input_storing(void)
RPL_ROUTE_FROM_MULTICAST_DAO : RPL_ROUTE_FROM_UNICAST_DAO;
/* Destination Advertisement Object */
PRINTF("RPL: Received a (%s) DAO with sequence number %u from ",
LOG_DBG("Received a (%s) DAO with sequence number %u from ",
learned_from == RPL_ROUTE_FROM_UNICAST_DAO? "unicast": "multicast", sequence);
PRINT6ADDR(&dao_sender_addr);
PRINTF("\n");
LOG_DBG_6ADDR(&dao_sender_addr);
LOG_DBG_("\n");
if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) {
/* Check whether this is a DAO forwarding loop. */
@ -707,7 +709,7 @@ dao_input_storing(void)
/* if we already route to this node it is likely */
if(parent != NULL &&
DAG_RANK(parent->rank, instance) < DAG_RANK(dag->rank, instance)) {
PRINTF("RPL: Loop detected when receiving a unicast DAO from a node with a lower rank! (%u < %u)\n",
LOG_WARN("Loop detected when receiving a unicast DAO from a node with a lower rank! (%u < %u)\n",
DAG_RANK(parent->rank, instance), DAG_RANK(dag->rank, instance));
parent->rank = RPL_INFINITE_RANK;
parent->flags |= RPL_PARENT_FLAG_UPDATED;
@ -716,7 +718,7 @@ dao_input_storing(void)
/* If we get the DAO from our parent, we also have a loop. */
if(parent != NULL && parent == dag->preferred_parent) {
PRINTF("RPL: Loop detected when receiving a unicast DAO from our parent\n");
LOG_WARN("Loop detected when receiving a unicast DAO from our parent\n");
parent->rank = RPL_INFINITE_RANK;
parent->flags |= RPL_PARENT_FLAG_UPDATED;
return;
@ -750,10 +752,10 @@ dao_input_storing(void)
}
}
PRINTF("RPL: DAO lifetime: %u, prefix length: %u prefix: ",
LOG_INFO("DAO lifetime: %u, prefix length: %u prefix: ",
(unsigned)lifetime, (unsigned)prefixlen);
PRINT6ADDR(&prefix);
PRINTF("\n");
LOG_INFO_6ADDR(&prefix);
LOG_INFO_("\n");
#if RPL_WITH_MULTICAST
if(uip_is_addr_mcast_global(&prefix)) {
@ -774,16 +776,16 @@ dao_input_storing(void)
rep = uip_ds6_route_lookup(&prefix);
if(lifetime == RPL_ZERO_LIFETIME) {
PRINTF("RPL: No-Path DAO received\n");
LOG_INFO("No-Path DAO received\n");
/* No-Path DAO received; invoke the route purging routine. */
if(rep != NULL &&
!RPL_ROUTE_IS_NOPATH_RECEIVED(rep) &&
rep->length == prefixlen &&
uip_ds6_route_nexthop(rep) != NULL &&
uip_ipaddr_cmp(uip_ds6_route_nexthop(rep), &dao_sender_addr)) {
PRINTF("RPL: Setting expiration timer for prefix ");
PRINT6ADDR(&prefix);
PRINTF("\n");
LOG_DBG("Setting expiration timer for prefix ");
LOG_DBG_6ADDR(&prefix);
LOG_DBG_("\n");
RPL_ROUTE_SET_NOPATH_RECEIVED(rep);
rep->state.lifetime = RPL_NOPATH_REMOVAL_DELAY;
@ -794,10 +796,10 @@ dao_input_storing(void)
uint8_t out_seq;
out_seq = prepare_for_dao_fwd(sequence, rep);
PRINTF("RPL: Forwarding No-path DAO to parent - out_seq:%d",
LOG_DBG("Forwarding No-path DAO to parent - out_seq:%d",
out_seq);
PRINT6ADDR(rpl_parent_get_ipaddr(dag->preferred_parent));
PRINTF("\n");
LOG_DBG_6ADDR(rpl_parent_get_ipaddr(dag->preferred_parent));
LOG_DBG_("\n");
buffer = UIP_ICMP_PAYLOAD;
buffer[3] = out_seq; /* add an outgoing seq no before fwd */
@ -815,15 +817,15 @@ dao_input_storing(void)
return;
}
PRINTF("RPL: Adding DAO route\n");
LOG_INFO("Adding DAO route\n");
/* Update and add neighbor - if no room - fail. */
if((nbr = rpl_icmp6_update_nbr_table(&dao_sender_addr, NBR_TABLE_REASON_RPL_DAO, instance)) == NULL) {
PRINTF("RPL: Out of Memory, dropping DAO from ");
PRINT6ADDR(&dao_sender_addr);
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("\n");
LOG_ERR("Out of Memory, dropping DAO from ");
LOG_ERR_6ADDR(&dao_sender_addr);
LOG_ERR_(", ");
LOG_ERR_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
LOG_ERR_("\n");
if(flags & RPL_DAO_K_FLAG) {
/* signal the failure to add the node */
dao_ack_output(instance, &dao_sender_addr, sequence,
@ -836,7 +838,7 @@ dao_input_storing(void)
rep = rpl_add_route(dag, &prefix, prefixlen, &dao_sender_addr);
if(rep == NULL) {
RPL_STAT(rpl_stats.mem_overflows++);
PRINTF("RPL: Could not add a route after receiving a DAO\n");
LOG_ERR("Could not add a route after receiving a DAO\n");
if(flags & RPL_DAO_K_FLAG) {
/* signal the failure to add the node */
dao_ack_output(instance, &dao_sender_addr, sequence,
@ -887,9 +889,9 @@ fwd_dao:
}
}
PRINTF("RPL: Forwarding DAO to parent ");
PRINT6ADDR(rpl_parent_get_ipaddr(dag->preferred_parent));
PRINTF(" in seq: %d out seq: %d\n", sequence, out_seq);
LOG_DBG("Forwarding DAO to parent ");
LOG_DBG_6ADDR(rpl_parent_get_ipaddr(dag->preferred_parent));
LOG_DBG_(" in seq: %d out seq: %d\n", sequence, out_seq);
buffer = UIP_ICMP_PAYLOAD;
buffer[3] = out_seq; /* add an outgoing seq no before fwd */
@ -897,7 +899,7 @@ fwd_dao:
ICMP6_RPL, RPL_CODE_DAO, buffer_length);
}
if(should_ack) {
PRINTF("RPL: Sending DAO ACK\n");
LOG_DBG("Sending DAO ACK\n");
uip_clear_buf();
dao_ack_output(instance, &dao_sender_addr, sequence,
RPL_DAO_ACK_UNCONDITIONAL_ACCEPT);
@ -927,6 +929,11 @@ dao_input_nonstoring(void)
int len;
int i;
/* Destination Advertisement Object */
LOG_INFO("Received a DAO from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO_("\n");
prefixlen = 0;
uip_ipaddr_copy(&dao_sender_addr, &UIP_IP_BUF->srcipaddr);
@ -949,7 +956,7 @@ dao_input_nonstoring(void)
/* Is the DAG ID present? */
if(flags & RPL_DAO_D_FLAG) {
if(memcmp(&dag->dag_id, &buffer[pos], sizeof(dag->dag_id))) {
PRINTF("RPL: Ignoring a DAO for a DAG different from ours\n");
LOG_INFO("Ignoring a DAO for a DAG different from ours\n");
return;
}
pos += 16;
@ -984,25 +991,29 @@ dao_input_nonstoring(void)
}
}
PRINTF("RPL: DAO lifetime: %u, prefix length: %u prefix: ",
LOG_INFO("DAO lifetime: %u, prefix length: %u prefix: ",
(unsigned)lifetime, (unsigned)prefixlen);
PRINT6ADDR(&prefix);
PRINTF(", parent: ");
PRINT6ADDR(&dao_parent_addr);
PRINTF(" \n");
LOG_INFO_6ADDR(&prefix);
LOG_INFO_(", parent: ");
LOG_INFO_6ADDR(&dao_parent_addr);
LOG_INFO_("\n");
if(lifetime == RPL_ZERO_LIFETIME) {
PRINTF("RPL: No-Path DAO received\n");
LOG_DBG("No-Path DAO received\n");
uip_sr_expire_parent(dag, &prefix, &dao_parent_addr);
} else {
if(uip_sr_update_node(dag, &prefix, &dao_parent_addr, RPL_LIFETIME(instance, lifetime)) == NULL) {
PRINTF("RPL: failed to add link\n");
LOG_WARN("DAO failed to add link prefix: ");
LOG_WARN_6ADDR(&prefix);
LOG_WARN_(", parent: ");
LOG_WARN_6ADDR(&dao_parent_addr);
LOG_WARN_("\n");
return;
}
}
if(flags & RPL_DAO_K_FLAG) {
PRINTF("RPL: Sending DAO ACK\n");
LOG_DBG("Sending DAO ACK\n");
uip_clear_buf();
dao_ack_output(instance, &dao_sender_addr, sequence,
RPL_DAO_ACK_UNCONDITIONAL_ACCEPT);
@ -1017,14 +1028,14 @@ dao_input(void)
uint8_t instance_id;
/* Destination Advertisement Object */
PRINTF("RPL: Received a DAO from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
LOG_INFO("Received a DAO from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO_("\n");
instance_id = UIP_ICMP_PAYLOAD[0];
instance = rpl_get_instance(instance_id);
if(instance == NULL) {
PRINTF("RPL: Ignoring a DAO for an unknown RPL instance(%u)\n",
LOG_INFO("Ignoring a DAO for an unknown RPL instance(%u)\n",
instance_id);
goto discard;
}
@ -1076,7 +1087,7 @@ handle_dao_retransmission(void *ptr)
return;
}
PRINTF("RPL: will retransmit DAO - seq:%d trans:%d\n", instance->my_dao_seqno,
LOG_INFO("will retransmit DAO - seq:%d trans:%d\n", instance->my_dao_seqno,
instance->my_dao_transmissions);
if(get_global_addr(&prefix) == 0) {
@ -1101,7 +1112,7 @@ dao_output(rpl_parent_t *parent, uint8_t lifetime)
uip_ipaddr_t prefix;
if(get_global_addr(&prefix) == 0) {
PRINTF("RPL: No global address set for this node - suppressing DAO\n");
LOG_ERR("No global address set for this node - suppressing DAO\n");
return;
}
@ -1159,30 +1170,30 @@ dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix,
}
if(parent == NULL) {
PRINTF("RPL dao_output_target error parent NULL\n");
LOG_ERR("dao_output_target error parent NULL\n");
return;
}
parent_ipaddr = rpl_parent_get_ipaddr(parent);
if(parent_ipaddr == NULL) {
PRINTF("RPL dao_output_target error parent IP address NULL\n");
LOG_ERR("dao_output_target error parent IP address NULL\n");
return;
}
dag = parent->dag;
if(dag == NULL) {
PRINTF("RPL dao_output_target error dag NULL\n");
LOG_ERR("dao_output_target error dag NULL\n");
return;
}
instance = dag->instance;
if(instance == NULL) {
PRINTF("RPL dao_output_target error instance NULL\n");
LOG_ERR("dao_output_target error instance NULL\n");
return;
}
if(prefix == NULL) {
PRINTF("RPL dao_output_target error prefix NULL\n");
LOG_ERR("dao_output_target error prefix NULL\n");
return;
}
#ifdef RPL_DEBUG_DAO_OUTPUT
@ -1240,15 +1251,15 @@ dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix,
dest_ipaddr = &parent->dag->dag_id;
}
PRINTF("RPL: Sending a %sDAO with sequence number %u, lifetime %u, prefix ",
LOG_INFO("Sending a %sDAO with sequence number %u, lifetime %u, prefix ",
lifetime == RPL_ZERO_LIFETIME ? "No-Path " : "", seq_no, lifetime);
PRINT6ADDR(prefix);
PRINTF(" to ");
PRINT6ADDR(dest_ipaddr);
PRINTF(" , parent ");
PRINT6ADDR(parent_ipaddr);
PRINTF("\n");
LOG_INFO_6ADDR(prefix);
LOG_INFO_(" to ");
LOG_INFO_6ADDR(dest_ipaddr);
LOG_INFO_(" , parent ");
LOG_INFO_6ADDR(parent_ipaddr);
LOG_INFO_("\n");
if(dest_ipaddr != NULL) {
uip_icmp6_send(dest_ipaddr, ICMP6_RPL, RPL_CODE_DAO, pos);
@ -1291,16 +1302,16 @@ dao_ack_input(void)
}
if(instance->current_dag->rank == ROOT_RANK(instance)) {
PRINTF("RPL: DODAG root received a DAO ACK, ignoring it\n");
LOG_DBG("DODAG root received a DAO ACK, ignoring it\n");
uip_clear_buf();
return;
}
PRINTF("RPL: Received a DAO %s with sequence number %d (%d) and status %d from ",
LOG_INFO("Received a DAO %s with sequence number %d (%d) and status %d from ",
status < 128 ? "ACK" : "NACK",
sequence, instance->my_dao_seqno, status);
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO_("\n");
if(sequence == instance->my_dao_seqno) {
instance->has_downward_route = status < 128;
@ -1334,11 +1345,11 @@ dao_ack_input(void)
nexthop = uip_ds6_route_nexthop(re);
if(nexthop == NULL) {
PRINTF("RPL: No next hop to fwd DAO ACK to\n");
LOG_WARN("No next hop to fwd DAO ACK to\n");
} else {
PRINTF("RPL: Fwd DAO ACK to:");
PRINT6ADDR(nexthop);
PRINTF("\n");
LOG_INFO("Fwd DAO ACK to:");
LOG_INFO_6ADDR(nexthop);
LOG_INFO_("\n");
buffer[2] = re->state.dao_seqno_in;
uip_icmp6_send(nexthop, ICMP6_RPL, RPL_CODE_DAO_ACK, 4);
}
@ -1348,7 +1359,7 @@ dao_ack_input(void)
uip_ds6_route_rm(re);
}
} else {
PRINTF("RPL: No route entry found to forward DAO ACK (seqno %u)\n", sequence);
LOG_WARN("No route entry found to forward DAO ACK (seqno %u)\n", sequence);
}
}
#endif /* RPL_WITH_DAO_ACK */
@ -1362,9 +1373,9 @@ dao_ack_output(rpl_instance_t *instance, uip_ipaddr_t *dest, uint8_t sequence,
#if RPL_WITH_DAO_ACK
unsigned char *buffer;
PRINTF("RPL: Sending a DAO %s with sequence number %d to ", status < 128 ? "ACK" : "NACK", sequence);
PRINT6ADDR(dest);
PRINTF(" with status %d\n", status);
LOG_INFO("Sending a DAO %s with sequence number %d to ", status < 128 ? "ACK" : "NACK", sequence);
LOG_INFO_6ADDR(dest);
LOG_INFO_(" with status %d\n", status);
buffer = UIP_ICMP_PAYLOAD;

View File

@ -51,8 +51,10 @@
#include "net/nbr-table.h"
#include "net/link-stats.h"
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#include "sys/log.h"
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
/* RFC6551 and RFC6719 do not mandate the use of a specific formula to
* compute the ETX value. This MRHOF implementation relies on the value
@ -97,7 +99,7 @@ to the threshold of 96 in the non-squared case) */
static void
reset(rpl_dag_t *dag)
{
PRINTF("RPL: Reset MRHOF\n");
LOG_INFO("Reset MRHOF\n");
}
/*---------------------------------------------------------------------------*/
#if RPL_WITH_DAO_ACK
@ -108,7 +110,7 @@ dao_ack_callback(rpl_parent_t *p, int status)
return;
}
/* here we need to handle failed DAO's and other stuff */
PRINTF("RPL: MRHOF - DAO ACK received with status: %d\n", status);
LOG_DBG("MRHOF - DAO ACK received with status: %d\n", status);
if(status >= RPL_DAO_ACK_UNABLE_TO_ACCEPT) {
/* punish the ETX as if this was 10 packets lost */
link_stats_packet_sent(rpl_get_parent_lladdr(p), MAC_TX_OK, 10);
@ -262,7 +264,7 @@ update_metric_container(rpl_instance_t *instance)
dag = instance->current_dag;
if(dag == NULL || !dag->joined) {
PRINTF("RPL: Cannot update the metric container when not joined\n");
LOG_WARN("Cannot update the metric container when not joined\n");
return;
}
@ -297,7 +299,7 @@ update_metric_container(rpl_instance_t *instance)
instance->mc.obj.energy.energy_est = path_cost >> 8;
break;
default:
PRINTF("RPL: MRHOF, non-supported MC %u\n", instance->mc.type);
LOG_WARN("MRHOF, non-supported MC %u\n", instance->mc.type);
break;
}
}

View File

@ -49,8 +49,10 @@
#include "net/ipv6/uip-ds6-nbr.h"
#include "net/ipv6/uip-ds6-route.h"
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#include "sys/log.h"
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
/*
* Policy for neighbor adds
@ -71,7 +73,7 @@ static int num_free;
static linkaddr_t *worst_rank_nbr; /* the parent that has the worst rank */
static rpl_rank_t worst_rank;
/*---------------------------------------------------------------------------*/
#if DEBUG == DEBUG_FULL
#if LOG_DBG_ENABLED
/*
* This create a periodic call of the update_nbr function that will print
* useful debugging information when in DEBUG_FULL mode
@ -85,7 +87,7 @@ handle_periodic_timer(void *ptr)
update_nbr();
ctimer_restart(&periodic_timer);
}
#endif /* DEBUG == DEBUG_FULL */
#endif /* LOG_DBG_ENABLED */
/*---------------------------------------------------------------------------*/
static void
update_nbr(void)
@ -96,13 +98,13 @@ update_nbr(void)
int is_used;
rpl_rank_t rank;
#if DEBUG == DEBUG_FULL
if(!timer_init) {
timer_init = 1;
ctimer_set(&periodic_timer, 60 * CLOCK_SECOND,
&handle_periodic_timer, NULL);
}
#endif /* DEBUG == DEBUG_FULL */
#if LOG_DBG_ENABLED
if(!timer_init) {
timer_init = 1;
ctimer_set(&periodic_timer, 60 * CLOCK_SECOND,
&handle_periodic_timer, NULL);
}
#endif /* LOG_DBG_ENABLED */
worst_rank = 0;
worst_rank_nbr = NULL;
@ -152,9 +154,9 @@ update_nbr(void)
worst_rank_nbr = lladdr;
worst_rank = RPL_INFINITE_RANK;
} else if(is_used > 1) {
PRINTF("NBR-POLICY: *** Neighbor is both child and candidate parent: ");
PRINTLLADDR((uip_lladdr_t *)lladdr);
PRINTF("\n");
LOG_DBG("nbr-policy: *** neighbor is both child and candidate parent: ");
LOG_DBG_LLADDR(lladdr);
LOG_DBG_("\n");
}
nbr = nbr_table_next(ds6_neighbors, nbr);
@ -163,7 +165,7 @@ update_nbr(void)
/* how many more IP neighbors can be have? */
num_free = NBR_TABLE_MAX_NEIGHBORS - num_used;
PRINTF("NBR-POLICY: Free: %d, Children: %d, Parents: %d Routes: %d\n",
LOG_DBG("nbr-policy: free: %d, children: %d, parents: %d routes: %d\n",
num_free, num_children, num_parents, uip_ds6_route_num_routes());
}
/*---------------------------------------------------------------------------*/
@ -177,7 +179,7 @@ find_removable_dis(uip_ipaddr_t *from)
if(num_free > 0) {
/* there are free entries (e.g. unsused by RPL and ND6) but since it is
used by other modules we can not pick these entries for removal. */
PRINTF("Num-free > 0 = %d - Other for RPL/ND6 unused NBR entry exists .",
LOG_DBG("nbr-policy: num-free > 0 = %d - Other for RPL/ND6 unused NBR entry exists.\n",
num_free);
}
if(num_children < MAX_CHILDREN) {
@ -195,20 +197,20 @@ find_removable_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
instance = rpl_get_instance(dio->instance_id);
if(instance == NULL || instance->current_dag == NULL) {
PRINTF("Did not find instance id: %d\n", dio->instance_id);
LOG_WARN("nbr-policy: did not find instance id: %d\n", dio->instance_id);
return NULL;
}
/* Add the new neighbor only if it is better than the worst parent. */
if(dio->rank + instance->min_hoprankinc < worst_rank - instance->min_hoprankinc / 2) {
/* Found *great* neighbor - add! */
PRINTF("Found better neighbor %d < %d - add to cache...\n",
LOG_DBG("nbr-policy: DIO rank %u, worst_rank %u -- add to cache\n",
dio->rank, worst_rank);
return worst_rank_nbr;
}
PRINTF("Found worse neighbor with new %d and old %d - NOT add to cache.\n",
LOG_DBG("nbr-policy: DIO rank %u, worst_rank %u -- do not add to cache\n",
dio->rank, worst_rank);
return NULL;
}
@ -229,7 +231,7 @@ find_removable_dao(uip_ipaddr_t *from, rpl_instance_t *instance)
/* Check if this DAO sender is not yet neighbor and there is already too
many children. */
if(num_children >= max) {
PRINTF("Can not add another child - already at max.\n");
LOG_ERR("nbr-policy: can not add another child - already at max.\n");
return NULL;
}
/* remove the worst ranked nbr */

View File

@ -47,8 +47,10 @@
#include "net/nbr-table.h"
#include "net/link-stats.h"
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#include "sys/log.h"
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
/* Constants from RFC6552. We use the default values. */
#define RANK_STRETCH 0 /* Must be in the range [0;5] */
@ -87,7 +89,7 @@
static void
reset(rpl_dag_t *dag)
{
PRINTF("RPL: Reset OF0\n");
LOG_INFO("Reset OF0\n");
}
/*---------------------------------------------------------------------------*/
#if RPL_WITH_DAO_ACK
@ -98,7 +100,7 @@ dao_ack_callback(rpl_parent_t *p, int status)
return;
}
/* here we need to handle failed DAO's and other stuff */
PRINTF("RPL: OF0 - DAO ACK received with status: %d\n", status);
LOG_DBG("OF0 - DAO ACK received with status: %d\n", status);
if(status >= RPL_DAO_ACK_UNABLE_TO_ACCEPT) {
/* punish the ETX as if this was 10 packets lost */
link_stats_packet_sent(rpl_get_parent_lladdr(p), MAC_TX_OK, 10);

View File

@ -48,9 +48,10 @@
#include "net/ipv6/uip-sr.h"
#include "lib/random.h"
#include "sys/ctimer.h"
#include "sys/log.h"
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
/* A configurable function called after update of the RPL DIO interval */
#ifdef RPL_CALLBACK_NEW_DIO_INTERVAL
@ -133,7 +134,7 @@ new_dio_interval(rpl_instance_t *instance)
/* keep some stats */
instance->dio_totint++;
instance->dio_totrecv += instance->dio_counter;
ANNOTATE("#A rank=%u.%u(%u),stats=%d %d %d %d,color=%s\n",
LOG_ANNOTATE("#A rank=%u.%u(%u),stats=%d %d %d %d,color=%s\n",
DAG_RANK(instance->current_dag->rank, instance),
(10 * (instance->current_dag->rank % instance->min_hoprankinc)) / instance->min_hoprankinc,
instance->current_dag->version,
@ -146,7 +147,7 @@ new_dio_interval(rpl_instance_t *instance)
instance->dio_counter = 0;
/* schedule the timer */
PRINTF("RPL: Scheduling DIO timer %lu ticks in future (Interval)\n", ticks);
LOG_INFO("Scheduling DIO timer %lu ticks in future (Interval)\n", ticks);
ctimer_set(&instance->dio_timer, ticks, &handle_dio_timer, instance);
#ifdef RPL_CALLBACK_NEW_DIO_INTERVAL
@ -161,12 +162,12 @@ handle_dio_timer(void *ptr)
instance = (rpl_instance_t *)ptr;
PRINTF("RPL: DIO Timer triggered\n");
LOG_DBG("DIO Timer triggered\n");
if(!dio_send_ok) {
if(uip_ds6_get_link_local(ADDR_PREFERRED) != NULL) {
dio_send_ok = 1;
} else {
PRINTF("RPL: Postponing DIO transmission since link local address is not ok\n");
LOG_WARN("Postponing DIO transmission since link local address is not ok\n");
ctimer_set(&instance->dio_timer, CLOCK_SECOND, &handle_dio_timer, instance);
return;
}
@ -180,25 +181,25 @@ handle_dio_timer(void *ptr)
#endif /* RPL_CONF_STATS */
dio_output(instance, NULL);
} else {
PRINTF("RPL: Suppressing DIO transmission (%d >= %d)\n",
LOG_DBG("Suppressing DIO transmission (%d >= %d)\n",
instance->dio_counter, instance->dio_redundancy);
}
instance->dio_send = 0;
PRINTF("RPL: Scheduling DIO timer %lu ticks in future (sent)\n",
LOG_DBG("Scheduling DIO timer %lu ticks in future (sent)\n",
instance->dio_next_delay);
ctimer_set(&instance->dio_timer, instance->dio_next_delay, handle_dio_timer, instance);
} else {
/* check if we need to double interval */
if(instance->dio_intcurrent < instance->dio_intmin + instance->dio_intdoubl) {
instance->dio_intcurrent++;
PRINTF("RPL: DIO Timer interval doubled %d\n", instance->dio_intcurrent);
LOG_DBG("DIO Timer interval doubled %d\n", instance->dio_intcurrent);
}
new_dio_interval(instance);
}
#if DEBUG
rpl_print_neighbor_list();
#endif
if(LOG_DBG_ENABLED) {
rpl_print_neighbor_list();
}
}
/*---------------------------------------------------------------------------*/
void
@ -245,7 +246,7 @@ set_dao_lifetime_timer(rpl_instance_t *instance)
CLOCK_SECOND / 2;
/* make the time for the re registration be betwen 1/2 - 3/4 of lifetime */
expiration_time = expiration_time + (random_rand() % (expiration_time / 2));
PRINTF("RPL: Scheduling DAO lifetime timer %u ticks in the future\n",
LOG_DBG("Scheduling DAO lifetime timer %u ticks in the future\n",
(unsigned)expiration_time);
ctimer_set(&instance->dao_lifetime_timer, expiration_time,
handle_dao_timer, instance);
@ -264,14 +265,14 @@ handle_dao_timer(void *ptr)
instance = (rpl_instance_t *)ptr;
if(!dio_send_ok && uip_ds6_get_link_local(ADDR_PREFERRED) == NULL) {
PRINTF("RPL: Postpone DAO transmission\n");
LOG_INFO("Postpone DAO transmission\n");
ctimer_set(&instance->dao_timer, CLOCK_SECOND, handle_dao_timer, instance);
return;
}
/* Send the DAO to the DAO parent set -- the preferred parent in our case. */
if(instance->current_dag->preferred_parent != NULL) {
PRINTF("RPL: handle_dao_timer - sending DAO\n");
LOG_INFO("handle_dao_timer - sending DAO\n");
/* Set the route lifetime to the default value. */
dao_output(instance->current_dag->preferred_parent, instance->default_lifetime);
@ -300,7 +301,7 @@ handle_dao_timer(void *ptr)
}
#endif
} else {
PRINTF("RPL: No suitable DAO parent\n");
LOG_INFO("No suitable DAO parent\n");
}
ctimer_stop(&instance->dao_timer);
@ -322,7 +323,7 @@ schedule_dao(rpl_instance_t *instance, clock_time_t latency)
expiration_time = etimer_expiration_time(&instance->dao_timer.etimer);
if(!etimer_expired(&instance->dao_timer.etimer)) {
PRINTF("RPL: DAO timer already scheduled\n");
LOG_DBG("DAO timer already scheduled\n");
} else {
if(latency != 0) {
expiration_time = latency / 2 +
@ -330,7 +331,7 @@ schedule_dao(rpl_instance_t *instance, clock_time_t latency)
} else {
expiration_time = 0;
}
PRINTF("RPL: Scheduling DAO timer %u ticks in the future\n",
LOG_DBG("Scheduling DAO timer %u ticks in the future\n",
(unsigned)expiration_time);
ctimer_set(&instance->dao_timer, expiration_time,
handle_dao_timer, instance);
@ -479,7 +480,7 @@ handle_probing_timer(void *ptr)
if(target_ipaddr != NULL) {
const struct link_stats *stats = rpl_get_parent_link_stats(probing_target);
(void)stats;
PRINTF("RPL: probing %u %s last tx %u min ago\n",
LOG_INFO("probing %u %s last tx %u min ago\n",
rpl_get_parent_lladdr(probing_target)->u8[7],
instance->urgent_probing_target != NULL ? "(urgent)" : "",
probing_target != NULL ?
@ -492,9 +493,9 @@ handle_probing_timer(void *ptr)
/* Schedule next probing */
rpl_schedule_probing(instance);
#if DEBUG
rpl_print_neighbor_list();
#endif
if(LOG_DBG_ENABLED) {
rpl_print_neighbor_list();
}
}
/*---------------------------------------------------------------------------*/
void

View File

@ -52,12 +52,14 @@
#include "net/routing/rpl-classic/rpl-dag-root.h"
#include "net/ipv6/multicast/uip-mcast6.h"
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#include "sys/log.h"
#include <limits.h>
#include <string.h>
#define LOG_MODULE "RPL"
#define LOG_LEVEL LOG_LEVEL_RPL
#if RPL_CONF_STATS
rpl_stats_t rpl_stats;
#endif
@ -83,7 +85,7 @@ rpl_set_mode(enum rpl_mode m)
inform our parent that we now are reachable. Before we do this,
we must set the mode variable, since DAOs will not be sent if
we are in feather mode. */
PRINTF("RPL: switching to mesh mode\n");
LOG_DBG("rpl_set_mode: switching to mesh mode\n");
mode = m;
if(default_instance != NULL) {
@ -91,15 +93,15 @@ rpl_set_mode(enum rpl_mode m)
}
} else if(m == RPL_MODE_FEATHER) {
PRINTF("RPL: switching to feather mode\n");
LOG_INFO("rpl_set_mode: switching to feather mode\n");
if(default_instance != NULL) {
PRINTF("rpl_set_mode: RPL sending DAO with zero lifetime\n");
LOG_INFO("rpl_set_mode: RPL sending DAO with zero lifetime\n");
if(default_instance->current_dag != NULL) {
dao_output(default_instance->current_dag->preferred_parent, RPL_ZERO_LIFETIME);
}
rpl_cancel_dao(default_instance);
} else {
PRINTF("rpl_set_mode: no default instance\n");
LOG_INFO("rpl_set_mode: no default instance\n");
}
mode = m;
@ -145,17 +147,17 @@ rpl_purge_routes(void)
uip_ipaddr_copy(&prefix, &r->ipaddr);
uip_ds6_route_rm(r);
r = uip_ds6_route_head();
PRINTF("No more routes to ");
PRINT6ADDR(&prefix);
LOG_INFO("No more routes to ");
LOG_INFO_6ADDR(&prefix);
dag = default_instance->current_dag;
/* Propagate this information with a No-Path DAO to preferred parent if we are not a RPL Root */
if(dag->rank != ROOT_RANK(default_instance)) {
PRINTF(" -> generate No-Path DAO\n");
LOG_INFO_(" -> generate No-Path DAO\n");
dao_output_target(dag->preferred_parent, &prefix, RPL_ZERO_LIFETIME);
/* Don't schedule more than 1 No-Path DAO, let next iteration handle that */
return;
}
PRINTF("\n");
LOG_INFO_("\n");
} else {
r = uip_ds6_route_next(r);
}
@ -223,7 +225,7 @@ rpl_remove_routes_by_nexthop(uip_ipaddr_t *nexthop, rpl_dag_t *dag)
}
r = uip_ds6_route_next(r);
}
ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
LOG_ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
}
/*---------------------------------------------------------------------------*/
uip_ds6_route_t *
@ -233,7 +235,7 @@ rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix, int prefix_len,
uip_ds6_route_t *rep;
if((rep = uip_ds6_route_add(prefix, prefix_len, next_hop)) == NULL) {
PRINTF("RPL: No space for more route entries\n");
LOG_ERR("No space for more route entries\n");
return NULL;
}
@ -242,11 +244,11 @@ rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix, int prefix_len,
/* always clear state flags for the no-path received when adding/refreshing */
RPL_ROUTE_CLEAR_NOPATH_RECEIVED(rep);
PRINTF("RPL: Added a route to ");
PRINT6ADDR(prefix);
PRINTF("/%d via ", prefix_len);
PRINT6ADDR(next_hop);
PRINTF("\n");
LOG_INFO("Added a route to ");
LOG_INFO_6ADDR(prefix);
LOG_INFO_("/%d via ", prefix_len);
LOG_INFO_6ADDR(next_hop);
LOG_INFO_("\n");
return rep;
}
@ -268,11 +270,13 @@ rpl_link_callback(const linkaddr_t *addr, int status, int numtx)
if(parent != NULL) {
/* If this is the neighbor we were probing urgently, mark urgent
probing as done */
#if RPL_WITH_PROBING
if(instance->urgent_probing_target == parent) {
instance->urgent_probing_target = NULL;
}
#endif /* RPL_WITH_PROBING */
/* Trigger DAG rank recalculation. */
PRINTF("RPL: rpl_link_callback triggering update\n");
LOG_DBG("rpl_link_callback triggering update\n");
parent->flags |= RPL_PARENT_FLAG_UPDATED;
}
}
@ -286,12 +290,12 @@ rpl_ipv6_neighbor_callback(uip_ds6_nbr_t *nbr)
rpl_instance_t *instance;
rpl_instance_t *end;
PRINTF("RPL: Neighbor state changed for ");
PRINT6ADDR(&nbr->ipaddr);
LOG_DBG("Neighbor state changed for ");
LOG_DBG_6ADDR(&nbr->ipaddr);
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA
PRINTF(", nscount=%u, state=%u\n", nbr->nscount, nbr->state);
LOG_DBG_(", nscount=%u, state=%u\n", nbr->nscount, nbr->state);
#else /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA */
PRINTF(", state=%u\n", nbr->state);
LOG_DBG_(", state=%u\n", nbr->state);
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA */
for(instance = &instance_table[0], end = instance + RPL_MAX_INSTANCES; instance < end; ++instance) {
if(instance->used == 1 ) {
@ -299,7 +303,7 @@ rpl_ipv6_neighbor_callback(uip_ds6_nbr_t *nbr)
if(p != NULL) {
p->rank = RPL_INFINITE_RANK;
/* Trigger DAG rank recalculation. */
PRINTF("RPL: rpl_ipv6_neighbor_callback infinite rank\n");
LOG_DBG("rpl_ipv6_neighbor_callback infinite rank\n");
p->flags |= RPL_PARENT_FLAG_UPDATED;
}
}
@ -320,9 +324,9 @@ rpl_purge_dags(void)
if(instance->dag_table[i].used) {
if(instance->dag_table[i].lifetime == 0) {
if(!instance->dag_table[i].joined) {
PRINTF("Removing dag ");
PRINT6ADDR(&instance->dag_table[i].dag_id);
PRINTF("\n");
LOG_INFO("Removing dag ");
LOG_INFO_6ADDR(&instance->dag_table[i].dag_id);
LOG_INFO_("\n");
rpl_free_dag(&instance->dag_table[i]);
}
} else {
@ -338,7 +342,7 @@ static void
init(void)
{
uip_ipaddr_t rplmaddr;
PRINTF("RPL started\n");
LOG_INFO("rpl-classic started\n");
default_instance = NULL;
rpl_dag_init();
@ -403,7 +407,7 @@ drop_route(uip_ds6_route_t *route)
static void
leave_network(void)
{
PRINTF("RPL: leave_network not supported in RPL Classic\n");
LOG_ERR("leave_network not supported in RPL Classic\n");
}
/*---------------------------------------------------------------------------*/
static int

View File

@ -191,6 +191,13 @@
#define RPL_DEFAULT_LEAF_ONLY 0
#endif
/*
* Function used to validate dio before using it to init dag
*/
#ifdef RPL_CONF_VALIDATE_DIO_FUNC
#define RPL_VALIDATE_DIO_FUNC RPL_CONF_VALIDATE_DIO_FUNC
#endif
/******************************************************************************/
/********************************** Timing ************************************/
/******************************************************************************/

View File

@ -61,6 +61,12 @@ static int init_dag_from_dio(rpl_dio_t *dio);
/* Allocate instance table. */
rpl_instance_t curr_instance;
/*---------------------------------------------------------------------------*/
#ifdef RPL_VALIDATE_DIO_FUNC
int RPL_VALIDATE_DIO_FUNC(rpl_dio_t *dio);
#endif /* RPL_PROBING_SELECT_FUNC */
/*---------------------------------------------------------------------------*/
const char *
rpl_dag_state_to_str(enum rpl_dag_state state)
@ -542,6 +548,13 @@ init_dag_from_dio(rpl_dio_t *dio)
static int
process_dio_init_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
{
#ifdef RPL_VALIDATE_DIO_FUNC
if(!RPL_VALIDATE_DIO_FUNC(dio)) {
LOG_WARN("DIO validation failed\n");
return 0;
}
#endif
/* Check MOP */
if(dio->mop != RPL_MOP_NO_DOWNWARD_ROUTES && dio->mop != RPL_MOP_NON_STORING) {
LOG_WARN("ignoring DIO with an unsupported MOP: %d\n", dio->mop);

@ -1 +1 @@
Subproject commit 5da931eeb78d1cd4a1e0068a91de9b78bd3f66de
Subproject commit 53a0d97da748a67093c49cb38744650c71d58c4d

View File

@ -74,8 +74,8 @@ static lwm2m_status_t
get_temp_value(const ipso_sensor_t *s, int32_t *value)
{
#ifdef IPSO_TEMPERATURE
if(IPSO_TEMPERATURE.read_value == NULL ||
IPSO_TEMPERATURE.read_value(value) != 0) {
if(IPSO_TEMPERATURE.read_value != NULL &&
IPSO_TEMPERATURE.read_value(value) == 0) {
return LWM2M_STATUS_OK;
}
#endif /* IPSO_TEMPERATURE */

View File

@ -84,7 +84,7 @@
#define STATE_MACHINE_UPDATE_INTERVAL 500
static struct lwm2m_session_info session_info;
static coap_request_state_t rd_request_state;
static coap_callback_request_state_t rd_request_state;
static coap_message_t request[1]; /* This way the message can be treated as pointer as usual. */
@ -118,7 +118,6 @@ static uint8_t rd_state = 0;
static uint8_t rd_flags = FLAG_RD_DATA_UPDATE_ON_DIRTY;
static uint64_t wait_until_network_check = 0;
static uint64_t last_update;
static uint64_t last_rd_progress = 0;
static char query_data[64]; /* allocate some data for queries and updates */
static uint8_t rd_data[128]; /* allocate some data for the RD */
@ -126,7 +125,7 @@ static uint8_t rd_data[128]; /* allocate some data for the RD */
static uint32_t rd_block1;
static uint8_t rd_more;
static coap_timer_t rd_timer;
static void (*rd_callback)(coap_request_state_t *state);
static void (*rd_callback)(coap_callback_request_state_t *callback_state);
static coap_timer_t block1_timer;
@ -143,7 +142,7 @@ static void queue_mode_awake_timer_callback(coap_timer_t *timer);
#endif
static void check_periodic_observations();
static void update_callback(coap_request_state_t *state);
static void update_callback(coap_callback_request_state_t *callback_state);
static int
set_rd_data(coap_message_t *request)
@ -370,10 +369,11 @@ update_bootstrap_server(void)
* TODO
*/
static void
bootstrap_callback(coap_request_state_t *state)
bootstrap_callback(coap_callback_request_state_t *callback_state)
{
coap_request_state_t *state = &callback_state->state;
LOG_DBG("Bootstrap callback Response: %d, ", state->response != NULL);
if(state->response) {
if(state->status == COAP_REQUEST_STATUS_RESPONSE) {
if(CHANGED_2_04 == state->response->code) {
LOG_DBG_("Considered done!\n");
rd_state = BOOTSTRAP_DONE;
@ -383,12 +383,14 @@ bootstrap_callback(coap_request_state_t *state)
LOG_DBG_("Failed with code %d. Retrying\n", state->response->code);
/* TODO Application callback? */
rd_state = INIT;
} else if(BOOTSTRAP_SENT == rd_state) { /* this can handle double invocations */
/* Failure! */
LOG_DBG("Bootstrap failed! Retry?");
} else if(state->status == COAP_REQUEST_STATUS_TIMEOUT) {
LOG_DBG_("Server not responding! Retry?");
rd_state = DO_BOOTSTRAP;
} else if(state->status == COAP_REQUEST_STATUS_FINISHED) {
LOG_DBG_("Request finished. Ignore\n");
} else {
LOG_DBG("Ignore\n");
LOG_DBG_("Unexpected error! Retry?");
rd_state = DO_BOOTSTRAP;
}
}
/*---------------------------------------------------------------------------*/
@ -427,10 +429,11 @@ block1_rd_callback(coap_timer_t *timer)
* Page 65-66 in 07 April 2016 spec.
*/
static void
registration_callback(coap_request_state_t *state)
registration_callback(coap_callback_request_state_t *callback_state)
{
LOG_DBG("Registration callback. Response: %d, ", state->response != NULL);
if(state->response) {
coap_request_state_t *state = &callback_state->state;
LOG_DBG("Registration callback. Status: %d. Response: %d, ", state->status, state->response != NULL);
if(state->status == COAP_REQUEST_STATUS_RESPONSE) {
/* check state and possibly set registration to done */
/* If we get a continue - we need to call the rd generator one more time */
if(CONTINUE_2_31 == state->response->code) {
@ -472,10 +475,14 @@ registration_callback(coap_request_state_t *state)
}
/* TODO Application callback? */
rd_state = INIT;
/* remember last progress time */
last_rd_progress = coap_timer_uptime();
} else if(state->status == COAP_REQUEST_STATUS_TIMEOUT) {
LOG_DBG_("Server not responding, trying to reconnect\n");
rd_state = INIT;
} else if(state->status == COAP_REQUEST_STATUS_FINISHED){
LOG_DBG_("Request finished. Ignore\n");
} else {
LOG_DBG_("Ignore\n");
LOG_DBG_("Unexpected error, trying to reconnect\n");
rd_state = INIT;
}
}
/*---------------------------------------------------------------------------*/
@ -483,11 +490,12 @@ registration_callback(coap_request_state_t *state)
* Page 65-66 in 07 April 2016 spec.
*/
static void
update_callback(coap_request_state_t *state)
update_callback(coap_callback_request_state_t *callback_state)
{
LOG_DBG("Update callback. Response: %d, ", state->response != NULL);
coap_request_state_t *state = &callback_state->state;
LOG_DBG("Update callback. Status: %d. Response: %d, ", state->status, state->response != NULL);
if(state->response) {
if(state->status == COAP_REQUEST_STATUS_RESPONSE) {
/* If we get a continue - we need to call the rd generator one more time */
if(CONTINUE_2_31 == state->response->code) {
/* We assume that size never change?! */
@ -522,20 +530,26 @@ update_callback(coap_request_state_t *state)
state->response->code);
rd_state = DO_REGISTRATION;
}
/* remember last progress */
last_rd_progress = coap_timer_uptime();
} else if(state->status == COAP_REQUEST_STATUS_TIMEOUT) {
LOG_DBG_("Server not responding, trying to reconnect\n");
rd_state = INIT;
} else if(state->status == COAP_REQUEST_STATUS_FINISHED){
LOG_DBG_("Request finished. Ignore\n");
} else {
LOG_DBG("Ignore\n");
LOG_DBG_("Unexpected error, trying to reconnect\n");
rd_state = INIT;
}
}
/*---------------------------------------------------------------------------*/
static void
deregister_callback(coap_request_state_t *state)
deregister_callback(coap_callback_request_state_t *callback_state)
{
LOG_DBG("Deregister callback. Response Code: %d\n",
coap_request_state_t *state = &callback_state->state;
LOG_DBG("Deregister callback. Status: %d. Response Code: %d\n",
state->status,
state->response != NULL ? state->response->code : 0);
if(state->response && (DELETED_2_02 == state->response->code)) {
if(state->status == COAP_REQUEST_STATUS_RESPONSE && (DELETED_2_02 == state->response->code)) {
LOG_DBG("Deregistration success\n");
rd_state = DEREGISTERED;
perform_session_callback(LWM2M_RD_CLIENT_DEREGISTERED);
@ -548,13 +562,6 @@ deregister_callback(coap_request_state_t *state)
}
}
/*---------------------------------------------------------------------------*/
static void
recover_from_rd_delay(void)
{
/* This can be improved in the future... */
rd_state = INIT;
}
/*---------------------------------------------------------------------------*/
/* CoAP timer callback */
static void
periodic_process(coap_timer_t *timer)
@ -611,10 +618,10 @@ periodic_process(coap_timer_t *timer)
LOG_INFO_COAP_EP(&session_info.bs_server_ep);
LOG_INFO_("] as '%s'\n", query_data);
coap_send_request(&rd_request_state, &session_info.bs_server_ep,
request, bootstrap_callback);
rd_state = BOOTSTRAP_SENT;
if(coap_send_request(&rd_request_state, &session_info.bs_server_ep,
request, bootstrap_callback)) {
rd_state = BOOTSTRAP_SENT;
}
}
}
break;
@ -710,18 +717,14 @@ periodic_process(coap_timer_t *timer)
}
LOG_INFO_("' More:%d\n", rd_more);
coap_send_request(&rd_request_state, &session_info.server_ep,
request, registration_callback);
last_rd_progress = coap_timer_uptime();
rd_state = REGISTRATION_SENT;
if(coap_send_request(&rd_request_state, &session_info.server_ep,
request, registration_callback)){
rd_state = REGISTRATION_SENT;
}
}
break;
case REGISTRATION_SENT:
/* just wait until the callback kicks us to the next state... */
if(last_rd_progress + MAX_RD_UPDATE_WAIT < coap_timer_uptime()) {
/* Timeout on the update - something is wrong? */
recover_from_rd_delay();
}
break;
case REGISTRATION_DONE:
/* All is done! */
@ -733,10 +736,10 @@ periodic_process(coap_timer_t *timer)
((uint32_t)session_info.lifetime * 500) <= now - last_update) {
/* triggered or time to send an update to the server, at half-time! sec vs ms */
prepare_update(request, rd_flags & FLAG_RD_DATA_UPDATE_TRIGGERED);
coap_send_request(&rd_request_state, &session_info.server_ep, request,
update_callback);
last_rd_progress = coap_timer_uptime();
rd_state = UPDATE_SENT;
if(coap_send_request(&rd_request_state, &session_info.server_ep, request,
update_callback)) {
rd_state = UPDATE_SENT;
}
}
break;
#if LWM2M_QUEUE_MODE_ENABLED
@ -754,27 +757,24 @@ periodic_process(coap_timer_t *timer)
LWM2M_QUEUE_MODE_WAKE_UP();
#endif /* LWM2M_QUEUE_MODE_WAKE_UP */
prepare_update(request, rd_flags & FLAG_RD_DATA_UPDATE_TRIGGERED);
coap_send_request(&rd_request_state, &session_info.server_ep, request,
update_callback);
last_rd_progress = coap_timer_uptime();
rd_state = UPDATE_SENT;
if(coap_send_request(&rd_request_state, &session_info.server_ep, request,
update_callback)) {
rd_state = UPDATE_SENT;
}
break;
#endif /* LWM2M_QUEUE_MODE_ENABLED */
case UPDATE_SENT:
/* just wait until the callback kicks us to the next state... */
if(last_rd_progress + MAX_RD_UPDATE_WAIT < coap_timer_uptime()) {
/* Timeout on the update - something is wrong? */
recover_from_rd_delay();
}
break;
case DEREGISTER:
LOG_INFO("DEREGISTER %s\n", session_info.assigned_ep);
coap_init_message(request, COAP_TYPE_CON, COAP_DELETE, 0);
coap_set_header_uri_path(request, session_info.assigned_ep);
coap_send_request(&rd_request_state, &session_info.server_ep, request,
deregister_callback);
rd_state = DEREGISTER_SENT;
if(coap_send_request(&rd_request_state, &session_info.server_ep, request,
deregister_callback)) {
rd_state = DEREGISTER_SENT;
}
break;
case DEREGISTER_SENT:
break;

View File

@ -45,6 +45,7 @@
#include "contiki.h"
#include "shell.h"
#include "shell-commands.h"
#include "lib/list.h"
#include "sys/log.h"
#include "dev/watchdog.h"
#include "net/ipv6/uip.h"
@ -76,7 +77,8 @@ static uint16_t curr_ping_datalen;
#if TSCH_WITH_SIXTOP
static shell_command_6top_sub_cmd_t sixtop_sub_cmd = NULL;
#endif /* TSCH_WITH_SIXTOP */
static struct shell_command_set_t builtin_shell_command_set;
LIST(shell_command_sets);
/*---------------------------------------------------------------------------*/
static const char *
ds6_nbr_state_to_str(uint8_t state)
@ -345,15 +347,16 @@ PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
static
PT_THREAD(cmd_help(struct pt *pt, shell_output_func output, char *args))
{
struct shell_command_t *cmd_ptr;
struct shell_command_set_t *set;
const struct shell_command_t *cmd;
PT_BEGIN(pt);
SHELL_OUTPUT(output, "Available commands:\n");
cmd_ptr = shell_commands;
while(cmd_ptr->name != NULL) {
SHELL_OUTPUT(output, "%s\n", cmd_ptr->help);
cmd_ptr++;
/* Note: we explicitly don't expend any code space to deal with shadowing */
for(set = list_head(shell_command_sets); set != NULL; set = list_item_next(set)) {
for(cmd = set->commands; cmd->name != NULL; ++cmd) {
SHELL_OUTPUT(output, "%s\n", cmd->help);
}
}
PT_END(pt);
@ -729,12 +732,48 @@ PT_THREAD(cmd_6top(struct pt *pt, shell_output_func output, char *args))
void
shell_commands_init(void)
{
list_init(shell_command_sets);
list_add(shell_command_sets, &builtin_shell_command_set);
/* Set up Ping Reply callback */
uip_icmp6_echo_reply_callback_add(&echo_reply_notification,
echo_reply_handler);
}
/*---------------------------------------------------------------------------*/
struct shell_command_t shell_commands[] = {
void
shell_command_set_register(struct shell_command_set_t *set)
{
list_push(shell_command_sets, set);
}
/*---------------------------------------------------------------------------*/
int
shell_command_set_deregister(struct shell_command_set_t *set)
{
if(!list_contains(shell_command_sets, set)) {
return !0;
}
list_remove(shell_command_sets, set);
return 0;
}
/*---------------------------------------------------------------------------*/
const struct shell_command_t *
shell_command_lookup(const char *name)
{
struct shell_command_set_t *set;
const struct shell_command_t *cmd;
for(set = list_head(shell_command_sets);
set != NULL;
set = list_item_next(set)) {
for(cmd = set->commands; cmd->name != NULL; ++cmd) {
if(!strcmp(cmd->name, name)) {
return cmd;
}
}
}
return NULL;
}
/*---------------------------------------------------------------------------*/
const struct shell_command_t builtin_shell_commands[] = {
{ "help", cmd_help, "'> help': Shows this help" },
{ "reboot", cmd_reboot, "'> reboot': Reboot the board by watchdog_reboot()" },
{ "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" },
@ -765,4 +804,8 @@ struct shell_command_t shell_commands[] = {
{ NULL, NULL, NULL },
};
static struct shell_command_set_t builtin_shell_command_set = {
.next = NULL,
.commands = builtin_shell_commands,
};
/** @} */

View File

@ -53,8 +53,14 @@ struct shell_command_t {
const char *help;
};
/* The set of supported commands */
extern struct shell_command_t shell_commands[];
struct shell_command_set_t {
struct shell_command_set_t *next;
const struct shell_command_t *const commands;
};
void shell_command_set_register(struct shell_command_set_t *);
int shell_command_set_deregister(struct shell_command_set_t *);
const struct shell_command_t *shell_command_lookup(const char *);
/**
* Initializes Shell-commands module

View File

@ -89,7 +89,7 @@ output_prompt(shell_output_func output)
PT_THREAD(shell_input(struct pt *pt, shell_output_func output, const char *cmd))
{
static char *args;
static struct shell_command_t *cmd_ptr;
static const struct shell_command_t *cmd_descr = NULL;
PT_BEGIN(pt);
@ -105,20 +105,14 @@ PT_THREAD(shell_input(struct pt *pt, shell_output_func output, const char *cmd))
args++;
}
/* Lookup for command */
cmd_ptr = shell_commands;
while(cmd_ptr->name != NULL) {
if(strcmp(cmd, cmd_ptr->name) == 0) {
static struct pt cmd_pt;
PT_SPAWN(pt, &cmd_pt, cmd_ptr->func(&cmd_pt, output, args));
goto done;
}
cmd_ptr++;
cmd_descr = shell_command_lookup(cmd);
if(cmd_descr != NULL) {
static struct pt cmd_pt;
PT_SPAWN(pt, &cmd_pt, cmd_descr->func(&cmd_pt, output, args));
} else {
SHELL_OUTPUT(output, "Command not found. Type 'help' for a list of commands\n");
}
SHELL_OUTPUT(output, "Command not found. Type 'help' for a list of commands\n");
done:
output_prompt(output);
PT_END(pt);
}

View File

@ -90,6 +90,21 @@ aql_clear(aql_adt_t *adt)
memset(adt->aggregators, 0, sizeof(adt->aggregators));
}
db_result_t
aql_add_relation(aql_adt_t *adt, const char *name)
{
if(adt->relation_count >= AQL_RELATION_LIMIT) {
return DB_LIMIT_ERROR;
}
strncpy(adt->relations[adt->relation_count], name,
sizeof(adt->relations[0]) - 1);
adt->relations[adt->relation_count][sizeof(adt->relations[0]) - 1] = '\0';
adt->relation_count++;
return DB_OK;
}
db_result_t
aql_add_attribute(aql_adt_t *adt, char *name, domain_t domain,
unsigned element_size, int processed_only)

View File

@ -207,6 +207,10 @@ next_string(lexer_t *lexer, const char *s)
*lexer->token = STRING_VALUE;
lexer->input = end + 1; /* Skip the closing delimiter. */
if(length > DB_MAX_ELEMENT_SIZE - 1) {
length = DB_MAX_ELEMENT_SIZE - 1;
}
memcpy(lexer->value, s, length);
(*lexer->value)[length] = '\0';
@ -236,6 +240,10 @@ next_token(lexer_t *lexer, const char *s)
*lexer->token = IDENTIFIER;
if(length > DB_MAX_ELEMENT_SIZE - 1) {
length = DB_MAX_ELEMENT_SIZE - 1;
}
memcpy(lexer->value, s, length);
(*lexer->value)[length] = '\0';

View File

@ -269,8 +269,10 @@ PARSER(operand)
NEXT;
switch(TOKEN) {
case IDENTIFIER:
lvm_register_variable(VALUE, LVM_LONG);
lvm_set_variable(&p, VALUE);
if(LVM_ERROR(lvm_register_variable(VALUE, LVM_LONG)) ||
LVM_ERROR(lvm_set_variable(&p, VALUE))) {
RETURN(SYNTAX_ERROR);
}
AQL_ADD_PROCESSING_ATTRIBUTE(adt, VALUE);
break;
case STRING_VALUE:
@ -278,7 +280,9 @@ PARSER(operand)
case FLOAT_VALUE:
break;
case INTEGER_VALUE:
lvm_set_long(&p, *(long *)lexer->value);
if(LVM_ERROR(lvm_set_long(&p, *(long *)lexer->value))) {
RETURN(SYNTAX_ERROR);
}
break;
default:
RETURN(SYNTAX_ERROR);
@ -340,7 +344,9 @@ PARSER(expr)
default:
RETURN(SYNTAX_ERROR);
}
lvm_set_op(&p, op);
if(LVM_ERROR(lvm_set_op(&p, op))) {
RETURN(SYNTAX_ERROR);
}
lvm_set_end(&p, saved_end);
}
@ -389,7 +395,9 @@ PARSER(comparison)
RETURN(SYNTAX_ERROR);
}
lvm_set_relation(&p, rel);
if(LVM_ERROR(lvm_set_relation(&p, rel))) {
RETURN(SYNTAX_ERROR);
}
lvm_set_end(&p, saved_end);
if(!PARSE(expr)) {
@ -422,7 +430,9 @@ PARSER(where)
connective = TOKEN == AND ? LVM_AND : LVM_OR;
saved_end = lvm_shift_for_operator(&p, saved_end);
lvm_set_relation(&p, connective);
if(LVM_ERROR(lvm_set_relation(&p, connective))) {
RETURN(SYNTAX_ERROR);
}
lvm_set_end(&p, saved_end);
NEXT;

View File

@ -188,10 +188,10 @@ typedef struct aql_adt aql_adt_t;
#define AQL_SET_FLAG(adt, flag) (((adt)->flags) |= (flag))
#define AQL_GET_FLAGS(adt) ((adt)->flags)
#define AQL_ADD_RELATION(adt, rel) \
strcpy((adt)->relations[(adt)->relation_count++], (rel))
#define AQL_RELATION_COUNT(adt) ((adt)->relation_count)
#define AQL_ADD_ATTRIBUTE(adt, attr, dom, size) \
#define AQL_ADD_RELATION(adt, name) \
aql_add_relation(adt, name)
#define AQL_ADD_ATTRIBUTE(adt, attr, dom, size) \
aql_add_attribute(adt, attr, dom, size, 0)
#define AQL_ADD_PROCESSING_ATTRIBUTE(adt, attr) \
aql_add_attribute((adt), (attr), DOMAIN_UNSPECIFIED, 0, 1)
@ -211,6 +211,7 @@ void lexer_rewind(lexer_t *);
void aql_clear(aql_adt_t *adt);
aql_status_t aql_parse(aql_adt_t *adt, char *query_string);
db_result_t aql_add_relation(aql_adt_t *adt, const char *name);
db_result_t aql_add_attribute(aql_adt_t *adt, char *name,
domain_t domain, unsigned element_size,
int processed_only);

View File

@ -108,7 +108,7 @@
/* The maximum size of the LVM bytecode compiled from a
single database query. */
#ifndef DB_VM_BYTECODE_SIZE
#define DB_VM_BYTECODE_SIZE 128
#define DB_VM_BYTECODE_SIZE 256
#endif /* DB_VM_BYTECODE_SIZE */
/*----------------------------------------------------------------------------*/

View File

@ -82,10 +82,10 @@ typedef struct derivation derivation_t;
/* Registered variables for a LVM expression. Their values may be
changed between executions of the expression. */
static variable_t variables[LVM_MAX_VARIABLE_ID - 1];
static variable_t variables[LVM_MAX_VARIABLE_ID];
/* Range derivations of variables that are used for index searches. */
static derivation_t derivations[LVM_MAX_VARIABLE_ID - 1];
static derivation_t derivations[LVM_MAX_VARIABLE_ID];
#if DEBUG
static void
@ -187,7 +187,7 @@ eval_expr(lvm_instance_t *p, operator_t op, operand_t *result)
get_operand(p, &operand[i]);
break;
default:
return SEMANTIC_ERROR;
return LVM_SEMANTIC_ERROR;
}
value[i] = operand_to_long(&operand[i]);
}
@ -204,18 +204,18 @@ eval_expr(lvm_instance_t *p, operator_t op, operand_t *result)
break;
case LVM_DIV:
if(value[1] == 0) {
return MATH_ERROR;
return LVM_MATH_ERROR;
}
result_value = value[0] / value[1];
break;
default:
return EXECUTION_ERROR;
return LVM_EXECUTION_ERROR;
}
result->type = LVM_LONG;
result->value.l = result_value;
return TRUE;
return LVM_TRUE;
}
static int
@ -236,7 +236,7 @@ eval_logic(lvm_instance_t *p, operator_t *op)
for(i = 0; i < arguments; i++) {
type = get_type(p);
if(type != LVM_CMP_OP) {
return SEMANTIC_ERROR;
return LVM_SEMANTIC_ERROR;
}
operator = get_operator(p);
logic_result[i] = eval_logic(p, operator);
@ -248,9 +248,9 @@ eval_logic(lvm_instance_t *p, operator_t *op)
if(*op == LVM_NOT) {
return !logic_result[0];
} else if(*op == LVM_AND) {
return logic_result[0] == TRUE && logic_result[1] == TRUE;
return logic_result[0] == LVM_TRUE && logic_result[1] == LVM_TRUE;
} else {
return logic_result[0] == TRUE || logic_result[1] == TRUE;
return logic_result[0] == LVM_TRUE || logic_result[1] == LVM_TRUE;
}
}
@ -268,7 +268,7 @@ eval_logic(lvm_instance_t *p, operator_t *op)
get_operand(p, &operand);
break;
default:
return SEMANTIC_ERROR;
return LVM_SEMANTIC_ERROR;
}
result[i] = operand_to_long(&operand);
}
@ -294,7 +294,7 @@ eval_logic(lvm_instance_t *p, operator_t *op)
break;
}
return EXECUTION_ERROR;
return LVM_EXECUTION_ERROR;
}
void
@ -334,7 +334,8 @@ lvm_shift_for_operator(lvm_instance_t *p, lvm_ip_t end)
old_end = p->end;
if(p->end + sizeof(operator_t) > p->size || end >= old_end) {
if(p->end + sizeof(operator_t) + sizeof(node_type_t) > p->size ||
end >= old_end) {
p->error = __LINE__;
return 0;
}
@ -369,13 +370,6 @@ lvm_set_end(lvm_instance_t *p, lvm_ip_t end)
return old_end;
}
void
lvm_set_type(lvm_instance_t *p, node_type_t type)
{
*(node_type_t *)(p->code + p->end) = type;
p->end += sizeof(type);
}
lvm_status_t
lvm_execute(lvm_instance_t *p)
{
@ -384,14 +378,14 @@ lvm_execute(lvm_instance_t *p)
lvm_status_t status;
p->ip = 0;
status = EXECUTION_ERROR;
status = LVM_EXECUTION_ERROR;
type = get_type(p);
switch(type) {
case LVM_CMP_OP:
operator = get_operator(p);
status = eval_logic(p, operator);
if(!LVM_ERROR(status)) {
PRINTF("The statement is %s\n", status == TRUE ? "true" : "false");
PRINTF("The statement is %s\n", status == LVM_TRUE ? "true" : "false");
} else {
PRINTF("Execution error: %d\n", (int)status);
}
@ -403,31 +397,80 @@ lvm_execute(lvm_instance_t *p)
return status;
}
void
lvm_status_t
lvm_set_type(lvm_instance_t *p, node_type_t type)
{
if(p->end + sizeof(node_type_t) >= DB_VM_BYTECODE_SIZE) {
PRINTF("Error: overflow in lvm_set_type\n");
return LVM_STACK_OVERFLOW;
}
*(node_type_t *)(p->code + p->end) = type;
p->end += sizeof(type);
return LVM_TRUE;
}
lvm_status_t
lvm_set_op(lvm_instance_t *p, operator_t op)
{
lvm_set_type(p, LVM_ARITH_OP);
lvm_status_t status;
status = lvm_set_type(p, LVM_ARITH_OP);
if(status != LVM_TRUE) {
return status;
}
if(p->end + sizeof(op) >= DB_VM_BYTECODE_SIZE) {
PRINTF("Error: overflow in lvm_set_op\n");
return LVM_STACK_OVERFLOW;
}
memcpy(&p->code[p->end], &op, sizeof(op));
p->end += sizeof(op);
return LVM_TRUE;
}
void
lvm_status_t
lvm_set_relation(lvm_instance_t *p, operator_t op)
{
lvm_set_type(p, LVM_CMP_OP);
lvm_status_t status;
status = lvm_set_type(p, LVM_CMP_OP);
if(status != LVM_TRUE) {
return status;
}
if(p->end + sizeof(op) >= DB_VM_BYTECODE_SIZE) {
PRINTF("Error: overflow in lvm_set_relation\n");
return LVM_STACK_OVERFLOW;
}
memcpy(&p->code[p->end], &op, sizeof(op));
p->end += sizeof(op);
return LVM_TRUE;
}
void
lvm_status_t
lvm_set_operand(lvm_instance_t *p, operand_t *op)
{
lvm_set_type(p, LVM_OPERAND);
lvm_status_t status;
status = lvm_set_type(p, LVM_OPERAND);
if(status != LVM_TRUE) {
return status;
}
if(p->end + sizeof(*op) >= DB_VM_BYTECODE_SIZE) {
PRINTF("Error: overflow in lvm_set_operand\n");
return LVM_STACK_OVERFLOW;
}
memcpy(&p->code[p->end], op, sizeof(*op));
p->end += sizeof(*op);
return LVM_TRUE;
}
void
lvm_status_t
lvm_set_long(lvm_instance_t *p, long l)
{
operand_t op;
@ -435,7 +478,7 @@ lvm_set_long(lvm_instance_t *p, long l)
op.type = LVM_LONG;
op.value.l = l;
lvm_set_operand(p, &op);
return lvm_set_operand(p, &op);
}
lvm_status_t
@ -446,7 +489,7 @@ lvm_register_variable(char *name, operand_type_t type)
id = lookup(name);
if(id == LVM_MAX_VARIABLE_ID) {
return VARIABLE_LIMIT_REACHED;
return LVM_VARIABLE_LIMIT_REACHED;
}
var = &variables[id];
@ -456,7 +499,7 @@ lvm_register_variable(char *name, operand_type_t type)
var->type = type;
}
return TRUE;
return LVM_TRUE;
}
lvm_status_t
@ -466,25 +509,28 @@ lvm_set_variable_value(char *name, operand_value_t value)
id = lookup(name);
if(id == LVM_MAX_VARIABLE_ID) {
return INVALID_IDENTIFIER;
return LVM_INVALID_IDENTIFIER;
}
variables[id].value = value;
return TRUE;
return LVM_TRUE;
}
void
lvm_status_t
lvm_set_variable(lvm_instance_t *p, char *name)
{
operand_t op;
variable_id_t id;
id = lookup(name);
if(id < LVM_MAX_VARIABLE_ID) {
PRINTF("var id = %d\n", id);
op.type = LVM_VARIABLE;
op.value.id = id;
lvm_set_operand(p, &op);
if(id == LVM_MAX_VARIABLE_ID) {
return LVM_INVALID_IDENTIFIER;
}
PRINTF("var id = %d\n", id);
op.type = LVM_VARIABLE;
op.value.id = id;
return lvm_set_operand(p, &op);
}
void
@ -598,7 +644,7 @@ derive_relation(lvm_instance_t *p, derivation_t *local_derivations)
derivation_t d2[LVM_MAX_VARIABLE_ID];
if(*operator != LVM_AND && *operator != LVM_OR) {
return DERIVATION_ERROR;
return LVM_DERIVATION_ERROR;
}
PRINTF("Attempting to infer ranges from a logical connective\n");
@ -608,7 +654,7 @@ derive_relation(lvm_instance_t *p, derivation_t *local_derivations)
if(LVM_ERROR(derive_relation(p, d1)) ||
LVM_ERROR(derive_relation(p, d2))) {
return DERIVATION_ERROR;
return LVM_DERIVATION_ERROR;
}
if(*operator == LVM_AND) {
@ -616,7 +662,7 @@ derive_relation(lvm_instance_t *p, derivation_t *local_derivations)
} else if(*operator == LVM_OR) {
create_union(local_derivations, d1, d2);
}
return TRUE;
return LVM_TRUE;
}
for(i = 0; i < 2; i++) {
@ -626,18 +672,18 @@ derive_relation(lvm_instance_t *p, derivation_t *local_derivations)
get_operand(p, &operand[i]);
break;
default:
return DERIVATION_ERROR;
return LVM_DERIVATION_ERROR;
}
}
if(operand[0].type == LVM_VARIABLE && operand[1].type == LVM_VARIABLE) {
return DERIVATION_ERROR;
return LVM_DERIVATION_ERROR;
}
/* Determine which of the operands that is the variable. */
if(operand[0].type == LVM_VARIABLE) {
if(operand[1].type == LVM_VARIABLE) {
return DERIVATION_ERROR;
return LVM_DERIVATION_ERROR;
}
variable_id = operand[0].value.id;
value = &operand[1].value;
@ -647,7 +693,7 @@ derive_relation(lvm_instance_t *p, derivation_t *local_derivations)
}
if(variable_id >= LVM_MAX_VARIABLE_ID) {
return DERIVATION_ERROR;
return LVM_DERIVATION_ERROR;
}
PRINTF("variable id %d, value %ld\n", variable_id, *(long *)value);
@ -675,12 +721,12 @@ derive_relation(lvm_instance_t *p, derivation_t *local_derivations)
derivation->max.l = value->l;
break;
default:
return DERIVATION_ERROR;
return LVM_DERIVATION_ERROR;
}
derivation->derived = 1;
return TRUE;
return LVM_TRUE;
}
lvm_status_t
@ -700,12 +746,12 @@ lvm_get_derived_range(lvm_instance_t *p, char *name,
if(derivations[i].derived) {
*min = derivations[i].min;
*max = derivations[i].max;
return TRUE;
return LVM_TRUE;
}
return DERIVATION_ERROR;
return LVM_DERIVATION_ERROR;
}
}
return INVALID_IDENTIFIER;
return LVM_INVALID_IDENTIFIER;
}
#if DEBUG
@ -755,7 +801,8 @@ print_operand(lvm_instance_t *p, lvm_ip_t index)
switch(operand.type) {
case LVM_VARIABLE:
if(operand.value.id >= LVM_MAX_VARIABLE_ID || variables[operand.value.id].name == NULL) {
if(operand.value.id >= LVM_MAX_VARIABLE_ID ||
variables[operand.value.id].name == NULL) {
PRINTF("var(id:%d):?? ", operand.value.id);
} else {
PRINTF("var(%s):%ld ", variables[operand.value.id].name,

View File

@ -45,16 +45,16 @@
#include "db-options.h"
enum lvm_status {
FALSE = 0,
TRUE = 1,
INVALID_IDENTIFIER = 2,
SEMANTIC_ERROR = 3,
MATH_ERROR = 4,
STACK_OVERFLOW = 5,
TYPE_ERROR = 6,
VARIABLE_LIMIT_REACHED = 7,
EXECUTION_ERROR = 8,
DERIVATION_ERROR = 9
LVM_FALSE = 0,
LVM_TRUE = 1,
LVM_INVALID_IDENTIFIER = 2,
LVM_SEMANTIC_ERROR = 3,
LVM_MATH_ERROR = 4,
LVM_STACK_OVERFLOW = 5,
LVM_TYPE_ERROR = 6,
LVM_VARIABLE_LIMIT_REACHED = 7,
LVM_EXECUTION_ERROR = 8,
LVM_DERIVATION_ERROR = 9
};
typedef enum lvm_status lvm_status_t;
@ -135,10 +135,10 @@ lvm_ip_t lvm_jump_to_operand(lvm_instance_t *p);
lvm_ip_t lvm_shift_for_operator(lvm_instance_t *p, lvm_ip_t end);
lvm_ip_t lvm_get_end(lvm_instance_t *p);
lvm_ip_t lvm_set_end(lvm_instance_t *p, lvm_ip_t end);
void lvm_set_op(lvm_instance_t *p, operator_t op);
void lvm_set_relation(lvm_instance_t *p, operator_t op);
void lvm_set_operand(lvm_instance_t *p, operand_t *op);
void lvm_set_long(lvm_instance_t *p, long l);
void lvm_set_variable(lvm_instance_t *p, char *name);
lvm_status_t lvm_set_op(lvm_instance_t *p, operator_t op);
lvm_status_t lvm_set_relation(lvm_instance_t *p, operator_t op);
lvm_status_t lvm_set_operand(lvm_instance_t *p, operand_t *op);
lvm_status_t lvm_set_long(lvm_instance_t *p, long l);
lvm_status_t lvm_set_variable(lvm_instance_t *p, char *name);
#endif /* LVM_H */

View File

@ -813,9 +813,9 @@ relation_process_select(void *handle_ptr)
}
}
wanted_result = TRUE;
wanted_result = LVM_TRUE;
if(AQL_GET_FLAGS(adt) & AQL_FLAG_INVERSE_LOGIC) {
wanted_result = FALSE;
wanted_result = LVM_FALSE;
}
/* Check whether the given predicate is true for this tuple. */

View File

@ -4,6 +4,6 @@
CONTIKI=$1
# Simulation file
BASENAME=01-border-router-cooja
BASENAME=$(basename $0 .sh)
bash test-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 60

View File

@ -4,7 +4,7 @@
CONTIKI=$1
# Simulation file
BASENAME=02-border-router-cooja-tsch
BASENAME=$(basename $0 .sh)
# Add a little extra initial time to account for TSCH association time
bash test-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 120

View File

@ -4,6 +4,6 @@
CONTIKI=$1
# Simulation file
BASENAME=03-border-router-sky
BASENAME=$(basename $0 .sh)
bash test-border-router.sh $CONTIKI $BASENAME fd00::0212:7404:0004:0404 60

View File

@ -5,7 +5,7 @@ source ../utils.sh
CONTIKI=$1
# Simulation file
BASENAME=04-border-router-traceroute
BASENAME=$(basename $0 .sh)
# Destination IPv6
IPADDR=fd00::204:4:4:4

View File

@ -4,7 +4,7 @@ source ../utils.sh
# Contiki directory
CONTIKI=$1
# Test basename
BASENAME=01-native-ping
BASENAME=$(basename $0 .sh)
IPADDR=fd00::302:304:506:708

View File

@ -4,7 +4,7 @@ source ../utils.sh
# Contiki directory
CONTIKI=$1
# Test basename
BASENAME=06-native-coap
BASENAME=$(basename $0 .sh)
IPADDR=fd00::302:304:506:708

View File

@ -4,6 +4,6 @@
CONTIKI=$1
# Simulation file
BASENAME=07-native-border-router-cooja
BASENAME=$(basename $0 .sh)
bash test-native-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 60

4
tests/17-tun-rpl-br/08-border-router-cooja-frag.sh Normal file → Executable file
View File

@ -4,6 +4,6 @@
CONTIKI=$1
# Simulation file
BASENAME=01-border-router-cooja
BASENAME=$(basename $0 .sh)
bash test-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 60 600 2
bash test-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 60 1200 4

View File

@ -0,0 +1,254 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project EXPORT="discard">[APPS_DIR]/mrm</project>
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
<project EXPORT="discard">[APPS_DIR]/avrora</project>
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
<simulation>
<title>My simulation</title>
<speedlimit>1.0</speedlimit>
<randomseed>123456</randomseed>
<motedelay_us>1000000</motedelay_us>
<radiomedium>
org.contikios.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>100.0</interference_range>
<success_ratio_tx>1.0</success_ratio_tx>
<success_ratio_rx>1.0</success_ratio_rx>
</radiomedium>
<events>
<logoutput>40000</logoutput>
</events>
<motetype>
org.contikios.cooja.contikimote.ContikiMoteType
<identifier>mtype295</identifier>
<description>Cooja Mote Type #1</description>
<source>[CONTIKI_DIR]/examples/slip-radio/slip-radio.c</source>
<commands>make TARGET=cooja clean
make -j slip-radio.cooja TARGET=cooja</commands>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<symbols>false</symbols>
</motetype>
<motetype>
org.contikios.cooja.contikimote.ContikiMoteType
<identifier>mtype686</identifier>
<description>Cooja Mote Type #2</description>
<source>[CONTIKI_DIR]/examples/hello-world/hello-world.c</source>
<commands>make TARGET=cooja clean
make -j hello-world.cooja TARGET=cooja</commands>
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
<symbols>false</symbols>
</motetype>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>54.36775767371176</x>
<y>24.409055040864118</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>1</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype295</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>83.54989222799365</x>
<y>52.63050856506214</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>2</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype686</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>108.91767775240822</x>
<y>78.59778809170032</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>3</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype686</motetype_identifier>
</mote>
<mote>
<interface_config>
org.contikios.cooja.interfaces.Position
<x>139.91021061864723</x>
<y>98.34190023350419</y>
<z>0.0</z>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
<id>4</id>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiRadio
<bitrate>250.0</bitrate>
</interface_config>
<interface_config>
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
</interface_config>
<motetype_identifier>mtype686</motetype_identifier>
</mote>
</simulation>
<plugin>
org.contikios.cooja.plugins.SimControl
<width>280</width>
<z>1</z>
<height>160</height>
<location_x>400</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Visualizer
<plugin_config>
<moterelations>true</moterelations>
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
<viewport>1.9798610460263038 0.0 0.0 1.9798610460263038 -61.112037797038525 -1.2848438586294648</viewport>
</plugin_config>
<width>400</width>
<z>4</z>
<height>400</height>
<location_x>1</location_x>
<location_y>1</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.LogListener
<plugin_config>
<filter>ID:4</filter>
<formatted_time />
<coloring />
</plugin_config>
<width>1404</width>
<z>2</z>
<height>240</height>
<location_x>400</location_x>
<location_y>160</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.TimeLine
<plugin_config>
<mote>0</mote>
<mote>1</mote>
<mote>2</mote>
<mote>3</mote>
<showRadioRXTX />
<showRadioHW />
<showLEDs />
<zoomfactor>500.0</zoomfactor>
</plugin_config>
<width>1804</width>
<z>6</z>
<height>166</height>
<location_x>0</location_x>
<location_y>753</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.Notes
<plugin_config>
<notes>Enter notes here</notes>
<decorations>true</decorations>
</plugin_config>
<width>1124</width>
<z>5</z>
<height>160</height>
<location_x>680</location_x>
<location_y>0</location_y>
</plugin>
<plugin>
org.contikios.cooja.serialsocket.SerialSocketServer
<mote_arg>0</mote_arg>
<plugin_config>
<port>60001</port>
<bound>true</bound>
</plugin_config>
<width>362</width>
<z>3</z>
<height>116</height>
<location_x>13</location_x>
<location_y>414</location_y>
</plugin>
<plugin>
org.contikios.cooja.plugins.ScriptRunner
<plugin_config>
<script>TIMEOUT(10000000000); /* milliseconds. no action at timeout */
/* Set simulaion speed to real time. Required for
* Native BR test, as the Native BR will run as a
* unix process, at real time. */
sim.setSpeedLimit(1.0);</script>
<active>true</active>
</plugin_config>
<width>600</width>
<z>0</z>
<height>700</height>
<location_x>1037</location_x>
<location_y>40</location_y>
</plugin>
</simconf>

View File

@ -4,6 +4,6 @@
CONTIKI=$1
# Simulation file
BASENAME=07-native-border-router-cooja
BASENAME=$(basename $0 .sh)
bash test-native-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 60 600 2
bash test-native-border-router.sh $CONTIKI $BASENAME fd00::204:4:4:4 60 1200 4

0
tests/17-tun-rpl-br/test-native-border-router.sh Normal file → Executable file
View File

View File

@ -100,7 +100,7 @@ do
if [[ "$platform" == "srf06-cc26xx" ]]
then
# srf06-cc26xx has multiple boards
BOARDS="srf06/cc26xx srf06/cc13xx launchpad/cc2650 launchpad/cc1350 sensortag/cc2650 sensortag/cc1350"
BOARDS="srf06/cc26xx srf06/cc13xx launchpad/cc2650 launchpad/cc1310 launchpad/cc1350 sensortag/cc2650 sensortag/cc1350"
elif [[ "$platform" == "zoul" ]]
then
# Zoul has multiple boards

@ -1 +1 @@
Subproject commit 22b1262d9e668d9cf6c8eaf70715f1bcd5728642
Subproject commit a5904b98366478bb9e7f7fe9f0bb78fc064914c5

1
tools/motelist Submodule

@ -0,0 +1 @@
Subproject commit 2f089ac9277521b32371e68391e53d0bd0017288

View File

@ -885,6 +885,17 @@ exit(1);
}
}
#ifdef __APPLE__
if(*tundev == '\0') {
/* Use default. */
if(tap) {
strcpy(tundev, "tap0");
} else {
strcpy(tundev, "tun0");
}
}
#endif
if(host != NULL) {
struct addrinfo hints, *servinfo, *p;
int rv;

View File

@ -1,15 +1,14 @@
#!/usr/bin/env bash
# i386 binary support on x64 system
# Install i386 binary support on x64 system and required tools
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y --no-install-recommends \
libc6:i386 libstdc++6:i386 libncurses5:i386 libz1:i386
libc6:i386 libstdc++6:i386 libncurses5:i386 libz1:i386 \
build-essential doxygen git wget unzip python-serial rlwrap npm \
default-jdk ant srecord python-pip iputils-tracepath uncrustify \
python-magic linux-image-extra-virtual
# Tools
sudo apt-get install -y --no-install-recommends \
build-essential doxygen git wget unzip python-serial rlwrap \
default-jdk ant srecord python-pip iputils-tracepath uncrustify python-magic
sudo apt-get clean
sudo python2 -m pip install intelhex
@ -61,8 +60,6 @@ source ${HOME}/.bashrc
echo "#!/bin/bash\nant -Dbasedir=${COOJA} -f ${COOJA}/build.xml run" > ${HOME}/cooja && chmod +x ${HOME}/cooja
# Install coap-cli
sudo apt-get install -y npm
sudo apt-get clean
sudo npm install coap-cli -g
sudo ln -s /usr/bin/nodejs /usr/bin/node