Add new CAPIs and unittest to set/get stable for onmesh 81/276681/1
authorhyunuk.tak <hyunuk.tak@samsung.com>
Wed, 15 Jun 2022 01:17:52 +0000 (10:17 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Thu, 23 Jun 2022 02:24:29 +0000 (11:24 +0900)
Change-Id: I9d177f6cf3759d6c49225c1832b116adfaf46c00
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
include/thread.h
src/thread-br.c
tests/unittest/thread-unittest-br.cpp

index ce93b68..65ac690 100644 (file)
@@ -922,6 +922,44 @@ int thread_onmesh_prefix_set_on_mesh(thread_onmesh_prefix_info_h onmesh_prefix,
 
 /**
  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Get stable 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_stable(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool *stable);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Set stable 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_stable(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool stable);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
  * @brief Get default route to on-mesh prefix info
  * @since_tizen 7.0
  *
index 8d06d93..ca5e108 100644 (file)
@@ -758,6 +758,38 @@ int thread_onmesh_prefix_get_on_mesh(thread_onmesh_prefix_info_h onmesh_prefix,
        return THREAD_ERROR_NONE;
 }
 
+int thread_onmesh_prefix_set_stable(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool stable)
+{
+       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->stable = stable;
+
+       FUNC_EXIT;
+       return THREAD_ERROR_NONE;
+}
+
+int thread_onmesh_prefix_get_stable(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool *stable)
+{
+       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;
+       *stable = onmesh_prefix_info->stable;
+
+       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,
index 5b6afb0..cc88dd2 100644 (file)
@@ -518,6 +518,26 @@ TEST_F(ThreadBRTest, BRGetOnmeshOnMeshErrorNone)
                thread_onmesh_prefix_get_on_mesh(onmeshPrefix, &onMesh));
 }
 
+TEST_F(ThreadBRTest, BRSetOnmeshStableErrorNone)
+{
+       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_stable(onmeshPrefix, stable));
+}
+
+TEST_F(ThreadBRTest, BRGetOnmeshStableErrorNone)
+{
+       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_stable(onmeshPrefix, stable));
+       EXPECT_EQ(THREAD_ERROR_NONE,
+               thread_onmesh_prefix_get_stable(onmeshPrefix, &stable));
+}
+
 TEST_F(ThreadBRTest, BRAddOnmeshPrefixNotEnabled)
 {
        EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));