Implementing notion of default routes (useful for Flooding scenarios)

Also, correcting SEGFAULT upon termination (when apps was destroyed
after ccnx stack)

Correcting LongestPrefixMatch to be able to perform default match
diff --git a/helper/ccnx-stack-helper.cc b/helper/ccnx-stack-helper.cc
index d9f9d6b..074bdde 100644
--- a/helper/ccnx-stack-helper.cc
+++ b/helper/ccnx-stack-helper.cc
@@ -126,6 +126,8 @@
 
     
 CcnxStackHelper::CcnxStackHelper ()
+  : m_limitsEnabled (false)
+  , m_needSetDefaultRoutes (false)
 {
   m_strategyFactory.SetTypeId ("ns3::CcnxFloodingStrategy");
 }
@@ -140,6 +142,14 @@
   m_strategyFactory.SetTypeId (strategy);
 }
 
+
+void
+CcnxStackHelper::SetDefaultRoutes (bool needSet)
+{
+  NS_LOG_FUNCTION (this << needSet);
+  m_needSetDefaultRoutes = needSet;
+}
+
 void
 CcnxStackHelper::EnableLimits (bool enable/* = true*/, Time avgRtt/*=Seconds(0.1)*/, uint32_t avgContentObject/*=1100*/, uint32_t avgInterest/*=40*/)
 {
@@ -197,9 +207,15 @@
 
       Ptr<CcnxNetDeviceFace> face = Create<CcnxNetDeviceFace> (node, device);
 
-      uint32_t __attribute__ ((unused)) face_id = ccnx->AddFace (face);
-      NS_LOG_LOGIC ("Node " << node->GetId () << ": added CcnxNetDeviceFace as face #" << face_id);
+      ccnx->AddFace (face);
+      NS_LOG_LOGIC ("Node " << node->GetId () << ": added CcnxNetDeviceFace as face #" << *face);
 
+      if (m_needSetDefaultRoutes)
+        {
+          // default route with lowest priority possible
+          AddRoute (node, "/", face, std::numeric_limits<int32_t>::max ()); 
+        }
+      
       if (m_limitsEnabled)
         {
           NS_LOG_INFO ("Limits are enabled");
@@ -242,8 +258,10 @@
 
 
 void
-CcnxStackHelper::AddRoute (Ptr<Node> node, std::string prefix, Ptr<CcnxFace> face, int32_t metric)
+CcnxStackHelper::AddRoute (Ptr<Node> node, std::string prefix, Ptr<CcnxFace> face, int32_t metric) const
 {
+  NS_LOG_LOGIC ("[" << node->GetId () << "]$ route add " << prefix << " via " << *face << " metric " << metric);
+
   Ptr<CcnxFib>  fib  = node->GetObject<CcnxFib> ();
 
   CcnxNameComponentsValue prefixValue;
@@ -252,10 +270,8 @@
 }
 
 void
-CcnxStackHelper::AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric)
+CcnxStackHelper::AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric) const
 {
-  NS_LOG_LOGIC ("[" << nodeName << "]$ route add " << prefix << " via " << faceId << " metric " << metric);
-  
   Ptr<Node> node = Names::Find<Node> (nodeName);
   NS_ASSERT_MSG (node != 0, "Node [" << nodeName << "] does not exist");
   
@@ -267,6 +283,7 @@
 
   AddRoute (node, prefix, face, metric);
 }
+
 /*
   void
   CcnxStackHelper::AddRoute (Ptr<Node> node, std::string prefix, uint32_t faceId, int32_t metric)
diff --git a/helper/ccnx-stack-helper.h b/helper/ccnx-stack-helper.h
index ee166fc..bcfab3f 100644
--- a/helper/ccnx-stack-helper.h
+++ b/helper/ccnx-stack-helper.h
@@ -156,7 +156,7 @@
    * \param metric Routing metric
    */
   void
-  AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric);
+  AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric) const;
 
   /**
    * \brief Add forwarding entry in FIB
@@ -167,8 +167,13 @@
    * \param metric Routing metric
    */
   void
-  AddRoute (Ptr<Node> node, std::string prefix, Ptr<CcnxFace> face, int32_t metric);
-  
+  AddRoute (Ptr<Node> node, std::string prefix, Ptr<CcnxFace> face, int32_t metric) const;
+
+  /**
+   * \brief Set flag indicating necessity to install default routes in FIB
+   */
+  void
+  SetDefaultRoutes (bool needSet);
 
   /**
    * \brief Install fake IPv4 routes that could be used to find nexthops for CCNx routes
@@ -207,6 +212,7 @@
   Time     m_avgRtt;
   uint32_t m_avgContentObjectSize;
   uint32_t m_avgInterestSize;
+  bool m_needSetDefaultRoutes;
   
   // /**
   //  * @brief Enable pcap output the indicated Ccnx and interface pair.