mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 22:57:47 +00:00
[posix] add Thread network default interface name configuration (#9089)
The default Thread interface name `wpan0` has been occupied by other programs in Android. Thread network has to use other network interface name. Then users have to specify an interface name when they are using the command `ot-ctl`. It's very inconvenient. This commit adds a configuration for developers to set the default Thread interface name.
This commit is contained in:
@@ -238,7 +238,7 @@ static bool ShouldEscape(char aChar)
|
||||
|
||||
Config ParseArg(int &aArgCount, char **&aArgVector)
|
||||
{
|
||||
Config config = {"wpan0"};
|
||||
Config config = {OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME};
|
||||
|
||||
optind = 1;
|
||||
|
||||
|
||||
@@ -197,6 +197,7 @@ static void ParseArg(int aArgCount, char *aArgVector[], PosixConfig *aConfig)
|
||||
aConfig->mPlatformConfig.mPersistentInterface = false;
|
||||
aConfig->mPlatformConfig.mSpeedUpFactor = 1;
|
||||
aConfig->mLogLevel = OT_LOG_LEVEL_CRIT;
|
||||
aConfig->mPlatformConfig.mInterfaceName = OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME;
|
||||
#ifdef __linux__
|
||||
aConfig->mPlatformConfig.mRealTimeSignal = SIGRTMIN;
|
||||
#endif
|
||||
|
||||
@@ -60,9 +60,10 @@ typedef char(Filename)[sizeof(sockaddr_un::sun_path)];
|
||||
|
||||
void GetFilename(Filename &aFilename, const char *aPattern)
|
||||
{
|
||||
int rval;
|
||||
int rval;
|
||||
const char *netIfName = strlen(gNetifName) > 0 ? gNetifName : OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME;
|
||||
|
||||
rval = snprintf(aFilename, sizeof(aFilename), aPattern, gNetifName);
|
||||
rval = snprintf(aFilename, sizeof(aFilename), aPattern, netIfName);
|
||||
if (rval < 0 && static_cast<size_t>(rval) >= sizeof(aFilename))
|
||||
{
|
||||
DieNow(OT_EXIT_INVALID_ARGUMENTS);
|
||||
|
||||
@@ -252,6 +252,16 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME
|
||||
*
|
||||
* Define the Thread default network interface name.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME
|
||||
#define OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME "wpan0"
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user