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

C++ ROOT_RANK函数代码示例

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

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



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

示例1: update_metric_container

static void
update_metric_container(rpl_instance_t *instance)
{
  rpl_path_metric_t path_metric;
  rpl_dag_t *dag;
#if RPL_DAG_MC == RPL_DAG_MC_ENERGY
  uint8_t type;
#endif

  instance->mc.flags = RPL_DAG_MC_FLAG_P;
  instance->mc.aggr = RPL_DAG_MC_AGGR_ADDITIVE;
  instance->mc.prec = 0;

  dag = instance->current_dag;

  if (!dag->joined) {
    /* We should probably do something here */
    return;
  }

  if(dag->rank == ROOT_RANK(instance)) {
    path_metric = 0;
  } else {
    path_metric = calculate_path_metric(dag->preferred_parent);
  }

#if RPL_DAG_MC == RPL_DAG_MC_ETX

  instance->mc.type = RPL_DAG_MC_ETX;
  instance->mc.length = sizeof(instance->mc.obj.etx);
  instance->mc.obj.etx = path_metric;

  PRINTF("RPL: My path ETX to the root is %u.%u\n",
	instance->mc.obj.etx / RPL_DAG_MC_ETX_DIVISOR,
	(instance->mc.obj.etx % RPL_DAG_MC_ETX_DIVISOR * 100) / RPL_DAG_MC_ETX_DIVISOR);

#elif RPL_DAG_MC == RPL_DAG_MC_ENERGY

  instance->mc.type = RPL_DAG_MC_ENERGY;
  instance->mc.length = sizeof(instance->mc.obj.energy);

  if(dag->rank == ROOT_RANK(instance)) {
    type = RPL_DAG_MC_ENERGY_TYPE_MAINS;
  } else {
    type = RPL_DAG_MC_ENERGY_TYPE_BATTERY;
  }

  instance->mc.obj.energy.flags = type << RPL_DAG_MC_ENERGY_TYPE;
  instance->mc.obj.energy.energy_est = path_metric;

#else

#error "Unsupported RPL_DAG_MC configured. See rpl.h."

#endif /* RPL_DAG_MC */
}
开发者ID:szehl,项目名称:contiki-zigbit-rpl-border-router,代码行数:56,代码来源:rpl-of-etx.c


示例2: update_metric_container

static void
update_metric_container(rpl_instance_t *instance)
{
  rpl_path_metric_t path_metric;
  rpl_dag_t *dag;
#if RPL_DAG_MC == RPL_DAG_MC_ENERGY
  uint8_t type;
#endif

  instance->mc.type = RPL_DAG_MC;
  instance->mc.flags = RPL_DAG_MC_FLAG_P;
  instance->mc.aggr = RPL_DAG_MC_AGGR_ADDITIVE;
  instance->mc.prec = 0;

  dag = instance->current_dag;

  if (!dag->joined) {
    PRINTF("RPL: Cannot update the metric container when not joined\n");
    return;
  }

  if(dag->rank == ROOT_RANK(instance)) {
    path_metric = 0;
  } else {
    path_metric = calculate_path_metric(dag->preferred_parent);
  }

#if RPL_DAG_MC == RPL_DAG_MC_ETX
  instance->mc.length = sizeof(instance->mc.obj.etx);
  instance->mc.obj.etx = path_metric;

  PRINTF("RPL: My path ETX to the root is %u.%u\n",
	instance->mc.obj.etx / RPL_DAG_MC_ETX_DIVISOR,
	(instance->mc.obj.etx % RPL_DAG_MC_ETX_DIVISOR * 100) /
	 RPL_DAG_MC_ETX_DIVISOR);
#elif RPL_DAG_MC == RPL_DAG_MC_ENERGY
  instance->mc.length = sizeof(instance->mc.obj.energy);
  if(dag->rank == ROOT_RANK(instance)) {
    type = RPL_DAG_MC_ENERGY_TYPE_MAINS;
  } else {
    type = RPL_DAG_MC_ENERGY_TYPE_BATTERY;
  }

  instance->mc.obj.energy.flags = type << RPL_DAG_MC_ENERGY_TYPE;
  instance->mc.obj.energy.energy_est = path_metric;
#elif RPL_DAG_MC == RPL_DAG_MC_TOTALENERGY
  instance->mc.length = sizeof(instance->mc.obj.total_energy);
  instance->mc.obj.total_energy = path_metric;
  // printf("total_energy path_metric:%u\n", path_metric);

#endif /* RPL_DAG_MC == RPL_DAG_MC_ETX */
}
开发者ID:zhuzhudaxia,项目名称:contiki-2.7,代码行数:52,代码来源:rpl-mrhof.c


示例3: update_metric_container

