From 6d0bce85a06b3aab8eea0cbc7d4531145b58feae Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 25 Jan 2019 08:37:59 -0800 Subject: [PATCH] [thread-netif] change Up()/Down() to void (no return) (#3513) --- include/openthread/ip6.h | 7 ++++--- src/core/api/ip6_api.cpp | 16 +++++++--------- src/core/thread/thread_netif.cpp | 8 ++++---- src/core/thread/thread_netif.hpp | 4 ++-- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/include/openthread/ip6.h b/include/openthread/ip6.h index f7cc2f292..30c4af758 100644 --- a/include/openthread/ip6.h +++ b/include/openthread/ip6.h @@ -183,15 +183,16 @@ typedef struct otMessageInfo } otMessageInfo; /** - * This function brings up the IPv6 interface. + * This function brings up/down the IPv6 interface. * * Call this function to enable/disable IPv6 communication. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aEnabled TRUE to enable IPv6, FALSE otherwise. * - * @retval OT_ERROR_NONE Successfully enabled the IPv6 interface, - * or the interface was already enabled. + * @retval OT_ERROR_NONE Successfully brought the IPv6 interface up/down. + * @retval OT_ERROR_INVALID_STATE IPv6 interface is not available since device is operating in raw-link mode + * (applicable only when `OPENTHREAD_ENABLE_RAW_LINK_API` feature is enabled). * */ OTAPI otError OTCALL otIp6SetEnabled(otInstance *aInstance, bool aEnabled); diff --git a/src/core/api/ip6_api.cpp b/src/core/api/ip6_api.cpp index 20720a622..32a5e93f6 100644 --- a/src/core/api/ip6_api.cpp +++ b/src/core/api/ip6_api.cpp @@ -48,24 +48,22 @@ otError otIp6SetEnabled(otInstance *aInstance, bool aEnabled) otError error = OT_ERROR_NONE; Instance &instance = *static_cast(aInstance); +#if OPENTHREAD_ENABLE_RAW_LINK_API + VerifyOrExit(!instance.GetLinkRaw().IsEnabled(), error = OT_ERROR_INVALID_STATE); +#endif + if (aEnabled) { -#if OPENTHREAD_ENABLE_RAW_LINK_API - VerifyOrExit(!instance.GetLinkRaw().IsEnabled(), error = OT_ERROR_INVALID_STATE); -#endif // OPENTHREAD_ENABLE_RAW_LINK_API - error = instance.GetThreadNetif().Up(); + instance.GetThreadNetif().Up(); } else { -#if OPENTHREAD_ENABLE_RAW_LINK_API - VerifyOrExit(!instance.GetLinkRaw().IsEnabled(), error = OT_ERROR_INVALID_STATE); -#endif // OPENTHREAD_ENABLE_RAW_LINK_API - error = instance.GetThreadNetif().Down(); + instance.GetThreadNetif().Down(); } #if OPENTHREAD_ENABLE_RAW_LINK_API exit: -#endif // OPENTHREAD_ENABLE_RAW_LINK_API +#endif return error; } diff --git a/src/core/thread/thread_netif.cpp b/src/core/thread/thread_netif.cpp index 3f9164412..cf228c529 100644 --- a/src/core/thread/thread_netif.cpp +++ b/src/core/thread/thread_netif.cpp @@ -113,7 +113,7 @@ ThreadNetif::ThreadNetif(Instance &aInstance) memset(mSlaacAddresses, 0, sizeof(mSlaacAddresses)); } -otError ThreadNetif::Up(void) +void ThreadNetif::Up(void) { VerifyOrExit(!mIsUp); @@ -139,10 +139,10 @@ otError ThreadNetif::Up(void) GetNotifier().Signal(OT_CHANGED_THREAD_NETIF_STATE); exit: - return OT_ERROR_NONE; + return; } -otError ThreadNetif::Down(void) +void ThreadNetif::Down(void) { VerifyOrExit(mIsUp); @@ -171,7 +171,7 @@ otError ThreadNetif::Down(void) GetNotifier().Signal(OT_CHANGED_THREAD_NETIF_STATE); exit: - return OT_ERROR_NONE; + return; } otError ThreadNetif::GetLinkAddress(Ip6::LinkAddress &address) const diff --git a/src/core/thread/thread_netif.hpp b/src/core/thread/thread_netif.hpp index 90fa3176d..62f514b48 100644 --- a/src/core/thread/thread_netif.hpp +++ b/src/core/thread/thread_netif.hpp @@ -109,13 +109,13 @@ public: * This method enables the Thread network interface. * */ - otError Up(void); + void Up(void); /** * This method disables the Thread network interface. * */ - otError Down(void); + void Down(void); /** * This method indicates whether or not the Thread network interface is enabled.