management: Implementing nrd::Controller and introducing new secret
environment option to enable NRD Prefix management protocol
Usage for the secret NFD and NRD environment variables
export NFD=1
export NRD=1
<run app>
or
NFD=1 NRD=1 <run app>
Change-Id: I874acbdcf7038f4d0fa05c59b34cd46d6ae627b0
diff --git a/src/management/nrd-controller.hpp b/src/management/nrd-controller.hpp
new file mode 100644
index 0000000..c5bd7bf
--- /dev/null
+++ b/src/management/nrd-controller.hpp
@@ -0,0 +1,64 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2014 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_MANAGEMENT_NFD_CONTROLLER_HPP
+#define NDN_MANAGEMENT_NFD_CONTROLLER_HPP
+
+#include "controller.hpp"
+#include "../security/key-chain.hpp"
+
+namespace ndn {
+namespace nrd {
+
+class PrefixRegOptions;
+
+class Controller : public ndn::Controller
+{
+public:
+ typedef function<void(const PrefixRegOptions&)> CommandSucceedCallback;
+
+ /**
+ * @brief Construct ndnd::Control object
+ */
+ Controller(Face& face);
+
+ virtual void
+ selfRegisterPrefix(const Name& prefixToRegister,
+ const SuccessCallback& onSuccess,
+ const FailCallback& onFail);
+
+ virtual void
+ selfDeregisterPrefix(const Name& prefixToRegister,
+ const SuccessCallback& onSuccess,
+ const FailCallback& onFail);
+
+protected:
+ void
+ startCommand(const std::string& command,
+ const PrefixRegOptions& options,
+ const CommandSucceedCallback& onSuccess,
+ const FailCallback& onFailure);
+
+private:
+ void
+ recordSelfRegisteredFaceId(const PrefixRegOptions& entry,
+ const SuccessCallback& onSuccess);
+
+ void
+ processCommandResponse(Data& data,
+ const CommandSucceedCallback& onSuccess,
+ const FailCallback& onFail);
+
+protected:
+ Face& m_face;
+ KeyChain m_keyChain;
+ uint64_t m_faceId; // internal face ID (needed for prefix de-registration)
+};
+
+} // namespace nrd
+} // namespace ndn
+
+#endif // NDN_MANAGEMENT_NFD_CONTROLLER_HPP