这篇教程C++ rpl_reset_dio_timer函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中rpl_reset_dio_timer函数的典型用法代码示例。如果您正苦于以下问题:C++ rpl_reset_dio_timer函数的具体用法?C++ rpl_reset_dio_timer怎么用?C++ rpl_reset_dio_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了rpl_reset_dio_timer函数的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: global_repairstatic voidglobal_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++);}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:26,
示例2: rpl_local_repair/*---------------------------------------------------------------------------*/voidrpl_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++);}
开发者ID:13416795,项目名称:contiki,代码行数:27,
示例3: rpl_select_parentrpl_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;}
开发者ID:CaptFrank,项目名称:contiki-stm32w,代码行数:57,
示例4: rpl_local_repairvoidrpl_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++);}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:11,
示例5: rpl_set_rootrpl_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;}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:54,
示例6: rpl_repair_dagintrpl_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;}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:11,
示例7: rpl_repair_root/*---------------------------------------------------------------------------*/intrpl_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;}
开发者ID:denghongcai,项目名称:6lbr,代码行数:17,
示例8: rpl_local_repair/*---------------------------------------------------------------------------*/voidrpl_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++);}
开发者ID:denghongcai,项目名称:6lbr,代码行数:18,
示例9: rpl_repair_root/*---------------------------------------------------------------------------*/intrpl_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;}
开发者ID:Johnyren,项目名称:orpl,代码行数:19,
示例10: rpl_select_parentrpl_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;}
开发者ID:Asterios,项目名称:contiki-tls-dtls,代码行数:41,
示例11: rpl_process_parent_eventintrpl_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;}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:39,
示例12: rpl_set_rootrpl_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;}
开发者ID:Feandil,项目名称:RPL_Gateway,代码行数:69,
示例13: rpl_verify_header/*---------------------------------------------------------------------------*/intrpl_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; }//.........这里部分代码省略.........
开发者ID:Ayesha-N,项目名称:6lbr,代码行数:101,
示例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"); }}
开发者ID:e2rezaei,项目名称:set-Tx,代码行数:101,
示例15: rpl_process_dio/*---------------------------------------------------------------------------*/voidrpl_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 (");//.........这里部分代码省略.........
开发者ID:Johnyren,项目名称:orpl,代码行数:101,
示例16: tcpip_ipv6_output//.........这里部分代码省略......... PRINTF("FALLBACK: removing ext hdrs & setting proto %d %d/n", uip_ext_len, *((uint8_t *)UIP_IP_BUF + 40)); if(uip_ext_len > 0) { extern void remove_ext_hdr(void); uint8_t proto = *((uint8_t *)UIP_IP_BUF + 40); remove_ext_hdr(); /* This should be copied from the ext header... */ UIP_IP_BUF->proto = proto; } UIP_FALLBACK_INTERFACE.output();#else PRINTF("tcpip_ipv6_output: Destination off-link but no route/n");#endif /* !UIP_FALLBACK_INTERFACE */ uip_clear_buf(); return; } } else { /* A route was found, so we look up the nexthop neighbor for the route. */ nexthop = uip_ds6_route_nexthop(route); /* If the nexthop is dead, for example because the neighbor never responded to link-layer acks, we drop its route. */ if(nexthop == NULL) {#if UIP_CONF_IPV6_RPL /* If we are running RPL, and if we are the root of the network, we'll trigger a DIO before we remove the route. */ rpl_dag_t *dag; dag = (rpl_dag_t *)route->state.dag; if(dag != NULL) { rpl_reset_dio_timer(dag->instance); }#endif /* UIP_CONF_IPV6_RPL */ uip_ds6_route_rm(route); /* We don't have a nexthop to send the packet to, so we drop it. */ return; } }#if TCPIP_CONF_ANNOTATE_TRANSMISSIONS if(nexthop != NULL) { static uint8_t annotate_last; static uint8_t annotate_has_last = 0; if(annotate_has_last) { printf("#L %u 0; red/n", annotate_last); } printf("#L %u 1; red/n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]); annotate_last = nexthop->u8[sizeof(uip_ipaddr_t) - 1]; annotate_has_last = 1; }#endif /* TCPIP_CONF_ANNOTATE_TRANSMISSIONS */ } /* End of next hop determination */#if UIP_CONF_IPV6_RPL if(rpl_update_header_final(nexthop)) { uip_clear_buf(); return; }#endif /* UIP_CONF_IPV6_RPL */
开发者ID:adutze,项目名称:6lbr,代码行数:67,
示例17: rpl_process_dio/*---------------------------------------------------------------------------*/voidrpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio){ rpl_instance_t *instance; rpl_dag_t *dag, *previous_dag; rpl_parent_t *p; anycast_update_neighbor_edc(packetbuf_addr(PACKETBUF_ADDR_SENDER), dio->rank); 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 { 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(dio->rank == INFINITE_RANK) { PRINTF("RPL: Ignoring DIO from node with infinite rank: "); 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);//.........这里部分代码省略.........
开发者ID:Johnyren,项目名称:orpl,代码行数:101,
示例18: rpl_process_dio/*---------------------------------------------------------------------------*/voidrpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio, int mobility){ rpl_instance_t *instance; rpl_dag_t *dag, *previous_dag; rpl_parent_t *p, *previous_preferred; uint32_t current_t; PRINTF("processing DIO from %u/n", from->u8[15]); 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); previous_preferred = dag->preferred_parent; 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(instance->current_dag->rank == ROOT_RANK(instance) && instance->current_dag != dag) { PRINTF("RPL: Root ignored DIO for different DAG/n"); 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++; } 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);//.........这里部分代码省略.........
开发者ID:jiangxianliang,项目名称:smart-HOP,代码行数:101,
示例19: join_dagstatic voidjoin_dag(uip_ipaddr_t *from, rpl_dio_t *dio){ rpl_dag_t *dag; rpl_parent_t *p; rpl_of_t *of; dag = rpl_alloc_dag(dio->instance_id); if(dag == NULL) { PRINTF("RPL: Failed to allocate a DAG object!/n"); return; } p = rpl_add_parent(dag, dio, from); PRINTF("RPL: Adding "); PRINT6ADDR(from); PRINTF(" as a parent: "); if(p == NULL) { PRINTF("failed/n"); return; } PRINTF("succeeded/n"); /* 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 %u does not specify a supported OF/n", dio->instance_id); return; } /* Autoconfigure an address if this node does not already have an address with this prefix. */ if((dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) { uip_ipaddr_t ipaddr; /* assume that the prefix ends with zeros! */ memcpy(&ipaddr, &dio->prefix_info.prefix, 16); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); if(uip_ds6_addr_lookup(&ipaddr) == NULL) { PRINTF("RPL: adding global IP address "); PRINT6ADDR(&ipaddr); PRINTF("/n"); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); } } dag->joined = 1; dag->used = 1; dag->of = of; dag->grounded = dio->grounded; dag->mop = dio->mop; dag->preference = dio->preference; dag->instance_id = dio->instance_id; dag->max_rankinc = dio->dag_max_rankinc; dag->min_hoprankinc = dio->dag_min_hoprankinc; dag->version = dio->version; dag->preferred_parent = p; dag->of->update_metric_container(dag); dag->dio_intdoubl = dio->dag_intdoubl; dag->dio_intmin = dio->dag_intmin; dag->dio_redundancy = dio->dag_redund; memcpy(&dag->dag_id, &dio->dag_id, sizeof(dio->dag_id)); /* copy prefix information into the dag */ memcpy(&dag->prefix_info, &dio->prefix_info, sizeof(rpl_prefix_t)); dag->rank = dag->of->calculate_rank(p, dio->rank); dag->min_rank = dag->rank; /* So far this is the lowest rank we know of. */ 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]); dag->default_lifetime = dio->default_lifetime; dag->lifetime_unit = dio->lifetime_unit; rpl_reset_dio_timer(dag, 1); rpl_set_default_route(dag, from); if(should_send_dao(dag, dio, p)) { rpl_schedule_dao(dag); } else { PRINTF("RPL: The DIO does not meet the prerequisites for sending a DAO/n"); }}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:94,
示例20: rpl_verify_headerintrpl_verify_header(int uip_ext_opt_offset){ rpl_instance_t *instance; int down; uint8_t sender_closer; uip_ds6_route_t *route; 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); /* If we are the root and just needed to remove a DAO route, chances are that the network needs to be repaired. The rpl_repair_root() function will cause a global repair if we happen to be the root node of the dag. */ PRINTF("RPL: initiate global repair/n"); rpl_repair_root(instance->instance_id); } /* Remove the forwarding error flag and return 0 to let the packet be forwarded again. */ UIP_EXT_HDR_OPT_RPL_BUF->flags &= ~RPL_HDR_OPT_FWD_ERR; return 0; } 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_closer = UIP_EXT_HDR_OPT_RPL_BUF->senderrank < instance->current_dag->rank; PRINTF("RPL: Packet going %s, sender closer %d (%d < %d)/n", down == 1 ? "down" : "up", sender_closer, UIP_EXT_HDR_OPT_RPL_BUF->senderrank, instance->current_dag->rank ); if((down && !sender_closer) || (!down && sender_closer)) { PRINTF("RPL: Loop detected - senderrank: %d my-rank: %d sender_closer: %d/n", UIP_EXT_HDR_OPT_RPL_BUF->senderrank, instance->current_dag->rank, sender_closer); if(UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_RANK_ERR) { PRINTF("RPL: Rank error signalled in RPL option!/n"); /* We should try to repair it, not implemented for the moment */ rpl_reset_dio_timer(instance); /* Forward the packet anyway. */ return 0; } PRINTF("RPL: Single error tolerated/n"); UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_RANK_ERR; return 0; } PRINTF("RPL: Rank OK/n"); return 0;}
开发者ID:Adimpression,项目名称:contiki,代码行数:82,
示例21: rpl_process_diovoidrpl_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. *///.........这里部分代码省略.........
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:101,
注:本文中的rpl_reset_dio_timer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ rpl_schedule_dao函数代码示例 C++ rpl_remove_parent函数代码示例 |