blob: ba2731fbedf0f27d80ad1b1ab544abdd63d74d01 [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);
40 _LOG_DEBUG("Seq No: " << m_seqNo);
41 m_nexthopList.writeLog();
42}
43
akmhoque53353462014-04-22 08:43:45 -050044ostream&
45operator<<(ostream& os, FibEntry fe)
46{
47 os << "Name Prefix: " << fe.getName() << endl;
48 os << "Time to Refresh: " << fe.getTimeToRefresh() << endl;
akmhoquefdbddb12014-05-02 18:35:19 -050049 os << fe.getNexthopList() << endl;
akmhoque53353462014-04-22 08:43:45 -050050 return os;
51}
52
53}//namespace nlsr