akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 1 | #include <list> |
| 2 | #include "fib-entry.hpp" |
| 3 | #include "nexthop.hpp" |
| 4 | |
| 5 | namespace nlsr { |
| 6 | |
| 7 | using namespace std; |
| 8 | |
| 9 | bool |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 10 | FibEntry::isEqualNextHops(NexthopList& nhlOther) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 11 | { |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 12 | if (m_nexthopList.getSize() != nhlOther.getSize()) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 13 | { |
| 14 | return false; |
| 15 | } |
| 16 | else |
| 17 | { |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 18 | uint32_t nhCount = 0; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 19 | std::list<NextHop>::iterator it1, it2; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 20 | for (it1 = m_nexthopList.getNextHops().begin(), |
| 21 | it2 = nhlOther.getNextHops().begin() ; |
| 22 | it1 != m_nexthopList.getNextHops().end() ; it1++, it2++) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 23 | { |
| 24 | if (it1->getConnectingFace() == it2->getConnectingFace()) |
| 25 | { |
| 26 | it1->setRouteCost(it2->getRouteCost()); |
| 27 | nhCount++; |
| 28 | } |
| 29 | else |
| 30 | { |
| 31 | break; |
| 32 | } |
| 33 | } |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 34 | return nhCount == m_nexthopList.getSize(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 35 | } |
| 36 | } |
| 37 | |
| 38 | ostream& |
| 39 | operator<<(ostream& os, FibEntry fe) |
| 40 | { |
| 41 | os << "Name Prefix: " << fe.getName() << endl; |
| 42 | os << "Time to Refresh: " << fe.getTimeToRefresh() << endl; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 43 | os << fe.getNexthopList() << endl; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 44 | return os; |
| 45 | } |
| 46 | |
| 47 | }//namespace nlsr |