Add new CAPIs and unittest to get/set ND DNS for onmesh 84/276684/1
authorhyunuk.tak <hyunuk.tak@samsung.com>
Mon, 20 Jun 2022 02:43:49 +0000 (11:43 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Thu, 23 Jun 2022 02:24:55 +0000 (11:24 +0900)
Change-Id: I5ed3bd189c5e091052dcd6c635ffe3ced74d412c
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
include/thread.h
src/thread-br.c
tests/unittest/thread-unittest-br.cpp

index d56eea3..2b58b2f 100644 (file)
@@ -979,6 +979,44 @@ int thread_onmesh_prefix_set_default_route(thread_onmesh_prefix_info_h onmesh_pr
 
 /**
  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Get ND DNS 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_nd_dns(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool *is_nd_dns);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Set ND DNS 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_nd_dns(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool is_nd_dns);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
  * @brief Get on-mesh prefixes to the network
  * @since_tizen 7.0
  *
index ecc0fa1..dae44cf 100644 (file)
@@ -882,6 +882,38 @@ int thread_onmesh_prefix_get_stable(thread_onmesh_prefix_info_h onmesh_prefix,
        return THREAD_ERROR_NONE;
 }
 
+int thread_onmesh_prefix_get_nd_dns(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool *is_nd_dns)
+{
+       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_nd_dns = onmesh_prefix_info->is_nd_dns;
+
+       FUNC_EXIT;
+       return THREAD_ERROR_NONE;
+}
+
+int thread_onmesh_prefix_set_nd_dns(thread_onmesh_prefix_info_h onmesh_prefix,
+       bool is_nd_dns)
+{
+       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_nd_dns = is_nd_dns;
+
+       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 c53251b..54033cf 100644 (file)
@@ -47,6 +47,7 @@ public:
        bool defaultRoute;
        bool onMesh;
        bool stable;
+       bool ndDns;
 
        thread_instance_h instance;
        thread_route_info_h routeInfo;
@@ -529,6 +530,26 @@ TEST_F(ThreadBRTest, BRGetOnmeshStableErrorNone)
                thread_onmesh_prefix_get_stable(onmeshPrefix, &stable));
 }
 
+TEST_F(ThreadBRTest, BRSetOnmeshNdDnsErrorNone)
+{
+       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_nd_dns(onmeshPrefix, ndDns));
+}
+
+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_nd_dns(onmeshPrefix, ndDns));
+       EXPECT_EQ(THREAD_ERROR_NONE,
+               thread_onmesh_prefix_get_nd_dns(onmeshPrefix, &ndDns));
+}
+
 TEST_F(ThreadBRTest, BRAddOnmeshPrefixNotInitialized)
 {
        EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize());