tlv: Use the encoding/decoding functions for "double" from ndn-cxx

refs: #4615

Change-Id: I0bde7085876646f272ee6006f4d3cfbd513d4ffd
diff --git a/src/conf-parameter.cpp b/src/conf-parameter.cpp
index 8a2cb5a..67a5b4b 100644
--- a/src/conf-parameter.cpp
+++ b/src/conf-parameter.cpp
@@ -29,7 +29,7 @@
 INIT_LOGGER(ConfParameter);
 
 // To be changed when breaking changes are made to sync
-const uint64_t ConfParameter::SYNC_VERSION = 6;
+const uint64_t ConfParameter::SYNC_VERSION = 7;
 
 static std::unique_ptr<ndn::security::v2::CertificateFetcherDirectFetch>
 makeCertificateFetcher(ndn::Face& face)
diff --git a/src/tlv/coordinate-lsa.cpp b/src/tlv/coordinate-lsa.cpp
index fc74241..20af101 100644
--- a/src/tlv/coordinate-lsa.cpp
+++ b/src/tlv/coordinate-lsa.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -52,10 +52,10 @@
   size_t totalLength = 0;
 
   for (auto it = m_hyperbolicAngle.rbegin(); it != m_hyperbolicAngle.rend(); ++it) {
-    totalLength += prependDouble(block, ndn::tlv::nlsr::HyperbolicAngle, *it);
+    totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::HyperbolicAngle, *it);
   }
 
-  totalLength += prependDouble(block, ndn::tlv::nlsr::HyperbolicRadius, m_hyperbolicRadius);
+  totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::HyperbolicRadius, m_hyperbolicRadius);
 
   totalLength += m_lsaInfo.wireEncode(block);
 
@@ -109,22 +109,20 @@
     ++val;
   }
   else {
-    std::cout << "Missing required LsaInfo field" << std::endl;
     BOOST_THROW_EXCEPTION(Error("Missing required LsaInfo field"));
   }
 
   if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::HyperbolicRadius) {
-    m_hyperbolicRadius = ndn::tlv::nlsr::readDouble(*val);
+    m_hyperbolicRadius = ndn::encoding::readDouble(*val);
     ++val;
   }
   else {
-    std::cout << "Missing required HyperbolicRadius field" << std::endl;
     BOOST_THROW_EXCEPTION(Error("Missing required HyperbolicRadius field"));
   }
 
   for (; val != m_wire.elements_end(); ++val) {
     if (val->type() == ndn::tlv::nlsr::HyperbolicAngle) {
-      m_hyperbolicAngle.push_back(ndn::tlv::nlsr::readDouble(*val));
+      m_hyperbolicAngle.push_back(ndn::encoding::readDouble(*val));
     }
   }
 }
diff --git a/src/tlv/nexthop.cpp b/src/tlv/nexthop.cpp
index 2db9c3c..d05473e 100644
--- a/src/tlv/nexthop.cpp
+++ b/src/tlv/nexthop.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018,  The University of Memphis,
+/*
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -50,7 +50,7 @@
 {
   size_t totalLength = 0;
 
-  totalLength += prependDouble(block, ndn::tlv::nlsr::Double, m_cost);
+  totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::CostDouble, m_cost);
 
   totalLength += block.prependByteArrayBlock(
     ndn::tlv::nlsr::Uri, reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());
@@ -108,7 +108,7 @@
     BOOST_THROW_EXCEPTION(Error("Missing required Uri field"));
   }
 
-  m_cost = ndn::tlv::nlsr::readDouble(*val);
+  m_cost = ndn::encoding::readDouble(*val);
 }
 
 std::ostream&
diff --git a/src/tlv/tlv-nlsr.hpp b/src/tlv/tlv-nlsr.hpp
index 0e400ea..265b2c6 100644
--- a/src/tlv/tlv-nlsr.hpp
+++ b/src/tlv/tlv-nlsr.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018,  The University of Memphis,
+/*
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -23,7 +23,6 @@
 #define NLSR_TLV_NLSR_HPP
 
 #include <ndn-cxx/encoding/tlv.hpp>
-#include <ndn-cxx/encoding/block-helpers.hpp>
 
 namespace ndn {
 namespace tlv {
@@ -41,7 +40,7 @@
   AdjacencyLsa     = 131,
   Adjacency        = 132,
   CoordinateLsa    = 133,
-  Double           = 134,
+  CostDouble       = 134,
   HyperbolicRadius = 135,
   HyperbolicAngle  = 136,
   NameLsa          = 137,
@@ -52,48 +51,9 @@
   Destination      = 142,
   NextHop          = 143,
   RoutingTable     = 144,
-  RouteTableEntry  = 145
+  RouteTableEntry  = 145,
 };
 
-/*! \brief Read a double from a TLV element
- *  \param block the TLV element
- *  \throw ndn::tlv::Error block does not contain a double
- *  \sa prependDouble
- */
-inline double
-readDouble(const ndn::Block& block)
-{
-  block.parse();
-  auto it = block.elements_begin();
-
-  double doubleFromBlock = 0.0;
-  if (it == it->elements_end() || it->type() != ndn::tlv::nlsr::Double ||
-      it->value_size() != sizeof(doubleFromBlock)) {
-    BOOST_THROW_EXCEPTION(ndn::tlv::Error("Block does not contain a double"));
-  }
-  memcpy(&doubleFromBlock, it->value(), sizeof(doubleFromBlock));
-  return doubleFromBlock;
-}
-
-/*! \brief Prepend a TLV element containing a double.
- *  \param encoder an EncodingBuffer or EncodingEstimator
- *  \param type TLV-TYPE number
- *  \param value double value
- */
-template<ndn::encoding::Tag TAG>
-inline size_t
-prependDouble(ndn::EncodingImpl<TAG>& encoder, uint32_t type, double value)
-{
-  size_t totalLength = 0;
-
-  const uint8_t* doubleBytes = reinterpret_cast<const uint8_t*>(&value);
-  totalLength = encoder.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes, 8);
-  totalLength += encoder.prependVarNumber(totalLength);
-  totalLength += encoder.prependVarNumber(type);
-
-  return totalLength;
-}
-
 } // namespace nlsr
 } // namespace tlv
 } // namespace ndn
