From d1cb89cede4ffb67061ab96ab6a1a7ef9b3ce009 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 12 Feb 2025 10:29:49 -0800 Subject: [PATCH] [routing-manager] map `otBorderRoutingDhcp6PdState` to core type (#11240) This commit updates `otBorderRoutingDhcp6PdState` to be properly mapped using `DefineMapEnum()` to its related core-internal `enum` definition. This avoids the use of `static_cast` for conversion and ensures only associated `enum` types can be mapped to each other. --- src/core/api/border_routing_api.cpp | 3 +-- src/core/border_router/routing_manager.cpp | 2 +- src/core/border_router/routing_manager.hpp | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/api/border_routing_api.cpp b/src/core/api/border_routing_api.cpp index 388d1f29f..306c9c282 100644 --- a/src/core/api/border_routing_api.cpp +++ b/src/core/api/border_routing_api.cpp @@ -221,8 +221,7 @@ void otBorderRoutingDhcp6PdSetEnabled(otInstance *aInstance, bool aEnabled) otBorderRoutingDhcp6PdState otBorderRoutingDhcp6PdGetState(otInstance *aInstance) { - return static_cast( - AsCoreType(aInstance).Get().GetDhcp6PdState()); + return MapEnum(AsCoreType(aInstance).Get().GetDhcp6PdState()); } void otBorderRoutingDhcp6PdSetRequestCallback(otInstance *aInstance, diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp index da6cba55f..3461f429f 100644 --- a/src/core/border_router/routing_manager.cpp +++ b/src/core/border_router/routing_manager.cpp @@ -4034,7 +4034,7 @@ void RoutingManager::PdPrefixManager::EvaluateStateChange(Dhcp6PdState aOldState // manager will refuse to request the prefix. // TODO: Either update the comment for the state callback or add a random delay when notifing the upper layer for // state change. - mStateCallback.InvokeIfSet(static_cast(newState)); + mStateCallback.InvokeIfSet(MapEnum(newState)); exit: return; diff --git a/src/core/border_router/routing_manager.hpp b/src/core/border_router/routing_manager.hpp index 4d275cda5..9b98032be 100644 --- a/src/core/border_router/routing_manager.hpp +++ b/src/core/border_router/routing_manager.hpp @@ -1640,6 +1640,7 @@ template <> void RoutingManager::RxRaTracker::Entry