tools: nfdc support add command
refs: #1407
Change-Id: I35d7d33fda57a34a0a4abc890a5a6dcbc60804c8
diff --git a/tools/nfdc.hpp b/tools/nfdc.hpp
index ab74e10..b54d12f 100644
--- a/tools/nfdc.hpp
+++ b/tools/nfdc.hpp
@@ -28,13 +28,12 @@
#include <ndn-cpp-dev/face.hpp>
#include <ndn-cpp-dev/management/controller.hpp>
#include <ndn-cpp-dev/management/nfd-controller.hpp>
-#include <vector>
namespace nfdc {
using namespace ndn::nfd;
-class Nfdc
+class Nfdc : boost::noncopyable
{
public:
class Error : public std::runtime_error
@@ -53,22 +52,31 @@
~Nfdc();
bool
- dispatch(const std::string& cmd,
- const char* cmdOptions[],
- int nOptions);
+ dispatch(const std::string& cmd);
/**
+ * \brief Adds a name to a FIB entry after creating the attaced face.
+ *
+ * Create a new face for the given faceUri and use it when adding the given name to the fib
+ *
+ *
+ * cmd format:
+ * add name faceUri [cost]
+ *
+ */
+ void
+ addName();
+ /**
* \brief Adds a nexthop to a FIB entry.
*
* If the FIB entry does not exist, it is inserted automatically
*
* cmd format:
- * name
+ * name faceId [cost]
*
- * \param cmdOptions Add next hop command parameters without leading 'add-nexthop' component
*/
void
- fibAddNextHop(const char* cmdOptions[], bool hasCost);
+ fibAddNextHop(bool hasCost);
/**
* \brief Removes a nexthop from an existing FIB entry
@@ -78,11 +86,9 @@
* cmd format:
* name faceId
*
- * \param cmdOptions Remove next hop command parameters without leading
- * 'remove-nexthop' component
*/
void
- fibRemoveNextHop(const char* cmdOptions[]);
+ fibRemoveNextHop();
/**
* \brief create new face
@@ -92,10 +98,9 @@
* cmd format:
* uri
*
- * \param cmdOptions Create face command parameters without leading 'create' component
*/
void
- faceCreate(const char* cmdOptions[]);
+ faceCreate();
/**
* \brief destroy a face
@@ -103,10 +108,9 @@
* cmd format:
* faceId
*
- * \param cmdOptions Destroy face command parameters without leading 'destroy' component
*/
void
- faceDestroy(const char* cmdOptions[]);
+ faceDestroy();
/**
* \brief Set the strategy for a namespace
@@ -115,11 +119,9 @@
* cmd format:
* name strategy
*
- * \param cmdOptions Set strategy choice command parameters without leading
- * 'set-strategy' component
*/
void
- strategyChoiceSet(const char* cmdOptions[]);
+ strategyChoiceSet();
/**
* \brief Unset the strategy for a namespace
@@ -128,23 +130,33 @@
* cmd format:
* name strategy
*
- * \param cmdOptions Unset strategy choice command parameters without leading
- * 'unset-strategy' component
*/
void
- strategyChoiceUnset(const char* cmdOptions[]);
+ strategyChoiceUnset();
private:
+
void
onSuccess(const ControlParameters& parameters,
const std::string& message);
void
+ onAddSuccess(const ControlParameters& parameters,
+ const std::string& message);
+
+ void
onError(uint32_t code, const std::string& error, const std::string& message);
+ void
+ fibAddNextHop(const std::string& name, const uint64_t faceId, bool hasCost);
+
public:
const char* m_programName;
+ // command parameters without leading 'cmd' component
+ const char** m_commandLineArguments;
+ int m_nOptions;
+
private:
Controller m_controller;
};