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"
29 
30 #include <ndn-cxx/face.hpp>
31 #include <ndn-cxx/util/signal.hpp>
32 #include <ChronoSync/socket.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 
75  void
76  onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& v);
77 
87  void
88  publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo);
89 
97  void
98  createSyncSocket(const ndn::Name& syncPrefix,
99  const ndn::time::milliseconds& syncInterestLifetime =
100  ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT));
101 
105  void
106  buildUpdatePrefix();
107 
108 private:
117  void
118  processUpdateFromSync(const ndn::Name& originRouter,
119  const ndn::Name& updateName, const uint64_t& seqNo);
120 
127  void
128  publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
129 
130 public:
131  std::unique_ptr<OnNewLsa> onNewLsa;
132 
133 private:
134  ndn::Face& m_syncFace;
135  std::shared_ptr<chronosync::Socket> m_syncSocket;
136  ndn::Name m_syncPrefix;
137  IsLsaNew m_isLsaNew;
138  const ConfParameter& m_confParam;
139 
141  ndn::Name m_nameLsaUserPrefix;
142  ndn::Name m_adjLsaUserPrefix;
143  ndn::Name m_coorLsaUserPrefix;
144 
145 private:
146  static const std::string NLSR_COMPONENT;
147  static const std::string LSA_COMPONENT;
148 
149 };
150 
151 } // namespace nlsr
152 
153 #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.
void createSyncSocket(const ndn::Name &syncPrefix, const ndn::time::milliseconds &syncInterestLifetime=ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT))
Create and configure a socket to enable ChronoSync for this NLSR.
const std::string LSA_COMPONENT
SyncLogicHandler(ndn::Face &face, const IsLsaNew &isLsaNew, const ConfParameter &conf)
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.