2008-07-17 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Thu, 17 Jul 2008 21:34:52 +0000 (21:34 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Thu, 17 Jul 2008 21:34:52 +0000 (21:34 -0000)
* IPInterfaceProperties.cs: implemented UnicastAddresses

svn path=/trunk/mcs/; revision=108179

mcs/class/System/System.Net.NetworkInformation/ChangeLog
mcs/class/System/System.Net.NetworkInformation/IPInterfaceProperties.cs

index 72a9604e04d54180d85914b0b6b9401a7f857b23..ccecedc84b83bd855b47cfd8bf82faa4b53392b9 100644 (file)
@@ -1,3 +1,7 @@
+2008-07-17  Marek Habersack  <mhabersack@novell.com>
+
+       * IPInterfaceProperties.cs: implemented UnicastAddresses
+
 2008-07-14  Marek Habersack  <mhabersack@novell.com>
 
        * NetworkInterface.cs: implemented support for Linux. Parts
index 441c162c30daeb514d9392699ab893099a7239a3..9c011a450c43c548a12695f9a30bd4604ff9651d 100644 (file)
@@ -28,6 +28,7 @@
 //
 #if NET_2_0
 using System.Collections.Generic;
+using System.Net.Sockets;
 
 namespace System.Net.NetworkInformation {
        public abstract class IPInterfaceProperties {
@@ -154,7 +155,20 @@ namespace System.Net.NetworkInformation {
                        get {
                                List<IPAddress> unicastAddresses = new List<IPAddress> ();
                                foreach (IPAddress address in addresses) {
-                                       // XXX: Add everything that's not multicast or anycast here.
+                                       switch (address.AddressFamily) {
+                                               case AddressFamily.InterNetwork:
+                                                       byte top = address.GetAddressBytes () [0];
+                                                       if (top >= 224 && top <= 239)
+                                                               continue;
+                                                       unicastAddresses.Add (address);
+                                                       break;
+
+                                               case AddressFamily.InterNetworkV6:
+                                                       if (address.IsIPv6Multicast)
+                                                               continue;
+                                                       unicastAddresses.Add (address);
+                                                       break;
+                                       }
                                }
                                return UnicastIPAddressInformationImplCollection.LinuxFromList (unicastAddresses);
                        }