diff --git a/src/aodv/model/aodv-rqueue.cc b/src/aodv/model/aodv-rqueue.cc index 8b79c1182..9f4fda357 100644 --- a/src/aodv/model/aodv-rqueue.cc +++ b/src/aodv/model/aodv-rqueue.cc @@ -76,13 +76,14 @@ RequestQueue::DropPacketWithDst (Ipv4Address dst) for (std::vector::iterator i = m_queue.begin (); i != m_queue.end (); ++i) { - if (IsEqual (*i, dst)) + if (i->GetIpv4Header ().GetDestination () == dst) { Drop (*i, "DropPacketWithDst "); } } - m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (), - std::bind2nd (std::ptr_fun (RequestQueue::IsEqual), dst)), m_queue.end ()); + auto new_end = std::remove_if (m_queue.begin (), m_queue.end (), + [&](const QueueEntry& en) { return en.GetIpv4Header ().GetDestination () == dst; }); + m_queue.erase (new_end, m_queue.end ()); } bool diff --git a/src/aodv/model/aodv-rqueue.h b/src/aodv/model/aodv-rqueue.h index 55afbf2f4..3bcfaab1d 100644 --- a/src/aodv/model/aodv-rqueue.h +++ b/src/aodv/model/aodv-rqueue.h @@ -271,16 +271,6 @@ private: uint32_t m_maxLen; /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds. Time m_queueTimeout; - /** - * Determine if queue matches a destination address - * \param en The queue entry - * \param dst The destination IPv4 address - * \returns true if the queue entry matches the destination address - */ - static bool IsEqual (QueueEntry en, const Ipv4Address dst) - { - return (en.GetIpv4Header ().GetDestination () == dst); - } }; diff --git a/src/dsdv/model/dsdv-packet-queue.cc b/src/dsdv/model/dsdv-packet-queue.cc index fd11bfe43..cb5306961 100644 --- a/src/dsdv/model/dsdv-packet-queue.cc +++ b/src/dsdv/model/dsdv-packet-queue.cc @@ -88,13 +88,14 @@ PacketQueue::DropPacketWithDst (Ipv4Address dst) for (std::vector::iterator i = m_queue.begin (); i != m_queue.end (); ++i) { - if (IsEqual (*i, dst)) + if (i->GetIpv4Header ().GetDestination () == dst) { Drop (*i, "DropPacketWithDst "); } } - m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (), - std::bind2nd (std::ptr_fun (PacketQueue::IsEqual), dst)), m_queue.end ()); + auto new_end = std::remove_if (m_queue.begin (), m_queue.end (), [&](const QueueEntry& en) + { return en.GetIpv4Header ().GetDestination () == dst; }); + m_queue.erase (new_end, m_queue.end ()); } bool diff --git a/src/dsdv/model/dsdv-packet-queue.h b/src/dsdv/model/dsdv-packet-queue.h index 6a42d48c3..2688f1c3b 100644 --- a/src/dsdv/model/dsdv-packet-queue.h +++ b/src/dsdv/model/dsdv-packet-queue.h @@ -291,16 +291,6 @@ private: uint32_t m_maxLenPerDst; /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds. Time m_queueTimeout; - /** - * Determine if queue entries are equal - * \param en the queue entry - * \param dst the IPv4 destination address - * \returns true if the entry is for the destination address - */ - static bool IsEqual (QueueEntry en, const Ipv4Address dst) - { - return (en.GetIpv4Header ().GetDestination () == dst); - } }; } } diff --git a/src/dsr/model/dsr-errorbuff.cc b/src/dsr/model/dsr-errorbuff.cc index b947a090f..1649be3ab 100644 --- a/src/dsr/model/dsr-errorbuff.cc +++ b/src/dsr/model/dsr-errorbuff.cc @@ -96,13 +96,15 @@ DsrErrorBuffer::DropPacketForErrLink (Ipv4Address source, Ipv4Address nextHop) for (std::vector::iterator i = m_errorBuffer.begin (); i != m_errorBuffer.end (); ++i) { - if (LinkEqual (*i, link)) + if ((i->GetSource () == link[0]) && (i->GetNextHop () == link[1])) { DropLink (*i, "DropPacketForErrLink"); } } - m_errorBuffer.erase (std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (), - std::bind2nd (std::ptr_fun (DsrErrorBuffer::LinkEqual), link)), m_errorBuffer.end ()); + + auto new_end = std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (), [&](const DsrErrorBuffEntry& en) + { return (en.GetSource () == link[0]) && (en.GetNextHop () == link[1]); }); + m_errorBuffer.erase (new_end, m_errorBuffer.end ()); } bool diff --git a/src/dsr/model/dsr-errorbuff.h b/src/dsr/model/dsr-errorbuff.h index a3ee87688..d2212054f 100644 --- a/src/dsr/model/dsr-errorbuff.h +++ b/src/dsr/model/dsr-errorbuff.h @@ -298,17 +298,6 @@ private: uint32_t m_maxLen; /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds. Time m_errorBufferTimeout; - /** - * Check if the send buffer entry is the same or not - * \param en Buffer Entry - * \param link Link description. - * \return true if the entry is compatible with the link description (source and next hop) - */ - /// - static bool LinkEqual (DsrErrorBuffEntry en, const std::vector link) - { - return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1])); - } }; /*******************************************************************************************************************************/ } // namespace dsr diff --git a/src/dsr/model/dsr-maintain-buff.cc b/src/dsr/model/dsr-maintain-buff.cc index d13ebf377..6323ec2be 100644 --- a/src/dsr/model/dsr-maintain-buff.cc +++ b/src/dsr/model/dsr-maintain-buff.cc @@ -85,8 +85,10 @@ DsrMaintainBuffer::DropPacketWithNextHop (Ipv4Address nextHop) NS_LOG_FUNCTION (this << nextHop); Purge (); NS_LOG_INFO ("Drop Packet With next hop " << nextHop); - m_maintainBuffer.erase (std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (), - std::bind2nd (std::ptr_fun (DsrMaintainBuffer::IsEqual), nextHop)), m_maintainBuffer.end ()); + + auto new_end = std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (), [&](const DsrMaintainBuffEntry& en) + { return en.GetNextHop () == nextHop; }); + m_maintainBuffer.erase (new_end, m_maintainBuffer.end ()); } bool diff --git a/src/dsr/model/dsr-maintain-buff.h b/src/dsr/model/dsr-maintain-buff.h index 4319bbf71..154453f90 100644 --- a/src/dsr/model/dsr-maintain-buff.h +++ b/src/dsr/model/dsr-maintain-buff.h @@ -483,14 +483,6 @@ private: uint32_t m_maxLen; /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds. Time m_maintainBufferTimeout; - /// Verify if the maintain buffer is equal or not - /// \param en The Entry to check - /// \param nextHop The next hop to check - /// \return true if an Entry next hop is equal to the function second parameter - static bool IsEqual (DsrMaintainBuffEntry en, const Ipv4Address nextHop) - { - return (en.GetNextHop () == nextHop); - } }; /*******************************************************************************************************************************/ } // namespace dsr diff --git a/src/dsr/model/dsr-rsendbuff.cc b/src/dsr/model/dsr-rsendbuff.cc index d5ff752ba..9ec9b703e 100644 --- a/src/dsr/model/dsr-rsendbuff.cc +++ b/src/dsr/model/dsr-rsendbuff.cc @@ -91,13 +91,14 @@ DsrSendBuffer::DropPacketWithDst (Ipv4Address dst) for (std::vector::iterator i = m_sendBuffer.begin (); i != m_sendBuffer.end (); ++i) { - if (IsEqual (*i, dst)) + if (i->GetDestination () == dst) { Drop (*i, "DropPacketWithDst"); } } - m_sendBuffer.erase (std::remove_if (m_sendBuffer.begin (), m_sendBuffer.end (), - std::bind2nd (std::ptr_fun (DsrSendBuffer::IsEqual), dst)), m_sendBuffer.end ()); + auto new_end = std::remove_if (m_sendBuffer.begin (), m_sendBuffer.end (), [&](const DsrSendBuffEntry& en) + { return en.GetDestination () == dst; }); + m_sendBuffer.erase (new_end, m_sendBuffer.end ()); } bool diff --git a/src/dsr/model/dsr-rsendbuff.h b/src/dsr/model/dsr-rsendbuff.h index 5a195a33f..a0f933c84 100644 --- a/src/dsr/model/dsr-rsendbuff.h +++ b/src/dsr/model/dsr-rsendbuff.h @@ -259,18 +259,6 @@ private: uint32_t m_maxLen; ///< The maximum number of packets that we allow a routing protocol to buffer. Time m_sendBufferTimeout; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds. - /** - * Check if the send buffer entry is the same or not - * - * \param en SendBufferEntry - * \param dst IPv4 address to check - * \return true if the SendBufferEntry destination is the same, - * false otherwise - */ - static bool IsEqual (DsrSendBuffEntry en, const Ipv4Address dst) - { - return (en.GetDestination () == dst); - } }; /*******************************************************************************************************************************/ } // namespace dsr