diff --git a/src/internet/helper/ipv6-interface-container.cc b/src/internet/helper/ipv6-interface-container.cc index 3c69c14e8..91dbb2b0c 100644 --- a/src/internet/helper/ipv6-interface-container.cc +++ b/src/internet/helper/ipv6-interface-container.cc @@ -80,6 +80,12 @@ void Ipv6InterfaceContainer::Add (const Ipv6InterfaceContainer& c) } } +std::pair, uint32_t> +Ipv6InterfaceContainer::Get (uint32_t i) const +{ + return m_interfaces[i]; +} + void Ipv6InterfaceContainer::SetForwarding (uint32_t i, bool router) { Ptr ipv6 = m_interfaces[i].first; diff --git a/src/internet/helper/ipv6-interface-container.h b/src/internet/helper/ipv6-interface-container.h index 4c9ba24da..42b0a2808 100644 --- a/src/internet/helper/ipv6-interface-container.h +++ b/src/internet/helper/ipv6-interface-container.h @@ -54,7 +54,7 @@ public: /** * \returns the number of Ptr and interface pairs stored in this - * Ipv4InterfaceContainer. + * Ipv6InterfaceContainer. * * Pairs can be retrieved from the container in two ways. First, * directly by an index into the container, and second, using an iterator. @@ -119,7 +119,7 @@ public: * for-loop to run through the pairs * * \code - * Ipv4InterfaceContainer::Iterator i; + * Ipv6InterfaceContainer::Iterator i; * for (i = container.Begin (); i != container.End (); ++i) * { * std::pair, uint32_t> pair = *i; @@ -166,6 +166,29 @@ public: */ void Add (std::string ipv6Name, uint32_t interface); + /** + * Get the std::pair of an Ptr and interface stored at the location + * specified by the index. + * + * \param i the index of the container entry to retrieve. + * \return the std::pair of a Ptr and an interface index + * + * \note The returned Ptr cannot be used directly to fetch the + * Ipv6Interface using the returned index (the GetInterface () method + * is provided in class Ipv6L3Protocol, and not class Ipv6). An + * example usage is provided below. + * + * \code + * Ipv6InterfaceContainer c; + * ... + * std::pair, uint32_t> returnValue = c.Get (0); + * Ptr ipv6 = returnValue.first; + * uint32_t index = returnValue.second; + * Ptr iface = ipv6->GetObject ()->GetInterface (index); + * \endcode + */ + std::pair, uint32_t> Get (uint32_t i) const; + /** * \brief Set the state of the stack (act as a router or as an host) for the specified index. * This automatically sets all the node's interfaces to the same forwarding state.