static void
update_metric_container(rpl_dag_t *dag)
{
  rpl_path_metric_t path_metric;
#if RPL_DAG_MC == RPL_DAG_MC_ENERGY
  uint8_t type;
#endif

  dag->mc.flags = RPL_DAG_MC_FLAG_P;
  dag->mc.aggr = RPL_DAG_MC_AGGR_ADDITIVE;
  dag->mc.prec = 0;

  if(dag->rank == ROOT_RANK(dag)) {
    path_metric = 0;
  } else {
    path_metric = calculate_path_metric(dag->preferred_parent);
  }

#if RPL_DAG_MC == RPL_DAG_MC_ETX

  dag->mc.type = RPL_DAG_MC_ETX;
  dag->mc.length = sizeof(dag->mc.obj.etx);
  dag->mc.obj.etx = path_metric;

  PRINTF("RPL: My path ETX to the root is %u.%u\n",
	dag->mc.obj.etx / RPL_DAG_MC_ETX_DIVISOR,
	(dag->mc.obj.etx % RPL_DAG_MC_ETX_DIVISOR * 100) / RPL_DAG_MC_ETX_DIVISOR);

#elif RPL_DAG_MC == RPL_DAG_MC_ENERGY

  dag->mc.type = RPL_DAG_MC_ENERGY;
  dag->mc.length = sizeof(dag->mc.obj.energy);

  if(dag->rank == ROOT_RANK(dag)) {
    type = RPL_DAG_MC_ENERGY_TYPE_MAINS;
  } else {
    type = RPL_DAG_MC_ENERGY_TYPE_BATTERY;
  }

  dag->mc.obj.energy.flags = type << RPL_DAG_MC_ENERGY_TYPE;
  dag->mc.obj.energy.energy_est = path_metric;

#else

#error "Unsupported RPL_DAG_MC configured. See rpl.h."

#endif /* RPL_DAG_MC */
}
开发者ID:Asterios,项目名称:contiki-econotag,代码行数:48,代码来源:rpl-of-etx.c


示例4: update_metric_container

/*---------------------------------------------------------------------------*/
#if !RPL_WITH_MC
static void
update_metric_container(rpl_instance_t *instance)
{
  instance->mc.type = RPL_DAG_MC_NONE;
}
#else /* RPL_WITH_MC */
static void
update_metric_container(rpl_instance_t *instance)
{
  rpl_dag_t *dag;
  uint16_t path_cost;
  uint8_t type;

  dag = instance->current_dag;
  if(dag == NULL || !dag->joined) {
    PRINTF("RPL: Cannot update the metric container when not joined\n");
    return;
  }

  if(dag->rank == ROOT_RANK(instance)) {
    /* Configure MC at root only, other nodes are auto-configured when joining */
    instance->mc.type = RPL_DAG_MC;
    instance->mc.flags = 0;
    instance->mc.aggr = RPL_DAG_MC_AGGR_ADDITIVE;
    instance->mc.prec = 0;
    path_cost = dag->rank;
  } else {
    path_cost = parent_path_cost(dag->preferred_parent);
  }

  /* Handle the different MC types */
  switch(instance->mc.type) {
    case RPL_DAG_MC_NONE:
      break;
    case RPL_DAG_MC_ETX:
      instance->mc.length = sizeof(instance->mc.obj.etx);
      instance->mc.obj.etx = path_cost;
      break;
    case RPL_DAG_MC_ENERGY:
      instance->mc.length = sizeof(instance->mc.obj.energy);
      if(dag->rank == ROOT_RANK(instance)) {
        type = RPL_DAG_MC_ENERGY_TYPE_MAINS;
      } else {
        type = RPL_DAG_MC_ENERGY_TYPE_BATTERY;
      }
      instance->mc.obj.energy.flags = type << RPL_DAG_MC_ENERGY_TYPE;
      /* Energy_est is only one byte, use the least significant byte of the path metric. */
      instance->mc.obj.energy.energy_est = path_cost >> 8;
      break;
    default:
      PRINTF("RPL: MRHOF, non-supported MC %u\n", instance->mc.type);
      break;
  }
}
开发者ID:1847123212,项目名称:contiki,代码行数:56,代码来源:rpl-mrhof.c


示例5: calculate_path_metric

static rpl_path_metric_t
calculate_path_metric(rpl_parent_t *p)
{
  if(p == NULL || (p->mc.obj.etx == 0 && p->rank > ROOT_RANK(p->dag))) {
    return MAX_PATH_COST * RPL_DAG_MC_ETX_DIVISOR;
  }
  return p->mc.obj.etx + NI_ETX_TO_RPL_ETX(p->link_metric);
}
开发者ID:Asterios,项目名称:contiki-econotag,代码行数:8,代码来源:rpl-of-etx.c


