[System] Fixed an error in the implementation of System.Net.IPAddress.IsIPv6Teredo
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Sat, 1 Feb 2014 21:02:27 +0000 (22:02 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Sat, 1 Feb 2014 21:02:27 +0000 (22:02 +0100)
The property was introduced with PR #870 but it missed to convert network byte order to host byte order, so the comparison
wasn't working correctly and the corresponding unit test failed. @marek-safar erroneously "fixed" the test in 27e07c7.

This is the corrected implementation and the original test now works as intended.

mcs/class/System/System.Net/IPAddress.cs
mcs/class/System/Test/System.Net/IPAddressTest.cs

index b1081f5bd29cfd9e05496bdff1c9b150729a7801..92c0f8e6e070b00090c2f27754b1bc65ff3de697 100644 (file)
@@ -337,7 +337,7 @@ namespace System.Net {
                public bool IsIPv6Teredo {
                        get {
                                return m_Family != AddressFamily.InterNetwork &&
-                                       m_Numbers[0] == 0x2001 &&
+                                       NetworkToHostOrder ((short) m_Numbers [0]) == 0x2001 &&
                                        m_Numbers[1] == 0;
                        }
                }
index 505bdfb881c0efdb2efc36942a15ac6311d02ebc..a07c1a19d92dd32b3a0623efab7cd890376f12a0 100644 (file)
@@ -550,7 +550,7 @@ public class IPAddressTest
        [Test]
        public void IsIPv6Teredo ()
        {
-               Assert.IsFalse (IPAddress.Parse ("2001::1").IsIPv6Teredo, "#1");
+               Assert.IsTrue (IPAddress.Parse ("2001::1").IsIPv6Teredo, "#1");
                Assert.IsFalse (IPAddress.Parse ("2002::1").IsIPv6Teredo, "#2");
        }
 #endif