llsec: Fixed style issues in CCM*

This commit is contained in:
Konrad Krentz 2015-07-01 07:00:14 -07:00 committed by kkrentz
parent b522c042ec
commit c656a4d1c5
7 changed files with 174 additions and 96 deletions

View file

@ -80,24 +80,6 @@
static uint8_t key[16] = NONCORESEC_KEY;
NBR_TABLE(struct anti_replay_info, anti_replay_table);
/*---------------------------------------------------------------------------*/
static const uint8_t *
get_extended_address(const linkaddr_t *addr)
#if LINKADDR_SIZE == 2
{
/* workaround for short addresses: derive EUI64 as in RFC 6282 */
static linkaddr_extended_t template = { { 0x00 , 0x00 , 0x00 ,
0xFF , 0xFE , 0x00 , 0x00 , 0x00 } };
template.u16[3] = LLSEC802154_HTONS(addr->u16);
return template.u8;
}
#else /* LINKADDR_SIZE == 2 */
{
return addr->u8;
}
#endif /* LINKADDR_SIZE == 2 */
/*---------------------------------------------------------------------------*/
static void
send(mac_callback_t sent, void *ptr)
@ -113,7 +95,7 @@ create(void)
{
int result;
uint8_t *dataptr;
uint8_t data_len;
uint8_t datalen;
result = framer_802154.create();
if(result == FRAMER_FAILED) {
@ -121,13 +103,13 @@ create(void)
}
dataptr = packetbuf_dataptr();
data_len = packetbuf_datalen();
ccm_star_mic_packetbuf(get_extended_address(&linkaddr_node_addr), dataptr + data_len, LLSEC802154_MIC_LENGTH);
datalen = packetbuf_datalen();
ccm_star_packetbuf_mic(&linkaddr_node_addr, dataptr + datalen, LLSEC802154_MIC_LENGTH);
#if WITH_ENCRYPTION
ccm_star_ctr_packetbuf(get_extended_address(&linkaddr_node_addr));
ccm_star_packetbuf_ctr(&linkaddr_node_addr);
#endif /* WITH_ENCRYPTION */
packetbuf_set_datalen(data_len + LLSEC802154_MIC_LENGTH);
packetbuf_set_datalen(datalen + LLSEC802154_MIC_LENGTH);
return result;
}
@ -159,9 +141,9 @@ input(void)
packetbuf_set_datalen(packetbuf_datalen() - LLSEC802154_MIC_LENGTH);
#if WITH_ENCRYPTION
ccm_star_ctr_packetbuf(get_extended_address(sender));
ccm_star_packetbuf_ctr(sender);
#endif /* WITH_ENCRYPTION */
ccm_star_mic_packetbuf(get_extended_address(sender), generated_mic, LLSEC802154_MIC_LENGTH);
ccm_star_packetbuf_mic(sender, generated_mic, LLSEC802154_MIC_LENGTH);
received_mic = ((uint8_t *) packetbuf_dataptr()) + packetbuf_datalen();
if(memcmp(generated_mic, received_mic, LLSEC802154_MIC_LENGTH) != 0) {