blob: 524b04ceb6ec82b428147611b445c8f697c0ec73 [file] [log] [blame]
akmhoque53353462014-04-22 08:43:45 -05001#include <list>
2#include "fib-entry.hpp"
3#include "nexthop.hpp"
4
5namespace nlsr {
6
7using namespace std;
8
9bool
akmhoquec8a10f72014-04-25 18:42:55 -050010FibEntry::isEqualNextHops(NexthopList& nhlOther)
akmhoque53353462014-04-22 08:43:45 -050011{
akmhoquefdbddb12014-05-02 18:35:19 -050012 if (m_nexthopList.getSize() != nhlOther.getSize())
akmhoque53353462014-04-22 08:43:45 -050013 {
14 return false;
15 }
16 else
17 {
akmhoquefdbddb12014-05-02 18:35:19 -050018 uint32_t nhCount = 0;
akmhoque53353462014-04-22 08:43:45 -050019 std::list<NextHop>::iterator it1, it2;
akmhoquefdbddb12014-05-02 18:35:19 -050020 for (it1 = m_nexthopList.getNextHops().begin(),
21 it2 = nhlOther.getNextHops().begin() ;
22 it1 != m_nexthopList.getNextHops().end() ; it1++, it2++)
akmhoque53353462014-04-22 08:43:45 -050023 {
24 if (it1->getConnectingFace() == it2->getConnectingFace())
25 {
26 it1->setRouteCost(it2->getRouteCost());
27 nhCount++;
28 }
29 else
30 {
31 break;
32 }
33 }
akmhoquefdbddb12014-05-02 18:35:19 -050034 return nhCount == m_nexthopList.getSize();
akmhoque53353462014-04-22 08:43:45 -050035 }
36}
37
38ostream&
39operator<<(ostream& os, FibEntry fe)
40{
41 os << "Name Prefix: " << fe.getName() << endl;
42 os << "Time to Refresh: " << fe.getTimeToRefresh() << endl;
akmhoquefdbddb12014-05-02 18:35:19 -050043 os << fe.getNexthopList() << endl;
akmhoque53353462014-04-22 08:43:45 -050044 return os;
45}
46
47}//namespace nlsr