IP: Add API to subscribe/unsubscribe to multicast addresses. (#899)

* IP: Add API to subscribe/unsubscribe to multicast addresses.

* CLI: Add commands to handle multicast addresses.
This commit is contained in:
Łukasz Duda
2016-11-02 11:24:35 -07:00
committed by Jonathan Hui
parent 30c9dfc0bc
commit bb97cbee17
10 changed files with 499 additions and 24 deletions
+14 -2
View File
@@ -645,6 +645,7 @@ ThreadError Ip6::HandleDatagram(Message &message, Netif *netif, int8_t interface
bool receive = false;
bool forward = false;
bool tunnel = false;
bool multicastPromiscuous = false;
uint8_t nextHeader;
uint8_t hopLimit;
@@ -677,9 +678,16 @@ ThreadError Ip6::HandleDatagram(Message &message, Netif *netif, int8_t interface
// determine destination of packet
if (header.GetDestination().IsMulticast())
{
if (netif != NULL && netif->IsMulticastSubscribed(header.GetDestination()))
if (netif != NULL)
{
receive = true;
if (netif->IsMulticastSubscribed(header.GetDestination()))
{
receive = true;
}
else if (netif->IsMulticastPromiscuousModeEnabled())
{
multicastPromiscuous = true;
}
}
if (netif == NULL)
@@ -739,6 +747,10 @@ ThreadError Ip6::HandleDatagram(Message &message, Netif *netif, int8_t interface
SuccessOrExit(error = HandlePayload(message, messageInfo, nextHeader));
}
else if (multicastPromiscuous)
{
ProcessReceiveCallback(message, messageInfo, nextHeader);
}
if (forward)
{