From: hyunuk.tak Date: Tue, 14 Jun 2022 23:13:57 +0000 (+0900) Subject: Add new CAPIs and unittest to set/get slaac for onmesh X-Git-Tag: accepted/tizen/unified/20220914.164046~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F76%2F276676%2F1;p=platform%2Fcore%2Fapi%2Fthread.git Add new CAPIs and unittest to set/get slaac for onmesh Change-Id: I32cad6c67d21bdb749856f0776cd52d28c9c5081 Signed-off-by: hyunuk.tak --- diff --git a/include/thread.h b/include/thread.h index a2c1aca..20bcf9a 100644 --- a/include/thread.h +++ b/include/thread.h @@ -751,6 +751,44 @@ int thread_onmesh_prefix_get_preferred(thread_onmesh_prefix_info_h onmesh_prefix /** * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE + * @brief Set slaac to on-mesh prefix info + * @since_tizen 7.0 + * + * @return 0 on success, otherwise a negative error value. + * @retval #THREAD_ERROR_NONE Successful + * @retval #THREAD_ERROR_NOT_INITIALIZED Not initialized + * @retval #THREAD_ERROR_OPERATION_FAILED Operation failed + * @retval #THREAD_ERROR_NOT_SUPPORTED Not supported + * + * @pre thread API must be initialized with thread_initialize(). + * + * @see thread_onmesh_prefix_create() + * @see thread_onmesh_prefix_destroy() + */ +int thread_onmesh_prefix_set_slaac(thread_onmesh_prefix_info_h onmesh_prefix, + bool slaac); + +/** + * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE + * @brief Get slaac to on-mesh prefix info + * @since_tizen 7.0 + * + * @return 0 on success, otherwise a negative error value. + * @retval #THREAD_ERROR_NONE Successful + * @retval #THREAD_ERROR_NOT_INITIALIZED Not initialized + * @retval #THREAD_ERROR_OPERATION_FAILED Operation failed + * @retval #THREAD_ERROR_NOT_SUPPORTED Not supported + * + * @pre thread API must be initialized with thread_initialize(). + * + * @see thread_onmesh_prefix_create() + * @see thread_onmesh_prefix_destroy() + */ +int thread_onmesh_prefix_get_slaac(thread_onmesh_prefix_info_h onmesh_prefix, + bool *slaac); + +/** + * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE * @brief Add an on-mesh prefix to the network * @since_tizen 7.0 * diff --git a/src/thread-br.c b/src/thread-br.c index cc2f9d9..fe341e7 100644 --- a/src/thread-br.c +++ b/src/thread-br.c @@ -598,6 +598,38 @@ int thread_onmesh_prefix_get_preferred(thread_onmesh_prefix_info_h onmesh_prefix return THREAD_ERROR_NONE; } +int thread_onmesh_prefix_set_slaac(thread_onmesh_prefix_info_h onmesh_prefix, + bool slaac) +{ + FUNC_ENTRY; + THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON); + THREAD_CHECK_INIT_STATUS(); + THREAD_VALIDATE_INPUT_PARAMETER(onmesh_prefix); + + thread_onmesh_prefix_info_s *onmesh_prefix_info = + (thread_onmesh_prefix_info_s *)onmesh_prefix; + onmesh_prefix_info->slaac = slaac; + + FUNC_EXIT; + return THREAD_ERROR_NONE; +} + +int thread_onmesh_prefix_get_slaac(thread_onmesh_prefix_info_h onmesh_prefix, + bool *slaac) +{ + FUNC_ENTRY; + THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON); + THREAD_CHECK_INIT_STATUS(); + THREAD_VALIDATE_INPUT_PARAMETER(onmesh_prefix); + + thread_onmesh_prefix_info_s *onmesh_prefix_info = + (thread_onmesh_prefix_info_s *)onmesh_prefix; + *slaac = onmesh_prefix_info->slaac; + + FUNC_EXIT; + return THREAD_ERROR_NONE; +} + int thread_br_add_onmesh_prefix(thread_instance_h instance, const uint8_t *ipv6_prefix, int ipv6_prefix_len, int8_t preference, bool preferred, bool slaac, bool dhcp, bool configure, bool default_route, diff --git a/tests/unittest/thread-unittest-br.cpp b/tests/unittest/thread-unittest-br.cpp index 4f94f11..e5ea49a 100644 --- a/tests/unittest/thread-unittest-br.cpp +++ b/tests/unittest/thread-unittest-br.cpp @@ -418,6 +418,26 @@ TEST_F(ThreadBRTest, BRGetOnmeshPreferredErrorNone) thread_onmesh_prefix_get_preferred(onmeshPrefix, &preferred)); } +TEST_F(ThreadBRTest, BRSetOnmeshSlaacErrorNone) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance)); + EXPECT_EQ(THREAD_ERROR_NONE, + thread_onmesh_prefix_create(instance, &onmeshPrefix)); + EXPECT_EQ(THREAD_ERROR_NONE, + thread_onmesh_prefix_set_slaac(onmeshPrefix, slaac)); +} + +TEST_F(ThreadBRTest, BRGetOnmeshSlaacErrorNone) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance)); + EXPECT_EQ(THREAD_ERROR_NONE, + thread_onmesh_prefix_create(instance, &onmeshPrefix)); + EXPECT_EQ(THREAD_ERROR_NONE, + thread_onmesh_prefix_set_slaac(onmeshPrefix, slaac)); + EXPECT_EQ(THREAD_ERROR_NONE, + thread_onmesh_prefix_get_slaac(onmeshPrefix, &slaac)); +} + TEST_F(ThreadBRTest, BRAddOnmeshPrefixNotEnabled) { EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));