示例6: new_dio_interval

/*---------------------------------------------------------------------------*/
static void
new_dio_interval(rpl_instance_t *instance, int isReset)
{
  uint32_t time;
  clock_time_t ticks;

  /* TODO: too small timer intervals for many cases */
  time = 1UL << instance->dio_intcurrent;

  /* Convert from milliseconds to CLOCK_TICKS. */
  ticks = (time * CLOCK_SECOND) / 1000;
  instance->dio_next_delay = ticks;

  /* random number between I/2 and I */
  ticks = ticks / 2 + (ticks / 2 * (uint32_t)random_rand()) / RANDOM_RAND_MAX;

  /* opt trickle*/
  /*
  if (isReset == 1) {
    ticks * (uint32_t)random_rand() / RANDOM_RAND_MAX;  
  }
  else {
    ticks = ticks / 2 + (ticks / 2 * (uint32_t)random_rand()) / RANDOM_RAND_MAX;
  }
  */
  

  /*
   * The intervals must be equally long among the nodes for Trickle to
   * operate efficiently. Therefore we need to calculate the delay between
   * the randomized time and the start time of the next interval.
   */
  instance->dio_next_delay -= ticks;
  instance->dio_send = 1;

#if RPL_CONF_STATS
  /* keep some stats */
  instance->dio_totint++;
  instance->dio_totrecv += instance->dio_counter;
  ANNOTATE("#A rank=%u.%u(%u),stats=%d %d %d %d,color=%s\n",
	   DAG_RANK(instance->current_dag->rank, instance),
           (10 * (instance->current_dag->rank % instance->min_hoprankinc)) / instance->min_hoprankinc,
           instance->current_dag->version,
           instance->dio_totint, instance->dio_totsend,
           instance->dio_totrecv,instance->dio_intcurrent,
	   instance->current_dag->rank == ROOT_RANK(instance) ? "BLUE" : "ORANGE");
#endif /* RPL_CONF_STATS */

  /* reset the redundancy counter */
  instance->dio_counter = 0;

  /* schedule the timer */
  PRINTF("RPL: Scheduling DIO timer %lu ticks in future (Interval)\n", ticks);
  ctimer_set(&instance->dio_timer, ticks, &handle_dio_timer, instance);
}
开发者ID:ChandlerWu,项目名称:Contiki,代码行数:56,代码来源:rpl-timers.c


示例7: calculate_path_metric

static rpl_path_metric_t
calculate_path_metric(rpl_parent_t *p)
{
  if(p == NULL || (p->mc.obj.etx == 0 && p->rank > ROOT_RANK(p->dag->instance))) {
    return MAX_PATH_COST * RPL_DAG_MC_ETX_DIVISOR;
  } else {
    long etx = p->link_metric;
    etx = (etx * RPL_DAG_MC_ETX_DIVISOR) / NEIGHBOR_INFO_ETX_DIVISOR;
    return p->mc.obj.etx + (uint16_t) etx;
  }
}
开发者ID:szehl,项目名称:contiki-zigbit-rpl-border-router,代码行数:11,代码来源:rpl-of-etx.c


示例8: 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;
}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:54,代码来源:rpl-dag.c


示例9: 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;
}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:11,代码来源:rpl-dag.c


示例10: rpl_opp_routing_reset

void
rpl_opp_routing_reset(void)
{
  rpl_dag_t *dag;
  dag = rpl_get_any_dag();
  if(uip_ds6_is_my_addr(&dag->dag_id)) {
    we_are_root = 1;
    current_rank = ROOT_RANK(dag->instance);
  } else {
    current_rank = INFINITE_RANK;
  }
}
开发者ID:mlwymore,项目名称:contiki,代码行数:12,代码来源:rpl-opp-routing.c


示例11: rpl_purge_routes

