Make all devices could receive and response to MGMT_ACTIVE_GET.req and MGMT_PENDING_GET.req (#917)

* Add Coap Resources ACTIVE_GET and PENDING_GET to all devices

* Add 'address' parameter to dataset mgmtgetcommand CLI

* Use the specified destination address when sending MGMT_ACTIVR_GET.req and
  MGMT_PENDING_GET.req, default to use Leader ALOC if the destination is not specified

* THCI update to take the destination address as a parameter in mgmtget API
This commit is contained in:
Shu Chen
2016-11-02 09:28:18 -07:00
committed by Jonathan Hui
parent 91b571f9bb
commit 4da1eb4124
8 changed files with 55 additions and 22 deletions
+4 -2
View File
@@ -3319,7 +3319,8 @@ otLwfIoCtl_otSendActiveGet(
otSendActiveGet(
pFilter->otCtx,
aTlvTypes,
aLength)
aLength,
NULL)
);
}
}
@@ -3393,7 +3394,8 @@ otLwfIoCtl_otSendPendingGet(
otSendPendingGet(
pFilter->otCtx,
aTlvTypes,
aLength)
aLength,
NULL)
);
}
}
+6 -2
View File
@@ -941,12 +941,14 @@ ThreadError otSetPendingDataset(otInstance *aInstance, const otOperationalDatase
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTlvTypes A pointer to the TLV Types.
* @param[in] aLength The length of TLV Types.
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
ThreadError otSendActiveGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength);
ThreadError otSendActiveGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress);
/**
* This function sends MGMT_ACTIVE_SET.
@@ -969,12 +971,14 @@ ThreadError otSendActiveSet(otInstance *aInstance, const otOperationalDataset *a
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTlvTypes A pointer to the TLV Types.
* @param[in] aLength The length of TLV Types.
* @param[in] aAddress A pointer to the IPv6 destination, if it is NULL, will use Leader ALOC as default.
*
* @retval kThreadError_None Successfully send the meshcop dataset command.
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
ThreadError otSendPendingGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength);
ThreadError otSendPendingGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress);
/**
* This function sends MGMT_PENDING_SET.
+4 -4
View File
@@ -531,12 +531,12 @@ Set mesh local prefix.
Done
```
### dataset mgmtgetcommand active \[TLVs list\] \[binary\]
### dataset mgmtgetcommand active \[address \<destination\>\] \[TLVs list\] \[binary\]
Send MGMT_ACTIVE_GET.
```bash
> dataset mgmtgetcommand active activetimestamp 123 binary 0001
> dataset mgmtgetcommand active address fdde:ad00:beef:0:558:f56b:d688:799 activetimestamp 123 binary 0001
Done
```
@@ -549,12 +549,12 @@ Send MGMT_ACTIVE_SET.
Done
```
### dataset mgmtgetcommand pending \[TLVs list\] \[binary\]
### dataset mgmtgetcommand pending \[address \<destination\>\] \[TLVs list\] \[binary\]
Send MGMT_PENDING_GET.
```bash
> dataset mgmtgetcommand pending activetimestamp binary 0001
> dataset mgmtgetcommand pending address fdde:ad00:beef:0:558:f56b:d688:799 activetimestamp binary 0001
Done
```
+12 -2
View File
@@ -574,6 +574,8 @@ ThreadError Dataset::ProcessMgmtGetCommand(otInstance *aInstance, int argc, char
uint8_t tlvs[32];
long value;
int length = 0;
bool destAddrSpecified = false;
otIp6Address address;
VerifyOrExit(argc > 0, error = kThreadError_Parse);
@@ -628,6 +630,12 @@ ThreadError Dataset::ProcessMgmtGetCommand(otInstance *aInstance, int argc, char
error = kThreadError_Parse);
length += value;
}
else if (strcmp(argv[index], "address") == 0)
{
VerifyOrExit(index < argc, error = kThreadError_Parse);
SuccessOrExit(error = otIp6AddressFromString(argv[++index], &address));
destAddrSpecified = true;
}
else
{
ExitNow(error = kThreadError_Parse);
@@ -636,11 +644,13 @@ ThreadError Dataset::ProcessMgmtGetCommand(otInstance *aInstance, int argc, char
if (strcmp(argv[0], "active") == 0)
{
SuccessOrExit(error = otSendActiveGet(aInstance, tlvs, static_cast<uint8_t>(length)));
SuccessOrExit(error = otSendActiveGet(aInstance, tlvs, static_cast<uint8_t>(length),
destAddrSpecified ? &address : NULL));
}
else if (strcmp(argv[0], "pending") == 0)
{
SuccessOrExit(error = otSendPendingGet(aInstance, tlvs, static_cast<uint8_t>(length)));
SuccessOrExit(error = otSendPendingGet(aInstance, tlvs, static_cast<uint8_t>(length),
destAddrSpecified ? &address : NULL));
}
else
{
+6 -4
View File
@@ -1482,9 +1482,10 @@ exit:
return error;
}
ThreadError otSendActiveGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength)
ThreadError otSendActiveGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.GetActiveDataset().SendGetRequest(aTlvTypes, aLength);
return aInstance->mThreadNetif.GetActiveDataset().SendGetRequest(aTlvTypes, aLength, aAddress);
}
ThreadError otSendActiveSet(otInstance *aInstance, const otOperationalDataset *aDataset, const uint8_t *aTlvs,
@@ -1493,9 +1494,10 @@ ThreadError otSendActiveSet(otInstance *aInstance, const otOperationalDataset *a
return aInstance->mThreadNetif.GetActiveDataset().SendSetRequest(*aDataset, aTlvs, aLength);
}
ThreadError otSendPendingGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength)
ThreadError otSendPendingGet(otInstance *aInstance, const uint8_t *aTlvTypes, uint8_t aLength,
const otIp6Address *aAddress)
{
return aInstance->mThreadNetif.GetPendingDataset().SendGetRequest(aTlvTypes, aLength);
return aInstance->mThreadNetif.GetPendingDataset().SendGetRequest(aTlvTypes, aLength, aAddress);
}
ThreadError otSendPendingSet(otInstance *aInstance, const otOperationalDataset *aDataset, const uint8_t *aTlvs,
+14 -7
View File
@@ -604,7 +604,8 @@ exit:
return error;
}
ThreadError DatasetManager::SendGetRequest(const uint8_t *aTlvTypes, const uint8_t aLength)
ThreadError DatasetManager::SendGetRequest(const uint8_t *aTlvTypes, const uint8_t aLength,
const otIp6Address *aAddress)
{
ThreadError error = kThreadError_None;
Coap::Header header;
@@ -627,11 +628,19 @@ ThreadError DatasetManager::SendGetRequest(const uint8_t *aTlvTypes, const uint8
SuccessOrExit(error = message->Append(aTlvTypes, aLength));
}
mMle.GetLeaderAloc(messageInfo.GetPeerAddr());
if (aAddress != NULL)
{
messageInfo.SetPeerAddr(*static_cast<const Ip6::Address *>(aAddress));
}
else
{
mMle.GetLeaderAloc(messageInfo.GetPeerAddr());
}
messageInfo.SetPeerPort(kCoapUdpPort);
SuccessOrExit(error = mCoapClient.SendMessage(*message, messageInfo));
otLogInfoMeshCoP("sent dataset get request to leader");
otLogInfoMeshCoP("sent dataset get request");
exit:
@@ -722,6 +731,7 @@ ActiveDataset::ActiveDataset(ThreadNetif &aThreadNetif):
mResourceGet(OPENTHREAD_URI_ACTIVE_GET, &ActiveDataset::HandleGet, this),
mResourceSet(OPENTHREAD_URI_ACTIVE_SET, &ActiveDataset::HandleSet, this)
{
mCoapServer.AddResource(mResourceGet);
}
ThreadError ActiveDataset::Restore(void)
@@ -783,13 +793,11 @@ void ActiveDataset::StartLeader(void)
mLocal.Store();
mNetwork = mLocal;
mCoapServer.AddResource(mResourceGet);
mCoapServer.AddResource(mResourceSet);
}
void ActiveDataset::StopLeader(void)
{
mCoapServer.RemoveResource(mResourceGet);
mCoapServer.RemoveResource(mResourceSet);
}
@@ -872,6 +880,7 @@ PendingDataset::PendingDataset(ThreadNetif &aThreadNetif):
mResourceSet(OPENTHREAD_URI_PENDING_SET, &PendingDataset::HandleSet, this),
mTimer(aThreadNetif.GetIp6().mTimerScheduler, &PendingDataset::HandleTimer, this)
{
mCoapServer.AddResource(mResourceGet);
}
ThreadError PendingDataset::Restore(void)
@@ -893,13 +902,11 @@ void PendingDataset::StartLeader(void)
mNetwork = mLocal;
ResetDelayTimer(kFlagNetworkUpdated);
mCoapServer.AddResource(mResourceGet);
mCoapServer.AddResource(mResourceSet);
}
void PendingDataset::StopLeader(void)
{
mCoapServer.RemoveResource(mResourceGet);
mCoapServer.RemoveResource(mResourceSet);
}
+1 -1
View File
@@ -59,7 +59,7 @@ public:
ThreadError ApplyConfiguration(void);
ThreadError SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength);
ThreadError SendGetRequest(const uint8_t *aTlvTypes, uint8_t aLength);
ThreadError SendGetRequest(const uint8_t *aTlvTypes, uint8_t aLength, const otIp6Address *aAddress);
protected:
enum
+8
View File
@@ -2148,6 +2148,10 @@ class ARM(IThci):
try:
cmd = 'dataset mgmtgetcommand active'
if Addr != '':
cmd += ' address '
cmd += Addr
if len(TLVs) != 0:
tlvs = "".join(hex(tlv).lstrip("0x").zfill(2) for tlv in TLVs)
cmd += ' binary '
@@ -2289,6 +2293,10 @@ class ARM(IThci):
try:
cmd = 'dataset mgmtgetcommand pending'
if Addr != '':
cmd += ' address '
cmd += Addr
if len(TLVs) != 0:
tlvs = "".join(hex(tlv).lstrip("0x").zfill(2) for tlv in TLVs)
cmd += ' binary '