poke: exit with status 5 if prefix registration fails

Change-Id: I2147570c37146011c9a4e8c024b74bcafdf18e4e
diff --git a/tools/peek/ndnpoke/main.cpp b/tools/peek/ndnpoke/main.cpp
index 33d91ea..fb26ab0 100644
--- a/tools/peek/ndnpoke/main.cpp
+++ b/tools/peek/ndnpoke/main.cpp
@@ -159,7 +159,7 @@
     program.start();
     face.processEvents();
 
-    return program.didSendData() ? 0 : 1;
+    return static_cast<int>(program.getResult());
   }
   catch (const std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
diff --git a/tools/peek/ndnpoke/ndnpoke.cpp b/tools/peek/ndnpoke/ndnpoke.cpp
index 2934404..e6730cf 100644
--- a/tools/peek/ndnpoke/ndnpoke.cpp
+++ b/tools/peek/ndnpoke/ndnpoke.cpp
@@ -48,7 +48,7 @@
 
   if (m_options.wantForceData) {
     m_face.put(*data);
-    m_didSendData = true;
+    m_result = Result::DATA_SENT;
     return;
   }
 
@@ -56,7 +56,7 @@
     [this, data] (auto&&...) {
       m_timeoutEvent.cancel();
       m_face.put(*data);
-      m_didSendData = true;
+      m_result = Result::DATA_SENT;
       m_registeredPrefix.cancel();
     },
     [this] (auto&&) {
@@ -64,7 +64,8 @@
         m_registeredPrefix.cancel();
       });
     },
-    [] (auto&&, const auto& reason) {
+    [this] (auto&&, const auto& reason) {
+      m_result = Result::PREFIX_REG_FAIL;
       std::cerr << "Prefix registration failure (" << reason << ")\n";
     });
 }
diff --git a/tools/peek/ndnpoke/ndnpoke.hpp b/tools/peek/ndnpoke/ndnpoke.hpp
index af5ad34..e47da81 100644
--- a/tools/peek/ndnpoke/ndnpoke.hpp
+++ b/tools/peek/ndnpoke/ndnpoke.hpp
@@ -56,15 +56,27 @@
 public:
   NdnPoke(Face& face, KeyChain& keyChain, std::istream& input, const PokeOptions& options);
 
+  enum class Result {
+    DATA_SENT = 0,
+    UNKNOWN = 1,
+    // 2 is reserved for "malformed command line"
+    TIMEOUT = 3,
+    // 4 is reserved for "nack"
+    PREFIX_REG_FAIL = 5,
+  };
+
+  /**
+   * @return the result of NdnPoke execution
+   */
+  Result
+  getResult() const
+  {
+    return m_result;
+  }
+
   void
   start();
 
-  bool
-  didSendData() const
-  {
-    return m_didSendData;
-  }
-
 private:
   shared_ptr<Data>
   createData() const;
@@ -77,7 +89,7 @@
   Scheduler m_scheduler;
   ScopedRegisteredPrefixHandle m_registeredPrefix;
   scheduler::ScopedEventId m_timeoutEvent;
-  bool m_didSendData = false;
+  Result m_result = Result::UNKNOWN;
 };
 
 } // namespace peek