mirror of
https://github.com/espressif/openthread.git
synced 2026-07-08 13:20:25 +00:00
[cli] add command for getting the network interface name and index (#4985)
* add a CLI command for getting the network interface name and index
On some platform (mostly BSDs), we do not have the option to specify
the tunnel name, although most of those platforms do have a way to dynamically
obtain a unique interface name if desired. Add a CLI command -- only enabled
on platforms that have PLATFORM_NETIF enabled -- that will return the
name of the tunnel interface, as well as it's index. Both are useful in doing
automated tests on non-Linux systems.
* remove OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE from the "check" scripts
This option really only applies to the POSIX "management" applications
(ot-daemon, ot-ctl), and not to the core radio or simulation component
builds (ot-cli, etc).
My other change adds a command ("netif") that is only useful when the
netif code is enabled, and that only happens when the netif code is linked,
which is only in those "management" utilities. Turning this setting off
allows the tests to pass, with no impact to the functionality previously
tested. But if this setting remains on, then my new code creates a
dependency that cannot be resolved outside the management applications.
This commit is contained in:
@@ -63,6 +63,9 @@
|
||||
#include <openthread/icmp6.h>
|
||||
#include <openthread/logging.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||
#include <openthread/platform/misc.h>
|
||||
#endif
|
||||
|
||||
#include "common/new.hpp"
|
||||
#include "net/ip6.hpp"
|
||||
@@ -184,6 +187,9 @@ const struct Command Interpreter::sCommands[] = {
|
||||
{"netdataregister", &Interpreter::ProcessNetworkDataRegister},
|
||||
#endif
|
||||
{"netdatashow", &Interpreter::ProcessNetworkDataShow},
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||
{"netif", &Interpreter::ProcessNetif},
|
||||
#endif
|
||||
#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE
|
||||
{"networkdiagnostic", &Interpreter::ProcessNetworkDiagnostic},
|
||||
#endif // OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE
|
||||
@@ -1985,6 +1991,25 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
|
||||
void Interpreter::ProcessNetif(uint8_t aArgsLength, char *aArgs[])
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aArgsLength);
|
||||
OT_UNUSED_VARIABLE(aArgs);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
const char * netif = NULL;
|
||||
unsigned int netifidx = 0;
|
||||
|
||||
SuccessOrExit(error = otPlatGetNetif(mInstance, &netif, &netifidx));
|
||||
|
||||
mServer->OutputFormat("%s:%u\r\n", netif ? netif : "<NULL>", netifidx);
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
|
||||
void Interpreter::ProcessService(uint8_t aArgsLength, char *aArgs[])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user