nlsrc: run command on remote router
refs #4544
Change-Id: I977ebfb94c84730bd2bcc73515f77cc4773ec2de
diff --git a/tools/nlsrc.hpp b/tools/nlsrc.hpp
index c3ee7f1..99a441c 100644
--- a/tools/nlsrc.hpp
+++ b/tools/nlsrc.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, The University of Memphis,
+ * Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -27,7 +27,7 @@
#include <boost/noncopyable.hpp>
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/security/validator-null.hpp>
+#include <ndn-cxx/security/validator.hpp>
#include <deque>
#include <map>
@@ -42,16 +42,31 @@
{
public:
explicit
- Nlsrc(ndn::Face& face);
+ Nlsrc(std::string programName, ndn::Face& face);
void
- printUsage();
+ printUsage() const;
+
+ const ndn::Name&
+ getRouterPrefix() const
+ {
+ return m_routerPrefix;
+ }
+
+ void
+ setRouterPrefix(ndn::Name prefix);
+
+ void
+ disableValidator();
+
+ bool
+ enableValidator(const std::string& filename);
void
getStatus(const std::string& command);
bool
- dispatch(const std::string& cmd);
+ dispatch(ndn::span<std::string> subcommand);
private:
void
@@ -65,7 +80,7 @@
*
*/
void
- advertiseName();
+ advertiseName(ndn::Name name, bool wantSave);
/**
* \brief Removes a name prefix from NLSR's Name LSA
@@ -75,7 +90,7 @@
*
*/
void
- withdrawName();
+ withdrawName(ndn::Name name, bool wantDelete);
void
sendNamePrefixUpdate(const ndn::Name& name,
@@ -96,7 +111,7 @@
void
fetchNameLsas();
- template <class T>
+ template<class T>
void
fetchFromLsdb(const ndn::Name::Component& datasetType,
const std::function<void(const T&)>& recordLsa);
@@ -107,11 +122,11 @@
void
fetchRtables();
- template <class T>
+ template<class T>
void
fetchFromRt(const std::function<void(const T&)>& recordLsa);
- template <class T>
+ template<class T>
void
onFetchSuccess(const ndn::ConstBufferPtr& data,
const std::function<void(const T&)>& recordLsa);
@@ -131,41 +146,22 @@
void
printAll();
-public:
- const char* programName;
-
- // command parameters without leading 'cmd' component
- const char* const* commandLineArguments;
- int nOptions;
-
private:
+ std::string m_programName;
+ ndn::Name m_routerPrefix;
+ std::unique_ptr<ndn::security::Validator> m_validator;
+ ndn::KeyChain m_keyChain;
+ ndn::Face& m_face;
+
struct Router
{
std::string adjacencyLsaString;
std::string coordinateLsaString;
std::string nameLsaString;
};
-
std::map<ndn::Name, Router> m_routers;
-
-private:
- ndn::KeyChain m_keyChain;
- ndn::Face& m_face;
- ndn::security::ValidatorNull m_validator;
- std::string commandString;
std::string m_rtString;
-
std::deque<std::function<void()>> m_fetchSteps;
-
- static const ndn::Name LOCALHOST_PREFIX;
- static const ndn::Name LSDB_PREFIX;
- static const ndn::Name NAME_UPDATE_PREFIX;
-
- static const ndn::Name RT_PREFIX;
-
- static const uint32_t ERROR_CODE_TIMEOUT;
- static const uint32_t RESPONSE_CODE_SUCCESS;
- static const uint32_t RESPONSE_CODE_SAVE_OR_DELETE;
};
} // namespace nlsrc