本文整理汇总了C++中rpl_process_parent_event函数的典型用法代码示例。如果您正苦于以下问题:C++ rpl_process_parent_event函数的具体用法?C++ rpl_process_parent_event怎么用?C++ rpl_process_parent_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rpl_process_parent_event函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: global_repair
/*---------------------------------------------------------------------------*/
static void
global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio)
{
rpl_parent_t *p;
remove_parents(dag, 0);
dag->version = dio->version;
dag->instance->of->reset(dag);
dag->min_rank = INFINITE_RANK;
RPL_LOLLIPOP_INCREMENT(dag->instance->dtsn_out);
p = rpl_add_parent(dag, dio, from);
if(p == NULL) {
PRINTF("RPL: Failed to add a parent during the global repair\n");
dag->rank = INFINITE_RANK;
} else {
dag->rank = dag->instance->of->calculate_rank(p, 0);
dag->min_rank = dag->rank;
PRINTF("RPL: 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",
dag->version, dag->rank);
RPL_STAT(rpl_stats.global_repairs++);
}
示例2: rpl_recalculate_ranks
/*---------------------------------------------------------------------------*/
void
rpl_recalculate_ranks(void)
{
rpl_parent_t *p;
/*
* We recalculate ranks when we receive feedback from the system rather
* than RPL protocol messages. This periodical recalculation is called
* from a timer in order to keep the stack depth reasonably low.
*/
p = nbr_table_head(rpl_parents);
while(p != NULL) {
#if WITH_ORPL
/* In ORPL the rank is not bound to a particular parent.
* We just want to calculate it once. */
if(p->dag != NULL && p->dag->instance) {
p->dag->instance->of->calculate_rank(p, 0);
break;
}
#else /* WITH_ORPL */
if(p->dag != NULL && p->dag->instance && p->updated) {
p->updated = 0;
PRINTF("RPL: rpl_process_parent_event recalculate_ranks\n");
if(!rpl_process_parent_event(p->dag->instance, p)) {
PRINTF("RPL: A parent was dropped\n");
}
}
#endif /* WITH_ORPL */
p = nbr_table_next(rpl_parents, p);
}
}
示例3: rpl_recalculate_ranks
void
rpl_recalculate_ranks(void)
{
rpl_dag_t *dag;
rpl_parent_t *p;
/*
* We recalculate ranks when we receive feedback from the system rather
* than RPL protocol messages. This periodical recalculation is called
* from a timer in order to keep the stack depth reasonably low.
*/
dag = rpl_get_dag(RPL_ANY_INSTANCE);
if(dag != NULL) {
for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(p->updated) {
p->updated = 0;
rpl_process_parent_event(dag, p);
/*
* Stop calculating here because the parent list may have changed.
* If more ranks need to be recalculated, it will be taken care of
* in subsequent calls to this functions.
*/
break;
}
}
}
}
示例4: rpl_recalculate_ranks
/*---------------------------------------------------------------------------*/
void
rpl_recalculate_ranks(void)
{
rpl_instance_t *instance, *end;
rpl_parent_t *p;
int i;
/*
* We recalculate ranks when we receive feedback from the system rather
* than RPL protocol messages. This periodical recalculation is called
* from a timer in order to keep the stack depth reasonably low.
*/
for(instance = &instance_table[0], end = instance + RPL_MAX_INSTANCES; instance < end; ++instance) {
if(instance->used) {
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; i++) {
if(instance->dag_table[i].used) {
for(p = list_head(instance->dag_table[i].parents); p != NULL; p = p->next) {
if(p->updated) {
p->updated = 0;
if(!rpl_process_parent_event(instance, p)) {
PRINTF("RPL: A parent was dropped\n");
}
/*
* Stop calculating here because the parent list may have changed.
* If more ranks need to be recalculated, it will be taken care of
* in subsequent calls to this functions.
*/
break;
}
}
}
}
}
}
}
示例5: rpl_recalculate_ranks
/*---------------------------------------------------------------------------*/
void
rpl_recalculate_ranks(void)
{
rpl_parent_t *p;
rpl_instance_t *instance;
rpl_instance_t *end;
int i;
int updated = 0;
/*
* We recalculate ranks when we receive feedback from the system rather
* than RPL protocol messages. This periodical recalculation is called
* from a timer in order to keep the stack depth reasonably low.
*/
p = nbr_table_head(rpl_parents);
while(p != NULL) {
if(p->dag != NULL && p->dag->instance && (p->flags & RPL_PARENT_FLAG_UPDATED)) {
p->flags &= ~RPL_PARENT_FLAG_UPDATED;
updated = 1;
PRINTF("RPL: rpl_process_parent_event recalculate_ranks\n");
if(!rpl_process_parent_event(p->dag->instance, p)) {
PRINTF("RPL: A parent was dropped\n");
}
}
p = nbr_table_next(rpl_parents, p);
}
if (!updated) {
for(instance = &instance_table[0], end = instance + RPL_MAX_INSTANCES;
instance < end; ++instance) {
if(instance->used) {
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; i++) {
if(instance->dag_table[i].used && instance->dag_table[i].preferred_parent != NULL) {
rpl_process_parent_event(instance, instance->dag_table[i].preferred_parent);
}
}
}
}
}
}
示例6: rpl_recalculate_ranks
/*---------------------------------------------------------------------------*/
void
rpl_recalculate_ranks(void)
{
rpl_parent_t *p;
//uip_ipaddr_t *x;
//rpl_parent_t *pref_parent =(&instance_table[0])->current_dag->preferred_parent;//mark
/*
* We recalculate ranks when we receive feedback from the system rather
* than RPL protocol messages. This periodical recalculation is called
* from a timer in order to keep the stack depth reasonably low.
*/
p = nbr_table_head(rpl_parents);
//printf("rank= %u:{", (((&instance_table[0])->current_dag->rank)/256));//,list_length((&instance_table[0])->current_dag->parents));//256);//mark
while(p != NULL) {
/*x=rpl_get_parent_ipaddr(p);
printf("(");//mark
if(p==pref_parent)//mark
printf("pref-prnt ");//mark
printf(" %02x%02x ",((uint8_t *)x)[14], ((uint8_t *)x)[15]);//mark
printf("etx=%d.%d, rssi=%d, rank=%u", p->link_metric/128, p->link_metric%128 ,p->rssi, p->rank/256);//mark*/
/* if(p->rssi > RSSI_THRESHOLD && (clock_seconds()-p->update_time)<AGE_THRESHOLD && p->flag==PRNT)
{p->flag= Pt_PRNT;
PRINTF("P_t prnt=");
PRINT6ADDR(rpl_get_parent_ipaddr(p));
PRINTF(",");
}*/
if(p->dag != NULL && p->dag->instance && p->updated) {
p->updated = 0;
// PRINTF("RPL: rpl_process_parent_event recalculate_ranks\n");
if(!rpl_process_parent_event(p->dag->instance, p)) {
// PRINTF("RPL: A parent was dropped\n");
}
}
//printf(")");//mark
p = nbr_table_next(rpl_parents, p);
}
//printf("}\n");//mark
}
示例7: rpl_process_dio
//.........这里部分代码省略.........
PRINTF("RPL: Ignoring DIO with too low rank: %u\n",
(unsigned)dio->rank);
return;
} else if(dio->rank == INFINITE_RANK && dag->joined) {
rpl_reset_dio_timer(instance);
}
/* 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");
rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);
}
}
if(dag->rank == ROOT_RANK(instance)) {
if(dio->rank != INFINITE_RANK) {
instance->dio_counter++;
}
#if !WITH_ORPL
return; /* With ORPL we want to have neighbors in the "rpl_parents"
table as we need their rank and ackcount for routing set. */
#endif
}
/*
* At this point, we know that this DIO pertains to a DAG that
* we are already part of. We consider the sender of the DIO to be
* a candidate parent, and let rpl_process_parent_event decide
* whether to keep it in the set.
*/
p = rpl_find_parent(dag, from);
if(p == NULL) {
previous_dag = find_parent_dag(instance, from);
if(previous_dag == NULL) {
/* 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");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else {
p = rpl_find_parent(previous_dag, from);
if(p != NULL) {
rpl_move_parent(previous_dag, dag, p);
}
}
} else {
if(p->rank == dio->rank) {
PRINTF("RPL: Received consistent DIO\n");
if(dag->joined) {
instance->dio_counter++;
}
} else {
p->rank=dio->rank;
}
}
#if WITH_ORPL
if(dag->rank == ROOT_RANK(instance)) {
/* We have added the parent, now return if we are root */
return;
}
#endif
PRINTF("RPL: preferred DAG ");
PRINT6ADDR(&instance->current_dag->dag_id);
PRINTF(", rank %u, min_rank %u, ",
instance->current_dag->rank, instance->current_dag->min_rank);
PRINTF("parent rank %u, parent etx %u, link metric %u, instance etx %u\n",
p->rank, -1/*p->mc.obj.etx*/, p->link_metric, instance->mc.obj.etx);
/* We have allocated a candidate parent; process the DIO further. */
#if RPL_DAG_MC != RPL_DAG_MC_NONE
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
#endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
if(rpl_process_parent_event(instance, p) == 0) {
PRINTF("RPL: The candidate parent is rejected\n");
return;
}
/* We don't use route control, so we can have only one official parent. */
if(dag->joined && p == dag->preferred_parent) {
if(should_send_dao(instance, dio, p)) {
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
rpl_schedule_dao(instance);
}
/* We received a new DIO from our preferred parent.
* Call uip_ds6_defrt_add to set a fresh value for the lifetime counter */
uip_ds6_defrt_add(from, RPL_LIFETIME(instance, instance->default_lifetime));
}
p->dtsn = dio->dtsn;
}
示例8: rpl_process_dio
//.........这里部分代码省略.........
PRINT6ADDR(from);
PRINTF("\n");
return;
}
if(instance == NULL) {
PRINTF("RPL: New instance detected: Joining...\n");
rpl_join_instance(from, dio);
return;
}
if(dag == NULL) {
PRINTF("RPL: Adding new DAG to known instance.\n");
rpl_add_dag(from, dio);
return;
}
if(dio->rank < ROOT_RANK(instance)) {
PRINTF("RPL: Ignoring DIO with too low rank: %u\n",
(unsigned)dio->rank);
return;
} else if(dio->rank == INFINITE_RANK && dag->joined) {
rpl_reset_dio_timer(instance);
}
if(dag->rank == ROOT_RANK(instance)) {
if(dio->rank != INFINITE_RANK) {
instance->dio_counter++;
}
return;
}
/*
* At this point, we know that this DIO pertains to a DAG that
* we are already part of. We consider the sender of the DIO to be
* a candidate parent, and let rpl_process_parent_event decide
* whether to keep it in the set.
*/
p = rpl_find_parent(dag, from);
if(p == NULL) {
previous_dag = find_parent_dag(instance, from);
if(previous_dag == NULL) {
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS_PER_DAG) {
/* Make room for a new parent. */
remove_worst_parent(dag, dio->rank);
}
/* 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");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else {
p = rpl_find_parent(previous_dag, from);
if(p != NULL) {
rpl_move_parent(previous_dag, dag, p);
}
}
} else {
if(p->rank == dio->rank) {
PRINTF("RPL: Received consistent DIO\n");
if(dag->joined) {
instance->dio_counter++;
}
} else {
p->rank=dio->rank;
}
}
PRINTF("RPL: preferred DAG ");
PRINT6ADDR(&instance->current_dag->dag_id);
PRINTF(", rank %u, min_rank %u, ",
instance->current_dag->rank, instance->current_dag->min_rank);
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);
/* We have allocated a candidate parent; process the DIO further. */
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
if(rpl_process_parent_event(instance, p) == 0) {
PRINTF("RPL: The candidate parent is rejected\n");
return;
}
/* We don't use route control, so we can have only one official parent. */
if(dag->joined && p == dag->preferred_parent) {
if(should_send_dao(instance, dio, p)) {
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
rpl_schedule_dao(instance);
}
}
p->dtsn = dio->dtsn;
}
示例9: rpl_process_dio
void
rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
{
rpl_dag_t *dag;
rpl_parent_t *p;
if(dio->mop != RPL_MOP_DEFAULT) {
PRINTF("RPL: Ignoring a DIO with an unsupported MOP: %d\n", dio->mop);
return;
}
// LVD 24/03/2011
instanceID = dio->instance_id;
dag = rpl_get_dag(dio->instance_id);
if(dag == NULL) {
/* Join the first possible DAG of this RPL instance. */
if(dio->rank != INFINITE_RANK) {
join_dag(from, dio);
} else {
PRINTF("RPL: Ignoring DIO from node with infinite rank: ");
PRINT6ADDR(from);
PRINTF("\n");
}
return;
}
if(memcmp(&dag->dag_id, &dio->dag_id, sizeof(dag->dag_id))) {
PRINTF("RPL: Ignoring DIO for another DAG within our instance\n");
return;
}
if(dio->version > dag->version) {
if(dag->rank == ROOT_RANK(dag)) {
PRINTF("RPL: Root received inconsistent DIO version number\n");
dag->version = dio->version + 1;
rpl_reset_dio_timer(dag, 1);
} else {
global_repair(from, dag, dio);
}
return;
} else if(dio->version < dag->version) {
/* Inconsistency detected - someone is still on old version */
PRINTF("RPL: old version received => inconsistency detected\n");
rpl_reset_dio_timer(dag, 1);
return;
}
if(dio->rank == INFINITE_RANK) {
rpl_reset_dio_timer(dag, 1);
} else if(dio->rank < ROOT_RANK(dag)) {
PRINTF("RPL: Ignoring DIO with too low rank: %u\n",
(unsigned)dio->rank);
return;
}
if(dag->rank == ROOT_RANK(dag)) {
if(dio->rank != INFINITE_RANK) {
dag->dio_counter++;
}
return;
}
/*
* At this point, we know that this DIO pertains to a DAG that
* we are already part of. We consider the sender of the DIO to be
* a candidate parent, and let rpl_process_parent_event decide
* whether to keep it in the set.
*/
p = rpl_find_parent(dag, from);
if(p == NULL) {
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS) {
/* Make room for a new parent. */
remove_worst_parent(dag, dio->rank);
}
/* 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");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else if(DAG_RANK(p->rank, dag) == DAG_RANK(dio->rank, dag)) {
PRINTF("RPL: Received consistent DIO\n");
dag->dio_counter++;
}
/* We have allocated a candidate parent; process the DIO further. */
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
p->rank = dio->rank;
if(rpl_process_parent_event(dag, p) == 0) {
/* The candidate parent no longer exists. */
//.........这里部分代码省略.........
示例10: rpl_process_dio
//.........这里部分代码省略.........
rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);
}
}
if(dag->rank == ROOT_RANK(instance)) {
if(dio->rank != INFINITE_RANK) {
instance->dio_counter++;
}
return;
}
/*
* At this point, we know that this DIO pertains to a DAG that
* we are already part of. We consider the sender of the DIO to be
* a candidate parent, and let rpl_process_parent_event decide
* whether to keep it in the set.
*/
p = rpl_find_parent(dag, from);
if(p == NULL) {
previous_dag = find_parent_dag(instance, from);
if(previous_dag == NULL) {
/* 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");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else {
p = rpl_find_parent(previous_dag, from);
if(p != NULL) {
rpl_move_parent(previous_dag, dag, p);
}
}
} else {
if(p->rank == dio->rank) {
PRINTF("RPL: Received consistent DIO\n");
if(dag->joined) {
instance->dio_counter++;
}
} else {
p->rank = dio->rank;
}
}
PRINTF("RPL: preferred DAG ");
PRINT6ADDR(&instance->current_dag->dag_id);
PRINTF(", rank %u, min_rank %u, ",
instance->current_dag->rank, instance->current_dag->min_rank);
PRINTF("parent rank %u, parent etx %u, link metric %u, instance etx %u\n",
p->rank, -1 /*p->mc.obj.etx */, p->link_metric,
instance->mc.obj.etx);
/*
* If the DIO being processed came from smart-HOP decision, change default route,
* schedule DAO and finish the mobility process.
*/
if(mobility) {
rpl_remove_parent(previous_preferred);
rpl_set_preferred_parent(dag, p);
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
/*dao_output(p, 255);*/
/* We received a new DIO from our preferred parent.
* Call uip_ds6_defrt_add to set a fresh value for the lifetime counter */
PRINTF("adding default route\n");
current_t = clock_time() * 1000 / CLOCK_SECOND;
printf("End %u\n", current_t);
rpl_set_default_route(instance, from);
rpl_schedule_dao(instance);
/*check_dao_ack = 1;*/
process_post(&tcpip_process, RESET_MOBILITY_FLAG, NULL);
return;
}
if(mobility == 0) {
#if RPL_DAG_MC != RPL_DAG_MC_NONE
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
#endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
if(rpl_process_parent_event(instance, p) == 0) {
PRINTF("RPL: The candidate parent is rejected\n");
return;
}
}
/* We don't use route control, so we can have only one official parent. */
if(dag->joined && p == dag->preferred_parent) {
if(should_send_dao(instance, dio, p)) {
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
rpl_schedule_dao(instance);
}
/* We received a new DIO from our preferred parent.
* Call uip_ds6_defrt_add to set a fresh value for the lifetime counter */
uip_ds6_defrt_add(from,
RPL_LIFETIME(instance, instance->default_lifetime));
}
p->dtsn = dio->dtsn;
}