NLSR - (Hello Protocol + FIB Update)
diff --git a/src/security/nlsr_cert_store.cpp b/src/security/nlsr_cert_store.cpp
index 108d0c6..d1e821a 100644
--- a/src/security/nlsr_cert_store.cpp
+++ b/src/security/nlsr_cert_store.cpp
@@ -2,138 +2,129 @@
 
 namespace nlsr
 {
-    static bool
-    nlsrCertificateStoreEntryCompare(NlsrCertificateStoreEntry& ncse1,
-                                               NlsrCertificateStoreEntry& ncse2)
-    
+  static bool
+  nlsrCertificateStoreEntryCompare(NlsrCertificateStoreEntry& ncse1,
+                                   NlsrCertificateStoreEntry& ncse2)
+
+  {
+    return ncse1.getCert()->getName().toUri() ==
+           ncse2.getCert()->getName().toUri() ;
+  }
+
+  static bool
+  nlsrCertificateStoreEntryCompareByName(NlsrCertificateStoreEntry& ncse1,
+                                         std::string compCertName)
+
+  {
+    ndn::Name ccn(compCertName);
+    return ( ncse1.getCert()->getName().toUri() == compCertName ||
+             ccn.isPrefixOf(ncse1.getCert()->getName()) );
+  }
+
+  bool
+  NlsrCertificateStore::addCertificate(NlsrCertificateStoreEntry & ncse)
+  {
+    std::list<NlsrCertificateStoreEntry>::iterator it =
+      std::find_if( certTable.begin(), certTable.end(),
+                    bind(&nlsrCertificateStoreEntryCompare, _1, ncse));
+    if(it == certTable.end())
     {
-        return ncse1.getCert()->getName().toUri() == 
-                                          ncse2.getCert()->getName().toUri() ;
+      certTable.push_back(ncse);
+      return true;
     }
-    
-    static bool
-    nlsrCertificateStoreEntryCompareByName(NlsrCertificateStoreEntry& ncse1,
-                                               std::string compCertName)
-    
+    if( it !=  certTable.end() )
     {
-        return ncse1.getCert()->getName().toUri() == compCertName ;
-    }
-    
-    bool
-    NlsrCertificateStore::addCertificate(NlsrCertificateStoreEntry & ncse)
-    {
-        std::list<NlsrCertificateStoreEntry>::iterator it = 
-                               std::find_if( certTable.begin(), certTable.end(),
-                             bind(&nlsrCertificateStoreEntryCompare, _1, ncse));
-        if(it == certTable.end())
-        {
-            certTable.push_back(ncse);
-            return true;
-        }
-        
-        if( it !=  certTable.end() )
-        {
-            if ( (*it).getCertSeqNum() < ncse.getCertSeqNum() )
-            {
-                certTable.erase(it);
-                certTable.push_back(ncse);
-                return true;
-            }
-        }
-        
-        return false;
-    }
-    
-    bool
-    NlsrCertificateStore::addCertificate(
-        ndn::shared_ptr<ndn::IdentityCertificate> pcert, uint32_t csn, bool isv)
-    {
-        NlsrCertificateStoreEntry ncse(pcert, csn, isv);
-        return addCertificate(ncse);
-    }
-    
-    std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
-    NlsrCertificateStore::getCertificateFromStore(const std::string certName)
-    {
-        std::list<NlsrCertificateStoreEntry>::iterator it = 
-                               std::find_if( certTable.begin(), certTable.end(),
-                   bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
-        if(it == certTable.end())
-        {
-            ndn::shared_ptr<ndn::IdentityCertificate> cert=
-                                   ndn::make_shared<ndn::IdentityCertificate>();
-                                   
-            return std::make_pair(cert,false);
-        }
-        
-        return std::make_pair((*it).getCert(),true);
-    }
-    
-    std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
-    NlsrCertificateStore::getCertificateFromStore(
-                                    const std::string certName, int checkSeqNum)
-    {
-        std::list<NlsrCertificateStoreEntry>::iterator it = 
-                               std::find_if( certTable.begin(), certTable.end(),
-                   bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
-        if(it == certTable.end())
-        {
-            ndn::shared_ptr<ndn::IdentityCertificate> cert=
-                                   ndn::make_shared<ndn::IdentityCertificate>();
-                                   
-            return std::make_pair(cert,false);
-        }
-        else
-        {
-            if( (*it).getCertSeqNum() == checkSeqNum )
-            {
-                return std::make_pair((*it).getCert(),true);
-            }
-        }
-           
-        return std::make_pair((*it).getCert(),false);
-        
-    }
-    
-    bool 
-    NlsrCertificateStore::isCertificateNewInStore(const std::string certName,
-                                                            int checkSeqNo)
-    {
-        std::list<NlsrCertificateStoreEntry>::iterator it = 
-                               std::find_if( certTable.begin(), certTable.end(),
-                   bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
-        if(it != certTable.end())
-        {
-            return (*it).getCertSeqNum() < checkSeqNo ;
-        }
-        
+      if ( (*it).getCertSeqNum() < ncse.getCertSeqNum() )
+      {
+        certTable.erase(it);
+        certTable.push_back(ncse);
         return true;
-        
+      }
     }
-    
-    bool
-    NlsrCertificateStore::removeCertificateFromStroe(const std::string certName)
+    return false;
+  }
+
+  bool
+  NlsrCertificateStore::addCertificate(
+    ndn::shared_ptr<ndn::IdentityCertificate> pcert, uint32_t csn, bool isv)
+  {
+    NlsrCertificateStoreEntry ncse(pcert, csn, isv);
+    return addCertificate(ncse);
+  }
+
+  std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
+  NlsrCertificateStore::getCertificateFromStore(const std::string certName)
+  {
+    std::list<NlsrCertificateStoreEntry>::iterator it =
+      std::find_if( certTable.begin(), certTable.end(),
+                    bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
+    if(it == certTable.end())
     {
-        std::list<NlsrCertificateStoreEntry>::iterator it = 
-                               std::find_if( certTable.begin(), certTable.end(),
-                   bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
-        if(it != certTable.end())
-        {
-            certTable.erase(it);
-            return true;
-        }
-        
-        return false;
+      ndn::shared_ptr<ndn::IdentityCertificate> cert=
+        ndn::make_shared<ndn::IdentityCertificate>();
+      return std::make_pair(cert,false);
     }
-    
-    void 
-    NlsrCertificateStore::printCertStore()
+    return std::make_pair((*it).getCert(),true);
+  }
+
+  std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
+  NlsrCertificateStore::getCertificateFromStore(
+    const std::string certName, int checkSeqNum)
+  {
+    std::list<NlsrCertificateStoreEntry>::iterator it =
+      std::find_if( certTable.begin(), certTable.end(),
+                    bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
+    if(it == certTable.end())
     {
-        std::list<NlsrCertificateStoreEntry>::iterator it;
-        for(it=certTable.begin(); it!=certTable.end(); ++it)
-        {
-            std::cout<<(*it)<<std::endl;
-        }
-        
+      ndn::shared_ptr<ndn::IdentityCertificate> cert=
+        ndn::make_shared<ndn::IdentityCertificate>();
+      return std::make_pair(cert,false);
     }
+    else
+    {
+      if( (*it).getCertSeqNum() == checkSeqNum )
+      {
+        return std::make_pair((*it).getCert(),true);
+      }
+    }
+    return std::make_pair((*it).getCert(),false);
+  }
+
+  bool
+  NlsrCertificateStore::isCertificateNewInStore(const std::string certName,
+      int checkSeqNo)
+  {
+    std::list<NlsrCertificateStoreEntry>::iterator it =
+      std::find_if( certTable.begin(), certTable.end(),
+                    bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
+    if(it != certTable.end())
+    {
+      return (*it).getCertSeqNum() < checkSeqNo ;
+    }
+    return true;
+  }
+
+  bool
+  NlsrCertificateStore::removeCertificateFromStroe(const std::string certName)
+  {
+    std::list<NlsrCertificateStoreEntry>::iterator it =
+      std::find_if( certTable.begin(), certTable.end(),
+                    bind(&nlsrCertificateStoreEntryCompareByName, _1, certName));
+    if(it != certTable.end())
+    {
+      certTable.erase(it);
+      return true;
+    }
+    return false;
+  }
+
+  void
+  NlsrCertificateStore::printCertStore()
+  {
+    std::list<NlsrCertificateStoreEntry>::iterator it;
+    for(it=certTable.begin(); it!=certTable.end(); ++it)
+    {
+      std::cout<<(*it)<<std::endl;
+    }
+  }
 }