src: schedule sync interest on NoRoute NACK

refs #5012

Change-Id: I671b507c66e1957aae976c859e81591c93dc4d94
diff --git a/src/logic.cpp b/src/logic.cpp
index 12b6feb..a8cd68e 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -369,6 +369,18 @@
 }
 
 void
+Logic::onSyncNack(const Interest& interest, const ndn::lp::Nack& nack)
+{
+  _LOG_DEBUG_ID(">> Logic::onSyncNack");
+  if (nack.getReason() == ndn::lp::NackReason::NO_ROUTE) {
+    auto after = ndn::time::milliseconds(m_reexpressionJitter(m_rng));
+    _LOG_DEBUG_ID("Schedule sync interest after: " << after);
+    m_scheduler.schedule(after, [this] { sendSyncInterest(); });
+  }
+  _LOG_DEBUG_ID("<< Logic::onSyncNack");
+}
+
+void
 Logic::onSyncTimeout(const Interest& interest)
 {
   // It is OK. Others will handle the time out situation.
@@ -627,7 +639,7 @@
 
   m_pendingSyncInterest = m_face.expressInterest(interest,
                                                  bind(&Logic::onSyncData, this, _1, _2),
-                                                 bind(&Logic::onSyncTimeout, this, _1), // Nack
+                                                 bind(&Logic::onSyncNack, this, _1, _2),
                                                  bind(&Logic::onSyncTimeout, this, _1));
 
   _LOG_DEBUG_ID("Send interest: " << interest.getName());
diff --git a/src/logic.hpp b/src/logic.hpp
index 408e164..b363e9d 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -292,6 +292,18 @@
   onResetData(const Interest& interest, const Data& data);
 
   /**
+   * @brief Callback to handle Sync Interest Nack
+   *
+   * This method checks whether the Nack is of type NoRoute
+   * and schedules a sync interest in m_reexpressionJitter
+   *
+   * @param interest The sync interest for which the Nack happened
+   * @param nack The incoming Nack
+   */
+  void
+  onSyncNack(const Interest& interest, const ndn::lp::Nack& nack);
+
+  /**
    * @brief Callback to handle Sync Interest timeout.
    *
    * This method does nothing, since Logic per se handles timeout explicitly.