bug 857 - Link-Local Multicast handle in Ipv4 Output processing

This commit is contained in:
Hajime Tazaki
2010-04-08 22:51:09 +09:00
parent 3ccf6c8ee7
commit 2c5084e25f
6 changed files with 39 additions and 3 deletions

View File

@@ -108,7 +108,8 @@ many cases referencing the Bugzilla bug number
- bug 850 - Ipv4GlobalRouting::LookupGlobal bug
- bug 864 - Invalid return value in UdpSocketImpl::Send and Ipv4RawSocketImpl::Send
- bug 865 - Ipv4RawSocketImpl::RecvFrom does not return from address all the time.
- Bug 859 - Output interface estimation for the source address bound socket in IPv4 Raw socket
- bug 859 - Output interface estimation for the source address bound socket in IPv4 Raw socket
- bug 857 - Link-Local Multicast handle in Ipv4 Output processing
Known issues
------------

View File

@@ -539,8 +539,8 @@ Ipv4L3Protocol::Send (Ptr<Packet> packet,
// 4) packet is not broadcast, and is passed in with a route entry but route->GetGateway is not set (e.g., on-demand)
// 5) packet is not broadcast, and route is NULL (e.g., a raw socket call, or ICMP)
// 1) packet is destined to limited broadcast address
if (destination.IsBroadcast ())
// 1) packet is destined to limited broadcast address or link-local multicast address
if (destination.IsBroadcast () || destination.IsLocalMulticast ())
{
NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 1: limited broadcast");
ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment);

View File

@@ -256,6 +256,16 @@ UdpSocketImplTest::DoRun (void)
m_receivedPacket = 0;
m_receivedPacket2 = 0;
// Simple Link-local multicast test
txSocket->BindToNetDevice (txDev1);
SendData (txSocket, "224.0.0.9");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the second interface's address");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "recv2: 224.0.0.9");
m_receivedPacket->RemoveAllByteTags ();
m_receivedPacket2->RemoveAllByteTags ();
Simulator::Destroy ();
return GetErrorStatus ();

View File

@@ -240,6 +240,13 @@ Ipv4Address::IsMulticast (void) const
return (m_address >= 0xe0000000 && m_address <= 0xefffffff);
}
bool
Ipv4Address::IsLocalMulticast (void) const
{
// Link-Local multicast address is 224.0.0.0/24
return (m_address & 0xffffff00) == 0xe0000000;
}
void
Ipv4Address::Serialize (uint8_t buf[4]) const
{

View File

@@ -111,6 +111,10 @@ public:
* \return true only if address is in the range 224.0.0.0 - 239.255.255.255
*/
bool IsMulticast (void) const;
/**
* \return true only if address is in local multicast address scope, 224.0.0.0/24
*/
bool IsLocalMulticast (void) const;
/**
* \brief Combine this address with a network mask
*

View File

@@ -222,6 +222,20 @@ Ipv4StaticRouting::LookupStatic (Ipv4Address dest, Ptr<NetDevice> oif)
Ptr<Ipv4Route> rtentry = 0;
uint16_t longest_mask = 0;
uint32_t shortest_metric = 0xffffffff;
/* when sending on local multicast, there have to be interface specified */
if (dest.IsLocalMulticast ())
{
NS_ASSERT_MSG (oif, "Try to send on link-local multicast address, and no interface index is given!");
rtentry = Create<Ipv4Route> ();
rtentry->SetDestination (dest);
rtentry->SetGateway (Ipv4Address::GetZero ());
rtentry->SetOutputDevice (oif);
rtentry->SetSource (m_ipv4->GetAddress (oif->GetIfIndex (), 0).GetLocal ());
return rtentry;
}
for (NetworkRoutesI i = m_networkRoutes.begin ();
i != m_networkRoutes.end ();
i++)