dataset-interest-handler.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
31 #ifndef NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP
32 #define NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP
33 
35 #include "route/routing-table.hpp"
36 #include "route/nexthop-list.hpp"
37 #include "lsdb.hpp"
38 #include "logger.hpp"
39 
40 #include "tlv/adjacency-lsa.hpp"
41 #include "tlv/coordinate-lsa.hpp"
42 #include "tlv/name-lsa.hpp"
45 
46 #include <ndn-cxx/mgmt/dispatcher.hpp>
47 #include <ndn-cxx/face.hpp>
48 #include <boost/noncopyable.hpp>
49 
50 namespace nlsr {
51 namespace dataset {
52 const ndn::Name::Component ADJACENCY_COMPONENT = ndn::Name::Component{"adjacencies"};
53 const ndn::Name::Component NAME_COMPONENT = ndn::Name::Component{"names"};
54 const ndn::Name::Component COORDINATE_COMPONENT = ndn::Name::Component{"coordinates"};
55 } // namespace dataset
56 
62 class DatasetInterestHandler : boost::noncopyable
63 {
64 public:
65  class Error : std::runtime_error
66  {
67  public:
68  explicit
69  Error(const std::string& what)
70  : std::runtime_error(what)
71  {
72  }
73  };
74 
75  DatasetInterestHandler(const Lsdb& lsdb,
76  const RoutingTable& rt,
77  ndn::mgmt::Dispatcher& dispatcher,
78  const ndn::Face& face,
79  const ndn::KeyChain& keyChain);
80 
81  ndn::Name&
83  {
84  return m_routerNamePrefix;
85  }
86 
87  void
88  setRouterNameCommandPrefix(const ndn::Name& routerName) {
89  m_routerNamePrefix = routerName;
90  m_routerNamePrefix.append(Lsdb::NAME_COMPONENT);
91  }
92 
93 private:
96  void
97  setDispatcher(ndn::mgmt::Dispatcher& dispatcher);
98 
101  std::vector<tlv::RoutingTable>
102  getTlvRTEntries();
103 
106  void
107  publishRtStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
108  ndn::mgmt::StatusDatasetContext& context);
109 
112  void
113  publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
114  ndn::mgmt::StatusDatasetContext& context);
115 
118  void
119  publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
120  ndn::mgmt::StatusDatasetContext& context);
121 
124  void
125  publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
126  ndn::mgmt::StatusDatasetContext& context);
127 
128 private:
129  const Lsdb& m_lsdb;
130  ndn::Name m_routerNamePrefix;
131 
132  ndn::mgmt::Dispatcher& m_dispatcher;
133 
134  const std::list<RoutingTableEntry>& m_routingTableEntries;
135  const std::list<RoutingTableEntry>& m_dryRoutingTableEntries;
136 };
137 
138 template<typename T> std::list<T>
139 getTlvLsas(const Lsdb& lsdb);
140 
141 template<> std::list<tlv::AdjacencyLsa>
142 getTlvLsas<tlv::AdjacencyLsa>(const Lsdb& lsdb);
143 
144 template<> std::list<tlv::CoordinateLsa>
145 getTlvLsas<tlv::CoordinateLsa>(const Lsdb& lsdb);
146 
147 template<> std::list<tlv::NameLsa>
148 getTlvLsas<tlv::NameLsa>(const Lsdb& lsdb);
149 
150 } // namespace nlsr
151 
152 #endif // NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP
Class to publish all dataset.
std::list< T > getTlvLsas(const Lsdb &lsdb)
const ndn::Name::Component COORDINATE_COMPONENT
STL namespace.
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
const ndn::Name::Component NAME_COMPONENT
static const ndn::Name::Component NAME_COMPONENT
Definition: lsdb.hpp:383
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
void setRouterNameCommandPrefix(const ndn::Name &routerName)
const ndn::Name::Component ADJACENCY_COMPONENT