internet: improve ndisc entries logging
This commit is contained in:
@@ -97,7 +97,8 @@ NdiscCache::Entry* NdiscCache::Lookup (Ipv6Address dst)
|
||||
if (m_ndCache.find (dst) != m_ndCache.end ())
|
||||
{
|
||||
NdiscCache::Entry* entry = m_ndCache[dst];
|
||||
NS_LOG_LOGIC ("Found an entry:" << dst << " to " << entry->GetMacAddress ());
|
||||
NS_LOG_LOGIC ("Found an entry: " << *entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
NS_LOG_LOGIC ("Nothing found");
|
||||
@@ -114,7 +115,7 @@ std::list<NdiscCache::Entry*> NdiscCache::LookupInverse (Address dst)
|
||||
NdiscCache::Entry *entry = (*i).second;
|
||||
if (entry->GetMacAddress () == dst)
|
||||
{
|
||||
NS_LOG_LOGIC ("Found an entry:" << (*i).first << " to " << (*i).second);
|
||||
NS_LOG_LOGIC ("Found an entry:" << (*entry));
|
||||
entryList.push_back (entry);
|
||||
}
|
||||
}
|
||||
@@ -214,13 +215,13 @@ void NdiscCache::PrintNdiscCache (Ptr<OutputStreamWrapper> stream)
|
||||
*os << " STALE\n";
|
||||
}
|
||||
else if (i->second->IsPermanent ())
|
||||
{
|
||||
*os << " PERMANENT\n";
|
||||
}
|
||||
{
|
||||
*os << " PERMANENT\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_FATAL_ERROR ("Test for possibly unreachable code-- please file a bug report, with a test case, if this is ever hit");
|
||||
}
|
||||
{
|
||||
NS_FATAL_ERROR ("Test for possibly unreachable code-- please file a bug report, with a test case, if this is ever hit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,5 +596,37 @@ void NdiscCache::Entry::SetMacAddress (Address mac)
|
||||
m_macAddress = mac;
|
||||
}
|
||||
|
||||
void NdiscCache::Entry::Print (std::ostream &os) const
|
||||
{
|
||||
os << m_ipv6Address << " lladdr " << m_macAddress << " state ";
|
||||
switch (m_state)
|
||||
{
|
||||
case INCOMPLETE:
|
||||
os << "INCOMPLETE";
|
||||
break;
|
||||
case REACHABLE:
|
||||
os << "REACHABLE";
|
||||
break;
|
||||
case STALE:
|
||||
os << "STALE";
|
||||
break;
|
||||
case DELAY:
|
||||
os << "DELAY";
|
||||
break;
|
||||
case PROBE:
|
||||
os << "PROBE";
|
||||
break;
|
||||
case PERMANENT:
|
||||
os << "PERMANENT";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& operator << (std::ostream& os, NdiscCache::Entry const& entry)
|
||||
{
|
||||
entry.Print (os);
|
||||
return os;
|
||||
}
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
* \param dst destination address.
|
||||
* \return the entry if found, 0 otherwise.
|
||||
*/
|
||||
NdiscCache::Entry* Lookup (Ipv6Address dst);
|
||||
virtual NdiscCache::Entry* Lookup (Ipv6Address dst);
|
||||
|
||||
/**
|
||||
* \brief Lookup in the cache for a MAC address.
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
* \param to address to add
|
||||
* \return an new Entry
|
||||
*/
|
||||
NdiscCache::Entry* Add (Ipv6Address to);
|
||||
virtual NdiscCache::Entry* Add (Ipv6Address to);
|
||||
|
||||
/**
|
||||
* \brief Delete an entry.
|
||||
@@ -162,6 +162,8 @@ public:
|
||||
*/
|
||||
Entry (NdiscCache* nd);
|
||||
|
||||
virtual ~Entry() = default;
|
||||
|
||||
/**
|
||||
* \brief Changes the state to this entry to INCOMPLETE.
|
||||
* \param p packet that wait to be sent
|
||||
@@ -342,6 +344,19 @@ public:
|
||||
*/
|
||||
void SetIpv6Address (Ipv6Address ipv6Address);
|
||||
|
||||
/**
|
||||
* \brief Print this entry to the given output stream.
|
||||
*
|
||||
* \param os the output stream to which this Ipv6Address is printed
|
||||
*/
|
||||
void Print (std::ostream &os) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* \brief the NdiscCache associated.
|
||||
*/
|
||||
NdiscCache* m_ndCache;
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief The IPv6 address.
|
||||
@@ -366,11 +381,6 @@ private:
|
||||
*/
|
||||
NdiscCacheEntryState_e m_state;
|
||||
|
||||
/**
|
||||
* \brief the NdiscCache associated.
|
||||
*/
|
||||
NdiscCache* m_ndCache;
|
||||
|
||||
/**
|
||||
* \brief The MAC address.
|
||||
*/
|
||||
@@ -402,7 +412,12 @@ private:
|
||||
uint8_t m_nsRetransmit;
|
||||
};
|
||||
|
||||
private:
|
||||
protected:
|
||||
/**
|
||||
* \brief Dispose this object.
|
||||
*/
|
||||
void DoDispose ();
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery Cache container
|
||||
*/
|
||||
@@ -412,6 +427,14 @@ private:
|
||||
*/
|
||||
typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>::iterator CacheI;
|
||||
|
||||
/**
|
||||
* \brief A list of Entry.
|
||||
*/
|
||||
Cache m_ndCache;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* \brief Copy constructor.
|
||||
*
|
||||
@@ -427,11 +450,6 @@ private:
|
||||
*/
|
||||
NdiscCache& operator= (NdiscCache const &);
|
||||
|
||||
/**
|
||||
* \brief Dispose this object.
|
||||
*/
|
||||
void DoDispose ();
|
||||
|
||||
/**
|
||||
* \brief The NetDevice.
|
||||
*/
|
||||
@@ -447,17 +465,22 @@ private:
|
||||
*/
|
||||
Ptr<Icmpv6L4Protocol> m_icmpv6;
|
||||
|
||||
/**
|
||||
* \brief A list of Entry.
|
||||
*/
|
||||
Cache m_ndCache;
|
||||
|
||||
/**
|
||||
* \brief Max number of packet stored in m_waiting.
|
||||
*/
|
||||
uint32_t m_unresQlen;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Stream insertion operator.
|
||||
*
|
||||
* \param os the reference to the output stream
|
||||
* \param entry the NdiscCache::Entry
|
||||
* \returns the reference to the output stream
|
||||
*/
|
||||
std::ostream & operator << (std::ostream& os, NdiscCache::Entry const& entry);
|
||||
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
#endif /* NDISC_CACHE_H */
|
||||
|
||||
Reference in New Issue
Block a user