From df6a435d4215a2e63b8cfda23fb79648f3f373c8 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 10 Nov 2014 14:23:42 +0100 Subject: [PATCH 1/2] struct frame802154_t: make sure dest_addr and src_addr are aligned --- core/net/mac/frame802154.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/net/mac/frame802154.h b/core/net/mac/frame802154.h index 1e97a41df..fcd0ae54a 100644 --- a/core/net/mac/frame802154.h +++ b/core/net/mac/frame802154.h @@ -169,12 +169,15 @@ typedef struct { * specification for details. */ typedef struct { + /* The fields dest_addr and src_addr must come first to ensure they are aligned to the + * CPU word size. Needed as they are accessed directly as linkaddr_t*. Note we cannot use + * the type linkaddr_t directly here, as we always need 8 bytes, not LINKADDR_SIZE bytes. */ + uint8_t dest_addr[8]; /**< Destination address */ + uint8_t src_addr[8]; /**< Source address */ frame802154_fcf_t fcf; /**< Frame control field */ uint8_t seq; /**< Sequence number */ uint16_t dest_pid; /**< Destination PAN ID */ - uint8_t dest_addr[8]; /**< Destination address */ uint16_t src_pid; /**< Source PAN ID */ - uint8_t src_addr[8]; /**< Source address */ frame802154_aux_hdr_t aux_hdr; /**< Aux security header */ uint8_t *payload; /**< Pointer to 802.15.4 payload */ int payload_len; /**< Length of payload field */ From 6b7017452bc9807b63ae4a7036278367cb0d3041 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 10 Nov 2014 14:23:09 +0100 Subject: [PATCH 2/2] frame802154: move inclusion of linkaddr.h from .h to .c file --- core/net/mac/frame802154.c | 1 + core/net/mac/frame802154.h | 1 - platform/micaz/init-net.c | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/net/mac/frame802154.c b/core/net/mac/frame802154.c index d98be6269..1d756d345 100644 --- a/core/net/mac/frame802154.c +++ b/core/net/mac/frame802154.c @@ -64,6 +64,7 @@ #include "sys/cc.h" #include "net/mac/frame802154.h" #include "net/llsec/llsec802154.h" +#include "net/linkaddr.h" #include /** diff --git a/core/net/mac/frame802154.h b/core/net/mac/frame802154.h index fcd0ae54a..b0f27aa42 100644 --- a/core/net/mac/frame802154.h +++ b/core/net/mac/frame802154.h @@ -62,7 +62,6 @@ #define FRAME_802154_H #include "contiki-conf.h" -#include "net/linkaddr.h" #ifdef IEEE802154_CONF_PANID #define IEEE802154_PANID IEEE802154_CONF_PANID diff --git a/platform/micaz/init-net.c b/platform/micaz/init-net.c index c0366c833..1ccf50b57 100644 --- a/platform/micaz/init-net.c +++ b/platform/micaz/init-net.c @@ -49,6 +49,7 @@ #include "dev/leds.h" #include "net/netstack.h" #include "net/mac/frame802154.h" +#include "net/linkaddr.h" #include "dev/ds2401.h" #include "sys/node-id.h"