Merge pull request #366 from OlegHahm/rpl_debug
tiny debug improvement for RPL
This commit is contained in:
commit
1d4ea91b82
@ -286,9 +286,13 @@ void send_DIO(ipv6_addr_t *destination)
|
|||||||
|
|
||||||
rpl_send_dio_buf = get_rpl_send_dio_buf();
|
rpl_send_dio_buf = get_rpl_send_dio_buf();
|
||||||
memset(rpl_send_dio_buf, 0, sizeof(*rpl_send_dio_buf));
|
memset(rpl_send_dio_buf, 0, sizeof(*rpl_send_dio_buf));
|
||||||
|
|
||||||
|
DEBUG("Sending DIO with ");
|
||||||
rpl_send_dio_buf->rpl_instanceid = mydodag->instance->id;
|
rpl_send_dio_buf->rpl_instanceid = mydodag->instance->id;
|
||||||
|
DEBUG("instance %02X ", rpl_send_dio_buf->rpl_instanceid);
|
||||||
rpl_send_dio_buf->version_number = mydodag->version;
|
rpl_send_dio_buf->version_number = mydodag->version;
|
||||||
rpl_send_dio_buf->rank = mydodag->my_rank;
|
rpl_send_dio_buf->rank = mydodag->my_rank;
|
||||||
|
DEBUG("rank %04X\n", rpl_send_dio_buf->rank);
|
||||||
rpl_send_dio_buf->g_mop_prf = (mydodag->grounded << RPL_GROUNDED_SHIFT) | (mydodag->mop << RPL_MOP_SHIFT) | mydodag->prf;
|
rpl_send_dio_buf->g_mop_prf = (mydodag->grounded << RPL_GROUNDED_SHIFT) | (mydodag->mop << RPL_MOP_SHIFT) | mydodag->prf;
|
||||||
rpl_send_dio_buf->dtsn = mydodag->dtsn;
|
rpl_send_dio_buf->dtsn = mydodag->dtsn;
|
||||||
rpl_send_dio_buf->flags = 0;
|
rpl_send_dio_buf->flags = 0;
|
||||||
@ -511,9 +515,12 @@ void rpl_process(void)
|
|||||||
|
|
||||||
void recv_rpl_dio(void)
|
void recv_rpl_dio(void)
|
||||||
{
|
{
|
||||||
|
DEBUG("Received DIO with ");
|
||||||
ipv6_buf = get_rpl_ipv6_buf();
|
ipv6_buf = get_rpl_ipv6_buf();
|
||||||
|
|
||||||
rpl_dio_buf = get_rpl_dio_buf();
|
rpl_dio_buf = get_rpl_dio_buf();
|
||||||
|
DEBUG("instance %04X ", rpl_dio_buf->rpl_instanceid);
|
||||||
|
DEBUG("rank %04X\n", rpl_dio_buf->rank);
|
||||||
int len = DIO_BASE_LEN;
|
int len = DIO_BASE_LEN;
|
||||||
|
|
||||||
rpl_instance_t *dio_inst = rpl_get_instance(rpl_dio_buf->rpl_instanceid);
|
rpl_instance_t *dio_inst = rpl_get_instance(rpl_dio_buf->rpl_instanceid);
|
||||||
@ -522,12 +529,14 @@ void recv_rpl_dio(void)
|
|||||||
if (dio_inst == NULL) {
|
if (dio_inst == NULL) {
|
||||||
if (my_inst != NULL) {
|
if (my_inst != NULL) {
|
||||||
/* already part of a DODAG -> impossible to join other instance */
|
/* already part of a DODAG -> impossible to join other instance */
|
||||||
|
DEBUG("Not joining another DODAG!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dio_inst = rpl_new_instance(rpl_dio_buf->rpl_instanceid);
|
dio_inst = rpl_new_instance(rpl_dio_buf->rpl_instanceid);
|
||||||
|
|
||||||
if (dio_inst == NULL) {
|
if (dio_inst == NULL) {
|
||||||
|
DEBUG("Failed to create a new RPL instance!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -563,6 +572,7 @@ void recv_rpl_dio(void)
|
|||||||
* icmpv6 header, so only ICMPV6_HDR_LEN remains to be
|
* icmpv6 header, so only ICMPV6_HDR_LEN remains to be
|
||||||
* subtracted. */
|
* subtracted. */
|
||||||
while (len < (ipv6_buf->length - ICMPV6_HDR_LEN)) {
|
while (len < (ipv6_buf->length - ICMPV6_HDR_LEN)) {
|
||||||
|
DEBUG("parsing DIO options\n");
|
||||||
rpl_opt_buf = get_rpl_opt_buf(len);
|
rpl_opt_buf = get_rpl_opt_buf(len);
|
||||||
|
|
||||||
switch (rpl_opt_buf->type) {
|
switch (rpl_opt_buf->type) {
|
||||||
@ -591,6 +601,7 @@ void recv_rpl_dio(void)
|
|||||||
has_dodag_conf_opt = 1;
|
has_dodag_conf_opt = 1;
|
||||||
|
|
||||||
if (rpl_opt_buf->length != RPL_OPT_DODAG_CONF_LEN) {
|
if (rpl_opt_buf->length != RPL_OPT_DODAG_CONF_LEN) {
|
||||||
|
DEBUG("DODAG configuration is malformed.\n");
|
||||||
/* error malformed */
|
/* error malformed */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,12 @@
|
|||||||
#include "trickle.h"
|
#include "trickle.h"
|
||||||
#include "rpl.h"
|
#include "rpl.h"
|
||||||
|
|
||||||
|
#define ENABLE_DEBUG (0)
|
||||||
|
#if ENABLE_DEBUG
|
||||||
|
char addr_str[IPV6_MAX_ADDR_STR_LEN];
|
||||||
|
#endif
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
rpl_instance_t instances[RPL_MAX_INSTANCES];
|
rpl_instance_t instances[RPL_MAX_INSTANCES];
|
||||||
rpl_dodag_t dodags[RPL_MAX_DODAGS];
|
rpl_dodag_t dodags[RPL_MAX_DODAGS];
|
||||||
rpl_parent_t parents[RPL_MAX_PARENTS];
|
rpl_parent_t parents[RPL_MAX_PARENTS];
|
||||||
@ -232,11 +238,11 @@ rpl_parent_t *rpl_find_preferred_parent(void)
|
|||||||
for (uint8_t i = 0; i < RPL_MAX_PARENTS; i++) {
|
for (uint8_t i = 0; i < RPL_MAX_PARENTS; i++) {
|
||||||
if (parents[i].used) {
|
if (parents[i].used) {
|
||||||
if ((parents[i].rank == INFINITE_RANK) || (parents[i].lifetime <= 1)) {
|
if ((parents[i].rank == INFINITE_RANK) || (parents[i].lifetime <= 1)) {
|
||||||
puts("bad parent");
|
DEBUG("Infinite rank, bad parent\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (best == NULL) {
|
else if (best == NULL) {
|
||||||
puts("parent");
|
DEBUG("possible parent\n");
|
||||||
best = &parents[i];
|
best = &parents[i];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -332,6 +338,14 @@ void rpl_join_dodag(rpl_dodag_t *dodag, ipv6_addr_t *parent, uint16_t parent_ran
|
|||||||
my_dodag->my_rank = dodag->of->calc_rank(preferred_parent, dodag->my_rank);
|
my_dodag->my_rank = dodag->of->calc_rank(preferred_parent, dodag->my_rank);
|
||||||
my_dodag->dao_seq = RPL_COUNTER_INIT;
|
my_dodag->dao_seq = RPL_COUNTER_INIT;
|
||||||
my_dodag->min_rank = my_dodag->my_rank;
|
my_dodag->min_rank = my_dodag->my_rank;
|
||||||
|
DEBUG("Joint DODAG:\n");
|
||||||
|
DEBUG("\tMOP:\t%02X\n", my_dodag->mop);
|
||||||
|
DEBUG("\tminhoprankincrease :\t%04X\n", my_dodag->minhoprankincrease);
|
||||||
|
DEBUG("\tdefault_lifetime:\t%02X\n", my_dodag->default_lifetime);
|
||||||
|
DEBUG("\tgrounded:\t%02X\n", my_dodag->grounded);
|
||||||
|
DEBUG("\tmy_preferred_parent:\t%s\n", ipv6_addr_to_str(addr_str, &my_dodag->my_preferred_parent->addr));
|
||||||
|
DEBUG("\tmy_preferred_parent rank\t%02X\n", my_dodag->my_preferred_parent->rank);
|
||||||
|
DEBUG("\tmy_preferred_parent lifetime\t%04X\n", my_dodag->my_preferred_parent->lifetime);
|
||||||
|
|
||||||
start_trickle(my_dodag->dio_min, my_dodag->dio_interval_doubling, my_dodag->dio_redundancy);
|
start_trickle(my_dodag->dio_min, my_dodag->dio_interval_doubling, my_dodag->dio_redundancy);
|
||||||
delay_dao();
|
delay_dao();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user