示例#1
0
/*---------------------------------------------------------------------------*/
rpl_dag_t *
rpl_alloc_dag(uint8_t instance_id, uip_ipaddr_t *dag_id)
{
  rpl_dag_t *dag, *end;
  rpl_instance_t *instance;

  instance = rpl_get_instance(instance_id);
  if(instance == NULL) {
    instance = rpl_alloc_instance(instance_id);
    if(instance == NULL) {
      RPL_STAT(rpl_stats.mem_overflows++);
      return NULL;
    }
  }

  for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DAG_PER_INSTANCE; dag < end; ++dag) {
    if(!dag->used) {
      memset(dag, 0, sizeof(*dag));
      dag->used = 1;
      dag->rank = INFINITE_RANK;
      dag->min_rank = INFINITE_RANK;
      dag->instance = instance;
      return dag;
    }
  }

  RPL_STAT(rpl_stats.mem_overflows++);
  rpl_free_instance(instance);
  return NULL;
}
示例#2
0
void
cetic_6lbr_end_dodag_root(rpl_instance_t *instance)
{
  if(is_dodag_root()) {
    LOG6LBR_INFO("Leaving DODAG root\n");
    rpl_local_repair(instance);
    dio_output(instance, NULL);
    rpl_free_dag(instance->current_dag);
    rpl_free_instance(instance);
    if(!rpl_fast_startup) {
      //Restart DODAG creation check
      ctimer_set(&create_dodag_root_timer, CLOCK_SECOND, check_dodag_creation, NULL);
    }
  }
}