From 2c5084e25fbf01cceba6cdcd8a7b23fbdf5809d7 Mon Sep 17 00:00:00 2001 From: Hajime Tazaki Date: Thu, 8 Apr 2010 22:51:09 +0900 Subject: [PATCH] bug 857 - Link-Local Multicast handle in Ipv4 Output processing --- RELEASE_NOTES | 3 ++- src/internet-stack/ipv4-l3-protocol.cc | 4 ++-- src/internet-stack/udp-test.cc | 10 ++++++++++ src/node/ipv4-address.cc | 7 +++++++ src/node/ipv4-address.h | 4 ++++ src/routing/static-routing/ipv4-static-routing.cc | 14 ++++++++++++++ 6 files changed, 39 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 28674ae99..6216f3cf1 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -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 ------------ diff --git a/src/internet-stack/ipv4-l3-protocol.cc b/src/internet-stack/ipv4-l3-protocol.cc index cd8ea586f..42f0c4aee 100644 --- a/src/internet-stack/ipv4-l3-protocol.cc +++ b/src/internet-stack/ipv4-l3-protocol.cc @@ -539,8 +539,8 @@ Ipv4L3Protocol::Send (Ptr 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); diff --git a/src/internet-stack/udp-test.cc b/src/internet-stack/udp-test.cc index 6bbec3f44..8125a59a2 100644 --- a/src/internet-stack/udp-test.cc +++ b/src/internet-stack/udp-test.cc @@ -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 (); diff --git a/src/node/ipv4-address.cc b/src/node/ipv4-address.cc index 24735291d..7689280c2 100644 --- a/src/node/ipv4-address.cc +++ b/src/node/ipv4-address.cc @@ -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 { diff --git a/src/node/ipv4-address.h b/src/node/ipv4-address.h index c691ffc3c..7b4717bb9 100644 --- a/src/node/ipv4-address.h +++ b/src/node/ipv4-address.h @@ -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 * diff --git a/src/routing/static-routing/ipv4-static-routing.cc b/src/routing/static-routing/ipv4-static-routing.cc index a15f80dc8..2875721a4 100644 --- a/src/routing/static-routing/ipv4-static-routing.cc +++ b/src/routing/static-routing/ipv4-static-routing.cc @@ -222,6 +222,20 @@ Ipv4StaticRouting::LookupStatic (Ipv4Address dest, Ptr oif) Ptr 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 (); + 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++)