lsdb-dataset-interest-handler.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
23 #define NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
24 
25 #include "tlv/adjacency-lsa.hpp"
26 #include "tlv/coordinate-lsa.hpp"
27 #include "tlv/name-lsa.hpp"
28 #include "lsdb.hpp"
29 
30 #include <ndn-cxx/mgmt/dispatcher.hpp>
31 #include <ndn-cxx/face.hpp>
32 #include <boost/noncopyable.hpp>
33 
34 namespace nlsr {
35 
36 namespace dataset {
37  const ndn::Name::Component ADJACENCY_COMPONENT = ndn::Name::Component{"adjacencies"};
38  const ndn::Name::Component NAME_COMPONENT = ndn::Name::Component{"names"};
39  const ndn::Name::Component COORDINATE_COMPONENT = ndn::Name::Component{"coordinates"};
40 } // namespace dataset
41 
46 class LsdbDatasetInterestHandler : boost::noncopyable
47 {
48 public:
49  class Error : std::runtime_error
50  {
51  public:
52  explicit
53  Error(const std::string& what)
54  : std::runtime_error(what)
55  {
56  }
57  };
58 
60  ndn::mgmt::Dispatcher& localHostDispatcher,
61  ndn::mgmt::Dispatcher& routerNameDispatcher,
62  ndn::Face& face,
63  ndn::KeyChain& keyChain);
64 
65  ndn::Name&
67  {
68  return m_routerNamePrefix;
69  }
70 
71  void
72  setRouterNameCommandPrefix(const ndn::Name& routerName) {
73  m_routerNamePrefix = routerName;
74  m_routerNamePrefix.append(Lsdb::NAME_COMPONENT);
75  }
76 
77 private:
81  void
82  setDispatcher(ndn::mgmt::Dispatcher& dispatcher);
83 
86  void
87  publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
88  ndn::mgmt::StatusDatasetContext& context);
89 
92  void
93  publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
94  ndn::mgmt::StatusDatasetContext& context);
95 
98  void
99  publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
100  ndn::mgmt::StatusDatasetContext& context);
101 
104  void
105  publishAllStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
106  ndn::mgmt::StatusDatasetContext& context);
107 
108 private:
109  const Lsdb& m_lsdb;
110  ndn::Name m_routerNamePrefix;
111 
112  ndn::mgmt::Dispatcher& m_localhostDispatcher;
113  ndn::mgmt::Dispatcher& m_routerNameDispatcher;
114 };
115 
116 template<typename T> std::list<T>
117 getTlvLsas(const Lsdb& lsdb);
118 
119 template<> std::list<tlv::AdjacencyLsa>
120 getTlvLsas<tlv::AdjacencyLsa>(const Lsdb& lsdb);
121 
122 template<> std::list<tlv::CoordinateLsa>
123 getTlvLsas<tlv::CoordinateLsa>(const Lsdb& lsdb);
124 
125 template<> std::list<tlv::NameLsa>
126 getTlvLsas<tlv::NameLsa>(const Lsdb& lsdb);
127 
128 } // namespace nlsr
129 
130 #endif // NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
Class to publish all lsa dataset.
std::list< T > getTlvLsas(const Lsdb &lsdb)
const ndn::Name::Component COORDINATE_COMPONENT
STL namespace.
void setRouterNameCommandPrefix(const ndn::Name &routerName)
const ndn::Name::Component NAME_COMPONENT
static const ndn::Name::Component NAME_COMPONENT
Definition: lsdb.hpp:376
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const ndn::Name::Component ADJACENCY_COMPONENT