diff --git a/src/core/meshcop/dataset_manager.cpp b/src/core/meshcop/dataset_manager.cpp index 8d5d67f96..12a68f5ad 100644 --- a/src/core/meshcop/dataset_manager.cpp +++ b/src/core/meshcop/dataset_manager.cpp @@ -334,6 +334,7 @@ ThreadError DatasetManager::Set(Coap::Header &aHeader, Message &aMessage, const ActiveTimestampTlv activeTimestamp; NetworkMasterKeyTlv masterKey; + ChannelTlv channel; activeTimestamp.SetLength(0); masterKey.SetLength(0); @@ -364,6 +365,11 @@ ThreadError DatasetManager::Set(Coap::Header &aHeader, Message &aMessage, const aMessage.Read(offset, sizeof(masterKey), &masterKey); break; + case Tlv::kChannel: + aMessage.Read(offset, sizeof(channel), &channel); + VerifyOrExit(channel.GetChannel() >= kPhyMinChannel && channel.GetChannel() <= kPhyMaxChannel, + state = StateTlv::kReject); + default: break; } @@ -544,10 +550,30 @@ ThreadError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset, if (isCommissioner) { - CommissionerSessionIdTlv sessionId; - sessionId.Init(); - sessionId.SetCommissionerSessionId(mNetif.GetCommissioner().GetSessionId()); - SuccessOrExit(error = message->Append(&sessionId, sizeof(sessionId))); + const uint8_t *cur = aTlvs; + const uint8_t *end = aTlvs + aLength; + bool hasSessionId = false; + + while (cur < end) + { + const Tlv *data = reinterpret_cast(cur); + + if (data->GetType() == Tlv::kCommissionerSessionId) + { + hasSessionId = true; + break; + } + + cur += sizeof(Tlv) + data->GetLength(); + } + + if (!hasSessionId) + { + CommissionerSessionIdTlv sessionId; + sessionId.Init(); + sessionId.SetCommissionerSessionId(mNetif.GetCommissioner().GetSessionId()); + SuccessOrExit(error = message->Append(&sessionId, sizeof(sessionId))); + } } #endif diff --git a/tools/harness-thci/ARM.py b/tools/harness-thci/ARM.py index 5f6653275..ce4685a77 100644 --- a/tools/harness-thci/ARM.py +++ b/tools/harness-thci/ARM.py @@ -2193,7 +2193,10 @@ class ARM(IThci): if listChannelMask != None: cmd += ' channelmask ' - cmd += str(hex(1 << listChannelMask[1])) + if len(listChannelMask) > 2: + cmd += '0x' + self.__convertLongToString(self.__convertChannelMask(listChannelMask)) + elif len(listChannelMask) == 2: + cmd += str(hex(1 << listChannelMask[1])) if sPSKc != None or listSecurityPolicy != None or \ xCommissioningSessionId != None or xTmfPort != None or xSteeringData != None or xBorderRouterLocator != None or \ @@ -2251,6 +2254,14 @@ class ARM(IThci): cmd += locator + if xSteeringData != None: + steeringData = self.__convertLongToString(xSteeringData) + cmd += '08' + str(len(steeringData)/2).zfill(2) + cmd += steeringData + + if BogusTLV != None: + cmd += "8202aa55" + print cmd return self.__sendCommand(cmd)[0] == 'Done'