harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r374051 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java
Date Wed, 01 Feb 2006 11:37:53 GMT
Author: tellison
Date: Wed Feb  1 03:37:47 2006
New Revision: 374051

URL: http://svn.apache.org/viewcvs?rev=374051&view=rev
Log:
Fixes to site local and link local broadcast address determination

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java?rev=374051&r1=374050&r2=374051&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java
Wed Feb  1 03:37:47 2006
@@ -67,25 +67,34 @@
 	}
 
 	/**
-	 * Answers false for all IPv4 addresses.
+	 * Answers whether this address has link-local scope.
 	 * 
-	 * @return boolean
+	 * RFC 3484 Default Address Selection for Internet Protocol version 6 (IPv6)
+	 * states IPv4 auto-configuration addresses, prefix 169.254/16, 
+	 * IPv4 loopback addresses, prefix 127/8, are assigned link-local scope.
 	 * 
-	 * There are no valid IPv4 link local addresses.
+	 * @return boolean
 	 */
 	public boolean isLinkLocalAddress() {
-		return false;
+		// The reference implementation does not return true
+		// for loopback addresses even though RFC 3484 says to do so
+		return (((ipaddress[0] & 255) == 169) && ((ipaddress[1] & 255) == 254));
 	}
 
 	/**
-	 * Answers false for all IPv4 addresses.
+	 * Answers whether this address has site-local scope.
 	 * 
 	 * @return boolean
 	 * 
-	 * There are no valid IPv4 site local addresses.
+	 * RFC 3484 Default Address Selection for Internet Protocol version 6 (IPv6)
+	 * states IPv4 private addresses, prefixes 10/8, 172.16/12, and 192.168/16,
+	 * are assigned site-local scope.
 	 */
 	public boolean isSiteLocalAddress() {
-		return false;
+		return ((ipaddress[0] & 255) == 10) || ((ipaddress[0] & 255) == 172)
+				&& (((ipaddress[1] & 255) > 15) && (ipaddress[1] & 255) <
32)
+				|| ((ipaddress[0] & 255) == 192)
+				&& ((ipaddress[1] & 255) == 168);
 	}
 
 	/**



Mime
View raw message