mirror of
https://github.com/espressif/openthread.git
synced 2026-09-13 20:50:05 +00:00
[cli] add OutputSockAddr() method (#7121)
This commit is contained in:
+2
-3
@@ -1536,9 +1536,8 @@ otError Interpreter::ProcessDns(Arg aArgs[])
|
|||||||
{
|
{
|
||||||
const otDnsQueryConfig *defaultConfig = otDnsClientGetDefaultConfig(GetInstancePtr());
|
const otDnsQueryConfig *defaultConfig = otDnsClientGetDefaultConfig(GetInstancePtr());
|
||||||
|
|
||||||
OutputFormat("Server: [");
|
OutputFormat("Server: ");
|
||||||
OutputIp6Address(defaultConfig->mServerSockAddr.mAddress);
|
OutputSockAddrLine(defaultConfig->mServerSockAddr);
|
||||||
OutputLine("]:%d", defaultConfig->mServerSockAddr.mPort);
|
|
||||||
OutputLine("ResponseTimeout: %u ms", defaultConfig->mResponseTimeout);
|
OutputLine("ResponseTimeout: %u ms", defaultConfig->mResponseTimeout);
|
||||||
OutputLine("MaxTxAttempts: %u", defaultConfig->mMaxTxAttempts);
|
OutputLine("MaxTxAttempts: %u", defaultConfig->mMaxTxAttempts);
|
||||||
OutputLine("RecursionDesired: %s",
|
OutputLine("RecursionDesired: %s",
|
||||||
|
|||||||
@@ -542,7 +542,6 @@ void History::OutputRxTxEntryListFormat(const otHistoryTrackerMessageInfo &aInfo
|
|||||||
constexpr uint8_t kIndentSize = 4;
|
constexpr uint8_t kIndentSize = 4;
|
||||||
|
|
||||||
char ageString[OT_HISTORY_TRACKER_ENTRY_AGE_STRING_SIZE];
|
char ageString[OT_HISTORY_TRACKER_ENTRY_AGE_STRING_SIZE];
|
||||||
char addrString[OT_IP6_SOCK_ADDR_STRING_SIZE];
|
|
||||||
|
|
||||||
otHistoryTrackerEntryAgeToString(aEntryAge, ageString, sizeof(ageString));
|
otHistoryTrackerEntryAgeToString(aEntryAge, ageString, sizeof(ageString));
|
||||||
|
|
||||||
@@ -561,11 +560,11 @@ void History::OutputRxTxEntryListFormat(const otHistoryTrackerMessageInfo &aInfo
|
|||||||
|
|
||||||
OutputLine(" %s:0x%04x radio:%s", aIsRx ? "from" : "to", aInfo.mNeighborRloc16, RadioTypeToString(aInfo));
|
OutputLine(" %s:0x%04x radio:%s", aIsRx ? "from" : "to", aInfo.mNeighborRloc16, RadioTypeToString(aInfo));
|
||||||
|
|
||||||
otIp6SockAddrToString(&aInfo.mSource, addrString, sizeof(addrString));
|
OutputFormat(kIndentSize, "src:");
|
||||||
OutputLine(kIndentSize, "src:%s", addrString);
|
OutputSockAddrLine(aInfo.mSource);
|
||||||
|
|
||||||
otIp6SockAddrToString(&aInfo.mDestination, addrString, sizeof(addrString));
|
OutputFormat(kIndentSize, "dst:");
|
||||||
OutputLine(kIndentSize, "dst:%s", addrString);
|
OutputSockAddrLine(aInfo.mDestination);
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::OutputRxTxEntryTableFormat(const otHistoryTrackerMessageInfo &aInfo, uint32_t aEntryAge, bool aIsRx)
|
void History::OutputRxTxEntryTableFormat(const otHistoryTrackerMessageInfo &aInfo, uint32_t aEntryAge, bool aIsRx)
|
||||||
|
|||||||
@@ -174,6 +174,21 @@ void Output::OutputIp6PrefixLine(const otIp6NetworkPrefix &aPrefix)
|
|||||||
OutputLine("");
|
OutputLine("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Output::OutputSockAddr(const otSockAddr &aSockAddr)
|
||||||
|
{
|
||||||
|
char string[OT_IP6_SOCK_ADDR_STRING_SIZE];
|
||||||
|
|
||||||
|
otIp6SockAddrToString(&aSockAddr, string, sizeof(string));
|
||||||
|
|
||||||
|
return OutputFormat("%s", string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Output::OutputSockAddrLine(const otSockAddr &aSockAddr)
|
||||||
|
{
|
||||||
|
OutputSockAddr(aSockAddr);
|
||||||
|
OutputLine("");
|
||||||
|
}
|
||||||
|
|
||||||
void Output::OutputDnsTxtData(const uint8_t *aTxtData, uint16_t aTxtDataLength)
|
void Output::OutputDnsTxtData(const uint8_t *aTxtData, uint16_t aTxtDataLength)
|
||||||
{
|
{
|
||||||
otDnsTxtEntry entry;
|
otDnsTxtEntry entry;
|
||||||
|
|||||||
@@ -239,6 +239,22 @@ public:
|
|||||||
*/
|
*/
|
||||||
void OutputIp6PrefixLine(const otIp6NetworkPrefix &aPrefix);
|
void OutputIp6PrefixLine(const otIp6NetworkPrefix &aPrefix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method outputs an IPv6 socket address to the CLI console.
|
||||||
|
*
|
||||||
|
* @param[in] aSockAddr A reference to the IPv6 socket address.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void OutputSockAddr(const otSockAddr &aSockAddr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method outputs an IPv6 socket address to the CLI console and at the end it also outputs newline "\r\n".
|
||||||
|
*
|
||||||
|
* @param[in] aSockAddr A reference to the IPv6 socket address.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void OutputSockAddrLine(const otSockAddr &aSockAddr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method outputs DNS TXT data to the CLI console.
|
* This method outputs DNS TXT data to the CLI console.
|
||||||
*
|
*
|
||||||
@@ -375,6 +391,8 @@ protected:
|
|||||||
void OutputIp6PrefixLine(const otIp6Prefix &aPrefix) { mOutput.OutputIp6PrefixLine(aPrefix); }
|
void OutputIp6PrefixLine(const otIp6Prefix &aPrefix) { mOutput.OutputIp6PrefixLine(aPrefix); }
|
||||||
void OutputIp6Prefix(const otIp6NetworkPrefix &aPrefix) { mOutput.OutputIp6Prefix(aPrefix); }
|
void OutputIp6Prefix(const otIp6NetworkPrefix &aPrefix) { mOutput.OutputIp6Prefix(aPrefix); }
|
||||||
void OutputIp6PrefixLine(const otIp6NetworkPrefix &aPrefix) { mOutput.OutputIp6PrefixLine(aPrefix); }
|
void OutputIp6PrefixLine(const otIp6NetworkPrefix &aPrefix) { mOutput.OutputIp6PrefixLine(aPrefix); }
|
||||||
|
void OutputSockAddr(const otSockAddr &aSockAddr) { mOutput.OutputSockAddr(aSockAddr); }
|
||||||
|
void OutputSockAddrLine(const otSockAddr &aSockAddr) { mOutput.OutputSockAddrLine(aSockAddr); }
|
||||||
void OutputDnsTxtData(const uint8_t *aTxtData, uint16_t aTxtDataLength)
|
void OutputDnsTxtData(const uint8_t *aTxtData, uint16_t aTxtDataLength)
|
||||||
{
|
{
|
||||||
mOutput.OutputDnsTxtData(aTxtData, aTxtDataLength);
|
mOutput.OutputDnsTxtData(aTxtData, aTxtDataLength);
|
||||||
|
|||||||
@@ -285,10 +285,7 @@ otError SrpClient::ProcessServer(Arg aArgs[])
|
|||||||
|
|
||||||
if (aArgs[0].IsEmpty())
|
if (aArgs[0].IsEmpty())
|
||||||
{
|
{
|
||||||
char string[OT_IP6_SOCK_ADDR_STRING_SIZE];
|
OutputSockAddrLine(*serverSockAddr);
|
||||||
|
|
||||||
otIp6SockAddrToString(serverSockAddr, string, sizeof(string));
|
|
||||||
OutputLine(string);
|
|
||||||
ExitNow();
|
ExitNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-7
@@ -475,7 +475,7 @@ void TcpExample::HandleTcpDisconnected(otTcpEndpoint *aEndpoint, otTcpDisconnect
|
|||||||
mEndpointConnected = false;
|
mEndpointConnected = false;
|
||||||
mSendBusy = false;
|
mSendBusy = false;
|
||||||
|
|
||||||
// Mark the benchmark as inactive if the connction was disconnected.
|
// Mark the benchmark as inactive if the connection was disconnected.
|
||||||
if (mBenchmarkBytesTotal != 0)
|
if (mBenchmarkBytesTotal != 0)
|
||||||
{
|
{
|
||||||
mBenchmarkBytesTotal = 0;
|
mBenchmarkBytesTotal = 0;
|
||||||
@@ -491,9 +491,9 @@ otTcpIncomingConnectionAction TcpExample::HandleTcpAcceptReady(otTcpListener *
|
|||||||
|
|
||||||
if (mEndpointConnected)
|
if (mEndpointConnected)
|
||||||
{
|
{
|
||||||
OutputFormat("TCP: Ignoring incoming connection request from [");
|
OutputFormat("TCP: Ignoring incoming connection request from ");
|
||||||
OutputIp6Address(aPeer->mAddress);
|
OutputSockAddr(*aPeer);
|
||||||
OutputLine("]:%u (active socket is busy)", static_cast<unsigned int>(aPeer->mPort));
|
OutputLine(" (active socket is busy)");
|
||||||
|
|
||||||
return OT_TCP_INCOMING_CONNECTION_ACTION_DEFER;
|
return OT_TCP_INCOMING_CONNECTION_ACTION_DEFER;
|
||||||
}
|
}
|
||||||
@@ -507,9 +507,8 @@ void TcpExample::HandleTcpAcceptDone(otTcpListener *aListener, otTcpEndpoint *aE
|
|||||||
OT_UNUSED_VARIABLE(aListener);
|
OT_UNUSED_VARIABLE(aListener);
|
||||||
OT_UNUSED_VARIABLE(aEndpoint);
|
OT_UNUSED_VARIABLE(aEndpoint);
|
||||||
|
|
||||||
OutputFormat("Accepted connection from [");
|
OutputFormat("Accepted connection from ");
|
||||||
OutputIp6Address(aPeer->mAddress);
|
OutputSockAddrLine(*aPeer);
|
||||||
OutputLine("]:%u", static_cast<unsigned int>(aPeer->mPort));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Cli
|
} // namespace Cli
|
||||||
|
|||||||
Reference in New Issue
Block a user