NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
face-query-status-publisher.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
27 
28 #include <boost/range/adaptor/reversed.hpp>
29 #include <ndn-cxx/management/nfd-face-status.hpp>
30 
31 namespace nfd {
32 
34  AppFace& face,
35  const Name& prefix,
36  const ndn::nfd::FaceQueryFilter& filter,
37  ndn::KeyChain& keyChain)
38  : SegmentPublisher(face, prefix, keyChain)
39  , m_faceTable(faceTable)
40  , m_faceFilter(filter)
41 {
42 }
43 
45 {
46 }
47 
48 bool
49 FaceQueryStatusPublisher::doesMatchFilter(const shared_ptr<Face>& face)
50 {
51  if (m_faceFilter.hasFaceId() &&
52  m_faceFilter.getFaceId() != static_cast<uint64_t>(face->getId())) {
53  return false;
54  }
55 
56  if (m_faceFilter.hasUriScheme() &&
57  (m_faceFilter.getUriScheme() != face->getRemoteUri().getScheme() ||
58  m_faceFilter.getUriScheme() != face->getLocalUri().getScheme())) {
59  return false;
60  }
61 
62  if (m_faceFilter.hasRemoteUri() &&
63  m_faceFilter.getRemoteUri() != face->getRemoteUri().toString()) {
64  return false;
65  }
66 
67  if (m_faceFilter.hasLocalUri() && m_faceFilter.getLocalUri() != face->getLocalUri().toString()) {
68  return false;
69  }
70 
71  if (m_faceFilter.hasFaceScope() &&
72  (m_faceFilter.getFaceScope() == ndn::nfd::FACE_SCOPE_LOCAL) != face->isLocal()) {
73  return false;
74  }
75 
76  if (m_faceFilter.hasFacePersistency() &&
77  m_faceFilter.getFacePersistency() != face->getPersistency()) {
78  return false;
79  }
80 
81  if (m_faceFilter.hasLinkType() &&
82  (m_faceFilter.getLinkType() == ndn::nfd::LINK_TYPE_MULTI_ACCESS) != face->isMultiAccess()) {
83  return false;
84  }
85 
86  return true;
87 }
88 
89 size_t
91 {
92  size_t totalLength = 0;
93 
94  for (const shared_ptr<Face>& face : m_faceTable | boost::adaptors::reversed) {
95  if (doesMatchFilter(face)) {
96  ndn::nfd::FaceStatus status = face->getFaceStatus();
97  totalLength += status.wireEncode(outBuffer);
98  }
99  }
100  return totalLength;
101 }
102 
103 } // namespace nfd
const std::string & getUriScheme() const
provides a publisher of Status Dataset or other segmented octet stream
FaceQueryStatusPublisher(const FaceTable &faceTable, AppFace &face, const Name &prefix, const ndn::nfd::FaceQueryFilter &filter, ndn::KeyChain &keyChain)
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend FaceStatus to the encoder
const std::string & getLocalUri() const
container of all Faces
Definition: face-table.hpp:38
EncodingImpl< EncoderTag > EncodingBuffer
FacePersistency getFacePersistency() const
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
represents Face status
Name abstraction to represent an absolute name.
Definition: name.hpp:46
represents Face Query Filter
const std::string & getRemoteUri() const
virtual size_t generate(ndn::EncodingBuffer &outBuffer)
In a derived class, write the octets into outBuffer.
bool doesMatchFilter(const shared_ptr< Face > &face)