sync-logic-handler.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2024, The University of Memphis,
4  * Regents of the University of California,
5  * Arizona Board of Regents.
6  *
7  * This file is part of NLSR (Named-data Link State Routing).
8  * See AUTHORS.md for complete list of NLSR authors and contributors.
9  *
10  * NLSR is free software: you can redistribute it and/or modify it under the terms
11  * of the GNU General Public License as published by the Free Software Foundation,
12  * either version 3 of the License, or (at your option) any later version.
13  *
14  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef NLSR_SYNC_LOGIC_HANDLER_HPP
23 #define NLSR_SYNC_LOGIC_HANDLER_HPP
24 
25 #include "conf-parameter.hpp"
26 #include "lsa/lsa.hpp"
27 #include "signals.hpp"
29 #include "test-access-control.hpp"
30 
31 #include <boost/lexical_cast.hpp>
32 
33 namespace nlsr {
34 
36 {
38  ndn::Name syncPrefix;
39  ndn::Name userPrefix;
40  ndn::time::milliseconds syncInterestLifetime;
41  ndn::Name routerPrefix;
43 };
44 
45 inline ndn::Name
46 makeLsaUserPrefix(const ndn::Name& userPrefix, Lsa::Type lsaType)
47 {
48  return ndn::Name(userPrefix).append(boost::lexical_cast<std::string>(lsaType));
49 }
50 
57 {
58 public:
59  class Error : public std::runtime_error
60  {
61  public:
62  using std::runtime_error::runtime_error;
63  };
64 
65  using IsLsaNew = std::function<
66  bool (const ndn::Name& routerName, Lsa::Type lsaType, uint64_t seqNo, uint64_t inFace)
67  >;
68 
69  SyncLogicHandler(ndn::Face& face, ndn::KeyChain& keyChain,
70  IsLsaNew isLsaNew, const SyncLogicOptions& opts);
71 
81  void
82  publishRoutingUpdate(Lsa::Type type, uint64_t seqNo);
83 
91  void
92  processUpdate(const ndn::Name& updateName, uint64_t highSeq, uint64_t incomingFaceId);
93 
102  void
103  processUpdateFromSync(const ndn::Name& originRouter,
104  const ndn::Name& updateName, uint64_t seqNo, uint64_t incomingFaceId);
105 
106 public:
108 
109 private:
110  IsLsaNew m_isLsaNew;
111  ndn::Name m_routerPrefix;
112  HyperbolicState m_hyperbolicState;
113 
115  ndn::Name m_nameLsaUserPrefix;
116  ndn::Name m_adjLsaUserPrefix;
117  ndn::Name m_coorLsaUserPrefix;
118 
119  SyncProtocolAdapter m_syncLogic;
120 };
121 
122 } // namespace nlsr
123 
124 #endif // NLSR_SYNC_LOGIC_HANDLER_HPP
NLSR-to-sync interaction point.
void publishRoutingUpdate(Lsa::Type type, uint64_t seqNo)
Instruct ChronoSync to publish an update.
std::function< bool(const ndn::Name &routerName, Lsa::Type lsaType, uint64_t seqNo, uint64_t inFace) > IsLsaNew
SyncLogicHandler(ndn::Face &face, ndn::KeyChain &keyChain, IsLsaNew isLsaNew, const SyncLogicOptions &opts)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
ndn::Name makeLsaUserPrefix(const ndn::Name &userPrefix, Lsa::Type lsaType)
ndn::signal::Signal< SyncLogicHandler, ndn::Name, uint64_t, ndn::Name, uint64_t > OnNewLsa
Definition: signals.hpp:36
HyperbolicState hyperbolicState
ndn::time::milliseconds syncInterestLifetime
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE