Merge branch 'develop' into bug/set-correct-dns-record-expiration

This commit is contained in:
Joakim Eriksson 2018-09-01 12:30:25 +02:00 committed by GitHub
commit e6df48a1bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 437 additions and 412 deletions

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

@ -36,18 +36,18 @@
#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
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 +64,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(int 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 +130,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;
}
@ -272,7 +274,7 @@ rpl_link_callback(const linkaddr_t *addr, int status, int numtx)
instance->urgent_probing_target = NULL;
}
/* 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 +288,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 +301,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 +322,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 +340,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 +405,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