Finishing with FIB initialization based on IPv4 global routing controller
Example ccnx-routing-simple.cc shows all necessary steps to make it work.
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index 4b832a4..d045339 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -38,6 +38,8 @@
#include "ccnx-interest-header.h"
#include "ccnx-content-object-header.h"
+#include "ccnx-net-device-face.h"
+
#include <boost/foreach.hpp>
NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol");
@@ -184,6 +186,20 @@
return 0;
}
+Ptr<CcnxFace>
+CcnxL3Protocol::GetFaceByNetDevice (Ptr<NetDevice> netDevice) const
+{
+ BOOST_FOREACH (const Ptr<CcnxFace> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
+ {
+ Ptr<CcnxNetDeviceFace> netDeviceFace = DynamicCast<CcnxNetDeviceFace> (face);
+ if (netDeviceFace == 0) continue;
+
+ if (netDeviceFace->GetNetDevice () == netDevice)
+ return face;
+ }
+ return 0;
+}
+
uint32_t
CcnxL3Protocol::GetNFaces (void) const
{
diff --git a/model/ccnx-l3-protocol.h b/model/ccnx-l3-protocol.h
index c4d4f29..5b57ee0 100644
--- a/model/ccnx-l3-protocol.h
+++ b/model/ccnx-l3-protocol.h
@@ -144,6 +144,9 @@
virtual void
RemoveFace (Ptr<CcnxFace> face);
+
+ virtual Ptr<CcnxFace>
+ GetFaceByNetDevice (Ptr<NetDevice> netDevice) const;
Ptr<CcnxPit> GetPit();
protected:
diff --git a/model/ccnx.h b/model/ccnx.h
index 7fc9217..cafa354 100644
--- a/model/ccnx.h
+++ b/model/ccnx.h
@@ -192,6 +192,12 @@
*/
virtual void
RemoveFace (Ptr<CcnxFace> face) = 0;
+
+ /**
+ * Get face for NetDevice
+ */
+ virtual Ptr<CcnxFace>
+ GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0;
};
} // namespace ns3
diff --git a/model/ipv4-global-routing-ordered-nexthops.cc b/model/ipv4-global-routing-ordered-nexthops.cc
index 9ed2b60..a01c044 100644
--- a/model/ipv4-global-routing-ordered-nexthops.cc
+++ b/model/ipv4-global-routing-ordered-nexthops.cc
@@ -108,8 +108,7 @@
Ptr<Ipv4Route>
Ipv4GlobalRoutingOrderedNexthops::LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif)
{
- NS_LOG_FUNCTION_NOARGS ();
- NS_LOG_LOGIC ("Looking for route for destination " << dest);
+ NS_LOG_FUNCTION (this << dest << oif);
Ipv4AddressTrieMap::const_iterator longest_prefix_map = m_routes.longest_prefix_match (dest);
if (longest_prefix_map == m_routes.end ())
@@ -134,6 +133,21 @@
return rtentry;
}
+const Ptr<Ipv4GlobalRoutingOrderedNexthops::EntryContainer>
+Ipv4GlobalRoutingOrderedNexthops::Lookup (Ipv4Address dest)
+{
+ NS_LOG_FUNCTION (this << dest);
+
+ Ipv4AddressTrieMap::const_iterator longest_prefix_map = m_routes.longest_prefix_match (dest);
+ if (longest_prefix_map == m_routes.end ())
+ {
+ return 0;
+ }
+
+ return longest_prefix_map->second;
+}
+
+
void
Ipv4GlobalRoutingOrderedNexthops::DeleteRoutes ()
{
diff --git a/model/ipv4-global-routing-ordered-nexthops.h b/model/ipv4-global-routing-ordered-nexthops.h
index b52779e..1ae8713 100644
--- a/model/ipv4-global-routing-ordered-nexthops.h
+++ b/model/ipv4-global-routing-ordered-nexthops.h
@@ -47,7 +47,7 @@
*/
class Ipv4GlobalRoutingOrderedNexthops : public Ipv4GlobalRouting
{
-private:
+public:
class i_iface {};
class i_metric {};
class i_index {};
@@ -109,6 +109,9 @@
virtual void DeleteRoutes ();
+ const Ptr<EntryContainer>
+ Lookup (Ipv4Address dest);
+
protected:
virtual Ptr<Ipv4Route> LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif = 0);