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

C++ rpl_remove_parent函数代码示例

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

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



在下文中一共展示了rpl_remove_parent函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: remove_parents

/* Remove DAG parents with a rank that is at least the same as minimum_rank. */
static void
remove_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
{
  rpl_parent_t *p, *p2;

  PRINTF("RPL: Removing parents (minimum rank %u)\n",
	minimum_rank);

  for(p = list_head(dag->parents); p != NULL; p = p2) {
    p2 = p->next;
    if(p->rank >= minimum_rank) {
      rpl_remove_parent(dag, p);
    }
  }
}
开发者ID:sanyaade-teachings,项目名称:contiki-2.x,代码行数:16,代码来源:rpl-dag.c


示例2: remove_parents

/* Remove DAG parents with a rank that is at least the same as minimum_rank. */
static void
remove_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
{
  rpl_parent_t *p;

  PRINTF("RPL: Removing parents (minimum rank %u)\n", minimum_rank);

  p = nbr_table_head(rpl_parents);
  while(p != NULL) {
    if(dag == p->dag && p->rank >= minimum_rank) {
      rpl_remove_parent(p);
    }
    p = nbr_table_next(rpl_parents, p);
  }
}
开发者ID:jiangxianliang,项目名称:smart-HOP,代码行数:16,代码来源:rpl-dag.c


示例3: remove_parents

/* Remove DAG parents with a rank that is at least the same as minimum_rank. */
static void
remove_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
{
  rpl_parent_t *p, *p2;

  PRINTF("RPL: Removing parents (minimum rank %u)\n",
	minimum_rank);

  for(p = list_head(dag->parents); p != NULL; p = p2) {
    p2 = p->next;
    if(p->rank >= minimum_rank) {
      rpl_remove_parent(dag, p);
      ANNOTATE("#L %u 0\n", p->addr.u8[sizeof(uip_ipaddr_t) - 1]);
    }
  }
}
开发者ID:Johnyren,项目名称:orpl,代码行数:17,代码来源:rpl-dag.c


示例4: remove_worst_parent

/*---------------------------------------------------------------------------*/
static void
remove_worst_parent(rpl_dag_t *dag, rpl_rank_t min_worst_rank)
{
  rpl_parent_t *p, *worst;

  PRINTF("RPL: Removing the worst parent\n");

  /* Find the parent with the highest rank. */
  worst = NULL;
  for(p = list_head(dag->parents); p != NULL; p = list_item_next(p)) {
    if(p != dag->preferred_parent &&
       (worst == NULL || p->rank > worst->rank)) {
      worst = p;
    }
  }
  /* Remove the neighbor if its rank is worse than the minimum worst rank. */
  if(worst != NULL && worst->rank > min_worst_rank) {
    rpl_remove_parent(dag, worst);
  }
}
开发者ID:denghongcai,项目名称:6lbr,代码行数:21,代码来源:rpl-dag.c


示例5: rpl_join_instance

/*---------------------------------------------------------------------------*/
void
rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio)
{
  rpl_instance_t *instance;
  rpl_dag_t *dag;
  rpl_parent_t *p;
  rpl_of_t *of;
int tx;//elnaz

  dag = rpl_alloc_dag(dio->instance_id, &dio->dag_id);
  if(dag == NULL) {
//    PRINTF("RPL: Failed to allocate a DAG object!\n");
    return;
  }

  instance = dag->instance;

  p = rpl_add_parent(dag, dio, from);
//  PRINTF("RPL: Adding ");
//  PRINT6ADDR(from);
//  PRINTF(" as a parent: ");
  if(p == NULL) {
//    PRINTF("failed\n");
    instance->used = 0;
    return;
  }
  p->dtsn = dio->dtsn;
//  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);
    rpl_remove_parent(p);
    instance->used = 0;
    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) {
    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;
//.........这里部分代码省略.........
开发者ID:e2rezaei,项目名称:set-Tx,代码行数:101,代码来源:rpl-dag.c


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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rpl_reset_dio_timer函数代码示例发布时间:2022-05-30
下一篇:
C++ rpl_process_parent_event函数代码示例发布时间: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