From 2f6d319a8bdf441aae82f42f71183dde482e2d5f Mon Sep 17 00:00:00 2001 From: janhauer Date: Wed, 20 May 2009 15:15:44 +0000 Subject: [PATCH] Added security parameter check to AssociateP; fixed ScanP to signal beacon with non-empty payload to next higher layer during active/passive scan. --- tos/lib/mac/tkn154/AssociateP.nc | 4 +++- tos/lib/mac/tkn154/ScanP.nc | 39 ++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/tos/lib/mac/tkn154/AssociateP.nc b/tos/lib/mac/tkn154/AssociateP.nc index f631f65c..d5296c87 100644 --- a/tos/lib/mac/tkn154/AssociateP.nc +++ b/tos/lib/mac/tkn154/AssociateP.nc @@ -238,7 +238,9 @@ implementation for (i=0; iSecurityLevel) + txStatus = IEEE154_UNSUPPORTED_SECURITY; + else if (i == MAX_PENDING_ASSOC_RESPONSES || !(txFrame = call TxFramePool.get())) txStatus = IEEE154_TRANSACTION_OVERFLOW; else if (!(txControl = call TxControlPool.get())) { call TxFramePool.put(txFrame); diff --git a/tos/lib/mac/tkn154/ScanP.nc b/tos/lib/mac/tkn154/ScanP.nc index 37ac03b6..72a04b6c 100644 --- a/tos/lib/mac/tkn154/ScanP.nc +++ b/tos/lib/mac/tkn154/ScanP.nc @@ -345,6 +345,7 @@ implementation { if (!m_busy) return frame; + if (m_scanType == ORPHAN_SCAN) { if (!m_resultIndex) if ((MHR(frame)[0] & FC1_FRAMETYPE_MASK) == FC1_FRAMETYPE_CMD && @@ -355,7 +356,14 @@ implementation call RadioOff.off(); } } else if ((((ieee154_header_t*) frame->header)->mhr[0] & FC1_FRAMETYPE_MASK) == FC1_FRAMETYPE_BEACON) { - // PASSIVE_SCAN / ACTIVE_SCAN + + // PASSIVE_SCAN / ACTIVE_SCAN: + // A beacon frame containing a non-empty payload is always signalled + // to the next higher layer (regardless of the value of macAutoRequest), + // but it is unclear whether it should in addition be added to the + // PAN Descriptor list when macAutoRequest is set to TRUE. This is, + // anyway, what the implementation currently does ... + if (!call MLME_GET.macAutoRequest()) return signal MLME_BEACON_NOTIFY.indication (frame); else if (m_resultIndex >= m_resultListNumEntries) { @@ -367,25 +375,28 @@ implementation IEEE154_SUPPORTED_CHANNELPAGE, &((ieee154_PANDescriptor_t*) m_resultList)[m_resultIndex]) == SUCCESS) { - // check uniqueness: both PAN ID and source address must not be in a previously received beacon + // check uniqueness: PAN ID and source address must + // not be found in a previously received beacon uint8_t i; ieee154_PANDescriptor_t* descriptor = (ieee154_PANDescriptor_t*) m_resultList; dbg_serial("ScanP", "Received beacon, source: 0x%lx, channel: %lu.\n", (uint32_t) descriptor[m_resultIndex].CoordAddress.shortAddress, (uint32_t) m_currentChannelNum); - if (m_resultIndex) - for (i=0; i 0) + return signal MLME_BEACON_NOTIFY.indication (frame); } // PASSIVE_SCAN / ACTIVE_SCAN return frame; } -- 2.39.2