Check whether or not commissioner session id tlv is repeated and the validity of channel tlv. (#1001)

This commit is contained in:
Xiao Ma
2016-11-22 20:53:36 -08:00
committed by Jonathan Hui
parent c12c95f368
commit f673c4aadd
2 changed files with 42 additions and 5 deletions
+30 -4
View File
@@ -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<const Tlv *>(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
+12 -1
View File
@@ -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'