src: Changing LSA names to conform with specs

Change LSA names from /<network>/NLSR/LSA/<network>/<site>/<router-name>/<type>/<version>
to /<network>/NLSR/LSA/<site>/<router-name>/<type>/<version> to conform with the
NLSR specification document. http://redmine.named-data.net/projects/nlsr/wiki/Build_LSAs

Change-Id: I89c9aaee44cd1f3d286a29bd8eb5585bfa844b43
diff --git a/nlsr.conf b/nlsr.conf
index 6cad1f7..d6f31bc 100644
--- a/nlsr.conf
+++ b/nlsr.conf
@@ -151,7 +151,7 @@
             k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><ksk-.*><ID-CERT>$
             k-expand \\1
             h-relation equal
-            p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><>$
+            p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><>$
             p-expand \\1\\2
           }
         }
@@ -165,7 +165,7 @@
       filter
       {
         type name
-        regex ^[^<KEY><%C1.O.R.>]*<%C1.O.R.><><KEY><ksk-.*><ID-CERT><>$
+        regex ^[^<KEY><%C1.O.R.>]*<%C1.O.R.>[^<KEY><NLSR>]*<KEY><ksk-.*><ID-CERT><>$
       }
       checker
       {
@@ -176,10 +176,10 @@
           type name
           hyper-relation
           {
-            k-regex ^([^<KEY><%C1.O.N.>]*)<%C1.O.N.><><KEY><ksk-.*><ID-CERT>$
+	    k-regex ^([^<KEY><%C1.O.N.>]*)<%C1.O.N.>[^<KEY>]*<KEY><ksk-.*><ID-CERT>$
             k-expand \\1
             h-relation equal
-            p-regex ^([^<KEY><%C1.O.R.>]*)<%C1.O.R.><><KEY><ksk-.*><ID-CERT><>$
+            p-regex ^([^<KEY><%C1.O.R.>]*)<%C1.O.R.>[^<KEY>]*<KEY><ksk-.*><ID-CERT><>$
             p-expand \\1
           }
         }
@@ -208,12 +208,12 @@
       file-name "root.cert"
     }
   }
-  ; cert-to-publish "root.cert" //optional, a file containing the root certificate. only the router
-                                //that is designated to publish root cert needs to specify this
-  ; cert-to-publish "site.cert" //optional, a file containing the root certificate. only the router
-                                //that is designated to publish site cert need to specify this
-  ; cert-to-publish "operator.cert" //optional, a file containing the root certificate. only the
-                                    //router that is designated to publish operator cert need to
-                                    //specify this
-  ; cert-to-publish "router.cert" //required, a file containing the router certificate.
+  ; cert-to-publish "root.cert"  ; optional, a file containing the root certificate. only the router
+                                 ; that is designated to publish root cert needs to specify this
+  ; cert-to-publish "site.cert"  ; optional, a file containing the root certificate. only the router
+                                 ; that is designated to publish site cert need to specify this
+  ; cert-to-publish "operator.cert" ; optional, a file containing the root certificate. only the
+                                    ; router that is designated to publish operator cert need to
+                                    ; specify this
+  cert-to-publish "router.cert"  ; required, a file containing the router certificate.
 }
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 16e7d1a..c5e7756 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -567,8 +567,11 @@
                 m_nlsr.getAdjacencyList());
   m_nlsr.getSequencingManager().increaseAdjLsaSeq();
   // publish routing update
+  //ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
+  //lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
   ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
-  lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
+  lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
+  lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
   m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
                                                     lsaPrefix);
   return installAdjLsa(adjLsa);
@@ -643,8 +646,11 @@
                                                                  chkNameLsa->getLsSeqNo(),
                                                                  ndn::time::seconds(m_lsaRefreshTime)));
         // publish routing update
+        //ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
+        //lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
         ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
-        lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
+        lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
+        lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
         m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
                                                           lsaPrefix);
       }
@@ -679,8 +685,11 @@
                                                                chkAdjLsa->getLsSeqNo(),
                                                                ndn::time::seconds(m_lsaRefreshTime)));
         // publish routing update
+        //ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
+        //lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
         ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
-        lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
+        lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
+        lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
         m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
                                                           lsaPrefix);
       }
@@ -719,8 +728,11 @@
                                         chkCorLsa->getLsSeqNo(),
                                         ndn::time::seconds(m_lsaRefreshTime)));
         // publish routing update
+        //ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
+        //lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
         ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
-        lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
+        lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
+        lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
         m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
                                                           lsaPrefix);
       }
@@ -762,8 +774,9 @@
   if (lsaPosition >= 0) {
     std::string interestedLsType;
     uint64_t interestedLsSeqNo;
-    ndn::Name origRouter = intName.getSubName(lsaPosition + 1,
-                                              interest.getName().size() - lsaPosition - 3);
+    ndn::Name origRouter = m_nlsr.getConfParameter().getNetwork();
+    origRouter.append(intName.getSubName(lsaPosition + 1,
+                                         interest.getName().size() - lsaPosition - 3));
     interestedLsType  = intName[-2].toUri();
     interestedLsSeqNo = intName[-1].toNumber();
     if (interestedLsType == "name") {
@@ -870,8 +883,9 @@
   if (lsaPosition >= 0) {
     std::string interestedLsType;
     uint64_t interestedLsSeqNo;
-    ndn::Name origRouter = dataName.getSubName(lsaPosition + 1,
-                                               dataName.size() - lsaPosition - 4);
+    ndn::Name origRouter = m_nlsr.getConfParameter().getNetwork();
+    origRouter.append(dataName.getSubName(lsaPosition + 1,
+                                          dataName.size() - lsaPosition - 4));
     interestedLsType  = dataName[-3].toUri();
     interestedLsSeqNo = dataName[-2].toNumber();
     if (interestedLsType == "name") {
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 76d841d..5484336 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -65,7 +65,8 @@
 Nlsr::setLsaInterestFilter()
 {
   ndn::Name name = m_confParam.getLsaPrefix();
-  name.append(m_confParam.getRouterPrefix());
+  name.append(m_confParam.getSiteName());
+  name.append(m_confParam.getRouterName());
   _LOG_DEBUG("Setting interest filter for name: " << name);
   getNlsrFace().setInterestFilter(name,
                                   ndn::bind(&Lsdb::processInterest,