本文整理汇总了C++中RPL_STAT函数的典型用法代码示例。如果您正苦于以下问题:C++ RPL_STAT函数的具体用法?C++ RPL_STAT怎么用?C++ RPL_STAT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RPL_STAT函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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++);
}
示例3: 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++);
}
示例4: rpl_add_parent
/*---------------------------------------------------------------------------*/
rpl_parent_t *
rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
{
rpl_parent_t *p;
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS_PER_DAG) {
return NULL;
}
p = memb_alloc(&parent_memb);
if(p == NULL) {
RPL_STAT(rpl_stats.mem_overflows++);
return NULL;
}
memcpy(&p->addr, addr, sizeof(p->addr));
p->dag = dag;
p->rank = dio->rank;
p->dtsn = dio->dtsn;
p->link_metric = RPL_INIT_LINK_METRIC;
#if RPL_DAG_MC != RPL_DAG_MC_NONE
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
#endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
list_add(dag->parents, p);
return p;
}
示例5: 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;
}
示例6: 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++);
}
示例7: 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++);
}
示例8: 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_STAT(rpl_stats.root_repairs++);
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;
}
示例9: rpl_add_parent
rpl_parent_t *
rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
{
rpl_parent_t *p;
p = memb_alloc(&parent_memb);
if(p == NULL) {
RPL_STAT(rpl_stats.mem_overflows++);
return NULL;
}
memcpy(&p->addr, addr, sizeof(p->addr));
p->dag = dag;
p->rank = dio->rank;
p->etx = INITIAL_ETX;
p->dtsn = 0;
list_add(dag->parents, p);
return p;
}
示例10: rpl_alloc_dag
rpl_dag_t *
rpl_alloc_dag(uint8_t instance_id)
{
rpl_dag_t *dag;
rpl_dag_t *end;
for(dag = &dag_table[0], end = dag + RPL_MAX_DAG_ENTRIES; dag < end; dag++) {
if(dag->used == 0) {
memset(dag, 0, sizeof(*dag));
dag->parents = &dag->parent_list;
list_init(dag->parents);
dag->instance_id = instance_id;
dag->def_route = NULL;
dag->rank = INFINITE_RANK;
dag->min_rank = INFINITE_RANK;
return dag;
}
}
RPL_STAT(rpl_stats.mem_overflows++);
return NULL;
}
示例11: rpl_add_parent
/*---------------------------------------------------------------------------*/
rpl_parent_t *
rpl_add_parent(rpl_dag_t *dag, rpl_dio_t *dio, uip_ipaddr_t *addr)
{
rpl_parent_t *p;
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS_PER_DAG) {
return NULL;
}
p = memb_alloc(&parent_memb);
if(p == NULL) {
RPL_STAT(rpl_stats.mem_overflows++);
return NULL;
}
memcpy(&p->addr, addr, sizeof(p->addr));
p->dag = dag;
p->rank = dio->rank;
p->dtsn = dio->dtsn;
p->link_metric = INITIAL_LINK_METRIC;
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
list_add(dag->parents, p);
ANNOTATE("#L %u 1\n", p->addr.u8[sizeof(uip_ipaddr_t) - 1]);
return p;
}
示例12: 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;
}
//.........这里部分代码省略.........