From ad9da1b51afde36b5973e414c0f0e39ff117808c Mon Sep 17 00:00:00 2001 From: whd <7058128+superwhd@users.noreply.github.com> Date: Tue, 5 Dec 2023 14:58:23 +0800 Subject: [posix] expose `platformInfraIfIsRunning()` as `otSysInfraIfIsRunning()` (#9672) When we are switching to another infra netif via `otBorderRoutingInit()`, we may want to read the state of the new infra netif via `otSysInfraIfIsRunning()`. (cherry picked from commit 11622a1b4a9eccf03627e776c98c32dcac8748b7) Change-Id: I00faebe02a7fa47e418db82124737c7e1a0a693b --- src/posix/platform/include/openthread/openthread-system.h | 8 ++++++++ src/posix/platform/infra_if.cpp | 6 +++--- src/posix/platform/platform-posix.h | 8 -------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/posix/platform/include/openthread/openthread-system.h b/src/posix/platform/include/openthread/openthread-system.h index 29dc3ee80..61a07410f 100644 --- a/src/posix/platform/include/openthread/openthread-system.h +++ b/src/posix/platform/include/openthread/openthread-system.h @@ -246,6 +246,14 @@ void otSysCountInfraNetifAddresses(otSysInfraNetIfAddressCounters *aAddressCount */ void otSysSetInfraNetif(const char *aInfraNetifName, int aIcmp6Socket); +/** + * Returns TRUE if the infrastructure interface is running. + * + * @returns TRUE if the infrastructure interface is running, FALSE if not. + * + */ +bool otSysInfraIfIsRunning(void); + #ifdef __cplusplus } // end of extern "C" #endif diff --git a/src/posix/platform/infra_if.cpp b/src/posix/platform/infra_if.cpp index 626d12822..6e16b3f7f 100644 --- a/src/posix/platform/infra_if.cpp +++ b/src/posix/platform/infra_if.cpp @@ -112,7 +112,7 @@ otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex) #endif } -bool platformInfraIfIsRunning(void) { return ot::Posix::InfraNetif::Get().IsRunning(); } +bool otSysInfraIfIsRunning(void) { return ot::Posix::InfraNetif::Get().IsRunning(); } const char *otSysGetInfraNetifName(void) { return ot::Posix::InfraNetif::Get().GetNetifName(); } @@ -452,7 +452,7 @@ void InfraNetif::SetUp(void) VerifyOrExit(mNetLinkSocket != -1); #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE - SuccessOrDie(otBorderRoutingInit(gInstance, mInfraIfIndex, platformInfraIfIsRunning())); + SuccessOrDie(otBorderRoutingInit(gInstance, mInfraIfIndex, otSysInfraIfIsRunning())); SuccessOrDie(otBorderRoutingSetEnabled(gInstance, /* aEnabled */ true)); #endif @@ -546,7 +546,7 @@ void InfraNetif::ReceiveNetLinkMessage(void) case RTM_NEWLINK: case RTM_DELLINK: #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE - SuccessOrDie(otPlatInfraIfStateChanged(gInstance, mInfraIfIndex, platformInfraIfIsRunning())); + SuccessOrDie(otPlatInfraIfStateChanged(gInstance, mInfraIfIndex, otSysInfraIfIsRunning())); #endif break; case NLMSG_ERROR: diff --git a/src/posix/platform/platform-posix.h b/src/posix/platform/platform-posix.h index 0617bfc05..912ceb590 100644 --- a/src/posix/platform/platform-posix.h +++ b/src/posix/platform/platform-posix.h @@ -415,14 +415,6 @@ extern unsigned int gNetifIndex; */ extern otInstance *gInstance; -/** - * Tells if the infrastructure interface is running. - * - * @returns TRUE if the infrastructure interface is running, FALSE if not. - * - */ -bool platformInfraIfIsRunning(void); - /** * Initializes backtrace module. * -- cgit v1.2.3