NetAnim: Skip ipaddress check if index cannot be found

This commit is contained in:
John Abraham
2012-10-31 23:17:27 -07:00
parent cc613cb57b
commit fc5cd8e466

View File

@@ -363,7 +363,12 @@ std::string AnimationInterface::GetIpv4Address (Ptr <NetDevice> nd)
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 ();