Ejemplo n.º 1
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(delete_process, ev, data)
{
  static struct etimer update_check_timer;
  static struct etimer update_send_timer;
  static struct akes_nbr_entry *next;

  PROCESS_BEGIN();

  PRINTF("akes-delete: Started update_process\n");
  etimer_set(&update_check_timer, UPDATE_CHECK_INTERVAL * CLOCK_SECOND);

  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&update_check_timer));
    PRINTF("akes-delete: #permanent = %d\n", akes_nbr_count(AKES_NBR_PERMANENT));
    next = akes_nbr_head();
    while(next) {
      if(!next->permanent || !akes_nbr_is_expired(next, AKES_NBR_PERMANENT)) {
        next = akes_nbr_next(next);
        continue;
      }

      /* wait for a random period of time to avoid collisions */
      etimer_set(&update_send_timer, akes_get_random_waiting_period());
      PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&update_send_timer));

      /* check if something happened in the meantime */
      if(!akes_nbr_is_expired(next, AKES_NBR_PERMANENT)) {
        next = akes_nbr_next(next);
        continue;
      }

      /* send UPDATE */
      akes_send_update(next);
      PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
      PRINTF("akes-delete: Sent UPDATE\n");
      etimer_set(&update_send_timer, UPDATEACK_WAITING_PERIOD * CLOCK_SECOND);
      PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&update_send_timer));
      if(akes_nbr_is_expired(next, AKES_NBR_PERMANENT)) {
        akes_nbr_delete(next, AKES_NBR_PERMANENT);
        next = akes_nbr_head();
      } else {
        next = akes_nbr_next(next);
      }
    }
    etimer_restart(&update_check_timer);
  }

  PROCESS_END();
}
Ejemplo n.º 2
0
/**
 * Payload format:
 * | 0x0d | 0x00 | CCM*-MIC for neighbor 0 | ... | CCM*-MIC for last neighbor |
 */
static void
prepare_announce(void)
{
  struct akes_nbr_entry *next;
  uint8_t announced_mics[NBR_TABLE_MAX_NEIGHBORS * ADAPTIVESEC_BROADCAST_MIC_LEN];
  uint8_t *payload;
  uint8_t announced_mics_len;
  uint8_t max_index;

  max_index = 0;
  next = akes_nbr_head();
  while(next) {
    if(next->permanent) {
      adaptivesec_aead(next->permanent->pairwise_key,
          0,
          announced_mics + (next->local_index * ADAPTIVESEC_BROADCAST_MIC_LEN),
          1);
      if(next->local_index > max_index) {
        max_index = next->local_index;
      }
    }
    next = akes_nbr_next(next);
  }

  /* reset packetbuf for sending a command frame */
  payload = adaptivesec_prepare_command(CORESEC_STRATEGY_ANNOUNCE_IDENTIFIER, &linkaddr_null);

  /* write payload */
  /* TODO We currently assume that all MICs fit within a single ANNOUNCE command */
  payload[0] = 0;
  announced_mics_len = (max_index + 1) * ADAPTIVESEC_BROADCAST_MIC_LEN;
  memcpy(payload + 1, announced_mics, announced_mics_len);
  packetbuf_set_datalen(1 + 1 + announced_mics_len);
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------*/
void
reset_trickle_info(void)
{
    struct akes_nbr_entry *next;

    next = akes_nbr_head();
    while(next) {
        if(next->permanent) {
            next->permanent->sent_authentic_hello = 0;
        }
        next = akes_nbr_next(next);
    }
}