• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ rpl_set_default_route函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rpl_set_default_route函数的典型用法代码示例。如果您正苦于以下问题:C++ rpl_set_default_route函数的具体用法?C++ rpl_set_default_route怎么用?C++ rpl_set_default_route使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rpl_set_default_route函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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++);
}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:26,代码来源:rpl-dag.c


示例2: 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;
}
开发者ID:CaptFrank,项目名称:contiki-stm32w,代码行数:57,代码来源:rpl-dag.c


示例3: rpl_free_dag

void
rpl_free_dag(rpl_dag_t *dag)
{
  PRINTF("RPL: Leaving the DAG ");
  PRINT6ADDR(&dag->dag_id);
  PRINTF("\n");

  /* Remove routes installed by DAOs. */
  rpl_remove_routes(dag);

  /* Remove parents and the default route. */
  remove_parents(dag, 0);
  rpl_set_default_route(dag, NULL);

  ctimer_stop(&dag->dio_timer);
  ctimer_stop(&dag->dao_timer);

  dag->used = 0;
  dag->joined = 0;
}
开发者ID:C3MA,项目名称:hexabus,代码行数:20,代码来源:rpl-dag.c


示例4: 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;
}
开发者ID:Asterios,项目名称:contiki-tls-dtls,代码行数:41,代码来源:rpl-dag.c


示例5: join_dag

static void
join_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,代码来源:rpl-dag.c


示例6: 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,代码来源:rpl-dag.c


示例7: 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;
}
开发者ID:jiangxianliang,项目名称:smart-HOP,代码行数:101,代码来源:rpl-dag.c



注:本文中的rpl_set_default_route函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rpl_set_prefix函数代码示例发布时间:2022-05-30
下一篇:
C++ rpl_schedule_dao函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap