diff --git a/CHANGES.html b/CHANGES.html index 0e89123f6..0b752b71e 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -78,6 +78,11 @@ protocols as well. Ipv6RoutingHelper can now print the IPv6 Routing Tables at specific intervals or time. Exactly like Ipv4RoutingHelper do. +
  • +New "SendIcmpv6Redirect" attribute (and getter/setter functions) to +Ipv6L3Protocol. The behavior is similar to Linux's conf "send_redirects", +i.e., enable/disable the ICMPv6 Redirect sending. +
  • Changes to build system:

    diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 4412fe67e..698e571ef 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -27,6 +27,9 @@ New user-visible features - Ipv6RoutingHelper is now in-line with Ipv4RoutingHelper concerning the RT print functions. Various minor changes made in Ipv6RoutingProtocol and derived classes to make this possible. +- New "SendIcmpv6Redirect" attribute (and getter/setter functions) to + Ipv6L3Protocol. The behavior is similar to Linux's conf "send_redirects", + i.e., enable/disable the ICMPv6 Redirect sending. Bugs fixed ---------- diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 624933621..a508ff515 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -22,6 +22,7 @@ #include "ns3/node.h" #include "ns3/uinteger.h" #include "ns3/vector.h" +#include "ns3/boolean.h" #include "ns3/callback.h" #include "ns3/trace-source-accessor.h" #include "ns3/object-vector.h" @@ -62,6 +63,11 @@ TypeId Ipv6L3Protocol::GetTypeId () ObjectVectorValue (), MakeObjectVectorAccessor (&Ipv6L3Protocol::m_interfaces), MakeObjectVectorChecker ()) + .AddAttribute ("SendIcmpv6Redirect", "Send the ICMPv6 Redirect when appropriate.", + BooleanValue (true), + MakeBooleanAccessor (&Ipv6L3Protocol::SetSendIcmpv6Redirect, + &Ipv6L3Protocol::GetSendIcmpv6Redirect), + MakeBooleanChecker ()) .AddTraceSource ("Tx", "Send IPv6 packet to outgoing interface.", MakeTraceSourceAccessor (&Ipv6L3Protocol::m_txTrace)) .AddTraceSource ("Rx", "Receive IPv6 packet from incoming interface.", @@ -492,6 +498,18 @@ bool Ipv6L3Protocol::GetIpForward () const return m_ipForward; } +void Ipv6L3Protocol::SetSendIcmpv6Redirect (bool sendIcmpv6Redirect) +{ + NS_LOG_FUNCTION (this << sendIcmpv6Redirect); + m_sendIcmpv6Redirect = sendIcmpv6Redirect; +} + +bool Ipv6L3Protocol::GetSendIcmpv6Redirect () const +{ + NS_LOG_FUNCTION_NOARGS (); + return m_sendIcmpv6Redirect; +} + void Ipv6L3Protocol::NotifyNewAggregate () { NS_LOG_FUNCTION_NOARGS (); @@ -878,8 +896,10 @@ void Ipv6L3Protocol::IpForward (Ptr rtentry, Ptr p, con * we send him an ICMPv6 redirect message to notify him that a short route * exists. */ - if ((!rtentry->GetGateway ().IsAny () && rtentry->GetGateway ().CombinePrefix (Ipv6Prefix (64)) == header.GetSourceAddress ().CombinePrefix (Ipv6Prefix (64))) - || (rtentry->GetDestination ().CombinePrefix (Ipv6Prefix (64)) == header.GetSourceAddress ().CombinePrefix (Ipv6Prefix (64)))) + + if (m_sendIcmpv6Redirect && + ((!rtentry->GetGateway ().IsAny () && rtentry->GetGateway ().CombinePrefix (Ipv6Prefix (64)) == header.GetSourceAddress ().CombinePrefix (Ipv6Prefix (64))) + || (rtentry->GetDestination ().CombinePrefix (Ipv6Prefix (64)) == header.GetSourceAddress ().CombinePrefix (Ipv6Prefix (64))))) { NS_LOG_LOGIC ("ICMPv6 redirect!"); Ptr icmpv6 = GetIcmpv6 (); diff --git a/src/internet/model/ipv6-l3-protocol.h b/src/internet/model/ipv6-l3-protocol.h index 0a0428230..6a46e82f1 100644 --- a/src/internet/model/ipv6-l3-protocol.h +++ b/src/internet/model/ipv6-l3-protocol.h @@ -468,6 +468,18 @@ private: */ virtual bool GetIpForward () const; + /** + * \brief Set the ICMPv6 Redirect sending state. + * \param sendIcmpv6Redirect ICMPv6 Redirect sending enabled or not + */ + virtual void SetSendIcmpv6Redirect (bool sendIcmpv6Redirect); + + /** + * \brief Get the ICMPv6 Redirect sending state. + * \return ICMPv6 Redirect sending state (enabled or not) + */ + virtual bool GetSendIcmpv6Redirect () const; + /** * \brief Node attached to stack. */ @@ -512,6 +524,11 @@ private: * \brief List of IPv6 prefix received from RA. */ Ipv6AutoconfiguredPrefixList m_prefixes; + + /** + * \brief Allow ICMPv6 Redirect sending state + */ + bool m_sendIcmpv6Redirect; }; } /* namespace ns3 */