[ncp] add border routing InfraIf send ICMP6 ND (#10793)

This commit is contained in:
Li Cao
2024-10-10 08:13:12 -07:00
committed by GitHub
parent 2dbaaa5cfd
commit ee851d2a62
4 changed files with 50 additions and 5 deletions
+10
View File
@@ -4763,6 +4763,16 @@ enum
*/
SPINEL_PROP_INFRA_IF_RECV_ICMP6 = SPINEL_PROP_INFRA_IF__BEGIN + 2,
/// ICMP6 message sent by NCP and needs to be sent on the infrastructure interface.
/** Format: `L6d`
* Type: Unsolicited notifications only
*
* `L`: The infrastructure interface index.
* `6`: The IP6 destination address of the message to send.
* `d`: The data of the message to send.
*/
SPINEL_PROP_INFRA_IF_SEND_ICMP6 = SPINEL_PROP_INFRA_IF__BEGIN + 3,
SPINEL_PROP_INFRA_IF__END = 0x920,
SPINEL_PROP_NEST__BEGIN = 0x3BC0,
+20
View File
@@ -224,6 +224,26 @@ public:
*/
bool InfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddress);
/**
* Send a ICMP6 ND message through the Infrastructure interface on the host.
*
* @param[in] aInfraIfIndex The index of the infrastructure interface this message is sent to.
* @param[in] aDestAddress The destination address this message is sent to.
* @param[in] aBuffer The ICMPv6 message buffer. The ICMPv6 checksum is left zero and the
* platform should do the checksum calculate.
* @param[in] aBufferLength The length of the message buffer.
*
* @note Per RFC 4861, the implementation should send the message with IPv6 link-local source address
* of interface @p aInfraIfIndex and IP Hop Limit 255.
*
* @retval OT_ERROR_NONE Successfully sent the ICMPv6 message.
* @retval OT_ERROR_FAILED Failed to send the ICMPv6 message.
*/
otError InfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
const otIp6Address *aDestAddress,
const uint8_t *aBuffer,
uint16_t aBufferLength);
protected:
static constexpr uint8_t kBitsPerByte = 8; ///< Number of bits in a byte.
+18
View File
@@ -1488,6 +1488,24 @@ bool NcpBase::InfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAdd
return aInfraIfIndex == mInfraIfIndex && InfraIfContainsAddress(*aAddress);
}
otError NcpBase::InfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
const otIp6Address *aDestAddress,
const uint8_t *aBuffer,
uint16_t aBufferLength)
{
otError error = OT_ERROR_NONE;
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
SuccessOrExit(error = mEncoder.BeginFrame(header, SPINEL_CMD_PROP_VALUE_IS, SPINEL_PROP_INFRA_IF_SEND_ICMP6));
SuccessOrExit(error = mEncoder.WriteUint32(aInfraIfIndex));
SuccessOrExit(error = mEncoder.WriteIp6Address(*aDestAddress));
SuccessOrExit(error = mEncoder.WriteDataWithLen(aBuffer, aBufferLength));
SuccessOrExit(error = mEncoder.EndFrame());
exit:
return error;
}
#endif // OPENTHREAD_CONFIG_NCP_INFRA_IF_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
} // namespace Ncp
+2 -5
View File
@@ -41,12 +41,9 @@ otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
const uint8_t *aBuffer,
uint16_t aBufferLength)
{
OT_UNUSED_VARIABLE(aInfraIfIndex);
OT_UNUSED_VARIABLE(aDestAddress);
OT_UNUSED_VARIABLE(aBuffer);
OT_UNUSED_VARIABLE(aBufferLength);
ot::Ncp::NcpBase *ncp = ot::Ncp::NcpBase::GetNcpInstance();
return OT_ERROR_NOT_IMPLEMENTED;
return ncp->InfraIfSendIcmp6Nd(aInfraIfIndex, aDestAddress, aBuffer, aBufferLength);
}
otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex)