* @see thread_onmesh_prefix_destroy()
*/
int thread_onmesh_prefix_set_preferred(thread_onmesh_prefix_info_h onmesh_prefix,
- bool preferred);
+ bool is_preferred);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
* @see thread_onmesh_prefix_destroy()
*/
int thread_onmesh_prefix_get_preferred(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *preferred);
+ bool *is_preferred);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
* @see thread_onmesh_prefix_destroy()
*/
int thread_onmesh_prefix_set_slaac(thread_onmesh_prefix_info_h onmesh_prefix,
- bool slaac);
+ bool is_slaac);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
* @see thread_onmesh_prefix_destroy()
*/
int thread_onmesh_prefix_get_slaac(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *slaac);
+ bool *is_slaac);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
* @see thread_onmesh_prefix_destroy()
*/
int thread_onmesh_prefix_set_dhcp(thread_onmesh_prefix_info_h onmesh_prefix,
- bool dhcp);
+ bool is_dhcp);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
* @see thread_onmesh_prefix_destroy()
*/
int thread_onmesh_prefix_get_dhcp(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *dhcp);
+ bool *is_dhcp);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
* @see thread_onmesh_prefix_destroy()
*/
int thread_onmesh_prefix_set_configure(thread_onmesh_prefix_info_h onmesh_prefix,
- bool configure);
+ bool is_configure);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
* @see thread_onmesh_prefix_destroy()
*/
int thread_onmesh_prefix_get_configure(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *configure);
+ bool *is_configure);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
- * @brief Set default route to on-mesh prefix info
+ * @brief Get on mesh to on-mesh prefix info
* @since_tizen 7.0
*
* @return 0 on success, otherwise a negative error value.
* @see thread_onmesh_prefix_create()
* @see thread_onmesh_prefix_destroy()
*/
-int thread_onmesh_prefix_set_default_route(thread_onmesh_prefix_info_h onmesh_prefix,
- bool default_route);
+int thread_onmesh_prefix_get_on_mesh(thread_onmesh_prefix_info_h onmesh_prefix,
+ bool *is_on_mesh);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
- * @brief Get on mesh to on-mesh prefix info
+ * @brief Set on mesh to on-mesh prefix info
* @since_tizen 7.0
*
* @return 0 on success, otherwise a negative error value.
* @see thread_onmesh_prefix_create()
* @see thread_onmesh_prefix_destroy()
*/
-int thread_onmesh_prefix_get_on_mesh(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *on_mesh);
+int thread_onmesh_prefix_set_on_mesh(thread_onmesh_prefix_info_h onmesh_prefix,
+ bool is_on_mesh);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
- * @brief Set on mesh to on-mesh prefix info
+ * @brief Get stable to on-mesh prefix info
* @since_tizen 7.0
*
* @return 0 on success, otherwise a negative error value.
* @see thread_onmesh_prefix_create()
* @see thread_onmesh_prefix_destroy()
*/
-int thread_onmesh_prefix_set_on_mesh(thread_onmesh_prefix_info_h onmesh_prefix,
- bool on_mesh);
+int thread_onmesh_prefix_get_stable(thread_onmesh_prefix_info_h onmesh_prefix,
+ bool *is_stable);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
- * @brief Get stable to on-mesh prefix info
+ * @brief Set stable to on-mesh prefix info
* @since_tizen 7.0
*
* @return 0 on success, otherwise a negative error value.
* @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);
+int thread_onmesh_prefix_set_stable(thread_onmesh_prefix_info_h onmesh_prefix,
+ bool is_stable);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
- * @brief Set stable to on-mesh prefix info
+ * @brief Get default route to on-mesh prefix info
* @since_tizen 7.0
*
* @return 0 on success, otherwise a negative error value.
* @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);
+int thread_onmesh_prefix_get_default_route(thread_onmesh_prefix_info_h onmesh_prefix,
+ bool *is_default_route);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
- * @brief Get default route to on-mesh prefix info
+ * @brief Set default route to on-mesh prefix info
* @since_tizen 7.0
*
* @return 0 on success, otherwise a negative error value.
* @see thread_onmesh_prefix_create()
* @see thread_onmesh_prefix_destroy()
*/
-int thread_onmesh_prefix_get_default_route(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *default_route);
+int thread_onmesh_prefix_set_default_route(thread_onmesh_prefix_info_h onmesh_prefix,
+ bool is_default_route);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Get on-mesh prefixes to the network
+ * @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_add_onmesh_prefix()
+ * @see thread_remove_onmesh_prefix()
+ */
+int thread_br_get_onmesh_prefixes(thread_instance_h instance,
+ thread_onmesh_prefix_foreach_cb callback, void *user_data);
/**
* @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
return new_onmesh_prefix;
}
+static int __thread_br_get_onmesh_prefix_cb(GVariant *val,
+ thread_onmesh_prefix_foreach_cb callback,
+ thread_instance_s* instance, void *user_data)
+{
+ FUNC_ENTRY;
+ THREAD_VALIDATE_INPUT_PARAMETER(callback);
+ THREAD_VALIDATE_INPUT_PARAMETER(instance);
+
+ GVariantIter iter;
+ uint8_t *prefix_address = NULL;
+ uint8_t prefix_len = 0;
+ uint16_t rloc = 0;
+ uint8_t preference = 0;
+ bool is_preferred = FALSE;
+ bool is_slaac = FALSE;
+ bool is_dhcp = FALSE;
+ bool is_configure = FALSE;
+ bool is_default_route = FALSE;
+ bool is_on_mesh = FALSE;
+ bool is_stable = FALSE;
+ bool is_nd_dns = FALSE;
+ bool is_dp = FALSE;
+ int count = 0;
+ thread_instance_s *current_instance = instance;
+
+ THREAD_DBG("Process callback for get onmesh prefix info");
+ g_variant_iter_init(&iter, val);
+
+ while (g_variant_iter_next(&iter, "((ayy)qybbbbbbbbb)",
+ &prefix_address, &prefix_len, &rloc, &preference,
+ &is_preferred, &is_slaac, &is_dhcp, &is_configure,
+ &is_default_route, &is_on_mesh, &is_stable,
+ &is_nd_dns, &is_dp)) {
+
+ thread_onmesh_prefix_info_s *onmesh_prefix_info =
+ _create_new_onmesh_prefix();
+ if (!onmesh_prefix_info)
+ break;
+
+ THREAD_DBG("Got the onmesh prefix...");
+
+ THREAD_DBG("prefix_address: %02x%02x:%02x%02x:%02x%02x:%02x%02x",
+ prefix_address[0], prefix_address[1], prefix_address[2],
+ prefix_address[3], prefix_address[4], prefix_address[5],
+ prefix_address[6], prefix_address[7]);
+
+ THREAD_DBG("prefix_len: %u", prefix_len);
+ THREAD_DBG("rloc: %u", rloc);
+ THREAD_DBG("preference: %u", preference);
+ THREAD_DBG("preferred: %s", is_preferred ? "TRUE" : "FALSE");
+ THREAD_DBG("slaac: %s", is_slaac ? "TRUE" : "FALSE");
+ THREAD_DBG("dhcp: %s", is_dhcp ? "TRUE" : "FALSE");
+ THREAD_DBG("configure: %s", is_configure ? "TRUE" : "FALSE");
+ THREAD_DBG("default_route: %s", is_default_route ? "TRUE" : "FALSE");
+ THREAD_DBG("on_mesh: %s", is_on_mesh ? "TRUE" : "FALSE");
+ THREAD_DBG("stable: %s", is_stable ? "TRUE" : "FALSE");
+ THREAD_DBG("nd_dns: %s", is_nd_dns ? "TRUE" : "FALSE");
+ THREAD_DBG("dp: %s", is_dp ? "TRUE" : "FALSE");
+
+ memcpy((onmesh_prefix_info->prefix).ipv6.fields.m8, prefix_address,
+ THREAD_IPV6_PREFIX_SIZE*sizeof(uint8_t));
+ (onmesh_prefix_info->prefix).length = prefix_len;
+ onmesh_prefix_info->preference = preference;
+ onmesh_prefix_info->is_preferred = is_preferred;
+ onmesh_prefix_info->is_slaac = is_slaac;
+ onmesh_prefix_info->is_dhcp = is_dhcp;
+ onmesh_prefix_info->is_configure = is_configure;
+ onmesh_prefix_info->is_default_route = is_default_route;
+ onmesh_prefix_info->is_on_mesh = is_on_mesh;
+ onmesh_prefix_info->is_stable = is_stable;
+ onmesh_prefix_info->is_nd_dns = is_nd_dns;
+ onmesh_prefix_info->is_dp = is_dp;
+
+ current_instance->onmesh_prefix_list = g_slist_append(
+ current_instance->onmesh_prefix_list,
+ onmesh_prefix_info);
+
+ if (callback)
+ (callback)(++count, (thread_onmesh_prefix_info_h)onmesh_prefix_info,
+ user_data);
+
+ current_instance->onmesh_prefix_list = g_slist_remove(
+ current_instance->onmesh_prefix_list,
+ onmesh_prefix_info);
+ g_free(onmesh_prefix_info);
+ }
+ THREAD_DBG("Exiting __thread_br_get_onmesh_prefix_cb ...");
+
+ FUNC_EXIT;
+ return THREAD_ERROR_NONE;
+}
+
static int __thread_br_get_external_route_cb(GVariant *val,
thread_external_route_foreach_cb callback,
thread_instance_s* instance, void *user_data)
}
int thread_onmesh_prefix_set_preferred(thread_onmesh_prefix_info_h onmesh_prefix,
- bool preferred)
+ bool is_preferred)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- onmesh_prefix_info->preferred = preferred;
+ onmesh_prefix_info->is_preferred = is_preferred;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_get_preferred(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *preferred)
+ bool *is_preferred)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- *preferred = onmesh_prefix_info->preferred;
+ *is_preferred = onmesh_prefix_info->is_preferred;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_set_slaac(thread_onmesh_prefix_info_h onmesh_prefix,
- bool slaac)
+ bool is_slaac)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- onmesh_prefix_info->slaac = slaac;
+ onmesh_prefix_info->is_slaac = is_slaac;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_get_slaac(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *slaac)
+ bool *is_slaac)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- *slaac = onmesh_prefix_info->slaac;
+ *is_slaac = onmesh_prefix_info->is_slaac;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_set_dhcp(thread_onmesh_prefix_info_h onmesh_prefix,
- bool dhcp)
+ bool is_dhcp)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- onmesh_prefix_info->dhcp = dhcp;
+ onmesh_prefix_info->is_dhcp = is_dhcp;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_get_dhcp(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *dhcp)
+ bool *is_dhcp)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- *dhcp = onmesh_prefix_info->dhcp;
+ *is_dhcp = onmesh_prefix_info->is_dhcp;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_set_configure(thread_onmesh_prefix_info_h onmesh_prefix,
- bool configure)
+ bool is_configure)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- onmesh_prefix_info->configure = configure;
+ onmesh_prefix_info->is_configure = is_configure;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_get_configure(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *configure)
+ bool *is_configure)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- *configure = onmesh_prefix_info->configure;
+ *is_configure = onmesh_prefix_info->is_configure;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_set_default_route(thread_onmesh_prefix_info_h onmesh_prefix,
- bool default_route)
+ bool is_default_route)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- onmesh_prefix_info->default_route = default_route;
+ onmesh_prefix_info->is_default_route = is_default_route;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_get_default_route(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *default_route)
+ bool *is_default_route)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- *default_route = onmesh_prefix_info->default_route;
+ *is_default_route = onmesh_prefix_info->is_default_route;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_set_on_mesh(thread_onmesh_prefix_info_h onmesh_prefix,
- bool on_mesh)
+ bool is_on_mesh)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- onmesh_prefix_info->on_mesh = on_mesh;
+ onmesh_prefix_info->is_on_mesh = is_on_mesh;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_get_on_mesh(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *on_mesh)
+ bool *is_on_mesh)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- *on_mesh = onmesh_prefix_info->on_mesh;
+ *is_on_mesh = onmesh_prefix_info->is_on_mesh;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_set_stable(thread_onmesh_prefix_info_h onmesh_prefix,
- bool stable)
+ bool is_stable)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- onmesh_prefix_info->stable = stable;
+ onmesh_prefix_info->is_stable = is_stable;
FUNC_EXIT;
return THREAD_ERROR_NONE;
}
int thread_onmesh_prefix_get_stable(thread_onmesh_prefix_info_h onmesh_prefix,
- bool *stable)
+ bool *is_stable)
{
FUNC_ENTRY;
THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
thread_onmesh_prefix_info_s *onmesh_prefix_info =
(thread_onmesh_prefix_info_s *)onmesh_prefix;
- *stable = onmesh_prefix_info->stable;
+ *is_stable = onmesh_prefix_info->is_stable;
+
+ 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)
+{
+ FUNC_ENTRY;
+ THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
+ THREAD_CHECK_INIT_STATUS();
+ THREAD_VALIDATE_INPUT_PARAMETER(instance);
+ THREAD_VALIDATE_INPUT_PARAMETER(callback);
+
+ thread_instance_s *current_instance = instance;
+ retv_if(!current_instance->is_br_enabled, THREAD_ERROR_NOT_ENABLED);
+
+ int ret = THREAD_ERROR_NONE;
+ GVariant *out = NULL;
+
+ ret = _thread_dbus_get_property(
+ THREAD_DBUS_PROPERTY_ON_MESH_PREFIXES, &out);
+ retv_if(ret != THREAD_ERROR_NONE, ret);
+
+ __thread_br_get_onmesh_prefix_cb(out, callback,
+ current_instance, user_data);
+
+ g_variant_unref(out);
+ THREAD_DBG("Freed out...");
FUNC_EXIT;
return THREAD_ERROR_NONE;
else if (onmesh_prefix_info->preference == 2)
strncat(msg, " high ", 7);
- if (onmesh_prefix_info->preferred)
+ if (onmesh_prefix_info->is_preferred)
strncat(msg, "p", 2);
- if (onmesh_prefix_info->slaac)
+ if (onmesh_prefix_info->is_slaac)
strncat(msg, "a", 2);
- if (onmesh_prefix_info->configure)
+ if (onmesh_prefix_info->is_configure)
strncat(msg, "c", 2);
- if (onmesh_prefix_info->default_route)
+ if (onmesh_prefix_info->is_default_route)
strncat(msg, "r", 2);
- if (onmesh_prefix_info->on_mesh)
+ if (onmesh_prefix_info->is_on_mesh)
strncat(msg, "o", 2);
- if (onmesh_prefix_info->stable)
+ if (onmesh_prefix_info->is_stable)
strncat(msg, "s", 2);
THREAD_DBG("DEBUG: BORDER ROUTER MESSAGE -> [%s]", msg);
thread_onmesh_prefix_info_h onmeshPrefix;
public:
+ static bool GetOnmeshPrefixesCallback(int total,
+ thread_onmesh_prefix_info_h onmesh_prefix_info, void *user_data)
+ {
+ return true;
+ };
+
static bool GetExternalRoutesCallback(int total,
thread_route_info_h route_info, void *user_data)
- {
- RouteInfo routeInfo = static_cast<RouteInfo>(GPOINTER_TO_UINT(user_data));
-
- switch (routeInfo) {
- case RouteInfo::kIpv6Prefix:
- {
- uint8_t ipv6Prefix[THREAD_IPV6_ADDRESS_SIZE];
- uint8_t ipv6PrefixLen;
- EXPECT_EQ(THREAD_ERROR_NONE, thread_br_get_ipv6_prefix(route_info, ipv6Prefix, &ipv6PrefixLen));
- }
- break;
- case RouteInfo::kRloc16:
- {
- uint16_t rloc16;
- EXPECT_EQ(THREAD_ERROR_NONE, thread_br_get_rloc16(route_info, &rloc16));
- }
- break;
- case RouteInfo::kPreference:
- {
- int8_t preference;
- EXPECT_EQ(THREAD_ERROR_NONE, thread_br_get_preference(route_info, &preference));
- }
- break;
- case RouteInfo::kStable:
- {
- bool isStable;
- EXPECT_EQ(THREAD_ERROR_NONE, thread_br_check_stable(route_info, &isStable));
- }
- break;
- case RouteInfo::kDeviceNexthop:
- {
- bool isDeviceNexthop;
- EXPECT_EQ(THREAD_ERROR_NONE, thread_br_check_device_nexthop(route_info, &isDeviceNexthop));
- }
- break;
- default:
- break;
+ {
+ RouteInfo routeInfo = static_cast<RouteInfo>(GPOINTER_TO_UINT(user_data));
+
+ switch (routeInfo) {
+ case RouteInfo::kIpv6Prefix:
+ {
+ uint8_t ipv6Prefix[THREAD_IPV6_ADDRESS_SIZE];
+ uint8_t ipv6PrefixLen;
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_br_get_ipv6_prefix(route_info, ipv6Prefix, &ipv6PrefixLen));
+ }
+ break;
+ case RouteInfo::kRloc16:
+ {
+ uint16_t rloc16;
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_br_get_rloc16(route_info, &rloc16));
+ }
+ break;
+ case RouteInfo::kPreference:
+ {
+ int8_t preference;
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_br_get_preference(route_info, &preference));
+ }
+ break;
+ case RouteInfo::kStable:
+ {
+ bool isStable;
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_br_check_stable(route_info, &isStable));
}
+ break;
+ case RouteInfo::kDeviceNexthop:
+ {
+ bool isDeviceNexthop;
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_br_check_device_nexthop(route_info, &isDeviceNexthop));
+ }
+ break;
+ default:
+ break;
+ }
- return true;
- };
+ return true;
+ };
protected:
void SetUp() override
thread_br_add_onmesh_prefix(instance, onmeshPrefix));
}
+TEST_F(ThreadBRTest, BRGetOnmeshPrefixesNotInitialized)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize());
+ EXPECT_EQ(THREAD_ERROR_NOT_INITIALIZED,
+ thread_br_get_onmesh_prefixes(instance,
+ GetOnmeshPrefixesCallback, nullptr));
+}
+
+TEST_F(ThreadBRTest, BRGetOnmeshPrefixesInvalidParameter)
+{
+ EXPECT_EQ(THREAD_ERROR_INVALID_PARAMETER,
+ thread_br_get_onmesh_prefixes(instance,
+ GetOnmeshPrefixesCallback, nullptr));
+}
+
+TEST_F(ThreadBRTest, BRGetOnmeshPrefixesNotEnabled)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));
+ EXPECT_EQ(THREAD_ERROR_NOT_ENABLED,
+ thread_br_get_onmesh_prefixes(instance,
+ GetOnmeshPrefixesCallback, nullptr));
+}
+
+TEST_F(ThreadBRTest, BRGetOnmeshPrefixesErrorNone)
+{
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance));
+ EXPECT_EQ(THREAD_ERROR_NONE, thread_br_enable(instance));
+ EXPECT_EQ(THREAD_ERROR_NONE,
+ thread_br_get_onmesh_prefixes(instance,
+ GetOnmeshPrefixesCallback, nullptr));
+}
+
TEST_F(ThreadBRTest, BRRemoveOnmeshPrefixNotInitialized)
{
EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize());