From 07ef46a6e22ded6a00e1f324d3fcb561895d885a Mon Sep 17 00:00:00 2001 From: kkrentz Date: Fri, 21 Jun 2013 10:34:31 -0700 Subject: [PATCH] llsec: Allow for sharing endianness functions --- core/net/llsec/llsec802154.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/net/llsec/llsec802154.h b/core/net/llsec/llsec802154.h index d716c9327..4a9b8eee8 100644 --- a/core/net/llsec/llsec802154.h +++ b/core/net/llsec/llsec802154.h @@ -54,6 +54,7 @@ #define LLSEC802154_H_ #include "net/mac/frame802154.h" +#include "net/ip/uip.h" #ifdef LLSEC802154_CONF_SECURITY_LEVEL #define LLSEC802154_SECURITY_LEVEL LLSEC802154_CONF_SECURITY_LEVEL @@ -75,6 +76,14 @@ #define LLSEC802154_USES_EXPLICIT_KEYS 0 #endif /* LLSEC802154_CONF_USES_EXPLICIT_KEYS */ +#if UIP_BYTE_ORDER == UIP_LITTLE_ENDIAN +#define LLSEC802154_HTONS(n) (n) +#define LLSEC802154_HTONL(n) (n) +#else /* UIP_CONF_BYTE_ORDER == UIP_LITTLE_ENDIAN */ +#define LLSEC802154_HTONS(n) (uint16_t)((((uint16_t) (n)) << 8) | (((uint16_t) (n)) >> 8)) +#define LLSEC802154_HTONL(n) (((uint32_t)UIP_HTONS(n) << 16) | UIP_HTONS((uint32_t)(n) >> 16)) +#endif /* UIP_CONF_BYTE_ORDER == UIP_LITTLE_ENDIAN */ + #endif /* LLSEC802154_H_ */ /** @} */