Improvements to style and commentary.

This commit is contained in:
nvt-se 2010-05-04 22:55:32 +00:00
parent 01881f92a8
commit 361e210751
3 changed files with 31 additions and 33 deletions

View File

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-dag.c,v 1.2 2010/05/04 14:41:55 joxe Exp $
* $Id: rpl-dag.c,v 1.3 2010/05/04 22:55:32 nvt-se Exp $
*/
/**
* \file
@ -266,8 +266,6 @@ rpl_find_neighbor(rpl_dag_t *dag, uip_ipaddr_t *addr)
rpl_neighbor_t *
rpl_first_parent(rpl_dag_t *dag)
{
//return list_head(dag->parents);
rpl_neighbor_t *n;
for(n = list_head(dag->neighbors); n != NULL; n = n->next) {
@ -392,14 +390,14 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
}
PRINTF("succeeded\n");
n->local_confidence = 0; /* Extract packet LQI here. */
n->local_confidence = 0; /* The lowest confidence for new parents. */
n->rank = dio->dag_rank;
/* Determine the objective function by using the
objective code point of the DIO. */
of = rpl_find_of(dio->ocp);
if(of == NULL) {
PRINTF("RPL: DIO for DAG instance %d does not specify a supported OF\n",
PRINTF("RPL: DIO for DAG instance %u does not specify a supported OF\n",
dio->instance_id);
return;
}
@ -423,7 +421,7 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
rpl_join_dag(dag);
PRINTF("RPL: Joined DAG with instance ID %d, rank %d, DAG ID ",
PRINTF("RPL: Joined DAG with instance ID %u, rank %hu, DAG ID ",
dio->instance_id, dag->rank);
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
@ -452,7 +450,7 @@ global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio)
dag->rank = dag->of->increment_rank(dio->dag_rank, n);
rpl_reset_dio_timer(dag, 1);
}
PRINTF("RPL: Participating in a global DAG repair. New DAG sequence number: %d NewRank: %d\n",
PRINTF("RPL: Participating in a global DAG repair. New DAG sequence number: %u, new rank: %hu\n",
dag->sequence_number, dag->rank);
}
@ -476,11 +474,6 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
uint8_t new_rank;
uint8_t new_parent;
/* if(from->u8[15] != 0xe7) { */
/* printf("last byte did not match e7 %x\n", from->u8[15]); */
/* return; */
/* } */
dag = rpl_get_dag(dio->instance_id);
if(dag == NULL) {
/* Always join the first possible DAG that is not of INF_RANK. */
@ -520,7 +513,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
} else if(n->rank < dio->dag_rank) {
PRINTF("RPL: Existing parent ");
PRINT6ADDR(from);
PRINTF(" got a higher rank (%d -> %d)\n",
PRINTF(" got a higher rank (%hu -> %hu)\n",
n->rank, dio->dag_rank);
n->rank = dio->dag_rank;
if(RPL_PARENT_COUNT(dag) > 1) {
@ -528,7 +521,8 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
rpl_remove_neighbor(dag, n);
} else if(dag->of->increment_rank(dio->dag_rank, n) <= dag->min_rank + dag->max_rankinc) {
dag->rank = dag->of->increment_rank(dio->dag_rank, n);
PRINTF("RPL: New rank is %i, max is %i\n", dag->rank, dag->min_rank + dag->max_rankinc);
PRINTF("RPL: New rank is %hu, max is %hu\n",
dag->rank, dag->min_rank + dag->max_rankinc);
rpl_set_default_route(dag, &n->addr);
} else {
PRINTF("RPL: Cannot find acceptable best neighbor\n");
@ -559,7 +553,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
}
n->rank = dio->dag_rank;
PRINTF("RPL: New parent with rank %d ", n->rank);
PRINTF("RPL: New parent with rank %hu ", n->rank);
PRINT6ADDR(from);
PRINTF("\n");
new_parent = 1;
@ -567,7 +561,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
new_rank = dag->of->increment_rank(dio->dag_rank, n);
if(new_rank < dag->rank) {
PRINTF("RPL: Moving up within the DAG from rank %d to %d\n",
PRINTF("RPL: Moving up within the DAG from rank %hu to %hu\n",
dag->rank, new_rank);
dag->rank = new_rank;
dag->min_rank = new_rank; /* So far this is the lowest rank we know */
@ -591,7 +585,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
if(n != NULL && n->rank < dio->dag_rank) {
PRINTF("RPL: Parent ");
PRINT6ADDR(&n->addr);
PRINTF(" has increased in rank from %d to %d. Removing it.\n",
PRINTF(" has increased in rank from %hu to %hu. Removing it.\n",
n->rank, dio->dag_rank);
rpl_remove_neighbor(dag, n);
if(RPL_PARENT_COUNT(dag) == 0) {
@ -632,7 +626,8 @@ rpl_ds6_neighbor_callback(uip_ds6_nbr_t *nbr)
if(dag->rank < dag->min_rank) {
dag->min_rank = dag->rank;
}
PRINTF("New rank is %i, max is %i\n", dag->rank, dag->min_rank + dag->max_rankinc);
PRINTF("RPL: New rank is %hu, max is %hu\n",
dag->rank, dag->min_rank + dag->max_rankinc);
rpl_set_default_route(dag, &n->addr);
} else {
PRINTF("RPL: Cannot find the best neighbor\n");

View File

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-icmp6.c,v 1.5 2010/05/04 14:41:55 joxe Exp $
* $Id: rpl-icmp6.c,v 1.6 2010/05/04 22:55:32 nvt-se Exp $
*/
/**
* \file
@ -245,13 +245,13 @@ dio_input(void)
dio.dag_redund = buffer[i + 5];
dio.dag_max_rankinc = buffer[i + 6];
dio.dag_min_hoprankinc = buffer[i + 7];
PRINTF("RPL: DIO trickle timer:dbl=%d, min=%d red=%d maxinc=%d mininc=%d\n", dio.dag_intdoubl,
dio.dag_intmin, dio.dag_redund,
PRINTF("RPL: DIO trickle timer: dbl=%d, min=%d red=%d maxinc=%d mininc=%d\n",
dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund,
dio.dag_max_rankinc, dio.dag_min_hoprankinc);
break;
case RPL_DIO_SUBOPT_OCP:
dio.ocp = buffer[i + 3] << 8 | buffer[i + 4];
PRINTF("RPL: DAG OCP Sub-opt received OCP = %d\n", dio.ocp);
PRINTF("RPL: DAG OCP Sub-opt received OCP = %u\n", dio.ocp);
break;
}
}
@ -267,7 +267,7 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
uip_ipaddr_t addr;
/* DAG Information Solicitation */
PRINTF("RPL: Sending a DIO with rank: %d\n", dag->rank);
PRINTF("RPL: Sending a DIO with rank: %hu\n", dag->rank);
pos = 0;
buffer = UIP_ICMP_PAYLOAD;
@ -312,11 +312,11 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
/* Unicast requests get unicast replies! */
if(uc_addr == NULL) {
PRINTF("RPL: Sending a multicast-DIO with rank %d\n", dag->rank);
PRINTF("RPL: Sending a multicast-DIO with rank %hu\n", dag->rank);
uip_create_linklocal_allrouters_mcast(&addr);
uip_icmp6_send(&addr, ICMP6_RPL, RPL_CODE_DIO, pos);
} else {
PRINTF("RPL: Sending unicast-DIO with rank %d to ", dag->rank);
PRINTF("RPL: Sending unicast-DIO with rank %hu to ", dag->rank);
PRINT6ADDR(uc_addr);
PRINTF("\n");
uip_icmp6_send(uc_addr, ICMP6_RPL, RPL_CODE_DIO, pos);
@ -366,12 +366,12 @@ dao_input(void)
dag = rpl_get_dag(instance_id);
if(dag == NULL) {
PRINTF("RPL: Ignoring a DAO for a different DAG instance (%d)\n",
PRINTF("RPL: Ignoring a DAO for a different DAG instance (%u)\n",
instance_id);
return;
}
PRINTF("RPL: Incoming DAO rank is %d, my rank is %d\n", rank, dag->rank);
PRINTF("RPL: Incoming DAO rank is %hu, my rank is %hu\n", rank, dag->rank);
if(rank < dag->rank) {
return;
}

View File

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-timers.c,v 1.1 2010/04/30 13:43:53 joxe Exp $
* $Id: rpl-timers.c,v 1.2 2010/05/04 22:55:32 nvt-se Exp $
*/
/**
* \file
@ -66,10 +66,10 @@ handle_periodic_timer(void *ptr)
/* handle DIS */
#ifdef RPL_DIS_SEND
next_dis++;
if(rpl_get_dag(RPL_ANY_INSTANCE) == NULL && next_dis >= RPL_DIS_INTERVAL) {
next_dis = 0;
dis_output(NULL);
}
if(rpl_get_dag(RPL_ANY_INSTANCE) == NULL && next_dis >= RPL_DIS_INTERVAL) {
next_dis = 0;
dis_output(NULL);
}
#endif
ctimer_reset(&periodic_timer);
}
@ -79,14 +79,17 @@ new_dio_interval(rpl_dag_t *dag)
{
unsigned long time;
/* TODO!!! too small timer intervals for many cases */
/* TODO: too small timer intervals for many cases */
time = 1L << dag->dio_intcurrent;
/* need to convert from milliseconds to CLOCK_TICKS */
time = (time * CLOCK_SECOND) / 1000;
dag->dio_next_delay = time;
/* random number between I/2 and I */
time = time >> 1;
time += (time * random_rand()) / RANDOM_MAX;
dag->dio_next_delay -= time;
dag->dio_send = 1;