From ca30b6c02a5794ae6ee85d1fce5541ae5a16e8bc Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Thu, 15 Jun 2017 13:01:19 -0400 Subject: [PATCH] wireless/ieee802154: Fixes issue with wrong information being sent in a rejected association response frame --- include/nuttx/wireless/ieee802154/ieee802154_mac.h | 14 ++++++++++++-- wireless/ieee802154/mac802154_assoc.c | 10 +++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/nuttx/wireless/ieee802154/ieee802154_mac.h b/include/nuttx/wireless/ieee802154/ieee802154_mac.h index d9732d4dd5..a07978a64e 100644 --- a/include/nuttx/wireless/ieee802154/ieee802154_mac.h +++ b/include/nuttx/wireless/ieee802154/ieee802154_mac.h @@ -200,14 +200,25 @@ enum ieee802154_status_e { + /* This first section of enums is defined in the standard. [1] pg. 70 + * They must be in this order + */ + IEEE802154_STATUS_SUCCESS = 0, + IEEE802154_STATUS_OUT_OF_CAPACITY, + IEEE802154_STATUS_DENIED, + + /* As of now, all values below do not have a specific value defined in the + * standard + */ + IEEE802154_STATUS_FAILURE, /* This value is not outlined in the standard. It * is a catch-all for any failures that are not * outlined in the standard */ + IEEE802154_STATUS_BEACON_LOSS, IEEE802154_STATUS_CHANNEL_ACCESS_FAILURE, - IEEE802154_STATUS_DENIED, IEEE802154_STATUS_DISABLE_TRX_FAILURE, IEEE802154_STATUS_FAILED_SECURITY_CHECK, IEEE802154_STATUS_FRAME_TOO_LONG, @@ -218,7 +229,6 @@ enum ieee802154_status_e IEEE802154_STATUS_NO_BEACON, IEEE802154_STATUS_NO_DATA, IEEE802154_STATUS_NO_SHORT_ADDRESS, - IEEE802154_STATUS_OUT_OF_CAP, IEEE802154_STATUS_PAN_ID_CONFLICT, IEEE802154_STATUS_REALIGNMENT, IEEE802154_STATUS_TRANSACTION_EXPIRED, diff --git a/wireless/ieee802154/mac802154_assoc.c b/wireless/ieee802154/mac802154_assoc.c index d0d77302a2..0de0ec1977 100644 --- a/wireless/ieee802154/mac802154_assoc.c +++ b/wireless/ieee802154/mac802154_assoc.c @@ -374,7 +374,15 @@ int mac802154_resp_associate(MACHANDLE mac, /* Copy in the assigned short address */ - memcpy(&iob->io_data[iob->io_len], &resp->assocsaddr, 2); + if (resp->status == IEEE802154_STATUS_SUCCESS) + { + memcpy(&iob->io_data[iob->io_len], &resp->assocsaddr, 2); + } + else + { + u16 = (FAR uint16_t *)&iob->io_data[iob->io_len]; + *u16 = IEEE802154_SADDR_UNSPEC; + } iob->io_len += 2; /* Copy in the association status */