#include <list>
#include "nlsr_fe.hpp"
#include "nlsr_nexthop.hpp"

namespace nlsr
{

  using namespace std;

  bool
  FibEntry::isEqualNextHops(Nhl &nhlOther)
  {
    if ( nhl.getNhlSize() != nhlOther.getNhlSize() )
    {
      return false;
    }
    else
    {
      int nhCount=0;
      std::list<NextHop>::iterator it1, it2;
      for ( it1=nhl.getNextHopList().begin(),
            it2 = nhlOther.getNextHopList().begin() ;
            it1 != nhl.getNextHopList().end() ; it1++, it2++)
      {
        if (it1->getConnectingFace() == it2->getConnectingFace() )
        {
          it1->setRouteCost(it2->getRouteCost());
          nhCount++;
        }
        else
        {
          break;
        }
      }
      return nhCount == nhl.getNhlSize();
    }
  }

  ostream&
  operator<<(ostream& os, FibEntry fe)
  {
    os<<"Name Prefix: "<<fe.getName()<<endl;
    os<<"Time to Refresh: "<<fe.getTimeToRefresh()<<endl;
    os<<fe.getNhl()<<endl;
    return os;
  }

}//namespace nlsr
