Own Name LSA installation
diff --git a/nlsr_lsdb.cpp b/nlsr_lsdb.cpp
new file mode 100644
index 0000000..a82c8a3
--- /dev/null
+++ b/nlsr_lsdb.cpp
@@ -0,0 +1,145 @@
+#include<string>
+#include "nlsr_lsdb.hpp"
+#include "nlsr.hpp"
+
+using namespace std;
+
+
+
+
+
+bool
+Lsdb::doesLsaExist(string key, int lsType)
+{
+ if ( lsType == 1)
+ {
+ return doesNameLsaExist(key);
+ }
+ else if ( lsType == 2)
+ {
+ return doesAdjLsaExist(key);
+ }
+ else if ( lsType == 3)
+ {
+ return doesCorLsaExist(key);
+ }
+
+ return false;
+
+}
+
+static bool
+nameLsaCompare(NameLsa& nlsa1, NameLsa& nlsa2){
+ return nlsa1.getLsaKey()==nlsa1.getLsaKey();
+}
+
+static bool
+nameLsaCompareByKey(NameLsa& nlsa1, string& key){
+ return nlsa1.getLsaKey()==key;
+}
+
+
+bool
+Lsdb::buildAndInstallOwnNameLsa(nlsr& pnlsr)
+{
+ NameLsa nameLsa(pnlsr.getConfParameter().getRouterPrefix()
+ , 1
+ , pnlsr.getNameLsaSeq()+1
+ , pnlsr.getConfParameter().getRouterDeadInterval()
+ , pnlsr.getNpl() );
+ pnlsr.setNameLsaSeq(pnlsr.getNameLsaSeq()+1);
+ cout<<nameLsa;
+ return installNameLsa(nameLsa);
+
+}
+
+NameLsa&
+Lsdb::getNameLsa(string key)
+{
+ std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
+ nameLsdb.end(),
+ bind(nameLsaCompareByKey, _1, key));
+
+ if( it != nameLsdb.end()){
+ return (*it);
+ }
+}
+
+
+
+bool
+Lsdb::installNameLsa(NameLsa &nlsa)
+{
+ bool doesLsaExist_ = doesNameLsaExist(nlsa.getLsaKey());
+ if ( !doesLsaExist_ )
+ {
+ // add name LSA
+ addNameLsa(nlsa);
+ // update NPT and FIB
+ }
+ else
+ {
+ // check for newer name LSA
+ NameLsa oldNameLsa=getNameLsa(nlsa.getLsaKey());
+ // Discard or Update Name lsa, NPT, FIB
+ }
+
+ return true;
+}
+
+bool
+Lsdb::addNameLsa(NameLsa &nlsa)
+{
+ std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
+ nameLsdb.end(),
+ bind(nameLsaCompare, _1, nlsa));
+
+ if( it == nameLsdb.end()){
+ nameLsdb.push_back(nlsa);
+ return true;
+ }
+ return false;
+}
+
+bool
+Lsdb::removeNameLsa(string& key)
+{
+ return false;
+}
+
+void
+Lsdb::printNameLsdb()
+{
+ for( std::list<NameLsa>::iterator it=nameLsdb.begin();
+ it!= nameLsdb.end() ; it++)
+ {
+ cout<< (*it) <<endl;
+ }
+}
+
+bool
+Lsdb::doesNameLsaExist(string key)
+{
+ std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
+ nameLsdb.end(),
+ bind(nameLsaCompareByKey, _1, key));
+
+ if( it == nameLsdb.end()){
+ return false;
+ }
+
+ return true;
+}
+
+
+bool
+Lsdb::doesAdjLsaExist(string key)
+{
+ return false;
+}
+
+bool
+Lsdb::doesCorLsaExist(string key)
+{
+ return false;
+}