diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index 59972d34f..c2b562bf0 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -1406,10 +1406,10 @@ bool Icmpv6L4Protocol::Lookup (Ptr p, const Ipv6Header & ipHeader, Ipv6A return false; } -void Icmpv6L4Protocol::FunctionDadTimeout (Ptr icmpv6, Ipv6Interface* interface, Ipv6Address addr) +void Icmpv6L4Protocol::FunctionDadTimeout (Ipv6Interface* interface, Ipv6Address addr) { - NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC (interface << " " << addr); + NS_LOG_FUNCTION (this << interface << addr); + Ipv6InterfaceAddress ifaddr; bool found = false; uint32_t i = 0; @@ -1426,6 +1426,11 @@ void Icmpv6L4Protocol::FunctionDadTimeout (Ptr icmpv6, Ipv6Int } } + if (!found) + { + NS_LOG_LOGIC ("Can not find the address in the interface."); + } + /* for the moment, this function is always called, if we was victim of a DAD the address is INVALID * and we do not set it to PREFERRED */ @@ -1437,14 +1442,19 @@ void Icmpv6L4Protocol::FunctionDadTimeout (Ptr icmpv6, Ipv6Int /* send an RS if our interface is not forwarding (router) and if address is a link-local ones * (because we will send RS with it) */ - Ptr ipv6 = icmpv6->m_node->GetObject (); + Ptr ipv6 = m_node->GetObject (); if (!ipv6->IsForwarding (ipv6->GetInterfaceForDevice (interface->GetDevice ())) && addr.IsLinkLocal ()) { /* \todo Add random delays before sending RS * because all nodes start at the same time, there will be many of RS around 1 second of simulation time */ - Simulator::Schedule (Seconds (0.0), &Icmpv6L4Protocol::SendRS, PeekPointer (icmpv6), ifaddr.GetAddress (), Ipv6Address::GetAllRoutersMulticast (), interface->GetDevice ()->GetAddress ()); + NS_LOG_LOGIC ("Scheduled a Router Solicitation"); + Simulator::Schedule (Seconds (0.0), &Icmpv6L4Protocol::SendRS, this, ifaddr.GetAddress (), Ipv6Address::GetAllRoutersMulticast (), interface->GetDevice ()->GetAddress ()); + } + else + { + NS_LOG_LOGIC ("Did not schedule a Router Solicitation because the interface is in forwarding mode"); } } } diff --git a/src/internet/model/icmpv6-l4-protocol.h b/src/internet/model/icmpv6-l4-protocol.h index 268f88a22..2b66a98ab 100644 --- a/src/internet/model/icmpv6-l4-protocol.h +++ b/src/internet/model/icmpv6-l4-protocol.h @@ -320,7 +320,7 @@ public: * \param interface the interface * \param addr the IPv6 address */ - static void FunctionDadTimeout (Ptr icmpv6, Ipv6Interface* interface, Ipv6Address addr); + void FunctionDadTimeout (Ipv6Interface* interface, Ipv6Address addr); /** * \brief Lookup in the ND cache for the IPv6 address diff --git a/src/internet/model/ipv6-interface.cc b/src/internet/model/ipv6-interface.cc index ef3d85d50..d99909ebb 100644 --- a/src/internet/model/ipv6-interface.cc +++ b/src/internet/model/ipv6-interface.cc @@ -219,7 +219,7 @@ void Ipv6Interface::SetForwarding (bool forwarding) bool Ipv6Interface::AddAddress (Ipv6InterfaceAddress iface) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << iface); Ipv6Address addr = iface.GetAddress (); /* DAD handling */ @@ -243,7 +243,7 @@ bool Ipv6Interface::AddAddress (Ipv6InterfaceAddress iface) int32_t interfaceId = m_node->GetObject ()->GetInterfaceForDevice (m_device); Ptr icmpv6 = DynamicCast (m_node->GetObject ()->GetProtocol (Icmpv6L4Protocol::GetStaticProtocolNumber (), interfaceId)); - if (icmpv6 && icmpv6->IsAlwaysDad ()) + if (icmpv6) { if (icmpv6->IsAlwaysDad ()) {