diff --git a/src/posix/client.cpp b/src/posix/client.cpp index e57516e66..632e9c966 100644 --- a/src/posix/client.cpp +++ b/src/posix/client.cpp @@ -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; diff --git a/src/posix/main.c b/src/posix/main.c index 2966965e1..0f989dfb5 100644 --- a/src/posix/main.c +++ b/src/posix/main.c @@ -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 diff --git a/src/posix/platform/daemon.cpp b/src/posix/platform/daemon.cpp index 731b4f2b7..bb7b0d2dd 100644 --- a/src/posix/platform/daemon.cpp +++ b/src/posix/platform/daemon.cpp @@ -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(rval) >= sizeof(aFilename)) { DieNow(OT_EXIT_INVALID_ARGUMENTS); diff --git a/src/posix/platform/openthread-posix-config.h b/src/posix/platform/openthread-posix-config.h index 33ee49767..3b727c9fd 100644 --- a/src/posix/platform/openthread-posix-config.h +++ b/src/posix/platform/openthread-posix-config.h @@ -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__ /**