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 "test-access-control.hpp"
26 #include "signals.hpp"
27 #include "lsa.hpp"
28 
29 #include <ndn-cxx/face.hpp>
30 #include <ndn-cxx/util/signal.hpp>
31 #include <ChronoSync/socket.hpp>
32 #include <boost/throw_exception.hpp>
33 
34 class InterestManager;
35 
36 namespace nlsr {
37 
38 class ConfParameter;
39 
49 {
50 public:
51  using IsLsaNew =
52  std::function<bool(const ndn::Name&, const Lsa::Type& lsaType, const uint64_t&)>;
53 
54  class Error : public std::runtime_error
55  {
56  public:
57  explicit
58  Error(const std::string& what)
59  : std::runtime_error(what)
60  {
61  }
62  };
63 
64  SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, ConfParameter& conf);
65 
74  void
75  onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& v);
76 
86  void
87  publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo);
88 
95  void
96  createSyncSocket(const ndn::Name& syncPrefix);
97 
101  void
102  buildUpdatePrefix();
103 
104 private:
113  void
114  processUpdateFromSync(const ndn::Name& originRouter,
115  const ndn::Name& updateName, const uint64_t& seqNo);
116 
123  void
124  publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
125 
126 public:
127  std::unique_ptr<OnNewLsa> onNewLsa;
128 
129 private:
130  ndn::Face& m_syncFace;
131  std::shared_ptr<chronosync::Socket> m_syncSocket;
132  ndn::Name m_syncPrefix;
133  IsLsaNew m_isLsaNew;
134  const ConfParameter& m_confParam;
135 
137  ndn::Name m_nameLsaUserPrefix;
138  ndn::Name m_adjLsaUserPrefix;
139  ndn::Name m_coorLsaUserPrefix;
140 
141 private:
142  static const std::string NLSR_COMPONENT;
143  static const std::string LSA_COMPONENT;
144 
145 };
146 
147 } // namespace nlsr
148 
149 #endif // NLSR_SYNC_LOGIC_HANDLER_HPP
const std::string NLSR_COMPONENT
A class to house all the configuration parameters for NLSR.
SyncLogicHandler(ndn::Face &face, const IsLsaNew &isLsaNew, ConfParameter &conf)
#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-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const std::string LSA_COMPONENT
void createSyncSocket(const ndn::Name &syncPrefix)
Create and configure a socket to enable ChronoSync for this NLSR.
void onChronoSyncUpdate(const std::vector< chronosync::MissingDataInfo > &v)
Hook function to call whenever sync detects new data.
void publishRoutingUpdate(const Lsa::Type &type, const uint64_t &seqNo)
Instruct ChronoSync to publish an update.