Add a new CAPI and test for thread_br_get_device_nexthop 68/276668/1
authorhyunuk.tak <hyunuk.tak@samsung.com>
Mon, 30 May 2022 08:03:36 +0000 (17:03 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Thu, 23 Jun 2022 02:21:54 +0000 (11:21 +0900)
Change-Id: I22568521b1c4b31af8e2652d135118b34d5d5a3d
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
include/thread.h
src/thread-br.c
tests/unittest/thread-unittest-br.cpp

index 614ce06..83e67ce 100644 (file)
@@ -564,6 +564,24 @@ int thread_br_get_stable(thread_route_info_h route,
 
 /**
  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
+ * @brief Get device next hop 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_device_nexthop(thread_route_info_h route,
+       bool *is_device_nexthop);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
  * @brief Add an external border routing rule to the network.
  * @since_tizen 7.0
  *
index 3305252..c8fb303 100644 (file)
@@ -343,6 +343,22 @@ int thread_br_get_stable(thread_route_info_h route,
        return THREAD_ERROR_NONE;
 }
 
+int thread_br_get_device_nexthop(thread_route_info_h route,
+       bool *is_device_nexthop)
+{
+       FUNC_ENTRY;
+       THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
+       THREAD_CHECK_INIT_STATUS();
+       THREAD_VALIDATE_INPUT_PARAMETER(route);
+       THREAD_VALIDATE_INPUT_PARAMETER(is_device_nexthop);
+
+       thread_route_info_s *route_info = (thread_route_info_s*)route;
+       *is_device_nexthop = route_info->is_nexthop_this_device;
+
+       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 bcd451d..93789b0 100644 (file)
@@ -28,6 +28,7 @@ public:
                kRloc16,
                kPreference,
                kStable,
+               kDeviceNexthop,
        };
 
        uint8_t ipv6Prefix[THREAD_IPV6_PREFIX_SIZE];
@@ -83,6 +84,12 @@ public:
                                        EXPECT_EQ(THREAD_ERROR_NONE, thread_br_get_stable(route_info, &isStable));
                                }
                                break;
+                       case RouteInfo::kDeviceNexthop:
+                               {
+                                       bool isDeviceNexthop;
+                                       EXPECT_EQ(THREAD_ERROR_NONE, thread_br_get_device_nexthop(route_info, &isDeviceNexthop));
+                               }
+                               break;
                        default:
                                break;
                        }
@@ -239,6 +246,15 @@ TEST_F(ThreadBRTest, BRGetStableErrorNone)
                GUINT_TO_POINTER(static_cast<guint>(RouteInfo::kStable))));
 }
 
+TEST_F(ThreadBRTest, BRGetDeviceNexthopErrorNone)
+{
+       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::kDeviceNexthop))));
+}
+
 TEST_F(ThreadBRTest, BRAddExternalRouteNotInitialized)
 {
        EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize());