mirror of
https://github.com/espressif/openthread.git
synced 2026-10-02 05:47:40 +00:00
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:
committed by
Jonathan Hui
parent
c1917179f7
commit
31d788ff98
@@ -127,6 +127,14 @@ ThreadError Filter::RemoveUnsecurePort(uint16_t aPort)
|
|||||||
{
|
{
|
||||||
if (mUnsecurePorts[i] == 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;
|
mUnsecurePorts[i] = 0;
|
||||||
ExitNow();
|
ExitNow();
|
||||||
}
|
}
|
||||||
@@ -140,7 +148,15 @@ exit:
|
|||||||
|
|
||||||
const uint16_t *Filter::GetUnsecurePorts(uint8_t &aNumEntries) const
|
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;
|
return mUnsecurePorts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1583,7 +1583,7 @@ ThreadError NcpBase::GetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, s
|
|||||||
|
|
||||||
for (; num_entries != 0; ports++, num_entries--)
|
for (; num_entries != 0; ports++, num_entries--)
|
||||||
{
|
{
|
||||||
SuccessOrExit(errorCode = OutboundFrameFeedPacked("S", ports));
|
SuccessOrExit(errorCode = OutboundFrameFeedPacked("S", *ports));
|
||||||
}
|
}
|
||||||
|
|
||||||
SuccessOrExit(errorCode = OutboundFrameSend());
|
SuccessOrExit(errorCode = OutboundFrameSend());
|
||||||
@@ -2688,7 +2688,7 @@ ThreadError NcpBase::SetPropertyHandler_THREAD_ASSISTING_PORTS(uint8_t header, s
|
|||||||
ThreadError errorCode = kThreadError_None;
|
ThreadError errorCode = kThreadError_None;
|
||||||
uint8_t num_entries = 0;
|
uint8_t num_entries = 0;
|
||||||
const uint16_t *ports = otGetUnsecurePorts(&num_entries);
|
const uint16_t *ports = otGetUnsecurePorts(&num_entries);
|
||||||
spinel_ssize_t parsedLength = 0;
|
spinel_ssize_t parsedLength = 1;
|
||||||
int ports_changed = 0;
|
int ports_changed = 0;
|
||||||
|
|
||||||
// First, we need to remove all of the current assisting ports.
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value_ptr += parsedLength;
|
||||||
|
value_len -= parsedLength;
|
||||||
|
|
||||||
ports_changed++;
|
ports_changed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user