L3Protocol::GetFace now returns face by index, not by ID as it was
before. To get face by ID, L3Protocol::GetFaceById method should be
used instead.
diff --git a/model/ndn-l3-protocol.cc b/model/ndn-l3-protocol.cc
index a32c7fa..86002e3 100644
--- a/model/ndn-l3-protocol.cc
+++ b/model/ndn-l3-protocol.cc
@@ -186,6 +186,13 @@
Ptr<Face>
L3Protocol::GetFace (uint32_t index) const
{
+ NS_ASSERT (0 <= index && index < m_faces.size ());
+ return m_faces[index];
+}
+
+Ptr<Face>
+L3Protocol::GetFaceById (uint32_t index) const
+{
BOOST_FOREACH (const Ptr<Face> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
{
if (face->GetId () == index)
diff --git a/model/ndn-l3-protocol.h b/model/ndn-l3-protocol.h
index 372ac6a..25dfd39 100644
--- a/model/ndn-l3-protocol.h
+++ b/model/ndn-l3-protocol.h
@@ -67,6 +67,8 @@
public Object
{
public:
+ typedef std::vector<Ptr<Face> > FaceList;
+
/**
* \brief Interface ID
*
@@ -103,14 +105,22 @@
*/
virtual uint32_t
GetNFaces () const;
-
+
/**
* \brief Get face by face index
- * \param face The face number of an Ndn interface.
+ * \param face The face number (number in face list)
* \returns The NdnFace associated with the Ndn face number.
*/
virtual Ptr<Face>
GetFace (uint32_t face) const;
+
+ /**
+ * \brief Get face by face ID
+ * \param face The face ID number
+ * \returns The NdnFace associated with the Ndn face number.
+ */
+ virtual Ptr<Face>
+ GetFaceById (uint32_t face) const;
/**
* \brief Remove face from ndn stack (remove callbacks)
@@ -143,7 +153,6 @@
private:
uint32_t m_faceCounter; ///< \brief counter of faces. Increased every time a new face is added to the stack
- typedef std::vector<Ptr<Face> > FaceList;
FaceList m_faces; ///< \brief list of faces that belongs to ndn stack on this node
// These objects are aggregated, but for optimization, get them here