Fixes for setting unsecure/assisting ports (#349)

This change addresses two problems:

* `otGetUnsecurePorts()` was not indicating the proper number of entries (it was indicating the maximum number of entries).
* The NCP getter/setter for `PROP_THREAD_ASSISTING_PORTS` was not implemented properly.
This commit is contained in:
Robert Quattlebaum
2016-08-08 18:11:41 -07:00
committed by Jonathan Hui
parent c1917179f7
commit 31d788ff98
2 changed files with 22 additions and 3 deletions
+17 -1
View File
@@ -127,6 +127,14 @@ ThreadError Filter::RemoveUnsecurePort(uint16_t aPort)
{
if (mUnsecurePorts[i] == aPort)
{
// Shift all of the ports higher than this
// port down.
for (; i < kMaxUnsecurePorts - 1; i++)
{
mUnsecurePorts[i] = mUnsecurePorts[i + 1];
}
// Clear the last port entry.
mUnsecurePorts[i] = 0;
ExitNow();
}
@@ -140,7 +148,15 @@ exit:
const uint16_t *Filter::GetUnsecurePorts(uint8_t &aNumEntries) const
{
aNumEntries = kMaxUnsecurePorts;
// Count the number of unsecure ports.
for (aNumEntries = 0; aNumEntries < kMaxUnsecurePorts; aNumEntries++)
{
if (mUnsecurePorts[aNumEntries] == 0)
{
break;
}
}
return mUnsecurePorts;
}
+5 -2
View File
@@ -1583,7 +1583,7 @@ ThreadError NcpBase::GetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, s
for (; num_entries != 0; ports++, num_entries--)
{
SuccessOrExit(errorCode = OutboundFrameFeedPacked("S", ports));
SuccessOrExit(errorCode = OutboundFrameFeedPacked("S", *ports));
}
SuccessOrExit(errorCode = OutboundFrameSend());
@@ -2688,7 +2688,7 @@ ThreadError NcpBase::SetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, s
ThreadError errorCode = kThreadError_None;
uint8_t num_entries = 0;
const uint16_t *ports = otGetUnsecurePorts(&num_entries);
spinel_ssize_t parsedLength = 0;
spinel_ssize_t parsedLength = 1;
int ports_changed = 0;
// First, we need to remove all of the current assisting ports.
@@ -2732,6 +2732,9 @@ ThreadError NcpBase::SetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, s
break;
}
value_ptr += parsedLength;
value_len -= parsedLength;
ports_changed++;
}