Add new CAPIs and unittestt to get/set DP for onmesh 85/276685/1
authorhyunuk.tak <hyunuk.tak@samsung.com>
Mon, 20 Jun 2022 02:47:09 +0000 (11:47 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Thu, 23 Jun 2022 02:25:03 +0000 (11:25 +0900)
Change-Id: Ide9fdf8fe7a97b5b38d0e3d3eff01301cd7153d4
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
include/thread.h
src/thread-br.c
tests/unittest/thread-unittest-br.cpp

index 2b58b2f..ba65271 100644 (file)
@@ -1017,6 +1017,44 @@ int thread_onmesh_prefix_set_nd_dns(thread_onmesh_prefix_info_h onmesh_prefix,
 
 /**
  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Get DP 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_dp(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool *is_dp);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Set DP 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_dp(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool is_dp);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
  * @brief Get on-mesh prefixes to the network
  * @since_tizen 7.0
  *
index dae44cf..b9e9dec 100644 (file)
@@ -914,6 +914,38 @@ int thread_onmesh_prefix_set_nd_dns(thread_onmesh_prefix_info_h onmesh_prefix,
        return THREAD_ERROR_NONE;
 }
 
+int thread_onmesh_prefix_get_dp(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool *is_dp)
+{
+       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;
+       *is_dp = onmesh_prefix_info->is_dp;
+
+       FUNC_EXIT;
+       return THREAD_ERROR_NONE;
+}
+
+int thread_onmesh_prefix_set_dp(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool is_dp)
+{
+       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->is_dp = is_dp;
+
+       FUNC_EXIT;
+       return THREAD_ERROR_NONE;
+}
+
 int thread_br_get_onmesh_prefixes(thread_instance_h instance,
        thread_onmesh_prefix_foreach_cb callback, void *user_data)
 {
index 54033cf..7cb6be7 100644 (file)
@@ -48,6 +48,7 @@ public:
        bool onMesh;
        bool stable;
        bool ndDns;
+       bool dp;
 
        thread_instance_h instance;
        thread_route_info_h routeInfo;
@@ -550,6 +551,26 @@ TEST_F(ThreadBRTest, BRGetOnmeshNdDnsErrorNone)
                thread_onmesh_prefix_get_nd_dns(onmeshPrefix, &ndDns));
 }
 
+TEST_F(ThreadBRTest, BRSetOnmeshDpErrorNone)
+{
+       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_dp(onmeshPrefix, dp));
+}
+
+TEST_F(ThreadBRTest, BRGetOnmeshNdDnsErrorNone)
+{
+       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_dp(onmeshPrefix, dp));
+       EXPECT_EQ(THREAD_ERROR_NONE,
+               thread_onmesh_prefix_get_dp(onmeshPrefix, &dp));
+}
+
 TEST_F(ThreadBRTest, BRAddOnmeshPrefixNotInitialized)
 {
        EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize());