NLSR - (Hello Protocol + FIB Update)
diff --git a/src/route/nlsr_npte.cpp b/src/route/nlsr_npte.cpp
index 60013ff..c342a21 100644
--- a/src/route/nlsr_npte.cpp
+++ b/src/route/nlsr_npte.cpp
@@ -7,77 +7,77 @@
namespace nlsr
{
- using namespace std;
+ using namespace std;
- void
- Npte::generateNhlfromRteList()
+ void
+ Npte::generateNhlfromRteList()
+ {
+ nhl.resetNhl();
+ for( std::list<RoutingTableEntry>::iterator it=rteList.begin();
+ it != rteList.end(); ++it )
{
- nhl.resetNhl();
- for( std::list<RoutingTableEntry>::iterator it=rteList.begin();
- it != rteList.end(); ++it )
- {
- for(std::list< NextHop >::iterator nhit=(*it).getNhl().getNextHopList().begin();
- nhit != (*it).getNhl().getNextHopList().end(); ++nhit)
- {
- nhl.addNextHop((*nhit));
- }
- }
+ for(std::list< NextHop >::iterator nhit=(*it).getNhl().getNextHopList().begin();
+ nhit != (*it).getNhl().getNextHopList().end(); ++nhit)
+ {
+ nhl.addNextHop((*nhit));
+ }
}
+ }
- static bool
- rteCompare(RoutingTableEntry& rte, string& destRouter)
+ static bool
+ rteCompare(RoutingTableEntry& rte, string& destRouter)
+ {
+ return rte.getDestination()==destRouter;
+ }
+
+ void
+ Npte::removeRoutingTableEntry(RoutingTableEntry& rte)
+ {
+ std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
+ rteList.end(),
+ bind(&rteCompare, _1, rte.getDestination()));
+ if ( it != rteList.end() )
{
- return rte.getDestination()==destRouter;
+ rteList.erase(it);
}
+ }
- void
- Npte::removeRoutingTableEntry(RoutingTableEntry& rte)
+ void
+ Npte::addRoutingTableEntry(RoutingTableEntry &rte)
+ {
+ std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
+ rteList.end(),
+ bind(&rteCompare, _1, rte.getDestination()));
+ if ( it == rteList.end() )
{
- std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
- rteList.end(),
- bind(&rteCompare, _1, rte.getDestination()));
- if ( it != rteList.end() )
- {
- rteList.erase(it);
- }
+ rteList.push_back(rte);
}
-
- void
- Npte::addRoutingTableEntry(RoutingTableEntry &rte)
+ else
{
- std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
- rteList.end(),
- bind(&rteCompare, _1, rte.getDestination()));
- if ( it == rteList.end() )
- {
- rteList.push_back(rte);
- }
- else
- {
- (*it).getNhl().resetNhl(); // reseting existing routing table's next hop
- for(std::list< NextHop >::iterator nhit=rte.getNhl().getNextHopList().begin();
- nhit != rte.getNhl().getNextHopList().end(); ++nhit)
- {
- (*it).getNhl().addNextHop((*nhit));
- }
- }
+ (*it).getNhl().resetNhl(); // reseting existing routing table's next hop
+ for(std::list< NextHop >::iterator nhit=rte.getNhl().getNextHopList().begin();
+ nhit != rte.getNhl().getNextHopList().end(); ++nhit)
+ {
+ (*it).getNhl().addNextHop((*nhit));
+ }
}
+ }
//debugging purpose
- ostream&
- operator<<(ostream& os, Npte& npte)
+ ostream&
+ operator<<(ostream& os, Npte& npte)
+ {
+ os<<"Name: "<<npte.getNamePrefix()<<endl;
+ std::list<RoutingTableEntry> rteList=npte.getRteList();
+ for(std::list<RoutingTableEntry >::iterator it=rteList.begin();
+ it !=rteList.end(); ++it)
{
- os<<"Name: "<<npte.getNamePrefix()<<endl;
- std::list<RoutingTableEntry> rteList=npte.getRteList();
- for(std::list<RoutingTableEntry >::iterator it=rteList.begin();
- it !=rteList.end(); ++it)
- {
- cout<<(*it);
- }
- os<<npte.getNhl();
- return os;
+ cout<<(*it);
}
+ os<<npte.getNhl();
+ return os;
+ }
}//namespace nlsr