sync-logic-handler.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_SYNC_LOGIC_HANDLER_HPP
23 #define NLSR_SYNC_LOGIC_HANDLER_HPP
24 
25 #include "conf-parameter.hpp"
26 #include "test-access-control.hpp"
27 #include "signals.hpp"
28 #include "lsa.hpp"
30 
31 #include <ndn-cxx/face.hpp>
32 #include <ndn-cxx/util/signal.hpp>
33 #include <boost/throw_exception.hpp>
34 
35 class InterestManager;
36 
37 namespace nlsr {
38 
39 class ConfParameter;
40 
50 {
51 public:
52  using IsLsaNew =
53  std::function<bool(const ndn::Name&, const Lsa::Type& lsaType, const uint64_t&)>;
54 
55  class Error : public std::runtime_error
56  {
57  public:
58  explicit
59  Error(const std::string& what)
60  : std::runtime_error(what)
61  {
62  }
63  };
64 
65  SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, const ConfParameter& conf);
66 
76  void
77  publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo);
78 
88  void
89  createSyncLogic(const ndn::Name& syncPrefix,
90  const ndn::time::milliseconds& syncInterestLifetime =
91  ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT));
92 
99  void
100  processUpdate(const ndn::Name& updateName, uint64_t highSeq);
101 
104  void
105  buildUpdatePrefix();
106 
115  void
116  processUpdateFromSync(const ndn::Name& originRouter,
117  const ndn::Name& updateName, uint64_t seqNo);
118 
119 public:
120  std::unique_ptr<OnNewLsa> onNewLsa;
121 
122 private:
123  ndn::Face& m_syncFace;
125  std::shared_ptr<SyncProtocolAdapter> m_syncLogic;
126 private:
127  IsLsaNew m_isLsaNew;
128  const ConfParameter& m_confParam;
129 
131  ndn::Name m_nameLsaUserPrefix;
132  ndn::Name m_adjLsaUserPrefix;
133  ndn::Name m_coorLsaUserPrefix;
134 
135 private:
136  static const std::string NLSR_COMPONENT;
137  static const std::string LSA_COMPONENT;
138 };
139 
140 } // namespace nlsr
141 
142 #endif // NLSR_SYNC_LOGIC_HANDLER_HPP
const std::string NLSR_COMPONENT
A class to house all the configuration parameters for NLSR.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
std::unique_ptr< OnNewLsa > onNewLsa
STL namespace.
std::function< bool(const ndn::Name &, const Lsa::Type &lsaType, const uint64_t &)> IsLsaNew
NLSR-to-ChronoSync interaction point.
Error(const std::string &what)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const std::string LSA_COMPONENT
SyncLogicHandler(ndn::Face &face, const IsLsaNew &isLsaNew, const ConfParameter &conf)
void publishRoutingUpdate(const Lsa::Type &type, const uint64_t &seqNo)
Instruct ChronoSync to publish an update.