50 , m_isLsaNew(isLsaNew)
57 SyncLogicHandler::createSyncLogic(
const ndn::Name& syncPrefix,
const ndn::time::milliseconds& syncInterestLifetime)
59 if (m_syncLogic !=
nullptr) {
60 NLSR_LOG_WARN(
"Trying to create Sync Logic object, but Sync Logic object already exists");
67 NLSR_LOG_DEBUG(
"Creating Sync Logic object. Sync Prefix: " << syncPrefix);
73 m_syncLogic = std::make_shared<SyncProtocolAdapter>(*facePtr,
78 std::bind(&SyncLogicHandler::processUpdate,
this, _1, _2));
81 m_syncLogic->addUserNode(m_adjLsaUserPrefix);
84 m_syncLogic->addUserNode(m_coorLsaUserPrefix);
87 m_syncLogic->addUserNode(m_adjLsaUserPrefix);
88 m_syncLogic->addUserNode(m_coorLsaUserPrefix);
93 SyncLogicHandler::processUpdate(
const ndn::Name& updateName, uint64_t highSeq)
95 NLSR_LOG_DEBUG(
"Update Name: " << updateName <<
" Seq no: " << highSeq);
100 if (nlsrPosition < 0 || lsaPosition < 0) {
105 ndn::Name networkName = updateName.getSubName(1, nlsrPosition-1);
106 ndn::Name routerName = updateName.getSubName(lsaPosition + 1).getPrefix(-1);
108 ndn::Name originRouter = networkName;
109 originRouter.append(routerName);
111 processUpdateFromSync(originRouter, updateName, highSeq);
115 SyncLogicHandler::processUpdateFromSync(
const ndn::Name& originRouter,
116 const ndn::Name& updateName, uint64_t seqNo)
124 std::istringstream(updateName.get(updateName.size()-1).toUri()) >> lsaType;
127 " sequence number than entry in LSDB");
129 if (m_isLsaNew(originRouter, lsaType, seqNo)) {
132 NLSR_LOG_ERROR(
"Got an update for adjacency LSA when hyperbolic routing " <<
133 "is enabled. Not going to fetch.");
139 NLSR_LOG_ERROR(
"Got an update for coordinate LSA when link-state " <<
140 "is enabled. Not going to fetch.");
143 (*onNewLsa)(updateName, seqNo);
151 if (m_syncLogic ==
nullptr) {
152 NLSR_LOG_FATAL(
"Cannot publish routing update; SyncLogic does not exist");
159 m_syncLogic->publishUpdate(m_adjLsaUserPrefix, seqNo);
162 m_syncLogic->publishUpdate(m_coorLsaUserPrefix, seqNo);
165 m_syncLogic->publishUpdate(m_nameLsaUserPrefix, seqNo);
173 SyncLogicHandler::buildUpdatePrefix()
179 m_nameLsaUserPrefix = updatePrefix;
182 m_adjLsaUserPrefix = updatePrefix;
185 m_coorLsaUserPrefix = updatePrefix;
const std::string NLSR_COMPONENT
A class to house all the configuration parameters for NLSR.
#define NLSR_LOG_DEBUG(x)
ndn::util::Signal< SyncLogicHandler, const ndn::Name &, const uint64_t & > OnNewLsa
const ndn::Name & getRouterPrefix() const
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
#define INIT_LOGGER(name)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
const ndn::Name & getSyncPrefix() const
std::function< bool(const ndn::Name &, const Lsa::Type &lsaType, const uint64_t &)> IsLsaNew
const ndn::Name & getLsaPrefix() const
NLSR-to-ChronoSync interaction point.
static int32_t getNameComponentPosition(const ndn::Name &name, const std::string &searchString)
search a name component in ndn::Name and return the position of the component
#define NLSR_LOG_ERROR(x)
uint32_t getSyncProtocol() const
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const ndn::Name & getRouterName() const
int32_t getHyperbolicState() const
const std::string LSA_COMPONENT
SyncLogicHandler(ndn::Face &face, const IsLsaNew &isLsaNew, const ConfParameter &conf)
const ndn::Name & getSiteName() const
#define NLSR_LOG_FATAL(x)
void publishRoutingUpdate(const Lsa::Type &type, const uint64_t &seqNo)
Instruct ChronoSync to publish an update.