mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 23:27:46 +00:00
[ncp] add border routing InfraIf recv ICMP6 ND (#10755)
In this commit, a new spinel property `SPINEL_PROP_INFRA_IF_RECV_ICMP6_ND` is added for the host to pass the ICMP6 ND messages to the NCP.
This commit is contained in:
@@ -4753,6 +4753,16 @@ enum
|
||||
*/
|
||||
SPINEL_PROP_INFRA_IF_STATE = SPINEL_PROP_INFRA_IF__BEGIN + 1,
|
||||
|
||||
/// Received ICMPv6 packet on the infrastructure interface.
|
||||
/** Format: `L6d`
|
||||
* Type: Write-only
|
||||
*
|
||||
* `L`: The infrastructure interface index.
|
||||
* `6`: The IP6 source address of the ICMPv6 packet.
|
||||
* `d`: The data of the ICMPv6 packet. The host MUST ensure the hoplimit is 255.
|
||||
*/
|
||||
SPINEL_PROP_INFRA_IF_RECV_ICMP6 = SPINEL_PROP_INFRA_IF__BEGIN + 2,
|
||||
|
||||
SPINEL_PROP_INFRA_IF__END = 0x920,
|
||||
|
||||
SPINEL_PROP_NEST__BEGIN = 0x3BC0,
|
||||
|
||||
@@ -739,7 +739,7 @@ protected:
|
||||
|
||||
uint64_t mLogTimestampBase; // Timestamp base used for logging
|
||||
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
otError InfraIfAddAddress(const otIp6Address &aAddress);
|
||||
bool InfraIfContainsAddress(const otIp6Address &aAddress);
|
||||
|
||||
|
||||
@@ -515,8 +515,9 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
#if OPENTHREAD_RADIO && OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_MULTIPAN_ACTIVE_INTERFACE),
|
||||
#endif
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_INFRA_IF_STATE),
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_INFRA_IF_RECV_ICMP6),
|
||||
#endif
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_UNSOL_UPDATE_FILTER),
|
||||
|
||||
@@ -1403,7 +1403,7 @@ exit:
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
|
||||
#if OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE
|
||||
#if OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_INFRA_IF_STATE>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -1438,6 +1438,26 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_INFRA_IF_RECV_ICMP6>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t infraIfIndex;
|
||||
const otIp6Address *address;
|
||||
const uint8_t *icmp6Data = nullptr;
|
||||
uint16_t len;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadUint32(infraIfIndex));
|
||||
VerifyOrExit(mInfraIfIndex == infraIfIndex, error = OT_ERROR_DROP);
|
||||
SuccessOrExit(error = mDecoder.ReadIp6Address(address));
|
||||
SuccessOrExit(error = mDecoder.ReadData(icmp6Data, len));
|
||||
|
||||
// Currently the ICMP6 messages can only be ND messages.
|
||||
otPlatInfraIfRecvIcmp6Nd(mInstance, infraIfIndex, address, icmp6Data, len);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError NcpBase::InfraIfAddAddress(const otIp6Address &aAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -1468,7 +1488,7 @@ bool NcpBase::InfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAdd
|
||||
return aInfraIfIndex == mInfraIfIndex && InfraIfContainsAddress(*aAddress);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE
|
||||
#endif // OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
|
||||
} // namespace Ncp
|
||||
} // namespace ot
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "ncp/ncp_base.hpp"
|
||||
|
||||
#if OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddress)
|
||||
{
|
||||
return ot::Ncp::NcpBase::GetNcpInstance()->InfraIfHasAddress(aInfraIfIndex, aAddress);
|
||||
@@ -56,4 +56,4 @@ otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex)
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE
|
||||
#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
|
||||
Reference in New Issue
Block a user