Add a new CAPI and test for thread_br_get_stable 67/276667/1
authorhyunuk.tak <hyunuk.tak@samsung.com>
Mon, 30 May 2022 07:57:05 +0000 (16:57 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Thu, 23 Jun 2022 02:21:38 +0000 (11:21 +0900)
Change-Id: I43ffe8efbb6f509f7e4dbadb770cc08b5d26d2df
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
include/thread.h
src/thread-br.c
tests/unittest/thread-unittest-br.cpp

index 97f6204e86d6ce94645055653e9aae6676dfb021..614ce06e2b51bbf4993d1cf2ff8b9e01e79f9dc7 100644 (file)
@@ -544,6 +544,24 @@ int thread_br_get_rloc16(thread_route_info_h route,
 int thread_br_get_preference(thread_route_info_h route,
        int8_t *preference);
 
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Get stable for route
+ * @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_external_route_foreach_cb()
+ */
+int thread_br_get_stable(thread_route_info_h route,
+       bool *is_stable);
+
 /**
  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
  * @brief Add an external border routing rule to the network.
index 8d8b87de01d6d1e5f2f69fe406f960ae05cb9355..3305252d935d90d3a227dfa7dfd1bb1a480f3ccd 100644 (file)
@@ -327,6 +327,22 @@ int thread_br_get_preference(thread_route_info_h route,
        return THREAD_ERROR_NONE;
 }
 
+int thread_br_get_stable(thread_route_info_h route,
+       bool *is_stable)
+{
+       FUNC_ENTRY;
+       THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
+       THREAD_CHECK_INIT_STATUS();
+       THREAD_VALIDATE_INPUT_PARAMETER(route);
+       THREAD_VALIDATE_INPUT_PARAMETER(is_stable);
+
+       thread_route_info_s *route_info = (thread_route_info_s*)route;
+       *is_stable = route_info->is_stable;
+
+       FUNC_EXIT;
+       return THREAD_ERROR_NONE;
+}
+
 int thread_br_add_external_route(thread_instance_h instance,
        const uint8_t *ipv6_prefix, uint8_t ipv6_prefix_len,
        uint16_t rloc16, int8_t preference,
index bdf1c39d4f7563b2dca508c38c6e79ef040b235a..bcd451d44ee6718d7a3e5dee781182049832a45d 100644 (file)
@@ -27,6 +27,7 @@ public:
                kIpv6Prefix,
                kRloc16,
                kPreference,
+               kStable,
        };
 
        uint8_t ipv6Prefix[THREAD_IPV6_PREFIX_SIZE];
@@ -76,6 +77,12 @@ public:
                                        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_get_stable(route_info, &isStable));
+                               }
+                               break;
                        default:
                                break;
                        }
@@ -223,6 +230,15 @@ TEST_F(ThreadBRTest, BRGetPreferenceErrorNone)
                GUINT_TO_POINTER(static_cast<guint>(RouteInfo::kPreference))));
 }
 
+TEST_F(ThreadBRTest, BRGetStableErrorNone)
+{
+       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_external_routes(instance, GetExternalRoutesCallback,
+               GUINT_TO_POINTER(static_cast<guint>(RouteInfo::kStable))));
+}
+
 TEST_F(ThreadBRTest, BRAddExternalRouteNotInitialized)
 {
        EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize());