Skip to content

Commit

Permalink
[posix] add a flag to turn posix multicast routing feature on/off (#9412
Browse files Browse the repository at this point in the history
)

This commit adds a separate flag to be able to turn the posix part of
multicast routing implementation off/on.

The new
OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE flag
guards the feature of posix multicast routing using MFC(multicast
forwarding cache) in MRT(multicast routing table).

The existing
OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE continues
to guard the core multicast routing feature, for example handling the
MLR.req message and the multicast listeners table.

In a system where it has its own multicast routing support for packet
forwarding between Thread network and AIL, it should set
OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE to 0.
  • Loading branch information
sunytt authored Sep 14, 2023
1 parent df010bc commit 8ed949e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/posix/platform/backbone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

char gBackboneNetifName[IFNAMSIZ] = "";
unsigned int gBackboneNetifIndex = 0;
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#if OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
static ot::Posix::MulticastRoutingManager sMulticastRoutingManager;
#endif

Expand All @@ -69,14 +69,14 @@ void platformBackboneInit(const char *aInterfaceName)

void platformBackboneSetUp(void)
{
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#if OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
sMulticastRoutingManager.SetUp();
#endif
}

void platformBackboneTearDown(void)
{
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#if OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
sMulticastRoutingManager.TearDown();
#endif
}
Expand All @@ -93,7 +93,7 @@ void platformBackboneStateChange(otInstance *aInstance, otChangedFlags aFlags)
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aFlags);

#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#if OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
sMulticastRoutingManager.HandleStateChange(aInstance, aFlags);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/posix/platform/multicast_routing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "posix/platform/multicast_routing.hpp"

#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#if OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE

#include <assert.h>
#include <net/if.h>
Expand Down Expand Up @@ -615,4 +615,4 @@ void MulticastRoutingManager::RemoveMulticastForwardingCache(
} // namespace Posix
} // namespace ot

#endif // OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#endif // OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
4 changes: 2 additions & 2 deletions src/posix/platform/multicast_routing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "openthread-posix-config.h"

#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#if OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -140,6 +140,6 @@ class MulticastRoutingManager : public Mainloop::Source, private NonCopyable
} // namespace Posix
} // namespace ot

#endif // OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#endif // OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE

#endif // OT_POSIX_PLATFORM_MULTICAST_ROUTING_HPP_
17 changes: 17 additions & 0 deletions src/posix/platform/openthread-posix-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@
#define OPENTHREAD_POSIX_CONFIG_MAX_MULTICAST_FORWARDING_CACHE_TABLE (OPENTHREAD_CONFIG_MAX_MULTICAST_LISTENERS * 10)
#endif

/**
* @def OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
*
* Define as 1 to enable multicast routing support.
*
*/
#ifndef OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#define OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE \
OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#endif

#if OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE && \
!OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
#error \
"OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE is required for OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE"
#endif

/**
* @def OPENTHREAD_POSIX_CONFIG_SECURE_SETTINGS_ENABLE
*
Expand Down

0 comments on commit 8ed949e

Please sign in to comment.