X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fkernel%2Fao_radio_cmac.c;h=155fce350b69f77c464d5fefe747ede3c6478b14;hp=bff848f6d249fd797bfd02198619e5f366fe68e8;hb=015d3055a52532070e96469907683c3aa3eda44e;hpb=24167015705ae831692b95735968b04a876f935e diff --git a/src/kernel/ao_radio_cmac.c b/src/kernel/ao_radio_cmac.c index bff848f6..155fce35 100644 --- a/src/kernel/ao_radio_cmac.c +++ b/src/kernel/ao_radio_cmac.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,9 +19,9 @@ #include #include -static __xdata uint8_t ao_radio_cmac_mutex; -__pdata int8_t ao_radio_cmac_rssi; -static __xdata uint8_t cmac_data[AO_CMAC_MAX_LEN + AO_CMAC_KEY_LEN + 2 + AO_CMAC_KEY_LEN]; +static uint8_t ao_radio_cmac_mutex; +int8_t ao_radio_cmac_rssi; +static uint8_t cmac_data[AO_CMAC_MAX_LEN + AO_CMAC_KEY_LEN + 2 + AO_CMAC_KEY_LEN]; static uint8_t round_len(uint8_t len) @@ -44,7 +45,7 @@ round_len(uint8_t len) * Sign and deliver the data sitting in the cmac buffer */ static void -radio_cmac_send(uint8_t len) __reentrant +radio_cmac_send(uint8_t len) { uint8_t i; @@ -76,7 +77,7 @@ radio_cmac_send(uint8_t len) __reentrant */ static int8_t -radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant +radio_cmac_recv(uint8_t len, uint16_t timeout) { uint8_t i; @@ -91,7 +92,6 @@ radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant return AO_RADIO_CMAC_TIMEOUT; } - ao_radio_cmac_rssi = ao_radio_rssi; if (!(cmac_data[len + AO_CMAC_KEY_LEN +1] & AO_RADIO_STATUS_CRC_OK)) return AO_RADIO_CMAC_CRC_ERROR; @@ -114,18 +114,20 @@ radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant /* Check the packet signature against the signature provided * over the link */ - + if (memcmp(&cmac_data[len], &cmac_data[len + AO_CMAC_KEY_LEN + 2], AO_CMAC_KEY_LEN) != 0) { return AO_RADIO_CMAC_MAC_ERROR; } + ao_radio_cmac_rssi = ao_radio_rssi; + return AO_RADIO_CMAC_OK; } int8_t -ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant +ao_radio_cmac_send(void *packet, uint8_t len) { if (len > AO_CMAC_MAX_LEN) return AO_RADIO_CMAC_LEN_ERROR; @@ -143,7 +145,7 @@ ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant } int8_t -ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant +ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout) { int8_t i; if (len > AO_CMAC_MAX_LEN) @@ -161,4 +163,3 @@ ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentr ao_mutex_put(&ao_radio_cmac_mutex); return i; } -