From 6550570e50837fa7a6700bb87f10abbf258dc00d Mon Sep 17 00:00:00 2001
From: Tommaso Pecorella
Date: Wed, 10 Jul 2013 00:06:35 +0200
Subject: [PATCH] RFC 3849 - IPv6 Address Prefix Reserved for Documentation
---
CHANGES.html | 3 +++
RELEASE_NOTES | 1 +
src/internet/model/ipv6-l3-protocol.cc | 8 ++++++++
src/network/utils/ipv6-address.cc | 13 +++++++++++++
src/network/utils/ipv6-address.h | 6 ++++++
5 files changed, 31 insertions(+)
diff --git a/CHANGES.html b/CHANGES.html
index 060bf3dd9..a480bf470 100644
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -60,6 +60,9 @@ us a note on ns-developers mailing list.
Changes to existing API:
+ - The documentation's IPv6 addresses (2001:db8::/32, RFC 3849) are now
+ dropped by routers.
+
- The 'src/tools' module has been removed, and most files migrated to
'src/stats'. For users of these programs (the statistics-processing
in average.h, or the gnuplot support), the main change is likely to be
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index f568c1ed4..f4b7d1c6d 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -22,6 +22,7 @@ Supported platforms
New user-visible features
-------------------------
- Time attributes can now be bounded. See attribute-test-suite.cc for an example.
+- IPv6 addrss class 2001:db8::/32 is now dropped by routers (RFC 3849).
Bugs fixed
----------
diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc
index 4df26eb48..4881a7dca 100644
--- a/src/internet/model/ipv6-l3-protocol.cc
+++ b/src/internet/model/ipv6-l3-protocol.cc
@@ -924,6 +924,14 @@ void Ipv6L3Protocol::IpForward (Ptr idev, Ptr rtentr
NS_LOG_FUNCTION (this << rtentry << p << header);
NS_LOG_LOGIC ("Forwarding logic for node: " << m_node->GetId ());
+ // Drop RFC 3849 packets: 2001:db8::/32
+ if (header.GetDestinationAddress().IsDocumentation())
+ {
+ NS_LOG_WARN ("Received a packet for 2001:db8::/32 (documentation class). Drop.");
+ m_dropTrace (header, p, DROP_ROUTE_ERROR, m_node->GetObject (), 0);
+ return;
+ }
+
// Forwarding
Ipv6Header ipHeader = header;
Ptr packet = p->Copy ();
diff --git a/src/network/utils/ipv6-address.cc b/src/network/utils/ipv6-address.cc
index 69b0a63b2..d0b2e29d3 100644
--- a/src/network/utils/ipv6-address.cc
+++ b/src/network/utils/ipv6-address.cc
@@ -522,6 +522,19 @@ bool Ipv6Address::IsAny () const
return (*this == any);
}
+
+bool Ipv6Address::IsDocumentation () const
+{
+ NS_LOG_FUNCTION (this);
+ Ipv6Address documentation ("2001:db8::0");
+ if (((Ipv6Address*)this)->CombinePrefix (Ipv6Prefix (32)) == documentation)
+ {
+ return true;
+ }
+ return false;
+}
+
+
bool Ipv6Address::IsMatchingType (const Address& address)
{
NS_LOG_FUNCTION (address);
diff --git a/src/network/utils/ipv6-address.h b/src/network/utils/ipv6-address.h
index 4283b1cfb..dcbaa0835 100644
--- a/src/network/utils/ipv6-address.h
+++ b/src/network/utils/ipv6-address.h
@@ -212,6 +212,12 @@ public:
*/
bool IsAny () const;
+ /**
+ * \brief If the IPv6 address is a documentation address (2001:DB8::/32).
+ * \return true if the address is documentation, false otherwise
+ */
+ bool IsDocumentation () const;
+
/**
* \brief Combine this address with a prefix.
* \param prefix a IPv6 prefix