Add SendIcmpv6Redirect attribute to Ipv6L3Protocol

This commit is contained in:
Tommaso Pecorella
2012-03-25 14:26:45 +02:00
parent 735c33592c
commit 1211b4f71b
4 changed files with 47 additions and 2 deletions
+5
View File
@@ -78,6 +78,11 @@ protocols as well.
Ipv6RoutingHelper can now print the IPv6 Routing Tables at specific
intervals or time. Exactly like Ipv4RoutingHelper do.
</li>
<li>
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.
</li>
</ul>
<h2>Changes to build system:</h2>
+3
View File
@@ -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
----------
+22 -2
View File
@@ -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<Ipv6Interface> ())
.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<Ipv6Route> rtentry, Ptr<const Packet> 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<Icmpv6L4Protocol> icmpv6 = GetIcmpv6 ();
+17
View File
@@ -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 */