File name format change and Removed warning messages (Except warning from boost for Logging)
Change-Id: If3a3a5411d377d925527fc3e8809c228a9a81e26
diff --git a/src/route/npte.cpp b/src/route/npte.cpp
new file mode 100644
index 0000000..3194635
--- /dev/null
+++ b/src/route/npte.cpp
@@ -0,0 +1,83 @@
+#include <list>
+#include <utility>
+#include "npte.hpp"
+#include "routing-table-entry.hpp"
+#include "nexthop.hpp"
+
+namespace nlsr {
+
+using namespace std;
+
+void
+Npte::generateNhlfromRteList()
+{
+ m_nhl.reset();
+ for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
+ it != m_rteList.end(); ++it)
+ {
+ for (std::list<NextHop>::iterator nhit =
+ (*it).getNhl().getNextHopList().begin();
+ nhit != (*it).getNhl().getNextHopList().end(); ++nhit)
+ {
+ m_nhl.addNextHop((*nhit));
+ }
+ }
+}
+
+
+
+static bool
+rteCompare(RoutingTableEntry& rte, string& destRouter)
+{
+ return rte.getDestination() == destRouter;
+}
+
+void
+Npte::removeRoutingTableEntry(RoutingTableEntry& rte)
+{
+ std::list<RoutingTableEntry>::iterator it = std::find_if(m_rteList.begin(),
+ m_rteList.end(),
+ bind(&rteCompare, _1, rte.getDestination()));
+ if (it != m_rteList.end())
+ {
+ m_rteList.erase(it);
+ }
+}
+
+void
+Npte::addRoutingTableEntry(RoutingTableEntry& rte)
+{
+ std::list<RoutingTableEntry>::iterator it = std::find_if(m_rteList.begin(),
+ m_rteList.end(),
+ bind(&rteCompare, _1, rte.getDestination()));
+ if (it == m_rteList.end())
+ {
+ m_rteList.push_back(rte);
+ }
+ else
+ {
+ (*it).getNhl().reset(); // 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)
+{
+ 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;
+}
+
+}//namespace nlsr