framer-802154: Conditional compilation of security-related code
This commit is contained in:
parent
fb6d2270ab
commit
124dde25f3
3 changed files with 27 additions and 3 deletions
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "net/mac/framer-802154.h"
|
||||
#include "net/mac/frame802154.h"
|
||||
#include "net/llsec/llsec802154.h"
|
||||
#include "net/packetbuf.h"
|
||||
#include "lib/random.h"
|
||||
#include <string.h>
|
||||
|
@ -102,9 +103,6 @@ create_frame(int type, int do_create)
|
|||
|
||||
/* Build the FCF. */
|
||||
params.fcf.frame_type = packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE);
|
||||
if(packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL)) {
|
||||
params.fcf.security_enabled = 1;
|
||||
}
|
||||
params.fcf.frame_pending = packetbuf_attr(PACKETBUF_ATTR_PENDING);
|
||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
||||
params.fcf.ack_required = 0;
|
||||
|
@ -116,10 +114,15 @@ create_frame(int type, int do_create)
|
|||
/* Insert IEEE 802.15.4 (2006) version bits. */
|
||||
params.fcf.frame_version = FRAME802154_IEEE802154_2006;
|
||||
|
||||
#if LLSEC802154_SECURITY_LEVEL
|
||||
if(packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL)) {
|
||||
params.fcf.security_enabled = 1;
|
||||
}
|
||||
/* Setting security-related attributes */
|
||||
params.aux_hdr.security_control.security_level = packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL);
|
||||
params.aux_hdr.frame_counter.u16[0] = packetbuf_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1);
|
||||
params.aux_hdr.frame_counter.u16[1] = packetbuf_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3);
|
||||
#endif /* LLSEC802154_SECURITY_LEVEL */
|
||||
|
||||
/* Increment and set the data sequence number. */
|
||||
if(!do_create) {
|
||||
|
@ -241,10 +244,12 @@ parse(void)
|
|||
/* packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, frame.fcf.ack_required);*/
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, frame.seq);
|
||||
|
||||
#if LLSEC802154_SECURITY_LEVEL
|
||||
/* Setting security-related attributes */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, frame.aux_hdr.security_control.security_level);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1, frame.aux_hdr.frame_counter.u16[0]);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3, frame.aux_hdr.frame_counter.u16[1]);
|
||||
#endif /* LLSEC802154_SECURITY_LEVEL */
|
||||
|
||||
PRINTF("15.4-IN: %2X", frame.fcf.frame_type);
|
||||
PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue