24 #include <ndn-cxx/encoding/block-helpers.hpp>
28 template<ndn::encoding::Tag TAG>
32 size_t totalLength = 0;
35 totalLength += ndn::encoding::prependStringBlock(block,
nlsr::tlv::Uri, m_connectingFaceUri.toString());
37 totalLength += block.prependVarNumber(totalLength);
48 if (m_wire.hasWire()) {
52 ndn::EncodingEstimator estimator;
55 ndn::EncodingBuffer buffer(estimatedSize, 0);
58 m_wire = buffer.block();
66 m_connectingFaceUri = {};
72 NDN_THROW(
Error(
"NextHop", m_wire.type()));
77 auto val = m_wire.elements_begin();
79 if (val != m_wire.elements_end() && val->type() ==
nlsr::tlv::Uri) {
81 m_connectingFaceUri = ndn::FaceUri(ndn::encoding::readString(*val));
83 catch (
const ndn::FaceUri::Error& e) {
84 NDN_THROW_NESTED(
Error(
"Invalid Uri"));
89 NDN_THROW(
Error(
"Missing required Uri field"));
93 m_routeCost = ndn::encoding::readDouble(*val);
97 NDN_THROW(
Error(
"Missing required CostDouble field"));
Data abstraction for Nexthop.
const ndn::Block & wireEncode() const
const ndn::FaceUri & getConnectingFaceUri() const
void wireDecode(const ndn::Block &wire)
double getRouteCost() const
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)