/*---------------------------------------------------------------------------*/
void
rpl_purge_routes(void)
{
  uip_ds6_route_t *r;
  uip_ipaddr_t prefix;
  rpl_dag_t *dag;
  rpl_instance_t *instance; //changed

  /* First pass, decrement lifetime */
  r = uip_ds6_route_head();

  while(r != NULL) {
    if(r->state.lifetime >= 1) {
      /*
       * If a route is at lifetime == 1, set it to 0, scheduling it for
       * immediate removal below. This achieves the same as the original code,
       * which would delete lifetime <= 1
       */
      r->state.lifetime--;
    }
    r = uip_ds6_route_next(r);
  }

  /* Second pass, remove dead routes */
  r = uip_ds6_route_head();

  while(r != NULL) {
    /*Pre-change handle second_instance*/
    if(r->state.lifetime < 1) {
      /* Routes with lifetime == 1 have only just been decremented from 2 to 1,
       * thus we want to keep them. Hence < and not <= */
      uip_ipaddr_copy(&prefix, &r->ipaddr);
      uip_ds6_route_rm(r);
      r = uip_ds6_route_head();
      PRINTF("No more routes to ");
      PRINT6ADDR(&prefix);
      /*Changed*/
      instance = rpl_get_instance(r->state.instance_id);
      dag = instance->current_dag;
      //dag1 = second_instance->current_dag;
      /* Propagate this information with a No-Path DAO to preferred parent if we are not a RPL Root */
      if(dag->rank != ROOT_RANK(instance)) {
        PRINTF(" -> generate No-Path DAO\n");
        dao_output_target(dag->preferred_parent, &prefix, RPL_ZERO_LIFETIME);
        /* Don't schedule more than 1 No-Path DAO, let next iteration handle that */
        return;
      }
      PRINTF("\n");
    } else {
      r = uip_ds6_route_next(r);
    }
  }
}
开发者ID:NPHiep,项目名称:contiki_limited_edittion,代码行数:54,代码来源:rpl.c


示例12: rpl_opp_routing_init

void
rpl_opp_routing_init(void)
{
  nbr_table_register(forwarder_set, NULL);
  memb_init(&forwarder_set_memb);
  rpl_dag_t *dag;
  dag = rpl_get_any_dag();
  if(uip_ds6_is_my_addr(&dag->dag_id)) {
    we_are_root = 1;
    current_rank = ROOT_RANK(dag->instance);
  } else {
    process_start(&rpl_forwarder_set_update_process, NULL);
  }
}
开发者ID:mlwymore,项目名称:contiki,代码行数:14,代码来源:rpl-opp-routing.c


示例13: 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;
}
开发者ID:denghongcai,项目名称:6lbr,代码行数:17,代码来源:rpl-dag.c


示例14: update_metric_container

static void
update_metric_container(rpl_dag_t *dag)
{
  dag->mc.type = RPL_DAG_MC_ETX;
  dag->mc.flags = RPL_DAG_MC_FLAG_P;
  dag->mc.aggr = RPL_DAG_MC_AGGR_ADDITIVE;
  dag->mc.prec = 0;
  dag->mc.length = sizeof(dag->mc.etx.etx);
  if(dag->rank == ROOT_RANK(dag)) {
    dag->mc.etx.etx = 0;
  } else {
    dag->mc.etx.etx = calculate_etx(dag->preferred_parent);
  }

  PRINTF("RPL: My path ETX to the root is %u.%u\n",
	dag->mc.etx.etx / RPL_DAG_MC_ETX_DIVISOR,
	(dag->mc.etx.etx % RPL_DAG_MC_ETX_DIVISOR * 100) / RPL_DAG_MC_ETX_DIVISOR);
}
开发者ID:Asterios,项目名称:contiki-tls-dtls,代码行数:18,代码来源:rpl-of-etx.c


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


示例16: rpl_dag_root_is_root

/*---------------------------------------------------------------------------*/
int
rpl_dag_root_is_root(void)
{
  rpl_instance_t *instance;

  instance = rpl_get_default_instance();

  if(instance == NULL) {
    return 0;
  }

  if(instance->current_dag &&
     instance->current_dag->rank == ROOT_RANK(instance)) {
    return 1;
  }

  return 0;
}
开发者ID:0009281,项目名称:contiki,代码行数:19,代码来源:rpl-dag-root.c


示例17: tsch_rpl_callback_new_dio_interval

/* Set TSCH EB period based on current RPL DIO period.
 * To use, set #define RPL_CALLBACK_PARENT_SWITCH tsch_rpl_callback_new_dio_interval */
void
tsch_rpl_callback_new_dio_interval(uint8_t dio_interval)
{
  /* Transmit EBs only if we have a valid rank as per 6TiSCH minimal */
  rpl_dag_t *dag = rpl_get_any_dag();
  if(dag != NULL && dag->rank != INFINITE_RANK) {
    /* If we are root set TSCH as coordinator */
    if(dag->rank == ROOT_RANK(dag->instance)) {
      tsch_set_coordinator(1);
    }
    /* Set EB period */
    tsch_set_eb_period(TSCH_EB_PERIOD);
    /* Set join priority based on RPL rank */
    tsch_set_join_priority(DAG_RANK(dag->rank, dag->instance) - 1);
  } else {
    tsch_set_eb_period(0);
  }
}
开发者ID:13416795,项目名称:contiki,代码行数:20,代码来源:tsch-rpl.c


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


示例19: 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 (");
//.........这里部分代码省略.........
开发者ID:Johnyren,项目名称:orpl,代码行数:101,代码来源:rpl-dag.c


示例20: 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;

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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