Added and updated debugging printouts and reformatted code to make it a little easier to read.

This commit is contained in:
Adam Dunkels 2013-08-11 23:42:51 +02:00 committed by Simon Duquennoy
parent 248301a041
commit 82e8eb420d
4 changed files with 39 additions and 5 deletions

View file

@ -106,6 +106,20 @@ static void
rpl_set_preferred_parent(rpl_dag_t *dag, rpl_parent_t *p) rpl_set_preferred_parent(rpl_dag_t *dag, rpl_parent_t *p)
{ {
if(dag != NULL && dag->preferred_parent != p) { if(dag != NULL && dag->preferred_parent != p) {
PRINTF("RPL: rpl_set_preferred_parent ");
if(p != NULL) {
PRINT6ADDR(rpl_get_parent_ipaddr(p));
} else {
PRINTF("NULL");
}
PRINTF(" used to be ");
if(dag->preferred_parent != NULL) {
PRINT6ADDR(rpl_get_parent_ipaddr(dag->preferred_parent));
} else {
PRINTF("NULL");
}
PRINTF("\n");
/* Always keep the preferred parent locked, so it remains in the /* Always keep the preferred parent locked, so it remains in the
* neighbor table. */ * neighbor table. */
nbr_table_unlock(rpl_parents, dag->preferred_parent); nbr_table_unlock(rpl_parents, dag->preferred_parent);
@ -288,11 +302,13 @@ rpl_repair_root(uint8_t instance_id)
instance = rpl_get_instance(instance_id); instance = rpl_get_instance(instance_id);
if(instance == NULL || if(instance == NULL ||
instance->current_dag->rank != ROOT_RANK(instance)) { instance->current_dag->rank != ROOT_RANK(instance)) {
PRINTF("RPL: rpl_repair_root triggered but not root\n");
return 0; return 0;
} }
RPL_LOLLIPOP_INCREMENT(instance->current_dag->version); RPL_LOLLIPOP_INCREMENT(instance->current_dag->version);
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out); RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
PRINTF("RPL: rpl_repair_root initiating global repair with version %d\n", instance->current_dag->version);
rpl_reset_dio_timer(instance); rpl_reset_dio_timer(instance);
return 1; return 1;
} }
@ -514,6 +530,7 @@ rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
* Typically, the parent is added upon receiving a DIO. */ * Typically, the parent is added upon receiving a DIO. */
uip_lladdr_t *lladdr = uip_ds6_nbr_lladdr_from_ipaddr(addr); uip_lladdr_t *lladdr = uip_ds6_nbr_lladdr_from_ipaddr(addr);
PRINTF("RPL: rpl_add_parent lladdr %p\n", lladdr);
if(lladdr != NULL) { if(lladdr != NULL) {
/* Add parent in rpl_parents */ /* Add parent in rpl_parents */
p = nbr_table_add_lladdr(rpl_parents, (rimeaddr_t *)lladdr); p = nbr_table_add_lladdr(rpl_parents, (rimeaddr_t *)lladdr);
@ -990,6 +1007,7 @@ global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio)
} else { } else {
dag->rank = dag->instance->of->calculate_rank(p, 0); dag->rank = dag->instance->of->calculate_rank(p, 0);
dag->min_rank = dag->rank; dag->min_rank = dag->rank;
PRINTF("RPL: rpl_process_parent_event global repair\n");
rpl_process_parent_event(dag->instance, p); rpl_process_parent_event(dag->instance, p);
} }
@ -1031,6 +1049,7 @@ rpl_recalculate_ranks(void)
while(p != NULL) { while(p != NULL) {
if(p->dag != NULL && p->dag->instance && p->updated) { if(p->dag != NULL && p->dag->instance && p->updated) {
p->updated = 0; p->updated = 0;
PRINTF("RPL: rpl_process_parent_event recalculate_ranks\n");
if(!rpl_process_parent_event(p->dag->instance, p)) { if(!rpl_process_parent_event(p->dag->instance, p)) {
PRINTF("RPL: A parent was dropped\n"); PRINTF("RPL: A parent was dropped\n");
} }
@ -1210,7 +1229,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
PRINTF(", rank %u, min_rank %u, ", PRINTF(", rank %u, min_rank %u, ",
instance->current_dag->rank, instance->current_dag->min_rank); instance->current_dag->rank, instance->current_dag->min_rank);
PRINTF("parent rank %u, parent etx %u, link metric %u, instance etx %u\n", PRINTF("parent rank %u, parent etx %u, link metric %u, instance etx %u\n",
p->rank, p->mc.obj.etx, p->link_metric, instance->mc.obj.etx); p->rank, -1/*p->mc.obj.etx*/, p->link_metric, instance->mc.obj.etx);
/* We have allocated a candidate parent; process the DIO further. */ /* We have allocated a candidate parent; process the DIO further. */

View file

@ -663,8 +663,13 @@ dao_input(void)
rep = uip_ds6_route_lookup(&prefix); rep = uip_ds6_route_lookup(&prefix);
if(lifetime == RPL_ZERO_LIFETIME) { if(lifetime == RPL_ZERO_LIFETIME) {
PRINTF("RPL: No-Path DAO received\n");
/* No-Path DAO received; invoke the route purging routine. */ /* No-Path DAO received; invoke the route purging routine. */
if(rep != NULL && rep->state.nopath_received == 0 && rep->length == prefixlen && uip_ipaddr_cmp(uip_ds6_route_nexthop(rep), &dao_sender_addr)) { if(rep != NULL &&
rep->state.nopath_received == 0 &&
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 "); PRINTF("RPL: Setting expiration timer for prefix ");
PRINT6ADDR(&prefix); PRINT6ADDR(&prefix);
PRINTF("\n"); PRINTF("\n");
@ -677,12 +682,15 @@ dao_input(void)
learned_from = uip_is_addr_mcast(&dao_sender_addr) ? learned_from = uip_is_addr_mcast(&dao_sender_addr) ?
RPL_ROUTE_FROM_MULTICAST_DAO : RPL_ROUTE_FROM_UNICAST_DAO; RPL_ROUTE_FROM_MULTICAST_DAO : RPL_ROUTE_FROM_UNICAST_DAO;
PRINTF("RPL: DAO from %s\n",
learned_from == RPL_ROUTE_FROM_UNICAST_DAO? "unicast": "multicast");
if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) { if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) {
/* Check whether this is a DAO forwarding loop. */ /* Check whether this is a DAO forwarding loop. */
p = rpl_find_parent(dag, &dao_sender_addr); p = rpl_find_parent(dag, &dao_sender_addr);
/* check if this is a new DAO registration with an "illegal" rank */ /* check if this is a new DAO registration with an "illegal" rank */
/* if we already route to this node it is likely */ /* if we already route to this node it is likely */
if(p != NULL && DAG_RANK(p->rank, instance) < DAG_RANK(dag->rank, instance)) { if(p != NULL &&
DAG_RANK(p->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", PRINTF("RPL: Loop detected when receiving a unicast DAO from a node with a lower rank! (%u < %u)\n",
DAG_RANK(p->rank, instance), DAG_RANK(dag->rank, instance)); DAG_RANK(p->rank, instance), DAG_RANK(dag->rank, instance));
p->rank = INFINITE_RANK; p->rank = INFINITE_RANK;
@ -691,6 +699,7 @@ dao_input(void)
} }
} }
PRINTF("RPL: adding DAO route\n");
rep = rpl_add_route(dag, &prefix, prefixlen, &dao_sender_addr); rep = rpl_add_route(dag, &prefix, prefixlen, &dao_sender_addr);
if(rep == NULL) { if(rep == NULL) {
RPL_STAT(rpl_stats.mem_overflows++); RPL_STAT(rpl_stats.mem_overflows++);
@ -704,7 +713,7 @@ dao_input(void)
if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) { if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) {
if(dag->preferred_parent) { if(dag->preferred_parent) {
PRINTF("RPL: Forwarding DAO to parent "); PRINTF("RPL: Forwarding DAO to parent ");
PRINT6ADDR(&dag->preferred_parent->addr); PRINT6ADDR(rpl_get_parent_ipaddr(dag->preferred_parent));
PRINTF("\n"); PRINTF("\n");
uip_icmp6_send(rpl_get_parent_ipaddr(dag->preferred_parent), uip_icmp6_send(rpl_get_parent_ipaddr(dag->preferred_parent),
ICMP6_RPL, RPL_CODE_DAO, buffer_length); ICMP6_RPL, RPL_CODE_DAO, buffer_length);
@ -789,7 +798,7 @@ dao_output_target(rpl_parent_t *parent, uip_ipaddr_t *prefix, uint8_t lifetime)
PRINTF("RPL: Sending DAO with prefix "); PRINTF("RPL: Sending DAO with prefix ");
PRINT6ADDR(prefix); PRINT6ADDR(prefix);
PRINTF(" to "); PRINTF(" to ");
PRINT6ADDR(&parent->addr); PRINT6ADDR(rpl_get_parent_ipaddr(parent));
PRINTF("\n"); PRINTF("\n");
uip_icmp6_send(rpl_get_parent_ipaddr(parent), ICMP6_RPL, RPL_CODE_DAO, pos); uip_icmp6_send(rpl_get_parent_ipaddr(parent), ICMP6_RPL, RPL_CODE_DAO, pos);

View file

@ -183,6 +183,7 @@ rpl_link_neighbor_callback(const rimeaddr_t *addr, int status, int numtx)
parent = rpl_find_parent_any_dag(instance, &ipaddr); parent = rpl_find_parent_any_dag(instance, &ipaddr);
if(parent != NULL) { if(parent != NULL) {
/* Trigger DAG rank recalculation. */ /* Trigger DAG rank recalculation. */
PRINTF("RPL: rpl_link_neighbor_callback triggering update\n");
parent->updated = 1; parent->updated = 1;
if(instance->of->neighbor_link_callback != NULL) { if(instance->of->neighbor_link_callback != NULL) {
instance->of->neighbor_link_callback(parent, status, numtx); instance->of->neighbor_link_callback(parent, status, numtx);
@ -208,6 +209,7 @@ rpl_ipv6_neighbor_callback(uip_ds6_nbr_t *nbr)
if(p != NULL) { if(p != NULL) {
p->rank = INFINITE_RANK; p->rank = INFINITE_RANK;
/* Trigger DAG rank recalculation. */ /* Trigger DAG rank recalculation. */
PRINTF("RPL: rpl_ipv6_neighbor_callback infinite rank\n");
p->updated = 1; p->updated = 1;
} }
} }

View file

@ -43,6 +43,10 @@
void void
uip_debug_ipaddr_print(const uip_ipaddr_t *addr) uip_debug_ipaddr_print(const uip_ipaddr_t *addr)
{ {
if(addr == NULL || addr->u8 == NULL) {
printf("(NULL IP addr)");
return;
}
#if UIP_CONF_IPV6 #if UIP_CONF_IPV6
uint16_t a; uint16_t a;
unsigned int i; unsigned int i;