model: Implementing two more events for forwarding strategy: DidAddFibEntry and WillRemoveFibEntry
Currently, only DidAddFibEntry method is used and only in PerFibLimits
strategy. Change logic in global routing helper: set per FIB limits only if
forwarding strategy has created a corresponding Limit object.
diff --git a/model/fib/ndn-fib-impl.cc b/model/fib/ndn-fib-impl.cc
index 30004b5..3fc29a4 100644
--- a/model/fib/ndn-fib-impl.cc
+++ b/model/fib/ndn-fib-impl.cc
@@ -22,6 +22,7 @@
#include "ns3/ndn-face.h"
#include "ns3/ndn-interest.h"
+#include "ns3/ndn-forwarding-strategy.h"
#include "ns3/node.h"
#include "ns3/assert.h"
@@ -107,7 +108,14 @@
super::modify (result.first,
ll::bind (&Entry::AddOrUpdateRoutingMetric, ll::_1, face, metric));
-
+
+ if (result.second)
+ {
+ // notify forwarding strategy about new FIB entry
+ NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0);
+ this->GetObject<ForwardingStrategy> ()->DidAddFibEntry (result.first->payload ());
+ }
+
return result.first->payload ();
}
else
@@ -119,7 +127,16 @@
{
NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
- super::erase (*prefix);
+ super::iterator fibEntry = super::find_exact (*prefix);
+ if (fibEntry != super::end ())
+ {
+ // notify forwarding strategy about soon be removed FIB entry
+ NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0);
+ this->GetObject<ForwardingStrategy> ()->WillRemoveFibEntry (fibEntry->payload ());
+
+ super::erase (fibEntry);
+ }
+ // else do nothing
}
// void
@@ -182,6 +199,10 @@
if (trieNode->payload ()->m_faces.size () == 0)
{
+ // notify forwarding strategy about soon be removed FIB entry
+ NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0);
+ this->GetObject<ForwardingStrategy> ()->WillRemoveFibEntry (trieNode->payload ());
+
trieNode = super::parent_trie::recursive_iterator (trieNode->erase ());
}
}