src/internet/model/ipv4-l3-protocol.cc
changeset 10670 d04c750525d7
parent 10652 dc18deba4502
child 10691 67ee979a1807
--- a/src/internet/model/ipv4-l3-protocol.cc	Mon Mar 17 19:43:11 2014 +0100
+++ b/src/internet/model/ipv4-l3-protocol.cc	Mon Mar 17 19:44:36 2014 +0100
@@ -540,6 +540,35 @@
 }
 
 bool
+Ipv4L3Protocol::IsUnicast (Ipv4Address ad) const
+{
+  NS_LOG_FUNCTION (this << ad);
+
+  if (ad.IsBroadcast () || ad.IsMulticast ())
+    {
+      return false;
+    }
+  else
+    {
+      // check for subnet-broadcast
+      for (uint32_t ifaceIndex = 0; ifaceIndex < GetNInterfaces (); ifaceIndex++)
+        {
+          for (uint32_t j = 0; j < GetNAddresses (ifaceIndex); j++)
+            {
+              Ipv4InterfaceAddress ifAddr = GetAddress (ifaceIndex, j);
+              NS_LOG_LOGIC ("Testing address " << ad << " with subnet-directed broadcast " << ifAddr.GetBroadcast () );
+              if (ad == ifAddr.GetBroadcast () )
+                {
+                  return false;
+                }
+            }
+        }
+    }
+
+  return true;
+}
+
+bool
 Ipv4L3Protocol::IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const
 {
   NS_LOG_FUNCTION (this << ad << interfaceMask);