daemon: Support query that explicitly specify version

Change-Id: I8eac2c5d2a646fbb965691498f8d416a86b70763
diff --git a/src/ndns-label.cpp b/src/ndns-label.cpp
index 585509c..1b1cc80 100644
--- a/src/ndns-label.cpp
+++ b/src/ndns-label.cpp
@@ -18,6 +18,7 @@
  */
 
 #include "ndns-label.hpp"
+
 #include <ndn-cxx/data.hpp>
 #include <ndn-cxx/interest.hpp>
 
@@ -59,7 +60,7 @@
           const Name& hint, const Name& zone,
           MatchResult& result)
 {
-  // [hint / FHLabel] / zoneName / <Update>|rrLabel / UPDATE|rrType
+  // [hint / FHLabel] / zoneName / <Update>|rrLabel / UPDATE|rrType / [VERSION]
 
   const Name& name = interest.getName();
   size_t skip = calculateSkip(name, hint, zone);
@@ -67,9 +68,17 @@
   if (name.size() - skip < 1)
     return false;
 
-  result.rrType = name.get(-1);
-  result.rrLabel = name.getSubName(skip, std::max<size_t>(0, name.size() - skip - 1));
-  result.version = name::Component();
+  size_t offset = 1;
+  if (name.get(-offset).isVersion()) {
+    result.version = name.get(-offset);
+    ++offset;
+  }
+  else {
+    result.version = name::Component();
+  }
+
+  result.rrType = name.get(-offset);
+  result.rrLabel = name.getSubName(skip, std::max<size_t>(0, name.size() - skip - offset));
 
   return true;
 }