本文整理汇总了C++中rpl_reset_dio_timer函数的典型用法代码示例。如果您正苦于以下问题:C++ rpl_reset_dio_timer函数的具体用法?C++ rpl_reset_dio_timer怎么用?C++ rpl_reset_dio_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rpl_reset_dio_timer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->dtsn_out = 1;
dag->of->reset(dag);
if((p = rpl_add_parent(dag, dio, from)) == NULL) {
PRINTF("RPL: Failed to add a parent during the global repair\n");
dag->rank = INFINITE_RANK;
} else {
rpl_set_default_route(dag, from);
dag->rank = dag->of->calculate_rank(NULL, dio->rank);
dag->min_rank = dag->rank;
rpl_reset_dio_timer(dag, 1);
if(should_send_dao(dag, dio, p)) {
rpl_schedule_dao(dag);
}
}
PRINTF("RPL: Participating in a global repair (version=%u, rank=%hu)\n",
dag->version, dag->rank);
RPL_STAT(rpl_stats.global_repairs++);
}
示例2: rpl_local_repair
/*---------------------------------------------------------------------------*/
void
rpl_local_repair(rpl_instance_t *instance)
{
int i;
if(instance == NULL) {
PRINTF("RPL: local repair requested for instance NULL\n");
return;
}
PRINTF("RPL: 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 = INFINITE_RANK;
nullify_parents(&instance->dag_table[i], 0);
}
}
/* no downward route anymore */
instance->has_downward_route = 0;
rpl_reset_dio_timer(instance);
/* Request refresh of DAO registrations next DIO */
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
RPL_STAT(rpl_stats.local_repairs++);
}
示例3: rpl_select_parent
rpl_parent_t *
rpl_select_parent(rpl_dag_t *dag)
{
rpl_parent_t *p;
rpl_parent_t *best;
best = NULL;
for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(p->rank == INFINITE_RANK) {
/* ignore this neighbor */
} else if(best == NULL) {
best = p;
} else {
best = dag->of->best_parent(best, p);
}
}
if(best == NULL) {
/* need to handle update of best... */
return NULL;
}
if(dag->preferred_parent != best) {
if(dag->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
PRINTF("RPL: Sending a No-Path DAO to old DAO parent\n");
dao_output(dag->preferred_parent, ZERO_LIFETIME);
}
dag->preferred_parent = best; /* Cache the value. */
dag->of->update_metric_container(dag);
rpl_set_default_route(dag, &best->addr);
/* The DAO parent set changed - schedule a DAO transmission. */
if(dag->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
rpl_schedule_dao(dag);
}
rpl_reset_dio_timer(dag, 1);
PRINTF("RPL: New preferred parent, rank changed from %u to %u\n",
(unsigned)dag->rank, dag->of->calculate_rank(best, 0));
RPL_STAT(rpl_stats.parent_switch++);
}
/* Update the DAG rank, since link-layer information may have changed
the local confidence. */
dag->rank = dag->of->calculate_rank(best, 0);
if(dag->rank < dag->min_rank) {
dag->min_rank = dag->rank;
} else if(!acceptable_rank(dag, best->rank)) {
/* Send a No-Path DAO to the soon-to-be-removed preferred parent. */
if(dag->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
dao_output(best, ZERO_LIFETIME);
}
remove_parents(dag, 0);
return NULL;
}
return best;
}
示例4: rpl_local_repair
void
rpl_local_repair(rpl_dag_t *dag)
{
PRINTF("RPL: Starting a local DAG repair\n");
dag->rank = INFINITE_RANK;
remove_parents(dag, 0);
rpl_reset_dio_timer(dag, 1);
RPL_STAT(rpl_stats.local_repairs++);
}
示例5: rpl_set_root
rpl_dag_t *
rpl_set_root(uip_ipaddr_t *dag_id)
{
rpl_dag_t *dag;
int version;
version = -1;
dag = rpl_get_dag(RPL_DEFAULT_INSTANCE);
if(dag != NULL) {
PRINTF("RPL: Dropping a joined DAG when setting this node as root");
version = dag->version;
rpl_free_dag(dag);
}
dag = rpl_alloc_dag(RPL_DEFAULT_INSTANCE);
if(dag == NULL) {
PRINTF("RPL: Failed to allocate a DAG\n");
return NULL;
}
dag->joined = 1;
dag->version = version + 1;
dag->grounded = RPL_GROUNDED;
dag->mop = RPL_MOP_DEFAULT;
dag->of = &RPL_OF;
dag->preferred_parent = NULL;
dag->dtsn_out = 1; /* Trigger DAOs from the beginning. */
memcpy(&dag->dag_id, dag_id, sizeof(dag->dag_id));
dag->dio_intdoubl = DEFAULT_DIO_INTERVAL_DOUBLINGS;
dag->dio_intmin = DEFAULT_DIO_INTERVAL_MIN;
dag->dio_redundancy = DEFAULT_DIO_REDUNDANCY;
dag->max_rankinc = DEFAULT_MAX_RANKINC;
dag->min_hoprankinc = DEFAULT_MIN_HOPRANKINC;
dag->default_lifetime = RPL_DEFAULT_LIFETIME;
dag->lifetime_unit = RPL_DEFAULT_LIFETIME_UNIT;
dag->rank = ROOT_RANK(dag);
dag->of->update_metric_container(dag);
PRINTF("RPL: Node set to be a DAG root with DAG ID ");
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
ANNOTATE("#A root=%u\n",dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
rpl_reset_dio_timer(dag, 1);
return dag;
}
示例6: rpl_repair_dag
int
rpl_repair_dag(rpl_dag_t *dag)
{
if(dag->rank == ROOT_RANK(dag)) {
dag->version++;
dag->dtsn_out = 1;
rpl_reset_dio_timer(dag, 1);
return 1;
}
return 0;
}
示例7: rpl_repair_root
/*---------------------------------------------------------------------------*/
int
rpl_repair_root(uint8_t instance_id)
{
rpl_instance_t *instance;
instance = rpl_get_instance(instance_id);
if(instance == NULL ||
instance->current_dag->rank != ROOT_RANK(instance)) {
return 0;
}
RPL_LOLLIPOP_INCREMENT(instance->current_dag->version);
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
rpl_reset_dio_timer(instance);
return 1;
}
示例8: rpl_local_repair
/*---------------------------------------------------------------------------*/
void
rpl_local_repair(rpl_instance_t *instance)
{
int i;
PRINTF("RPL: 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 = INFINITE_RANK;
nullify_parents(&instance->dag_table[i], 0);
}
}
rpl_reset_dio_timer(instance);
RPL_STAT(rpl_stats.local_repairs++);
}
示例9: rpl_repair_root
/*---------------------------------------------------------------------------*/
int
rpl_repair_root(uint8_t instance_id)
{
rpl_instance_t *instance;
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");
return 0;
}
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);
rpl_reset_dio_timer(instance);
return 1;
}
示例10: rpl_select_parent
rpl_parent_t *
rpl_select_parent(rpl_dag_t *dag)
{
rpl_parent_t *p;
rpl_parent_t *best;
best = NULL;
for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(best == NULL) {
best = p;
} else {
best = dag->of->best_parent(best, p);
}
}
if(dag->preferred_parent != best) {
dag->preferred_parent = best; /* Cache the value. */
dag->of->update_metric_container(dag);
rpl_set_default_route(dag, &best->addr);
/* The DAO parent set changed - schedule a DAO transmission. */
rpl_schedule_dao(dag);
rpl_reset_dio_timer(dag, 1);
PRINTF("RPL: New preferred parent, rank changed from %u to %u\n",
(unsigned)dag->rank, dag->of->calculate_rank(best, 0));
}
/* Update the DAG rank, since link-layer information may have changed
the local confidence. */
dag->rank = dag->of->calculate_rank(best, 0);
if(dag->rank < dag->min_rank) {
dag->min_rank = dag->rank;
} else if(!acceptable_rank(dag, best->rank)) {
/* Send a No-Path DAO to the soon-to-be-removed preferred parent. */
dao_output(p, ZERO_LIFETIME);
remove_parents(dag, 0);
return NULL;
}
return best;
}
示例11: rpl_process_parent_event
int
rpl_process_parent_event(rpl_dag_t *dag, rpl_parent_t *p)
{
rpl_rank_t parent_rank;
rpl_rank_t old_rank;
/* Update the parent rank. */
parent_rank = p->rank;
old_rank = dag->rank;
if(rpl_select_parent(dag) == NULL) {
/* No suitable parent; trigger a local repair. */
PRINTF("RPL: No parents found in a DAG\n");
rpl_local_repair(dag);
return 1;
}
if(DAG_RANK(old_rank, dag) != DAG_RANK(dag->rank, dag)) {
if(dag->rank < dag->min_rank) {
dag->min_rank = dag->rank;
}
PRINTF("RPL: Moving in the DAG from rank %hu to %hu\n",
DAG_RANK(old_rank, dag), DAG_RANK(dag->rank, dag));
PRINTF("RPL: The preferred parent is ");
PRINT6ADDR(&dag->preferred_parent->addr);
PRINTF(" (rank %u)\n",
(unsigned)DAG_RANK(dag->preferred_parent->rank, dag));
rpl_reset_dio_timer(dag, 1);
}
if(parent_rank == INFINITE_RANK ||
!acceptable_rank(dag, dag->of->calculate_rank(NULL, parent_rank))) {
/* The candidate parent is no longer valid: the rank increase resulting
from the choice of it as a parent would be too high. */
return 0;
}
return 1;
}
示例12: rpl_set_root
rpl_dag_t *
rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
{
rpl_dag_t *dag;
rpl_instance_t *instance;
uint8_t version;
version = RPL_LOLLIPOP_INIT;
dag = rpl_get_dodag(instance_id, dag_id);
if(dag != NULL) {
version = dag->version;
RPL_LOLLIPOP_INCREMENT(version);
PRINTF("RPL: Dropping a joined DAG when setting this node as root");
if(dag==dag->instance->current_dag) {
dag->instance->current_dag=NULL;
}
rpl_free_dodag(dag);
}
dag = rpl_alloc_dodag(instance_id,dag_id);
if(dag == NULL) {
PRINTF("RPL: Failed to allocate a DAG\n");
return NULL;
}
instance = dag->instance;
dag->version = version;
dag->joined = 1;
dag->grounded = RPL_GROUNDED;
instance->mop = RPL_MOP_DEFAULT;
instance->of = &RPL_OF;
memcpy(&dag->dag_id, dag_id, sizeof(dag->dag_id));
instance->dio_intdoubl = DEFAULT_DIO_INTERVAL_DOUBLINGS;
instance->dio_intmin = DEFAULT_DIO_INTERVAL_MIN;
instance->dio_redundancy = DEFAULT_DIO_REDUNDANCY;
instance->max_rankinc = DEFAULT_MAX_RANKINC;
instance->min_hoprankinc = DEFAULT_MIN_HOPRANKINC;
instance->default_lifetime = DEFAULT_RPL_DEF_LIFETIME;
instance->lifetime_unit = DEFAULT_RPL_LIFETIME_UNIT;
dag->rank = ROOT_RANK(instance);
if(instance->current_dag != dag && instance->current_dag != NULL) {
/* Remove routes installed by DAOs. */
rpl_remove_routes(instance->current_dag);
(instance->current_dag)->joined = 0;
}
instance->current_dag = dag;
instance->dtsn_out=RPL_LOLLIPOP_INIT;
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");
ANNOTATE("#A root=%u\n",dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
instance->dio_timer.instance=instance;
rpl_reset_dio_timer(instance, 1);
return dag;
}
示例13: rpl_verify_header
/*---------------------------------------------------------------------------*/
int
rpl_verify_header(int uip_ext_opt_offset)
{
rpl_instance_t *instance;
int down;
uint16_t sender_rank;
uint8_t sender_closer;
uip_ds6_route_t *route;
rpl_parent_t *sender = NULL;
if(UIP_HBHO_BUF->len != RPL_HOP_BY_HOP_LEN - 8) {
PRINTF("RPL: Hop-by-hop extension header has wrong size\n");
return 1;
}
if(UIP_EXT_HDR_OPT_RPL_BUF->opt_type != UIP_EXT_HDR_OPT_RPL) {
PRINTF("RPL: Non RPL Hop-by-hop option\n");
return 1;
}
if(UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) {
PRINTF("RPL: Bad header option! (wrong length)\n");
return 1;
}
instance = rpl_get_instance(UIP_EXT_HDR_OPT_RPL_BUF->instance);
if(instance == NULL) {
PRINTF("RPL: Unknown instance: %u\n",
UIP_EXT_HDR_OPT_RPL_BUF->instance);
return 1;
}
if(UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_FWD_ERR) {
PRINTF("RPL: 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
us. */
route = uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr);
if(route != NULL) {
uip_ds6_route_rm(route);
}
RPL_STAT(rpl_stats.forward_errors++);
/* Trigger DAO retransmission */
rpl_reset_dio_timer(instance);
/* drop the packet as it is not routable */
return 1;
}
if(!instance->current_dag->joined) {
PRINTF("RPL: No DAG in the instance\n");
return 1;
}
down = 0;
if(UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_DOWN) {
down = 1;
}
sender_rank = UIP_HTONS(UIP_EXT_HDR_OPT_RPL_BUF->senderrank);
sender_closer = sender_rank < instance->current_dag->rank;
PRINTF("RPL: Packet going %s, sender closer %d (%d < %d)\n", down == 1 ? "down" : "up",
sender_closer,
sender_rank,
instance->current_dag->rank
);
sender = nbr_table_get_from_lladdr(rpl_parents, packetbuf_addr(PACKETBUF_ADDR_SENDER));
if(sender != NULL && (UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_RANK_ERR)) {
/* A rank error was signalled, attempt to repair it by updating
* the sender's rank from ext header */
sender->rank = sender_rank;
rpl_select_dag(instance, sender);
}
if((down && !sender_closer) || (!down && sender_closer)) {
PRINTF("RPL: 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
* so that it gets a fresh update of our rank. */
if(sender != NULL) {
instance->unicast_dio_target = sender;
rpl_schedule_unicast_dio_immediately(instance);
}
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");
/* Packet must be dropped and dio trickle timer reset, see RFC6550 - 11.2.2.2 */
rpl_reset_dio_timer(instance);
return 1;
}
PRINTF("RPL: Single error tolerated\n");
RPL_STAT(rpl_stats.loop_warnings++);
UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_RANK_ERR;
return 0;
}
//.........这里部分代码省略.........
示例14: rpl_join_instance
//.........这里部分代码省略.........
with this prefix. */
if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {
check_prefix(NULL, &dio->prefix_info);
}
//-----------------elnaz
tx =cc2420_get_txpower();
printf("Power=%d \n",tx);
switch(tx) {
case 3:
dag->Tx = 0.003;
break;
case 7:
dag->Tx = 0.03;
break;
case 11:
dag->Tx = 0.1;
break;
case 15:
dag->Tx = 0.2;
break;
case 19:
dag->Tx = 0.3;
break;
case 23:
dag->Tx = 0.5;
break;
case 27:
dag->Tx = 0.8;
break;
case 31:
dag->Tx = 1;
}
/*
float mv = (bateria * 2.500 * 2) / 4096;
printf("Battery: (%ld.%03d mV)\n", (long) mv, (unsigned) ((mv - floor(mv)) * 1000));
*/
//printf("Test tx=%ld ",(long) (dag->Tx*1000));
//----------------------elnaz
dag->joined = 1;
dag->preference = dio->preference;
dag->grounded = dio->grounded;
dag->version = dio->version;
instance->of = of;
instance->mop = dio->mop;
instance->current_dag = dag;
instance->dtsn_out = RPL_LOLLIPOP_INIT;
instance->max_rankinc = dio->dag_max_rankinc;
instance->min_hoprankinc = dio->dag_min_hoprankinc;
instance->dio_intdoubl = dio->dag_intdoubl;
instance->dio_intmin = dio->dag_intmin;
instance->dio_intcurrent = instance->dio_intmin + instance->dio_intdoubl;
instance->dio_redundancy = dio->dag_redund;
instance->default_lifetime = dio->default_lifetime;
instance->lifetime_unit = dio->lifetime_unit;
memcpy(&dag->dag_id, &dio->dag_id, sizeof(dio->dag_id));
/* Copy prefix information from the DIO into the DAG object. */
memcpy(&dag->prefix_info, &dio->prefix_info, sizeof(rpl_prefix_t));
rpl_set_preferred_parent(dag, p);
instance->of->update_metric_container(instance);
dag->rank = instance->of->calculate_rank(p, 0);
/* So far this is the lowest rank we are aware of. */
dag->min_rank = dag->rank;
if(default_instance == NULL) {
default_instance = instance;
}
// PRINTF("RPL: Joined DAG with instance ID %u, rank %hu, DAG ID ", dio->instance_id, dag->rank);
// PRINT6ADDR(&dag->dag_id);
// PRINTF("\n");
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);
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");
}
}
示例15: rpl_process_dio
/*---------------------------------------------------------------------------*/
void
rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
{
rpl_instance_t *instance;
rpl_dag_t *dag, *previous_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;
}
dag = get_dag(dio->instance_id, &dio->dag_id);
instance = rpl_get_instance(dio->instance_id);
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\n");
dag->version = dio->version;
RPL_LOLLIPOP_INCREMENT(dag->version);
rpl_reset_dio_timer(instance);
} else {
PRINTF("RPL: 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");
rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);
}
}
global_repair(from, dag, dio);
}
return;
}
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");
if(dag->joined) {
rpl_reset_dio_timer(instance);
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);
}
/* 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 (");
//.........这里部分代码省略.........