bug 857 - Link-Local Multicast handle in Ipv4 Output processing
authorHajime Tazaki <tazaki@sfc.wide.ad.jp>
Thu, 08 Apr 2010 22:51:09 +0900
changeset 6181 05727a89b220
parent 6180 cd0d8ba00e6c
child 6182 9e060dd421fa
bug 857 - Link-Local Multicast handle in Ipv4 Output processing
RELEASE_NOTES
src/internet-stack/ipv4-l3-protocol.cc
src/internet-stack/udp-test.cc
src/node/ipv4-address.cc
src/node/ipv4-address.h
src/routing/static-routing/ipv4-static-routing.cc
--- a/RELEASE_NOTES	Thu Apr 08 13:39:07 2010 +0200
+++ b/RELEASE_NOTES	Thu Apr 08 22:51:09 2010 +0900
@@ -108,7 +108,8 @@
    - 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
 ------------
--- a/src/internet-stack/ipv4-l3-protocol.cc	Thu Apr 08 13:39:07 2010 +0200
+++ b/src/internet-stack/ipv4-l3-protocol.cc	Thu Apr 08 22:51:09 2010 +0900
@@ -539,8 +539,8 @@
   // 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);
--- a/src/internet-stack/udp-test.cc	Thu Apr 08 13:39:07 2010 +0200
+++ b/src/internet-stack/udp-test.cc	Thu Apr 08 22:51:09 2010 +0900
@@ -256,6 +256,16 @@
   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 ();
--- a/src/node/ipv4-address.cc	Thu Apr 08 13:39:07 2010 +0200
+++ b/src/node/ipv4-address.cc	Thu Apr 08 22:51:09 2010 +0900
@@ -240,6 +240,13 @@
   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
 {
--- a/src/node/ipv4-address.h	Thu Apr 08 13:39:07 2010 +0200
+++ b/src/node/ipv4-address.h	Thu Apr 08 22:51:09 2010 +0900
@@ -112,6 +112,10 @@
     */
   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
    *
    * This method returns an IPv4 address that is this address combined
--- a/src/routing/static-routing/ipv4-static-routing.cc	Thu Apr 08 13:39:07 2010 +0200
+++ b/src/routing/static-routing/ipv4-static-routing.cc	Thu Apr 08 22:51:09 2010 +0900
@@ -222,6 +222,20 @@
   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++)