mirror of
https://github.com/espressif/openthread.git
synced 2026-07-08 13:20:25 +00:00
otAddUnicastAddress Doesn't Hold onto External Pointers (#504)
* Modify ot*UnicastAddress functions to use internal memory instead of holding onto an external memory address.
This commit is contained in:
+8
-10
@@ -102,8 +102,6 @@ const struct Command Interpreter::sCommands[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
otNetifAddress Interpreter::sAddress;
|
||||
|
||||
static otDEFINE_ALIGNED_VAR(sPingTimerBuf, sizeof(Timer), uint64_t);
|
||||
Timer *Interpreter::sPingTimer;
|
||||
|
||||
@@ -611,14 +609,15 @@ exit:
|
||||
ThreadError Interpreter::ProcessIpAddrAdd(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error;
|
||||
otNetifAddress aAddress;
|
||||
|
||||
VerifyOrExit(argc > 0, error = kThreadError_Parse);
|
||||
|
||||
SuccessOrExit(error = otIp6AddressFromString(argv[0], &sAddress.mAddress));
|
||||
sAddress.mPrefixLength = 64;
|
||||
sAddress.mPreferredLifetime = 0xffffffff;
|
||||
sAddress.mValidLifetime = 0xffffffff;
|
||||
error = otAddUnicastAddress(&sAddress);
|
||||
SuccessOrExit(error = otIp6AddressFromString(argv[0], &aAddress.mAddress));
|
||||
aAddress.mPrefixLength = 64;
|
||||
aAddress.mPreferredLifetime = 0xffffffff;
|
||||
aAddress.mValidLifetime = 0xffffffff;
|
||||
error = otAddUnicastAddress(&aAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -632,8 +631,7 @@ ThreadError Interpreter::ProcessIpAddrDel(int argc, char *argv[])
|
||||
VerifyOrExit(argc > 0, error = kThreadError_Parse);
|
||||
|
||||
SuccessOrExit(error = otIp6AddressFromString(argv[0], &address));
|
||||
VerifyOrExit(otIsIp6AddressEqual(&address, &sAddress.mAddress), error = kThreadError_Parse);
|
||||
error = otRemoveUnicastAddress(&sAddress);
|
||||
error = otRemoveUnicastAddress(&address);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -1989,7 +1987,7 @@ void Interpreter::HandleNetifStateChanged(uint32_t aFlags, void *aContext)
|
||||
|
||||
if (!found)
|
||||
{
|
||||
otRemoveUnicastAddress(address);
|
||||
otRemoveUnicastAddress(&address->mAddress);
|
||||
address->mValidLifetime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user