25 #ifndef NFD_DAEMON_FACE_LOCAL_FACE_HPP
26 #define NFD_DAEMON_FACE_LOCAL_FACE_HPP
29 #include <ndn-cxx/management/nfd-control-parameters.hpp>
33 using ndn::nfd::LocalControlFeature;
34 using ndn::nfd::LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID;
35 using ndn::nfd::LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID;
42 LocalFace(
const FaceUri& remoteUri,
const FaceUri& localUri);
94 template<
class Packet>
99 std::vector<bool> m_localControlHeaderFeatures;
104 :
Face(remoteUri, localUri, true)
105 , m_localControlHeaderFeatures(
LocalFace::LOCAL_CONTROL_FEATURE_MAX)
118 BOOST_ASSERT(0 < feature &&
119 static_cast<size_t>(feature) < m_localControlHeaderFeatures.size());
120 return m_localControlHeaderFeatures[feature];
126 BOOST_ASSERT(0 < feature &&
127 static_cast<size_t>(feature) < m_localControlHeaderFeatures.size());
129 m_localControlHeaderFeatures[feature] = enabled;
132 std::find(m_localControlHeaderFeatures.begin() + 1,
133 m_localControlHeaderFeatures.end(),
true) <
134 m_localControlHeaderFeatures.end();
142 const Block& payload = ndn::nfd::LocalControlHeader::getPayload(element);
148 if (payload.type() == tlv::Interest)
150 shared_ptr<Interest> i = make_shared<Interest>();
151 i->wireDecode(payload);
152 if (&payload != &element)
156 mask |= ndn::nfd::LocalControlHeader::ENCODE_NEXT_HOP;
158 i->getLocalControlHeader().wireDecode(element, mask);
163 else if (payload.type() == tlv::Data)
165 shared_ptr<Data> d = make_shared<Data>();
166 d->wireDecode(payload);
186 catch (tlv::Error&) {
199 mask |= ndn::nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID;
201 return header.empty(mask);
204 template<
class Packet>
210 mask |= ndn::nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID;
212 return packet.getLocalControlHeader().wireEncode(packet, mask);
217 #endif // NFD_DAEMON_FACE_LOCAL_FACE_HPP
static const size_t LOCAL_CONTROL_FEATURE_ANY
upper bound of LocalControlFeature enum
EventEmitter< Data > onReceiveData
fires when a Data is received
Block filterAndEncodeLocalControlHeader(const Packet &packet)
Create LocalControlHeader, considering enabled features.
bool isLocalControlHeaderEnabled() const
get whether any LocalControlHeader feature is enabled
bool decodeAndDispatchInput(const Block &element)
any feature
LocalFace(const FaceUri &remoteUri, const FaceUri &localUri)
bool isEmptyFilteredLocalControlHeader(const ndn::nfd::LocalControlHeader &header) const
Check if LocalControlHeader needs to be included, taking into account both set parameters in supplied...
static const size_t LOCAL_CONTROL_FEATURE_MAX
EventEmitter< Interest > onReceiveInterest
fires when an Interest is received
void setLocalControlHeaderFeature(LocalControlFeature feature, bool enabled=true)
enable or disable a LocalControlHeader feature