25 #include <ndn-cxx/util/concepts.hpp> 26 #include <ndn-cxx/encoding/block-helpers.hpp> 31 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<RoutingTable>));
32 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<RoutingTable>));
33 static_assert(std::is_base_of<ndn::tlv::Error, RoutingTable::Error>::value,
34 "RoutingTable::Error must inherit from tlv::Error");
37 : m_hasNexthops(false)
55 m_nexthops.push_back(nexthop);
65 m_hasNexthops =
false;
69 template<ndn::encoding::Tag TAG>
73 size_t totalLength = 0;
75 for (std::list<NextHop>::const_reverse_iterator it = m_nexthops.rbegin();
76 it != m_nexthops.rend(); ++it) {
77 totalLength += it->wireEncode(block);
82 totalLength += block.prependVarNumber(totalLength);
93 if (m_wire.hasWire()) {
97 ndn::EncodingEstimator estimator;
100 ndn::EncodingBuffer buffer(estimatedSize, 0);
103 m_wire = buffer.block();
111 m_hasNexthops =
false;
117 std::stringstream error;
118 error <<
"Expected RoutingTable Block, but Block is of a different type: #" 120 BOOST_THROW_EXCEPTION(
Error(error.str()));
125 ndn::Block::element_const_iterator val = m_wire.elements_begin();
132 BOOST_THROW_EXCEPTION(
Error(
"Missing required destination field"));
135 for (; val != m_wire.elements_end(); ++val) {
137 m_nexthops.push_back(
NextHop(*val));
138 m_hasNexthops =
true;
141 std::stringstream error;
142 error <<
"Expected NextHop Block, but Block is of a different type: #" 144 BOOST_THROW_EXCEPTION(
Error(error.str()));
153 os <<
"NexthopList(" << std::endl;
155 for (
const auto& rtentry : routingtable) {
void wireDecode(const ndn::Block &wire)
Data abstraction for Nexthop.
const Destination & getDestination() const
RoutingTable & clearNexthops()
Data abstraction for RouteTableInfo.
const ndn::Block & wireEncode() const
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Destination)
void wireDecode(const ndn::Block &wire)
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
size_t wireEncode(ndn::EncodingImpl< TAG > &block) const
RoutingTable & addNexthops(const NextHop &nexthop)