From a4605e44ef1091af5f71fb116f8c62e45c555b97 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 13 Oct 2025 05:56:14 -0700 Subject: [PATCH] [border-router] conditionally compile NAT64 `InfrIf` methods (#12030) This change makes the NAT64-related method in `InfraIf` conditionally compiled based on the configuration `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE`. The methods `DiscoverNat64Prefix()`, `DiscoverNat64PrefixDone()`, and are now entirely excluded from the build when NAT64 border routing is disabled. --- src/core/border_router/infra_if.cpp | 18 ++++++++++-------- src/core/border_router/infra_if.hpp | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/core/border_router/infra_if.cpp b/src/core/border_router/infra_if.cpp index c01751c79..bc3fa7b25 100644 --- a/src/core/border_router/infra_if.cpp +++ b/src/core/border_router/infra_if.cpp @@ -106,29 +106,23 @@ exit: } } +#if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE + Error InfraIf::DiscoverNat64Prefix(void) const { OT_ASSERT(mInitialized); -#if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE return otPlatInfraIfDiscoverNat64Prefix(mIfIndex); -#else - return kErrorNotImplemented; -#endif } void InfraIf::DiscoverNat64PrefixDone(uint32_t aIfIndex, const Ip6::Prefix &aPrefix) { Error error = kErrorNone; - OT_UNUSED_VARIABLE(aPrefix); - VerifyOrExit(mInitialized && mIsRunning, error = kErrorInvalidState); VerifyOrExit(aIfIndex == mIfIndex, error = kErrorInvalidArgs); -#if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE Get().HandleDiscoverNat64PrefixDone(aPrefix); -#endif exit: if (error != kErrorNone) @@ -137,6 +131,8 @@ exit: } } +#endif // OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE + Error InfraIf::GetLinkLayerAddress(LinkLayerAddress &aLinkLayerAddress) { return otPlatGetInfraIfLinkLayerAddress(&GetInstance(), mIfIndex, &aLinkLayerAddress); @@ -233,7 +229,13 @@ extern "C" void otPlatInfraIfDiscoverNat64PrefixDone(otInstance *aInstanc uint32_t aInfraIfIndex, const otIp6Prefix *aIp6Prefix) { +#if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE AsCoreType(aInstance).Get().DiscoverNat64PrefixDone(aInfraIfIndex, AsCoreType(aIp6Prefix)); +#else + OT_UNUSED_VARIABLE(aInstance); + OT_UNUSED_VARIABLE(aInfraIfIndex); + OT_UNUSED_VARIABLE(aIp6Prefix); +#endif } #if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE diff --git a/src/core/border_router/infra_if.hpp b/src/core/border_router/infra_if.hpp index 9405eb311..bdc1a100c 100644 --- a/src/core/border_router/infra_if.hpp +++ b/src/core/border_router/infra_if.hpp @@ -171,6 +171,7 @@ public: */ void HandledReceived(uint32_t aIfIndex, const Ip6::Address &aSource, const Icmp6Packet &aPacket); +#if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE /** * Sends a request to discover the NAT64 prefix on the infrastructure interface. * @@ -188,6 +189,7 @@ public: * @param[in] aPrefix The NAT64 prefix on the infrastructure link. */ void DiscoverNat64PrefixDone(uint32_t aIfIndex, const Ip6::Prefix &aPrefix); +#endif #if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE