blob: f35bae720ceb54fe52d97c1aae6b1988db027346 [file] [log] [blame]
akmhoque53353462014-04-22 08:43:45 -05001#include <list>
2#include "fib-entry.hpp"
3#include "nexthop.hpp"
akmhoque674b0b12014-05-20 14:33:28 -05004#include "logger.hpp"
akmhoque53353462014-04-22 08:43:45 -05005
6namespace nlsr {
7
akmhoque674b0b12014-05-20 14:33:28 -05008INIT_LOGGER("FibEntry");
9
akmhoque53353462014-04-22 08:43:45 -050010using namespace std;
11
12bool
akmhoquec8a10f72014-04-25 18:42:55 -050013FibEntry::isEqualNextHops(NexthopList& nhlOther)
akmhoque53353462014-04-22 08:43:45 -050014{
akmhoque157b0a42014-05-13 00:26:37 -050015 if (m_nexthopList.getSize() != nhlOther.getSize()) {
akmhoque53353462014-04-22 08:43:45 -050016 return false;
17 }
akmhoque157b0a42014-05-13 00:26:37 -050018 else {
akmhoquefdbddb12014-05-02 18:35:19 -050019 uint32_t nhCount = 0;
akmhoque53353462014-04-22 08:43:45 -050020 std::list<NextHop>::iterator it1, it2;
akmhoquefdbddb12014-05-02 18:35:19 -050021 for (it1 = m_nexthopList.getNextHops().begin(),
22 it2 = nhlOther.getNextHops().begin() ;
akmhoque157b0a42014-05-13 00:26:37 -050023 it1 != m_nexthopList.getNextHops().end() ; it1++, it2++) {
24 if (it1->getConnectingFaceUri() == it2->getConnectingFaceUri()) {
akmhoque53353462014-04-22 08:43:45 -050025 it1->setRouteCost(it2->getRouteCost());
26 nhCount++;
27 }
akmhoque157b0a42014-05-13 00:26:37 -050028 else {
akmhoque53353462014-04-22 08:43:45 -050029 break;
30 }
31 }
akmhoquefdbddb12014-05-02 18:35:19 -050032 return nhCount == m_nexthopList.getSize();
akmhoque53353462014-04-22 08:43:45 -050033 }
34}
35
akmhoque674b0b12014-05-20 14:33:28 -050036void
37FibEntry::writeLog()
38{
39 _LOG_DEBUG("Name Prefix: " << m_name);
akmhoquec7a79b22014-05-26 08:06:19 -050040 _LOG_DEBUG("Time to Refresh: " << m_expirationTimePoint);
akmhoque674b0b12014-05-20 14:33:28 -050041 _LOG_DEBUG("Seq No: " << m_seqNo);
42 m_nexthopList.writeLog();
43}
44
akmhoque53353462014-04-22 08:43:45 -050045ostream&
46operator<<(ostream& os, FibEntry fe)
47{
48 os << "Name Prefix: " << fe.getName() << endl;
akmhoquec7a79b22014-05-26 08:06:19 -050049 os << "Time to Refresh: " << fe.getExpirationTimePoint() << endl;
akmhoquefdbddb12014-05-02 18:35:19 -050050 os << fe.getNexthopList() << endl;
akmhoque53353462014-04-22 08:43:45 -050051 return os;
52}
53
54}//namespace nlsr