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