From 430b47b62f21f41191eec1e2bb61937004761844 Mon Sep 17 00:00:00 2001 From: Li Cao Date: Thu, 2 Oct 2025 03:41:21 +0800 Subject: [PATCH] [spinel] add udp port to the epskc state property (#11975) This commit adds a field UDP port in the property SPINEL_PROP_BORDER_AGENT_EPHEMERAL_KEY_STATE. Similar as `SPINEL_PROP_BORDER_AGENT_MESHCOP_SERVICE_STATE`, NCP needs to sync the UDP port number to the host as well so that the UDP proxy on the host can correctly map the port and forward the UDP packet to the NCP. I missed the field in the previous commit. But since the spinel property was just added recently and it hasn't been put into usage, I think it's fine to change the existing spinel protocol. --- src/lib/spinel/spinel.h | 4 +++- src/ncp/ncp_base_ftd.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/spinel/spinel.h b/src/lib/spinel/spinel.h index 72e06bbdc..821244d15 100644 --- a/src/lib/spinel/spinel.h +++ b/src/lib/spinel/spinel.h @@ -4913,9 +4913,11 @@ enum /// Border Agent Ephemeral Key State. /** - * Format: `C` - Get and Unsolicited notifications. + * Format: `CS` - Get and Unsolicited notifications. * * `C`: The Ephemeral Key state. The value corresponds to `otBorderAgentEphemeralKeyState`. + * `S`: The UDP port that is being used by the ephemeral key. If the state is 'Disabled' or 'Stopped' , the port + * MUST be 0. */ SPINEL_PROP_BORDER_AGENT_EPHEMERAL_KEY_STATE = SPINEL_PROP_BORDER_AGENT__BEGIN + 2, diff --git a/src/ncp/ncp_base_ftd.cpp b/src/ncp/ncp_base_ftd.cpp index 84298a181..0fba6ecf5 100644 --- a/src/ncp/ncp_base_ftd.cpp +++ b/src/ncp/ncp_base_ftd.cpp @@ -1748,7 +1748,13 @@ exit: template <> otError NcpBase::HandlePropertyGet(void) { - return mEncoder.WriteUint8(static_cast(otBorderAgentEphemeralKeyGetState(mInstance))); + otError error = OT_ERROR_NONE; + + SuccessOrExit(error = mEncoder.WriteUint8(static_cast(otBorderAgentEphemeralKeyGetState(mInstance)))); + SuccessOrExit(error = mEncoder.WriteUint16(otBorderAgentEphemeralKeyGetUdpPort(mInstance))); + +exit: + return error; } #endif