NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
nfd-channel-status.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#include "
nfd-channel-status.hpp
"
23
#include "
encoding/tlv-nfd.hpp
"
24
#include "
encoding/block-helpers.hpp
"
25
#include "
util/concepts.hpp
"
26
27
namespace
ndn
{
28
namespace
nfd
{
29
30
//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<ChannelStatus>));
31
BOOST_CONCEPT_ASSERT((
WireEncodable<ChannelStatus>
));
32
BOOST_CONCEPT_ASSERT((
WireDecodable<ChannelStatus>
));
33
static_assert(std::is_base_of<tlv::Error, ChannelStatus::Error>::value,
34
"ChannelStatus::Error must inherit from tlv::Error"
);
35
36
ChannelStatus::ChannelStatus
()
37
{
38
}
39
40
ChannelStatus::ChannelStatus
(
const
Block
& payload)
41
{
42
this->
wireDecode
(payload);
43
}
44
45
template
<encoding::Tag TAG>
46
size_t
47
ChannelStatus::wireEncode
(
EncodingImpl<TAG>
& encoder)
const
48
{
49
size_t
totalLength = 0;
50
51
totalLength += encoder.prependByteArrayBlock(
tlv::nfd::LocalUri
,
52
reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size());
53
54
totalLength += encoder.prependVarNumber(totalLength);
55
totalLength += encoder.prependVarNumber(
tlv::nfd::ChannelStatus
);
56
return
totalLength;
57
}
58
59
template
size_t
60
ChannelStatus::wireEncode<encoding::EncoderTag>(
EncodingImpl<encoding::EncoderTag>
&)
const
;
61
62
template
size_t
63
ChannelStatus::wireEncode<encoding::EstimatorTag>(
EncodingImpl<encoding::EstimatorTag>
&)
const
;
64
65
const
Block
&
66
ChannelStatus::wireEncode
()
const
67
{
68
if
(m_wire.
hasWire
())
69
return
m_wire;
70
71
EncodingEstimator
estimator;
72
size_t
estimatedSize =
wireEncode
(estimator);
73
74
EncodingBuffer
buffer(estimatedSize, 0);
75
wireEncode
(buffer);
76
77
m_wire = buffer.block();
78
return
m_wire;
79
}
80
81
void
82
ChannelStatus::wireDecode
(
const
Block
& block)
83
{
84
if
(block.
type
() !=
tlv::nfd::ChannelStatus
) {
85
BOOST_THROW_EXCEPTION(
Error
(
"Expecting ChannelStatus block"
));
86
}
87
m_wire = block;
88
m_wire.
parse
();
89
Block::element_const_iterator
val = m_wire.
elements_begin
();
90
91
if
(val != m_wire.
elements_end
() && val->type() ==
tlv::nfd::LocalUri
) {
92
m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
93
++val;
94
}
95
else
{
96
BOOST_THROW_EXCEPTION(
Error
(
"Missing required LocalUri field"
));
97
}
98
}
99
100
ChannelStatus
&
101
ChannelStatus::setLocalUri
(
const
std::string localUri)
102
{
103
m_wire.
reset
();
104
m_localUri = localUri;
105
return
*
this
;
106
}
107
108
}
// namespace nfd
109
}
// namespace ndn
ndn::Block::elements_begin
element_const_iterator elements_begin() const
Definition:
block.cpp:589
ndn::Block::hasWire
bool hasWire() const
Check if the Block has fully encoded wire.
Definition:
block.cpp:471
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::tlv::nfd::ChannelStatus
Definition:
tlv-nfd.hpp:63
ndn::encoding::EncodingEstimator
EncodingImpl< EstimatorTag > EncodingEstimator
Definition:
encoding-buffer-fwd.hpp:48
ndn::nfd::ChannelStatus::Error
Definition:
nfd-channel-status.hpp:38
ndn::nfd::ChannelStatus::wireEncode
const Block & wireEncode() const
Definition:
nfd-channel-status.cpp:66
ndn::Block::elements_end
element_const_iterator elements_end() const
Definition:
block.cpp:595
ndn::Block::parse
void parse() const
Parse wire buffer into subblocks.
Definition:
block.cpp:322
block-helpers.hpp
ndn::Block
Class representing a wire element of NDN-TLV packet format.
Definition:
block.hpp:43
ndn::tlv::nfd::LocalUri
Definition:
tlv-nfd.hpp:62
ndn::encoding::EncodingBuffer
EncodingImpl< EncoderTag > EncodingBuffer
Definition:
encoding-buffer-fwd.hpp:45
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
ndn::Block::element_const_iterator
element_container::const_iterator element_const_iterator
Definition:
block.hpp:48
ndn::Block::reset
void reset()
Reset wire buffer of the element.
Definition:
block.cpp:302
ndn::encoding::EncodingImpl
Definition:
encoding-buffer-fwd.hpp:45
concepts.hpp
tlv-nfd.hpp
ndn::nfd::ChannelStatus
represents NFD Channel Status dataset
Definition:
nfd-channel-status.hpp:35
nfd-channel-status.hpp
ndn::WireEncodable
a concept check for TLV abstraction with .wireEncode method
Definition:
concepts.hpp:34
ndn::WireDecodable
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Definition:
concepts.hpp:70
ndn::nfd::ChannelStatus::wireDecode
void wireDecode(const Block &wire)
Definition:
nfd-channel-status.cpp:82
ndn::Block::type
uint32_t type() const
Definition:
block.hpp:346
ndn::nfd::ChannelStatus::setLocalUri
ChannelStatus & setLocalUri(const std::string localUri)
Definition:
nfd-channel-status.cpp:101
ndn::nfd::ChannelStatus::ChannelStatus
ChannelStatus()
Definition:
nfd-channel-status.cpp:36
ndnSIM
ndn-cxx
src
management
nfd-channel-status.cpp
Generated on Fri Feb 23 2018 12:30:54 for ndnSIM by
1.8.14