diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index ea293fde8..b5d887bae 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -439,6 +439,15 @@ Icmpv6L4Protocol::HandleRA(Ptr packet, p->RemoveHeader(raHeader); + // If 'M' flag is set, we need to start DHCPv6. + if (raHeader.GetFlagM()) + { + if (!m_startDhcpv6.IsNull()) + { + m_startDhcpv6(ipv6->GetInterfaceForDevice(interface->GetDevice())); + } + } + if (raHeader.GetLifeTime()) { defaultRouter = src; diff --git a/src/internet/model/icmpv6-l4-protocol.h b/src/internet/model/icmpv6-l4-protocol.h index 1ce4b53f2..d0e3bbc25 100644 --- a/src/internet/model/icmpv6-l4-protocol.h +++ b/src/internet/model/icmpv6-l4-protocol.h @@ -413,6 +413,16 @@ class Icmpv6L4Protocol : public IpL4Protocol */ Time GetDadTimeout() const; + /** + * Set DHCPv6 callback. + * Invoked when an RA is received with the M flag set. + * \param cb the callback function + */ + void SetDhcpv6Callback(Callback cb) + { + m_startDhcpv6 = cb; + } + protected: /** * \brief Dispose this object. @@ -700,6 +710,12 @@ class Icmpv6L4Protocol : public IpL4Protocol * Includes the address whose state has been changed. */ ns3::TracedCallback m_dadSuccessAddressTrace; + + /** + * The DHCPv6 callback when the M flag is set in a Router Advertisement. + * Includes the interface on which the RA was received. + */ + Callback m_startDhcpv6; }; } /* namespace ns3 */