mirror of
https://github.com/espressif/openthread.git
synced 2026-07-23 12:34:07 +00:00
NcpBase: Implement get handler for IPV6_LL_ADDR spinel property (#1826)
This commit add a new API `otThreadGetLinkLocalIp6Address()` to get the Thread link-local address (which is is derived using IEEE802.15.4 Extended Address as Interface Identifier). The new API is then used to implement the get handler for spinel property `IPV6_LL_ADDR` in `NcpBase` class.
This commit is contained in:
committed by
Jonathan Hui
parent
06bf90cef3
commit
9c09577d52
@@ -275,6 +275,17 @@ OTAPI const uint8_t *OTCALL otThreadGetMeshLocalPrefix(otInstance *aInstance);
|
||||
*/
|
||||
OTAPI otError OTCALL otThreadSetMeshLocalPrefix(otInstance *aInstance, const uint8_t *aMeshLocalPrefix);
|
||||
|
||||
/**
|
||||
* This function returns the Thread link-local IPv6 address.
|
||||
*
|
||||
* The Thread link local address is derived using IEEE802.15.4 Extended Address as Interface Identifier.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
* @returns A pointer to Thread link-local IPv6 address.
|
||||
*/
|
||||
const otIp6Address *otThreadGetLinkLocalIp6Address(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the Thread Network Name.
|
||||
*
|
||||
|
||||
@@ -195,6 +195,11 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
const otIp6Address *otThreadGetLinkLocalIp6Address(otInstance *aInstance)
|
||||
{
|
||||
return &aInstance->mThreadNetif.GetMle().GetLinkLocalAddress();
|
||||
}
|
||||
|
||||
const char *otThreadGetNetworkName(otInstance *aInstance)
|
||||
{
|
||||
return aInstance->mThreadNetif.GetMac().GetNetworkName();
|
||||
|
||||
@@ -675,6 +675,11 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
const Ip6::Address &Mle::GetLinkLocalAddress(void) const
|
||||
{
|
||||
return mLinkLocal64.GetAddress();
|
||||
}
|
||||
|
||||
otError Mle::UpdateLinkLocalAddress(void)
|
||||
{
|
||||
mNetif.RemoveUnicastAddress(mLinkLocal64);
|
||||
|
||||
@@ -650,6 +650,16 @@ public:
|
||||
*/
|
||||
otError SetMeshLocalPrefix(const uint8_t *aPrefix);
|
||||
|
||||
/**
|
||||
* This method returns a reference to the Thread link-local address.
|
||||
*
|
||||
* The Thread link local address is derived using IEEE802.15.4 Extended Address as Interface Identifier.
|
||||
*
|
||||
* @returns A reference to the Thread link local address.
|
||||
*
|
||||
*/
|
||||
const Ip6::Address &GetLinkLocalAddress(void) const;
|
||||
|
||||
/**
|
||||
* This method updates the link local address.
|
||||
*
|
||||
|
||||
+23
-3
@@ -3131,10 +3131,30 @@ otError NcpBase::GetPropertyHandler_IPV6_ML_ADDR(uint8_t header, spinel_prop_key
|
||||
|
||||
otError NcpBase::GetPropertyHandler_IPV6_LL_ADDR(uint8_t header, spinel_prop_key_t key)
|
||||
{
|
||||
// TODO!
|
||||
(void)key;
|
||||
otError errorCode = OT_ERROR_NONE;
|
||||
const otIp6Address *address = otThreadGetLinkLocalIp6Address(mInstance);
|
||||
|
||||
return SendLastStatus(header, SPINEL_STATUS_UNIMPLEMENTED);
|
||||
if (address)
|
||||
{
|
||||
errorCode = SendPropertyUpdate(
|
||||
header,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
key,
|
||||
SPINEL_DATATYPE_IPv6ADDR_S,
|
||||
address
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorCode = SendPropertyUpdate(
|
||||
header,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
key,
|
||||
SPINEL_DATATYPE_VOID_S
|
||||
);
|
||||
}
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
otError NcpBase::GetPropertyHandler_IPV6_ADDRESS_TABLE(uint8_t header, spinel_prop_key_t key)
|
||||
|
||||
Reference in New Issue
Block a user