internet: Add SetDhcpv6Callback to trigger client on set M flag in RA

This commit is contained in:
Kavya Bhat
2024-09-23 09:44:29 -04:00
committed by Tommaso Pecorella
parent 460b25f5a5
commit c3d3d81997
2 changed files with 25 additions and 0 deletions

View File

@@ -439,6 +439,15 @@ Icmpv6L4Protocol::HandleRA(Ptr<Packet> 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;

View File

@@ -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<void, uint32_t> 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<const Ipv6Address&> 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<void, uint32_t> m_startDhcpv6;
};
} /* namespace ns3 */