Ejemplo n.º 1
0
/*---------------------------------------------------------------------------*/
static void
send(mac_callback_t sent, void *ptr)
{
  struct akes_nbr_entry *entry;

  packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_DATAFRAME);
  if(packetbuf_holds_broadcast()) {
    if(!akes_nbr_count(AKES_NBR_PERMANENT)) {
      mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 0);
      return;
    }
    adaptivesec_add_security_header(NULL);
  } else {
    entry = akes_nbr_get_receiver_entry();
    if(!entry || !entry->permanent) {
      mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 0);
      return;
    }
    adaptivesec_add_security_header(&entry->permanent->anti_replay_info);
#if ANTI_REPLAY_WITH_SUPPRESSION
    packetbuf_set_attr(PACKETBUF_ATTR_NEIGHBOR_INDEX, entry->local_index);
#endif /* ANTI_REPLAY_WITH_SUPPRESSION */
  }
#if !ANTI_REPLAY_WITH_SUPPRESSION && !POTR_ENABLED
  framer_802154_set_seqno();
#endif /* ANTI_REPLAY_WITH_SUPPRESSION && !POTR_ENABLED */
  ADAPTIVESEC_STRATEGY.send(sent, ptr);
}
Ejemplo n.º 2
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.º 3
0
/*---------------------------------------------------------------------------*/
static int
get_reset_threshold(void)
{
    return MAX(akes_nbr_count(AKES_NBR_PERMANENT) / 4, 1);
}