mirror of
https://github.com/espressif/openthread.git
synced 2026-10-01 21:37:39 +00:00
[ip6] add multicast forwarding restrictions to host (#9863)
On Android, the platform doesn't restrict link-local/mesh-local source addresses when forwarding multicast packets. For multicast packets sent from link-local/mesh-local address to scope larger than realm-local, set the hoplimit to 1 so the packet can be delivered to host, and will not be forwarded to infrastructure link. The feature is guarded by OPENTHREAD_CONFIG_IP6_RESTRICT_FORWARDING_LARGER_SCOPE_MCAST_WITH_LOCAL_SRC, set as 1 to enable.
This commit is contained in:
@@ -227,6 +227,16 @@
|
|||||||
#define OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
#define OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def OPENTHREAD_CONFIG_IP6_RESTRICT_FORWARDING_LARGER_SCOPE_MCAST_WITH_LOCAL_SRC
|
||||||
|
*
|
||||||
|
* Define as 1 to restrict multicast forwarding to larger scope from local sources.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef OPENTHREAD_CONFIG_IP6_RESTRICT_FORWARDING_LARGER_SCOPE_MCAST_WITH_LOCAL_SRC
|
||||||
|
#define OPENTHREAD_CONFIG_IP6_RESTRICT_FORWARDING_LARGER_SCOPE_MCAST_WITH_LOCAL_SRC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1037,6 +1037,19 @@ Error Ip6::PassToHost(OwnedPtr<Message> &aMessagePtr,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if OPENTHREAD_CONFIG_IP6_RESTRICT_FORWARDING_LARGER_SCOPE_MCAST_WITH_LOCAL_SRC
|
||||||
|
// Some platforms (e.g. Android) currently doesn't restrict link-local/mesh-local source
|
||||||
|
// addresses when forwarding multicast packets.
|
||||||
|
// For a multicast packet sent from link-local/mesh-local address to scope larger
|
||||||
|
// than realm-local, set the hop limit to 1 before sending to host, so this packet
|
||||||
|
// will not be forwarded by host.
|
||||||
|
if (aMessageInfo.GetSockAddr().IsMulticastLargerThanRealmLocal() &&
|
||||||
|
(aMessageInfo.GetPeerAddr().IsLinkLocal() || (Get<Mle::Mle>().IsMeshLocalAddress(aMessageInfo.GetPeerAddr()))))
|
||||||
|
{
|
||||||
|
messagePtr->Write<uint8_t>(Header::kHopLimitFieldOffset, 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Pass message to callback transferring its ownership.
|
// Pass message to callback transferring its ownership.
|
||||||
mReceiveIp6DatagramCallback.Invoke(messagePtr.Release());
|
mReceiveIp6DatagramCallback.Invoke(messagePtr.Release());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user