From 84b38de4941259106445eeaf5115e99e397d639d Mon Sep 17 00:00:00 2001 From: nifi Date: Thu, 9 Apr 2009 21:54:09 +0000 Subject: [PATCH] removed bitfields for compatibility with cc65 --- core/net/mac/frame802154.c | 28 ++++++++++++++++------------ core/net/mac/frame802154.h | 27 +++++++++++++-------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/core/net/mac/frame802154.c b/core/net/mac/frame802154.c index 39e5f1b4b..3eea0bfc8 100644 --- a/core/net/mac/frame802154.c +++ b/core/net/mac/frame802154.c @@ -44,7 +44,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: frame802154.c,v 1.1 2009/04/06 13:19:03 nifi Exp $ + * $Id: frame802154.c,v 1.2 2009/04/09 21:54:09 nifi Exp $ */ /* * \brief This file is where the main functions that relate to frame @@ -99,15 +99,16 @@ field_len(frame802154_t *p, field_length_t *flen) memset(flen, 0, sizeof(field_length_t)); /* Determine lengths of each field based on fcf and other args */ - if(p->fcf.dest_addr_mode) { + if(p->fcf.dest_addr_mode & 3) { flen->dest_pid_len = 2; } - if(p->fcf.src_addr_mode) { + if(p->fcf.src_addr_mode & 3) { flen->src_pid_len = 2; } /* Set PAN ID compression bit if src pan id matches dest pan id. */ - if(p->fcf.dest_addr_mode && p->fcf.src_addr_mode && p->src_pid == p->dest_pid) { + if(p->fcf.dest_addr_mode & 3 && p->fcf.src_addr_mode & 3 && + p->src_pid == p->dest_pid) { p->fcf.panid_compression = 1; /* compressed header, only do dest pid */ @@ -117,11 +118,11 @@ field_len(frame802154_t *p, field_length_t *flen) } /* determine address lengths */ - flen->dest_addr_len = addr_len(p->fcf.dest_addr_mode); - flen->src_addr_len = addr_len(p->fcf.src_addr_mode); + flen->dest_addr_len = addr_len(p->fcf.dest_addr_mode & 3); + flen->src_addr_len = addr_len(p->fcf.src_addr_mode & 3); /* Aux security header */ - if(p->fcf.security_enabled) { + if(p->fcf.security_enabled & 1) { /* TODO Aux security header not yet implemented */ #if 0 switch(p->aux_hdr.security_control.key_id_mode) { @@ -195,11 +196,14 @@ frame802154_create(frame802154_t *p, uint8_t *buf, uint8_t buf_len) /* OK, now we have field lengths. Time to actually construct */ /* the outgoing frame, and store it in tx_frame_buffer */ tx_frame_buffer = buf; - tx_frame_buffer[0] = (p->fcf.frame_type) | - (p->fcf.security_enabled << 3) | (p->fcf.frame_pending << 4) | - (p->fcf.ack_required << 5) | (p->fcf.panid_compression << 6); - tx_frame_buffer[1] = (p->fcf.dest_addr_mode << 2) | - (p->fcf.frame_version << 4) | (p->fcf.src_addr_mode << 6); + tx_frame_buffer[0] = (p->fcf.frame_type & 7) | + ((p->fcf.security_enabled & 1) << 3) | + ((p->fcf.frame_pending & 1) << 4) | + ((p->fcf.ack_required & 1) << 5) | + ((p->fcf.panid_compression & 1) << 6); + tx_frame_buffer[1] = ((p->fcf.dest_addr_mode & 3) << 2) | + ((p->fcf.frame_version & 3) << 4) | + ((p->fcf.src_addr_mode & 3) << 6); /* sequence number */ tx_frame_buffer[2] = p->seq; diff --git a/core/net/mac/frame802154.h b/core/net/mac/frame802154.h index 783f95fdb..c0fbc8694 100644 --- a/core/net/mac/frame802154.h +++ b/core/net/mac/frame802154.h @@ -54,7 +54,7 @@ * This file converts to and from a structure to a packed 802.15.4 * frame. * - * $Id: frame802154.h,v 1.1 2009/04/06 13:19:03 nifi Exp $ + * $Id: frame802154.h,v 1.2 2009/04/09 21:54:09 nifi Exp $ */ @@ -114,27 +114,26 @@ * 5. CRC - 2 bytes - Fixed */ - /** * \brief Defines the bitfields of the frame control field (FCF). */ typedef struct { - uint8_t frame_type : 3; /**< Frame type field, see 802.15.4 */ - uint8_t security_enabled : 1; /**< True if security is used in this frame */ - uint8_t frame_pending : 1; /**< True if sender has more data to send */ - uint8_t ack_required : 1; /**< Is an ack frame required? */ - uint8_t panid_compression : 1; /**< Is this a compressed header? */ - uint8_t reserved : 3; /**< Unused bits */ - uint8_t dest_addr_mode : 2; /**< Destination address mode, see 802.15.4 */ - uint8_t frame_version : 2; /**< 802.15.4 frame version */ - uint8_t src_addr_mode : 2; /**< Source address mode, see 802.15.4 */ + uint8_t frame_type; /**< 3 bit. Frame type field, see 802.15.4 */ + uint8_t security_enabled; /**< 1 bit. True if security is used in this frame */ + uint8_t frame_pending; /**< 1 bit. True if sender has more data to send */ + uint8_t ack_required; /**< 1 bit. Is an ack frame required? */ + uint8_t panid_compression; /**< 1 bit. Is this a compressed header? */ + /* uint8_t reserved; */ /**< 3 bit. Unused bits */ + uint8_t dest_addr_mode; /**< 2 bit. Destination address mode, see 802.15.4 */ + uint8_t frame_version; /**< 2 bit. 802.15.4 frame version */ + uint8_t src_addr_mode; /**< 2 bit. Source address mode, see 802.15.4 */ } frame802154_fcf_t; /** \brief 802.15.4 security control bitfield. See section 7.6.2.2.1 in 802.15.4 specification */ typedef struct { - uint8_t security_level : 3; /**< security level */ - uint8_t key_id_mode : 2; /**< Key identifier mode */ - uint8_t reserved : 3; /**< Reserved bits */ + uint8_t security_level; /**< 3 bit. security level */ + uint8_t key_id_mode; /**< 2 bit. Key identifier mode */ + uint8_t reserved; /**< 3 bit. Reserved bits */ } frame802154_scf_t; /** \brief 802.15.4 Aux security header */