/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Create an 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_destroy()
+ */
+int thread_onmesh_prefix_create(thread_instance_h instance,
+ thread_onmesh_prefix_info_h *onmesh_prefix);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Destroy 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()
+ */
+int thread_onmesh_prefix_destroy(thread_instance_h instance,
+ thread_onmesh_prefix_info_h onmesh_prefix);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
* @brief Add an on-mesh prefix to the network
* @since_tizen 7.0
*
return THREAD_ERROR_NONE;
}
+int thread_onmesh_prefix_create(thread_instance_h instance,
+ thread_onmesh_prefix_info_h *onmesh_prefix)
+{
+ FUNC_ENTRY;
+ THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
+ THREAD_CHECK_INIT_STATUS();
+ THREAD_VALIDATE_INPUT_PARAMETER(instance);
+ THREAD_VALIDATE_INPUT_PARAMETER(onmesh_prefix);
+
+ thread_instance_s *current_instance = instance;
+ retv_if(!current_instance->is_br_enabled, THREAD_ERROR_NOT_ENABLED);
+
+ thread_onmesh_prefix_info_s* new_onmesh_prefix =
+ _create_new_onmesh_prefix();
+ retv_if (!new_onmesh_prefix, THREAD_ERROR_OUT_OF_MEMORY);
+
+ current_instance->onmesh_prefix_list = g_slist_append(
+ current_instance->onmesh_prefix_list,
+ new_onmesh_prefix);
+
+ *onmesh_prefix = (thread_onmesh_prefix_info_h)new_onmesh_prefix;
+
+ FUNC_EXIT;
+ return THREAD_ERROR_NONE;
+}
+
+int thread_onmesh_prefix_destroy(thread_instance_h instance,
+ thread_onmesh_prefix_info_h onmesh_prefix)
+{
+ FUNC_ENTRY;
+ THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
+ THREAD_CHECK_INIT_STATUS();
+ THREAD_VALIDATE_INPUT_PARAMETER(instance);
+ THREAD_VALIDATE_INPUT_PARAMETER(onmesh_prefix);
+
+ thread_instance_s *current_instance = instance;
+ retv_if(!current_instance->is_br_enabled, THREAD_ERROR_NOT_ENABLED);
+
+ if (g_slist_find(current_instance->onmesh_prefix_list, onmesh_prefix)) {
+ current_instance->onmesh_prefix_list = g_slist_remove(
+ current_instance->onmesh_prefix_list,
+ onmesh_prefix);
+ g_free(onmesh_prefix);
+ }
+
+ 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,
dhcp, configure, defaultRoute, onMesh, stable, &onmeshPrefix));
}
+TEST_F(ThreadBRTest, BRCreateOnmeshPrefixNotEnabled)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));
+ EXPECT_EQ(THREAD_ERROR_NOT_ENABLED,
+ thread_onmesh_prefix_create(instance, &onmeshPrefix));
+}
+
+TEST_F(ThreadBRTest, BRCreateOnmeshPrefixErrorNone)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_br_enable(instance));
+ EXPECT_EQ(THREAD_ERROR_NONE,
+ thread_onmesh_prefix_create(instance, &onmeshPrefix));
+}
+
+TEST_F(ThreadBRTest, BRDestroyOnmeshPrefixNotEnabled)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));
+ EXPECT_EQ(THREAD_ERROR_NOT_ENABLED,
+ thread_onmesh_prefix_destroy(instance, onmeshPrefix));
+}
+
+TEST_F(ThreadBRTest, BRDestroyOnmeshPrefixErrorNone)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_br_enable(instance));
+ EXPECT_EQ(THREAD_ERROR_NONE,
+ thread_onmesh_prefix_create(instance, &onmeshPrefix));
+ EXPECT_EQ(THREAD_ERROR_NONE,
+ thread_onmesh_prefix_destroy(instance, onmeshPrefix));
+}
+
TEST_F(ThreadBRTest, BRAddOnmeshPrefixNotEnabled)
{
EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));