From 0379af3624f8173972a1f27123129a18cc327957 Mon Sep 17 00:00:00 2001 From: kkrentz Date: Thu, 17 Dec 2015 01:42:00 -0800 Subject: [PATCH] llsec: Do not define surrogates in packetbuf.h, as otherwise configuration errors go unnoticed --- core/net/llsec/anti-replay.c | 4 ++++ core/net/llsec/ccm-star-packetbuf.c | 4 ++++ core/net/llsec/noncoresec/noncoresec.c | 3 +++ core/net/mac/tsch/tsch-slot-operation.c | 4 ++++ core/net/packetbuf.h | 23 ----------------------- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/core/net/llsec/anti-replay.c b/core/net/llsec/anti-replay.c index 7c392bff7..a59f6b4c8 100644 --- a/core/net/llsec/anti-replay.c +++ b/core/net/llsec/anti-replay.c @@ -45,6 +45,9 @@ #include "net/llsec/anti-replay.h" #include "net/packetbuf.h" +#include "net/llsec/llsec802154.h" + +#if LLSEC802154_USES_FRAME_COUNTER /* This node's current frame counter value */ static uint32_t counter; @@ -107,5 +110,6 @@ anti_replay_was_replayed(struct anti_replay_info *info) } } /*---------------------------------------------------------------------------*/ +#endif /* LLSEC802154_USES_FRAME_COUNTER */ /** @} */ diff --git a/core/net/llsec/ccm-star-packetbuf.c b/core/net/llsec/ccm-star-packetbuf.c index 61e681b1c..9b3a95644 100644 --- a/core/net/llsec/ccm-star-packetbuf.c +++ b/core/net/llsec/ccm-star-packetbuf.c @@ -41,8 +41,11 @@ #include "llsec/ccm-star-packetbuf.h" #include "net/linkaddr.h" #include "net/packetbuf.h" +#include "net/llsec/llsec802154.h" #include +#if LLSEC802154_SECURITY_LEVEL && LLSEC802154_USES_FRAME_COUNTER + /*---------------------------------------------------------------------------*/ static const uint8_t * get_extended_address(const linkaddr_t *addr) @@ -76,3 +79,4 @@ ccm_star_packetbuf_set_nonce(uint8_t *nonce, int forward) nonce[12] = packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL); } /*---------------------------------------------------------------------------*/ +#endif /* LLSEC802154_SECURITY_LEVEL && LLSEC802154_USES_FRAME_COUNTER */ diff --git a/core/net/llsec/noncoresec/noncoresec.c b/core/net/llsec/noncoresec/noncoresec.c index 860f7e613..97d018ede 100644 --- a/core/net/llsec/noncoresec/noncoresec.c +++ b/core/net/llsec/noncoresec/noncoresec.c @@ -76,6 +76,8 @@ #define PRINTF(...) #endif /* DEBUG */ +#if LLSEC802154_SECURITY_LEVEL && LLSEC802154_USES_FRAME_COUNTER + /* network-wide CCM* key */ static uint8_t key[16] = NONCORESEC_KEY; NBR_TABLE(struct anti_replay_info, anti_replay_table); @@ -256,5 +258,6 @@ const struct framer noncoresec_framer = { parse }; /*---------------------------------------------------------------------------*/ +#endif /* LLSEC802154_SECURITY_LEVEL && LLSEC802154_USES_FRAME_COUNTER */ /** @} */ diff --git a/core/net/mac/tsch/tsch-slot-operation.c b/core/net/mac/tsch/tsch-slot-operation.c index befd5a18f..6bad7cf47 100644 --- a/core/net/mac/tsch/tsch-slot-operation.c +++ b/core/net/mac/tsch/tsch-slot-operation.c @@ -604,7 +604,11 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) log->tx.drift = drift_correction; log->tx.drift_used = is_drift_correction_used; log->tx.is_data = ((((uint8_t *)(queuebuf_dataptr(current_packet->qb)))[0]) & 7) == FRAME802154_DATAFRAME; +#if TSCH_SECURITY_ENABLED log->tx.sec_level = queuebuf_attr(current_packet->qb, PACKETBUF_ATTR_SECURITY_LEVEL); +#else /* TSCH_SECURITY_ENABLED */ + log->tx.sec_level = 0; +#endif /* TSCH_SECURITY_ENABLED */ log->tx.dest = TSCH_LOG_ID_FROM_LINKADDR(queuebuf_addr(current_packet->qb, PACKETBUF_ADDR_RECEIVER)); ); diff --git a/core/net/packetbuf.h b/core/net/packetbuf.h index 12b0d9dce..969e020cd 100644 --- a/core/net/packetbuf.h +++ b/core/net/packetbuf.h @@ -365,29 +365,6 @@ enum { PACKETBUF_ATTR_MAX }; -/* Define surrogates when 802.15.4 security is off */ -#if !LLSEC802154_SECURITY_LEVEL -enum { - PACKETBUF_ATTR_SECURITY_LEVEL, -}; -#endif /* LLSEC802154_SECURITY_LEVEL */ - -#if !LLSEC802154_USES_FRAME_COUNTER -enum { - PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1, - PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3 -}; -#endif /* LLSEC802154_USES_FRAME_COUNTER */ - -/* Define surrogates when not using explicit keys */ -#if !LLSEC802154_USES_EXPLICIT_KEYS -enum { - PACKETBUF_ATTR_KEY_ID_MODE, - PACKETBUF_ATTR_KEY_INDEX, - PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1 -}; -#endif /* LLSEC802154_USES_EXPLICIT_KEYS */ - #if NETSTACK_CONF_WITH_RIME #define PACKETBUF_NUM_ADDRS 4 #else /* NETSTACK_CONF_WITH_RIME */