mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #5897 from miri64/ieee802154/enh/cleanup
ieee802154: clean-up (Intra-PAN behavior + broadcast)
This commit is contained in:
commit
359f3b5fc7
@ -100,7 +100,6 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
|
||||
/* set default TX power */
|
||||
at86rf2xx_set_txpower(dev, AT86RF2XX_DEFAULT_TXPOWER);
|
||||
/* set default options */
|
||||
at86rf2xx_set_option(dev, NETDEV2_IEEE802154_PAN_COMP, true);
|
||||
at86rf2xx_set_option(dev, AT86RF2XX_OPT_AUTOACK, true);
|
||||
at86rf2xx_set_option(dev, AT86RF2XX_OPT_CSMA, true);
|
||||
at86rf2xx_set_option(dev, AT86RF2XX_OPT_TELL_RX_START, false);
|
||||
|
@ -38,22 +38,21 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define NETDEV2_IEEE802154_SEND_MASK (0x0068) /**< flags to take for send packets */
|
||||
#define NETDEV2_IEEE802154_RESV1 (0x0001) /**< reserved flag */
|
||||
#define NETDEV2_IEEE802154_SEND_MASK (0x0028) /**< flags to take for send packets */
|
||||
#define NETDEV2_IEEE802154_RAW (0x0002) /**< pass raw frame to upper layer */
|
||||
/**
|
||||
* @brief use long source addres (set) or short source address (unset)
|
||||
*/
|
||||
#define NETDEV2_IEEE802154_SRC_MODE_LONG (0x0004)
|
||||
#define NETDEV2_IEEE802154_SECURITY_EN (0x0008) /**< enable security */
|
||||
#define NETDEV2_IEEE802154_RESV2 (0x0010) /**< reserved flag */
|
||||
/**
|
||||
* @brief enable security
|
||||
*/
|
||||
#define NETDEV2_IEEE802154_SECURITY_EN (IEEE802154_FCF_SECURITY_EN)
|
||||
|
||||
/**
|
||||
* @brief request ACK from receiver
|
||||
*/
|
||||
#define NETDEV2_IEEE802154_ACK_REQ (0x0020)
|
||||
#define NETDEV2_IEEE802154_PAN_COMP (0x0040) /**< compress source PAN ID */
|
||||
#define NETDEV2_IEEE802154_RESV3 (0x0080) /**< reserved flag */
|
||||
#define NETDEV2_IEEE802154_ACK_REQ (IEEE802154_FCF_ACK_REQ)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -78,12 +78,24 @@ extern "C" {
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Flag for @ref ieee802154_set_frame_hdr to indicate to ignore @p dst
|
||||
* and @p dst_len and send broadcast.
|
||||
* @note This flag is RIOT internal and shall not be used in the FCF of
|
||||
* packets send over the air
|
||||
* @brief Special address defintions
|
||||
* @{
|
||||
*/
|
||||
#define IEEE802154_BCAST (0x80)
|
||||
/**
|
||||
* @brief Static initializer for broadcast address
|
||||
*/
|
||||
#define IEEE802154_ADDR_BCAST { 0xff, 0xff }
|
||||
|
||||
/**
|
||||
* @brief Length in byte of @ref IEEE802154_ADDR_BCAST
|
||||
*/
|
||||
#define IEEE802154_ADDR_BCAST_LEN (IEEE802154_SHORT_ADDRESS_LEN)
|
||||
|
||||
/**
|
||||
* @brief Broadcast address
|
||||
*/
|
||||
extern const uint8_t ieee802154_addr_bcast[IEEE802154_ADDR_BCAST_LEN];
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Initializes an IEEE 802.15.4 MAC frame header in @p buf.
|
||||
@ -119,12 +131,8 @@ extern "C" {
|
||||
* first byte of the IEEE 802.15.4 FCF. This means that
|
||||
* it encompasses the type values,
|
||||
* @ref IEEE802154_FCF_SECURITY_EN,
|
||||
* @ref IEEE802154_FCF_FRAME_PEND,
|
||||
* @ref IEEE802154_FCF_ACK_REQ, and
|
||||
* @ref IEEE802154_FCF_PAN_COMP.
|
||||
* Additionally the @ref IEEE802154_BCAST flag can be set
|
||||
* do ignore @p dst and @p dst_len and just set `ff:ff`
|
||||
* (broadcast) as destination address
|
||||
* @ref IEEE802154_FCF_FRAME_PEND, and
|
||||
* @ref IEEE802154_FCF_ACK_REQ.
|
||||
* @param[in] seq Sequence number for frame.
|
||||
*
|
||||
* The version field in the FCF will be set implicitly to version 1.
|
||||
|
@ -144,9 +144,9 @@ static int _send(gnrc_netdev2_t *gnrc_netdev2, gnrc_pktsnip_t *pkt)
|
||||
netdev2_ieee802154_t *state = (netdev2_ieee802154_t *)gnrc_netdev2->dev;
|
||||
gnrc_netif_hdr_t *netif_hdr;
|
||||
gnrc_pktsnip_t *vec_snip;
|
||||
uint8_t *src, *dst = NULL;
|
||||
const uint8_t *src, *dst = NULL;
|
||||
int res = 0;
|
||||
size_t n, src_len;
|
||||
size_t n, src_len, dst_len;
|
||||
uint8_t mhr[IEEE802154_MAX_HDR_LEN];
|
||||
uint8_t flags = (uint8_t)(state->flags & NETDEV2_IEEE802154_SEND_MASK);
|
||||
le_uint16_t dev_pan = byteorder_btols(byteorder_htons(state->pan));
|
||||
@ -164,10 +164,12 @@ static int _send(gnrc_netdev2_t *gnrc_netdev2, gnrc_pktsnip_t *pkt)
|
||||
/* prepare destination address */
|
||||
if (netif_hdr->flags & /* If any of these flags is set so this is correct */
|
||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
flags |= IEEE802154_BCAST;
|
||||
dst = ieee802154_addr_bcast;
|
||||
dst_len = IEEE802154_ADDR_BCAST_LEN;
|
||||
}
|
||||
else {
|
||||
dst = gnrc_netif_hdr_get_dst_addr(netif_hdr);
|
||||
dst_len = netif_hdr->dst_l2addr_len;
|
||||
}
|
||||
src_len = netif_hdr->src_l2addr_len;
|
||||
if (src_len > 0) {
|
||||
@ -183,9 +185,8 @@ static int _send(gnrc_netdev2_t *gnrc_netdev2, gnrc_pktsnip_t *pkt)
|
||||
}
|
||||
/* fill MAC header, seq should be set by device */
|
||||
if ((res = ieee802154_set_frame_hdr(mhr, src, src_len,
|
||||
dst, netif_hdr->dst_l2addr_len,
|
||||
dev_pan, dev_pan, flags,
|
||||
state->seq++)) == 0) {
|
||||
dst, dst_len, dev_pan,
|
||||
dev_pan, flags, state->seq++)) == 0) {
|
||||
DEBUG("_send_ieee802154: Error preperaring frame\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -199,7 +200,8 @@ static int _send(gnrc_netdev2_t *gnrc_netdev2, gnrc_pktsnip_t *pkt)
|
||||
vector[0].iov_base = mhr;
|
||||
vector[0].iov_len = (size_t)res;
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
if (flags & IEEE802154_BCAST) {
|
||||
if (netif_hdr->flags &
|
||||
(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) {
|
||||
gnrc_netdev2->dev->stats.tx_mcast_count++;
|
||||
}
|
||||
else {
|
||||
|
@ -15,9 +15,12 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "net/ieee802154.h"
|
||||
|
||||
const uint8_t ieee802154_addr_bcast[IEEE802154_ADDR_BCAST_LEN] = IEEE802154_ADDR_BCAST;
|
||||
|
||||
size_t ieee802154_set_frame_hdr(uint8_t *buf, const uint8_t *src, size_t src_len,
|
||||
const uint8_t *dst, size_t dst_len,
|
||||
le_uint16_t src_pan, le_uint16_t dst_pan,
|
||||
@ -25,15 +28,12 @@ size_t ieee802154_set_frame_hdr(uint8_t *buf, const uint8_t *src, size_t src_len
|
||||
{
|
||||
int pos = 3; /* 0-1: FCS, 2: seq */
|
||||
uint8_t type = (flags & IEEE802154_FCF_TYPE_MASK);
|
||||
uint8_t bcast = (flags & IEEE802154_BCAST);
|
||||
|
||||
buf[0] = flags & (~IEEE802154_BCAST);
|
||||
buf[0] = flags;
|
||||
buf[1] = IEEE802154_FCF_VERS_V1;
|
||||
|
||||
if (((src_len != 0) && (src == NULL)) ||
|
||||
((!bcast) && (dst_len != 0) && (dst == NULL)) ||
|
||||
((flags & IEEE802154_FCF_PAN_COMP) &&
|
||||
(((!bcast) && (dst_len == 0)) || (src_len == 0)))) {
|
||||
((dst_len != 0) && (dst == NULL))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -46,46 +46,46 @@ size_t ieee802154_set_frame_hdr(uint8_t *buf, const uint8_t *src, size_t src_len
|
||||
/* set sequence number */
|
||||
buf[2] = seq;
|
||||
|
||||
if (bcast || (dst_len != 0)) {
|
||||
if (dst_len != 0) {
|
||||
buf[pos++] = dst_pan.u8[0];
|
||||
buf[pos++] = dst_pan.u8[1];
|
||||
}
|
||||
|
||||
/* fill in destination address */
|
||||
if (bcast) {
|
||||
/* no ACK_REQ for broadcast */
|
||||
buf[0] &= ~IEEE802154_FCF_ACK_REQ;
|
||||
buf[1] &= ~IEEE802154_FCF_DST_ADDR_MASK;
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_SHORT;
|
||||
buf[pos++] = 0xff;
|
||||
buf[pos++] = 0xff;
|
||||
}
|
||||
else {
|
||||
switch (dst_len) {
|
||||
case 0:
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_VOID;
|
||||
break;
|
||||
case 2:
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_SHORT;
|
||||
buf[pos++] = dst[1];
|
||||
buf[pos++] = dst[0];
|
||||
break;
|
||||
case 8:
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_LONG;
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
buf[pos++] = dst[i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
switch (dst_len) {
|
||||
case 0:
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_VOID;
|
||||
break;
|
||||
case 2:
|
||||
if (memcmp(dst, ieee802154_addr_bcast,
|
||||
sizeof(ieee802154_addr_bcast)) == 0) {
|
||||
/* do not request ACKs for broadcast address */
|
||||
buf[0] &= ~IEEE802154_FCF_ACK_REQ;
|
||||
}
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_SHORT;
|
||||
buf[pos++] = dst[1];
|
||||
buf[pos++] = dst[0];
|
||||
break;
|
||||
case 8:
|
||||
buf[1] |= IEEE802154_FCF_DST_ADDR_LONG;
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
buf[pos++] = dst[i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* fill in source PAN ID (if applicable) */
|
||||
if (!(flags & IEEE802154_FCF_PAN_COMP) && (src_len != 0)) {
|
||||
/* (little endian) */
|
||||
buf[pos++] = src_pan.u8[0];
|
||||
buf[pos++] = src_pan.u8[1];
|
||||
if (src_len != 0) {
|
||||
if ((dst_len != 0) && (src_pan.u16 == dst_pan.u16)) {
|
||||
buf[0] |= IEEE802154_FCF_PAN_COMP;
|
||||
}
|
||||
else {
|
||||
/* (little endian) */
|
||||
buf[pos++] = src_pan.u8[0];
|
||||
buf[pos++] = src_pan.u8[1];
|
||||
}
|
||||
}
|
||||
|
||||
/* fill in source address */
|
||||
|
@ -68,13 +68,14 @@ static void test_ieee802154_set_frame_hdr_bcast_src0(void)
|
||||
IEEE802154_FCF_DST_ADDR_SHORT,
|
||||
TEST_UINT8,
|
||||
dst_pan.u8[0], dst_pan.u8[1],
|
||||
0xff, 0xff };
|
||||
ieee802154_addr_bcast[0], ieee802154_addr_bcast[1] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_BCAST;
|
||||
const uint8_t flags = 0;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, NULL, 0,
|
||||
NULL, 0,
|
||||
ieee802154_addr_bcast,
|
||||
IEEE802154_ADDR_BCAST_LEN,
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
@ -92,70 +93,16 @@ static void test_ieee802154_set_frame_hdr_bcast_src2(void)
|
||||
IEEE802154_FCF_SRC_ADDR_SHORT,
|
||||
TEST_UINT8,
|
||||
dst_pan.u8[0], dst_pan.u8[1],
|
||||
0xff, 0xff,
|
||||
ieee802154_addr_bcast[0], ieee802154_addr_bcast[1],
|
||||
src_pan.u8[0], src_pan.u8[1],
|
||||
src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_BCAST;
|
||||
const uint8_t flags = 0;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
NULL, 0,
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_bcast_dst2_src2(void)
|
||||
{
|
||||
const network_uint16_t src = byteorder_htons(TEST_UINT16);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16 + 1);
|
||||
const network_uint16_t dst = byteorder_htons(TEST_UINT16);
|
||||
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 2);
|
||||
/* IEEE 802.15.4 is little endian! */
|
||||
const uint8_t exp[] = { 0x00,
|
||||
IEEE802154_FCF_VERS_V1 |
|
||||
IEEE802154_FCF_DST_ADDR_SHORT |
|
||||
IEEE802154_FCF_SRC_ADDR_SHORT,
|
||||
TEST_UINT8,
|
||||
dst_pan.u8[0], dst_pan.u8[1],
|
||||
0xff, 0xff,
|
||||
src_pan.u8[0], src_pan.u8[1],
|
||||
src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_BCAST; /* broadcast flag lets dst be ignored */
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
dst.u8, sizeof(dst),
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_bcast_dst8_src2(void)
|
||||
{
|
||||
const network_uint16_t src = byteorder_htons(TEST_UINT16);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16 + 1);
|
||||
const network_uint64_t dst = byteorder_htonll(TEST_UINT64);
|
||||
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 2);
|
||||
/* IEEE 802.15.4 is little endian! */
|
||||
const uint8_t exp[] = { 0x00,
|
||||
IEEE802154_FCF_VERS_V1 |
|
||||
/* broadcast address is short */
|
||||
IEEE802154_FCF_DST_ADDR_SHORT |
|
||||
IEEE802154_FCF_SRC_ADDR_SHORT,
|
||||
TEST_UINT8,
|
||||
dst_pan.u8[0], dst_pan.u8[1],
|
||||
0xff, 0xff,
|
||||
src_pan.u8[0], src_pan.u8[1],
|
||||
src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_BCAST; /* broadcast flag lets dst be ignored */
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
dst.u8, sizeof(dst),
|
||||
ieee802154_addr_bcast,
|
||||
IEEE802154_ADDR_BCAST_LEN,
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
@ -173,85 +120,22 @@ static void test_ieee802154_set_frame_hdr_bcast_src8(void)
|
||||
IEEE802154_FCF_SRC_ADDR_LONG,
|
||||
TEST_UINT8,
|
||||
dst_pan.u8[0], dst_pan.u8[1],
|
||||
0xff, 0xff,
|
||||
ieee802154_addr_bcast[0], ieee802154_addr_bcast[1],
|
||||
src_pan.u8[0], src_pan.u8[1],
|
||||
src.u8[7], src.u8[6], src.u8[5], src.u8[4],
|
||||
src.u8[3], src.u8[2], src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_BCAST;
|
||||
const uint8_t flags = 0;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
NULL, 0,
|
||||
ieee802154_addr_bcast,
|
||||
IEEE802154_ADDR_BCAST_LEN,
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_dst0_src2(void)
|
||||
{
|
||||
const network_uint16_t src = byteorder_htons(TEST_UINT16);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16 + 1);
|
||||
const le_uint16_t dst_pan = byteorder_htols(0);
|
||||
/* IEEE 802.15.4 is little endian! */
|
||||
const uint8_t exp[] = { IEEE802154_FCF_ACK_REQ,
|
||||
IEEE802154_FCF_VERS_V1 |
|
||||
IEEE802154_FCF_DST_ADDR_VOID |
|
||||
IEEE802154_FCF_SRC_ADDR_SHORT,
|
||||
TEST_UINT8,
|
||||
src_pan.u8[0], src_pan.u8[1],
|
||||
src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_FCF_ACK_REQ;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
NULL, 0,
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_dst0_src8(void)
|
||||
{
|
||||
const network_uint64_t src = byteorder_htonll(TEST_UINT64);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16);
|
||||
const le_uint16_t dst_pan = byteorder_htols(0);
|
||||
/* IEEE 802.15.4 is little endian! */
|
||||
const uint8_t exp[] = { IEEE802154_FCF_FRAME_PEND,
|
||||
IEEE802154_FCF_VERS_V1 |
|
||||
IEEE802154_FCF_DST_ADDR_VOID |
|
||||
IEEE802154_FCF_SRC_ADDR_LONG,
|
||||
TEST_UINT8,
|
||||
src_pan.u8[0], src_pan.u8[1],
|
||||
src.u8[7], src.u8[6], src.u8[5], src.u8[4],
|
||||
src.u8[3], src.u8[2], src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_FCF_FRAME_PEND;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
NULL, 0,
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_dst0_src8_pancomp(void)
|
||||
{
|
||||
const network_uint64_t src = byteorder_htonll(TEST_UINT64);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16);
|
||||
const le_uint16_t dst_pan = byteorder_htols(0);
|
||||
uint8_t res;
|
||||
const uint8_t flags = IEEE802154_FCF_PAN_COMP;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0,
|
||||
ieee802154_set_frame_hdr(&res, src.u8, sizeof(src),
|
||||
NULL, 0,
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_dst2_src0(void)
|
||||
{
|
||||
const network_uint16_t dst = byteorder_htons(TEST_UINT16);
|
||||
@ -276,21 +160,6 @@ static void test_ieee802154_set_frame_hdr_dst2_src0(void)
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_dst2_src0_pancomp(void)
|
||||
{
|
||||
const network_uint16_t dst = byteorder_htons(TEST_UINT16);
|
||||
const le_uint16_t src_pan = byteorder_htols(0);
|
||||
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 1);
|
||||
uint8_t res;
|
||||
const uint8_t flags = IEEE802154_FCF_PAN_COMP;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0,
|
||||
ieee802154_set_frame_hdr(&res, NULL, 0,
|
||||
dst.u8, sizeof(dst),
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_dst2_src2(void)
|
||||
{
|
||||
const network_uint16_t src = byteorder_htons(TEST_UINT16);
|
||||
@ -323,7 +192,7 @@ static void test_ieee802154_set_frame_hdr_dst2_src2_pancomp(void)
|
||||
const network_uint16_t src = byteorder_htons(TEST_UINT16);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16 + 1);
|
||||
const network_uint16_t dst = byteorder_htons(TEST_UINT16 + 2);
|
||||
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 3);
|
||||
const le_uint16_t dst_pan = src_pan;
|
||||
/* IEEE 802.15.4 is little endian! */
|
||||
const uint8_t exp[] = { IEEE802154_FCF_TYPE_DATA | IEEE802154_FCF_PAN_COMP,
|
||||
IEEE802154_FCF_VERS_V1 |
|
||||
@ -335,7 +204,7 @@ static void test_ieee802154_set_frame_hdr_dst2_src2_pancomp(void)
|
||||
/* src_pan compressed (and assumed equal to dst_pan) */
|
||||
src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_FCF_TYPE_DATA | IEEE802154_FCF_PAN_COMP;
|
||||
const uint8_t flags = IEEE802154_FCF_TYPE_DATA;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
@ -378,7 +247,7 @@ static void test_ieee802154_set_frame_hdr_dst2_src8_pancomp(void)
|
||||
const network_uint64_t src = byteorder_htonll(TEST_UINT64);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16);
|
||||
const network_uint16_t dst = byteorder_htons(TEST_UINT16 + 1);
|
||||
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 2);
|
||||
const le_uint16_t dst_pan = src_pan;
|
||||
/* IEEE 802.15.4 is little endian! */
|
||||
const uint8_t exp[] = { IEEE802154_FCF_TYPE_DATA | IEEE802154_FCF_PAN_COMP,
|
||||
IEEE802154_FCF_VERS_V1 |
|
||||
@ -391,7 +260,7 @@ static void test_ieee802154_set_frame_hdr_dst2_src8_pancomp(void)
|
||||
src.u8[7], src.u8[6], src.u8[5], src.u8[4],
|
||||
src.u8[3], src.u8[2], src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_FCF_TYPE_DATA | IEEE802154_FCF_PAN_COMP;
|
||||
const uint8_t flags = IEEE802154_FCF_TYPE_DATA;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
@ -426,21 +295,6 @@ static void test_ieee802154_set_frame_hdr_dst8_src0(void)
|
||||
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_dst8_src0_pancomp(void)
|
||||
{
|
||||
const network_uint64_t dst = byteorder_htonll(TEST_UINT64);
|
||||
const le_uint16_t src_pan = byteorder_htols(0);
|
||||
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16);
|
||||
uint8_t res;
|
||||
const uint8_t flags = IEEE802154_FCF_PAN_COMP;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0,
|
||||
ieee802154_set_frame_hdr(&res, NULL, 0,
|
||||
dst.u8, sizeof(dst),
|
||||
src_pan, dst_pan,
|
||||
flags, TEST_UINT8));
|
||||
}
|
||||
|
||||
static void test_ieee802154_set_frame_hdr_dst8_src2(void)
|
||||
{
|
||||
const network_uint16_t src = byteorder_htons(TEST_UINT16);
|
||||
@ -474,7 +328,7 @@ static void test_ieee802154_set_frame_hdr_dst8_src2_pancomp(void)
|
||||
const network_uint16_t src = byteorder_htons(TEST_UINT16);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16 + 1);
|
||||
const network_uint64_t dst = byteorder_htonll(TEST_UINT64);
|
||||
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 2);
|
||||
const le_uint16_t dst_pan = src_pan;
|
||||
/* IEEE 802.15.4 is little endian! */
|
||||
const uint8_t exp[] = { IEEE802154_FCF_TYPE_BEACON | IEEE802154_FCF_PAN_COMP,
|
||||
IEEE802154_FCF_VERS_V1 |
|
||||
@ -487,7 +341,7 @@ static void test_ieee802154_set_frame_hdr_dst8_src2_pancomp(void)
|
||||
/* src_pan compressed (and assumed equal to dst_pan) */
|
||||
src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_FCF_TYPE_BEACON | IEEE802154_FCF_PAN_COMP;
|
||||
const uint8_t flags = IEEE802154_FCF_TYPE_BEACON;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
@ -531,7 +385,7 @@ static void test_ieee802154_set_frame_hdr_dst8_src8_pancomp(void)
|
||||
const network_uint64_t src = byteorder_htonll(TEST_UINT64);
|
||||
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16);
|
||||
const network_uint64_t dst = byteorder_htonll(TEST_UINT64);
|
||||
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 1);
|
||||
const le_uint16_t dst_pan = src_pan;
|
||||
/* IEEE 802.15.4 is little endian! */
|
||||
const uint8_t exp[] = { IEEE802154_FCF_TYPE_BEACON | IEEE802154_FCF_PAN_COMP,
|
||||
IEEE802154_FCF_VERS_V1 |
|
||||
@ -545,7 +399,7 @@ static void test_ieee802154_set_frame_hdr_dst8_src8_pancomp(void)
|
||||
src.u8[7], src.u8[6], src.u8[5], src.u8[4],
|
||||
src.u8[3], src.u8[2], src.u8[1], src.u8[0] };
|
||||
uint8_t res[sizeof(exp)];
|
||||
const uint8_t flags = IEEE802154_FCF_TYPE_BEACON | IEEE802154_FCF_PAN_COMP;
|
||||
const uint8_t flags = IEEE802154_FCF_TYPE_BEACON;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(exp),
|
||||
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
|
||||
@ -1164,20 +1018,13 @@ Test *tests_ieee802154_tests(void)
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_flags0_non_beacon_non_ack),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_bcast_src0),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_bcast_src2),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_bcast_dst2_src2),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_bcast_dst8_src2),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_bcast_src8),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst0_src2),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst0_src8),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst0_src8_pancomp),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src0),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src0_pancomp),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src2),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src2_pancomp),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src8),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src8_pancomp),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src0),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src0_pancomp),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src2),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src2_pancomp),
|
||||
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src8),
|
||||
|
Loading…
Reference in New Issue
Block a user