diff --git a/tests/tlv/test-adjacency-lsa.cpp b/tests/tlv/test-adjacency-lsa.cpp
index 5959535..65fe2b6 100644
--- a/tests/tlv/test-adjacency-lsa.cpp
+++ b/tests/tlv/test-adjacency-lsa.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -24,7 +24,7 @@
 #include "../boost-test.hpp"
 
 namespace nlsr {
-namespace tlv  {
+namespace tlv {
 namespace test {
 
 BOOST_AUTO_TEST_SUITE(TlvTestAdjacencyLsa)
@@ -50,7 +50,7 @@
   0x83, 0x13,
   // LsaInfo
   0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
-  0x80, 0x8b, 0x02, 0x27, 0x10,
+  0x80, 0x8b, 0x02, 0x27, 0x10
 };
 
 BOOST_AUTO_TEST_CASE(AdjacencyLsaEncodeWithAdjacencies)
diff --git a/tests/tlv/test-adjacency.cpp b/tests/tlv/test-adjacency.cpp
index 3126073..b271a62 100644
--- a/tests/tlv/test-adjacency.cpp
+++ b/tests/tlv/test-adjacency.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -24,7 +24,7 @@
 #include "../boost-test.hpp"
 
 namespace nlsr {
-namespace tlv  {
+namespace tlv {
 namespace test {
 
 BOOST_AUTO_TEST_SUITE(TlvTestAdjacency)
diff --git a/tests/tlv/test-coordinate-lsa.cpp b/tests/tlv/test-coordinate-lsa.cpp
index fa05d95..dc289ca 100644
--- a/tests/tlv/test-coordinate-lsa.cpp
+++ b/tests/tlv/test-coordinate-lsa.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -32,14 +32,15 @@
 const uint8_t CoordinateLsaData[] =
 {
   // Header
-  0x85, 0x2b,
+  0x85, 0x27,
   // LsaInfo
   0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
   0x80, 0x8b, 0x02, 0x27, 0x10,
   // HyperbolicRadius
-  0x87, 0x0a, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f,
+  0x87, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
   // HyperbolicAngle
-  0x88, 0x0a, 0x86, 0x08, 0x7b, 0x14, 0xae, 0x47, 0xe1, 0x7a, 0xfc, 0x3f
+  0x88, 0x08, 0x3f, 0xfc, 0x7a, 0xe1, 0x47, 0xae, 0x14, 0x7b
+
 };
 
 BOOST_AUTO_TEST_CASE(CoordinateLsaEncode)
diff --git a/tests/tlv/test-lsdb-status.cpp b/tests/tlv/test-lsdb-status.cpp
index 12284e8..c058fb1 100644
--- a/tests/tlv/test-lsdb-status.cpp
+++ b/tests/tlv/test-lsdb-status.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -34,7 +34,7 @@
 const uint8_t LsdbStatusData1[] =
 {
   // Header
-  0x8a, 0x7f,
+  0x8a, 0x7b,
   // AdjacencyLsa
   0x83, 0x32,
     // LsaInfo
@@ -44,15 +44,15 @@
     0x84, 0x1d, 0x07, 0x0c, 0x08, 0x0a, 0x61, 0x64, 0x6a, 0x61, 0x63, 0x65, 0x6e, 0x63,
     0x79, 0x31, 0x8d, 0x0a, 0x61, 0x64, 0x6a, 0x61, 0x63, 0x65, 0x6e, 0x63, 0x79, 0x31,
     0x8c, 0x01, 0x80,
-  // CoordianteLsa
-  0x85, 0x2b,
+  // CoordinateLsa
+  0x85, 0x27,
     // LsaInfo
     0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
     0x80, 0x8b, 0x02, 0x27, 0x10,
     // HyperbolicRadius
-    0x87, 0x0a, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f,
+    0x87, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
     // HyperbolicAngle
-    0x88, 0x0a, 0x86, 0x08, 0x7b, 0x14, 0xae, 0x47, 0xe1, 0x7a, 0xfc, 0x3f,
+    0x88, 0x08, 0x3f, 0xfc, 0x7a, 0xe1, 0x47, 0xae, 0x14, 0x7b,
   // NameLsa
   0x89, 0x1c,
     // LsaInfo
@@ -71,16 +71,16 @@
 const uint8_t LsdbStatusData3[] =
 {
   // Header
-  0x8a, 0x7f,
+  0x8a, 0x7b,
   // CoordianteLsa
-  0x85, 0x2b,
+  0x85, 0x27,
     // LsaInfo
     0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
-    0x80, 0x8b, 0x02, 0x27, 0x10,
+    0x80, 0x8B, 0x02, 0x27, 0x10,
     // HyperbolicRadius
-    0x87, 0x0a, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f,
+    0x87, 0x08, 0x3F, 0xFA, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
     // HyperbolicAngle
-    0x88, 0x0a, 0x86, 0x08, 0x7b, 0x14, 0xae, 0x47, 0xe1, 0x7a, 0xfc, 0x3f,
+    0x88, 0x08, 0x3F, 0xFC, 0x7A, 0xE1, 0x47, 0xAE, 0x14, 0x7B,
   // NameLsa
   0x89, 0x1c,
     // LsaInfo
@@ -89,14 +89,14 @@
     // Name
     0x07, 0x07, 0x08, 0x05, 0x6e, 0x61, 0x6d, 0x65, 0x31,
   // AdjacencyLsa
-   0x83, 0x32,
-     // LsaInfo
-     0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
-     0x80, 0x8b, 0x02, 0x27, 0x10,
-     // Adjacency
-     0x84, 0x1d, 0x07, 0x0c, 0x08, 0x0a, 0x61, 0x64, 0x6a, 0x61, 0x63, 0x65, 0x6e, 0x63,
-     0x79, 0x31, 0x8d, 0x0a, 0x61, 0x64, 0x6a, 0x61, 0x63, 0x65, 0x6e, 0x63, 0x79, 0x31,
-     0x8c, 0x01, 0x80
+  0x83, 0x32,
+    // LsaInfo
+    0x80, 0x11, 0x81, 0x08, 0x07, 0x06, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x82, 0x01,
+    0x80, 0x8B, 0x02, 0x27, 0x10,
+    // Adjacency
+    0x84, 0x1d, 0x07, 0x0c, 0x08, 0x0a, 0x61, 0x64, 0x6a, 0x61, 0x63, 0x65, 0x6e, 0x63,
+    0x79, 0x31, 0x8d, 0x0a, 0x61, 0x64, 0x6a, 0x61, 0x63, 0x65, 0x6e, 0x63, 0x79, 0x31,
+    0x8c, 0x01, 0x80
 };
 
 BOOST_AUTO_TEST_CASE(LsdbStatusEncode1)
@@ -150,7 +150,6 @@
   LsdbStatus lsdbStatus;
 
   const ndn::Block& wire = lsdbStatus.wireEncode();
-
   BOOST_REQUIRE_EQUAL_COLLECTIONS(LsdbStatusData2,
                                   LsdbStatusData2 + sizeof(LsdbStatusData2),
                                   wire.begin(), wire.end());
diff --git a/tests/tlv/test-name-lsa.cpp b/tests/tlv/test-name-lsa.cpp
index b84b12f..f5ce311 100644
--- a/tests/tlv/test-name-lsa.cpp
+++ b/tests/tlv/test-name-lsa.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -24,7 +24,7 @@
 #include "../boost-test.hpp"
 
 namespace nlsr {
-namespace tlv  {
+namespace tlv {
 namespace test {
 
 BOOST_AUTO_TEST_SUITE(TlvTestNameLsa)
diff --git a/tests/tlv/test-nexthops.cpp b/tests/tlv/test-nexthops.cpp
index 9e8158f..1714bbf 100644
--- a/tests/tlv/test-nexthops.cpp
+++ b/tests/tlv/test-nexthops.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2018,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -32,11 +32,12 @@
 const uint8_t NexthopData[] =
 {
   // Header
-  0x8f, 0x1f,
+  0x8f, 0x1d,
   // Uri
-  0x8d, 0x11, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x2f, 0x74, 0x6c, 0x76,
+  0x8d, 0x11, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f,
+  0x70, 0x2f, 0x74, 0x6c, 0x76,
   // Cost
-  0x86, 0x0a, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f
+  0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
 };
 
 BOOST_AUTO_TEST_CASE(NexthopEncode)
@@ -46,7 +47,6 @@
   nexthops1.setCost(1.65);
 
   const ndn::Block& wire = nexthops1.wireEncode();
-
   BOOST_REQUIRE_EQUAL_COLLECTIONS(NexthopData,
                                   NexthopData + sizeof(NexthopData),
                                   wire.begin(), wire.end());
diff --git a/tests/tlv/test-nlsr.cpp b/tests/tlv/test-nlsr.cpp
deleted file mode 100644
index 43d1487..0000000
--- a/tests/tlv/test-nlsr.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018,  The University of Memphis,
- *                           Regents of the University of California,
- *                           Arizona Board of Regents.
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "tlv/tlv-nlsr.hpp"
-
-#include "../boost-test.hpp"
-
-#include <ndn-cxx/encoding/estimator.hpp>
-#include <ndn-cxx/encoding/encoding-buffer.hpp>
-#include <ndn-cxx/encoding/block-helpers.hpp>
-
-namespace nlsr {
-namespace tlv {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TlvTestNlsr)
-
-BOOST_AUTO_TEST_CASE(TestDouble)
-{
-  ndn::Block block = ndn::encoding::makeNonNegativeIntegerBlock(0x01, 1);
-  BOOST_CHECK_THROW(ndn::tlv::nlsr::readDouble(block), ndn::tlv::Error);
-
-  double value = 1.65;
-  uint32_t type = 0x251;
-
-  ndn::encoding::EncodingEstimator estimator;
-  size_t totalLength = ndn::tlv::nlsr::prependDouble(estimator, type, value);
-
-  ndn::encoding::EncodingBuffer encoder(totalLength, 0);
-  ndn::tlv::nlsr::prependDouble(encoder, type, value);
-
-  BOOST_CHECK_CLOSE(value, ndn::tlv::nlsr::readDouble(encoder.block()), 0.001);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace tlv
-} // namespace nlsr
diff --git a/tests/tlv/test-routing-table-entry.cpp b/tests/tlv/test-routing-table-entry.cpp
index deaad1c..9415210 100644
--- a/tests/tlv/test-routing-table-entry.cpp
+++ b/tests/tlv/test-routing-table-entry.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2018,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -32,15 +32,15 @@
 const uint8_t RoutingTableEntryWithNexthopsData[] =
 {
   // Header
-  0x91, 0x3b,
+  0x91, 0x37,
   // Destination
   0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
   // Nexthop
-  0x8f, 0x16, 0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70,
-  0x31, 0x86, 0x0a, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f,
+  0x8f, 0x14, 0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x31, 0x86, 0x08,
+  0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x8f, 0x14,
   // Nexthop
-  0x8f, 0x16, 0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70,
-  0x32, 0x86, 0x0a, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f
+  0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x32, 0x86, 0x08, 0x3f, 0xfa,
+  0x66, 0x66, 0x66, 0x66, 0x66, 0x66
 };
 
 const uint8_t RoutingTableEntryWithoutNexthopsData[] =
diff --git a/tests/tlv/test-routing-table.cpp b/tests/tlv/test-routing-table.cpp
index 85a9850..6e9ce43 100644
--- a/tests/tlv/test-routing-table.cpp
+++ b/tests/tlv/test-routing-table.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2018,  The University of Memphis,
+ * Copyright (c) 2014-2019,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -32,14 +32,14 @@
 const uint8_t RoutingTableData1[] =
 {
   // Header
-  0x90, 0x24,
+  0x90, 0x22,
   // Routing table entry
-  0x91, 0x22,
-    // Destination
-    0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
-    // Nexthop
-    0x8f, 0x15, 0x8d, 0x07, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70,
-    0x86, 0x0a, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f
+  0x91, 0x20,
+  // Destination
+  0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
+  // Nexthop
+  0x8f, 0x13, 0x8d, 0x07, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x86, 0x08, 0x3f,
+  0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
 };
 
 const uint8_t RoutingTableData2[] =