[cli] update SNTP and Diagnostic CLI commands (#12870)

This commit fixes the CLI implementation of `sntp` and `diagnostic`
commands by ensuring they use the public `otMessageInfo` type instead
of the internal `ot::Ip6::MessageInfo` class.
This commit is contained in:
Abtin Keshavarzian
2026-04-12 21:39:55 -05:00
committed by GitHub
parent 32ade1684b
commit 1ddfe45402
2 changed files with 15 additions and 15 deletions
+14 -14
View File
@@ -6355,10 +6355,10 @@ template <> otError Interpreter::Process<Cmd("singleton")>(Arg aArgs[])
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
template <> otError Interpreter::Process<Cmd("sntp")>(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
uint16_t port = OT_SNTP_DEFAULT_SERVER_PORT;
Ip6::MessageInfo messageInfo;
otSntpQuery query;
otError error = OT_ERROR_NONE;
uint16_t port = OT_SNTP_DEFAULT_SERVER_PORT;
otMessageInfo messageInfo;
otSntpQuery query;
/**
* @cli sntp query
@@ -6384,14 +6384,16 @@ template <> otError Interpreter::Process<Cmd("sntp")>(Arg aArgs[])
{
VerifyOrExit(!mSntpQueryingInProgress, error = OT_ERROR_BUSY);
ClearAllBytes(messageInfo);
if (!aArgs[1].IsEmpty())
{
SuccessOrExit(error = aArgs[1].ParseAsIp6Address(messageInfo.GetPeerAddr()));
SuccessOrExit(error = aArgs[1].ParseAsIp6Address(messageInfo.mPeerAddr));
}
else
{
// Use IPv6 address of default SNTP server.
SuccessOrExit(error = messageInfo.GetPeerAddr().FromString(OT_SNTP_DEFAULT_SERVER_IP));
SuccessOrExit(error = otIp6AddressFromString(OT_SNTP_DEFAULT_SERVER_IP, &messageInfo.mPeerAddr));
}
if (!aArgs[2].IsEmpty())
@@ -6399,9 +6401,8 @@ template <> otError Interpreter::Process<Cmd("sntp")>(Arg aArgs[])
SuccessOrExit(error = aArgs[2].ParseAsUint16(port));
}
messageInfo.SetPeerPort(port);
query.mMessageInfo = static_cast<const otMessageInfo *>(&messageInfo);
messageInfo.mPeerPort = port;
query.mMessageInfo = &messageInfo;
SuccessOrExit(error = otSntpClientQuery(GetInstancePtr(), &query, &Interpreter::HandleSntpResponse, this));
@@ -7790,13 +7791,12 @@ void Interpreter::HandleDiagnosticGetResponse(otError aError,
const otMessageInfo *aMessageInfo,
void *aContext)
{
static_cast<Interpreter *>(aContext)->HandleDiagnosticGetResponse(
aError, aMessage, static_cast<const Ip6::MessageInfo *>(aMessageInfo));
static_cast<Interpreter *>(aContext)->HandleDiagnosticGetResponse(aError, aMessage, aMessageInfo);
}
void Interpreter::HandleDiagnosticGetResponse(otError aError,
const otMessage *aMessage,
const Ip6::MessageInfo *aMessageInfo)
void Interpreter::HandleDiagnosticGetResponse(otError aError,
const otMessage *aMessage,
const otMessageInfo *aMessageInfo)
{
uint8_t buf[16];
uint16_t bytesToPrint;
+1 -1
View File
@@ -260,7 +260,7 @@ private:
static void HandleLinkPcapReceive(const otRadioFrame *aFrame, bool aIsTx, void *aContext);
#if OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE
void HandleDiagnosticGetResponse(otError aError, const otMessage *aMessage, const Ip6::MessageInfo *aMessageInfo);
void HandleDiagnosticGetResponse(otError aError, const otMessage *aMessage, const otMessageInfo *aMessageInfo);
static void HandleDiagnosticGetResponse(otError aError,
otMessage *aMessage,
const otMessageInfo *aMessageInfo,