NetAnim: Skip ipaddress check if index cannot be found
authorJohn Abraham <john.abraham.in@gmail.com>
Wed, 31 Oct 2012 23:17:27 -0700
changeset 9115 c9b19f516c5f
parent 9114 41bfd88f8055
child 9117 6ed1556809ea
NetAnim: Skip ipaddress check if index cannot be found
src/netanim/model/animation-interface.cc
--- a/src/netanim/model/animation-interface.cc	Mon Oct 29 05:33:13 2012 -0700
+++ b/src/netanim/model/animation-interface.cc	Wed Oct 31 23:17:27 2012 -0700
@@ -363,7 +363,12 @@
   Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> ();
   if (!ipv4)
     return "0.0.0.0";
-  uint32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
+  int32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
+  if (ifIndex == -1)
+    {
+      NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
+      return "0.0.0.0";
+    }
   Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0);
   std::ostringstream oss;
   oss << addr.GetLocal ();