Ip4Address: Update Self Assigned IP from 169.x.y.z to 169.254.x.y

Update the prefix for self assigned IPs, so we can support more IPs when using HostLocationProvider.

 Dynamic Configuration of IPv4 Link-Local Addresses https://tools.ietf.org/html/rfc3927

Change-Id: I29931ee45f01a4c9d89784884ef27adb376f5efa
This commit is contained in:
Eduardo Ferreira 2018-01-24 18:59:43 -02:00
parent 67b756023b
commit cf8ee3ca46
2 changed files with 2 additions and 2 deletions

View File

@ -335,7 +335,7 @@ public class IpAddress implements Comparable<IpAddress> {
* @return true if this address is self-assigned * @return true if this address is self-assigned
*/ */
public boolean isSelfAssigned() { public boolean isSelfAssigned() {
return isIp4() && octets[0] == (byte) 169; return isIp4() && octets[0] == (byte) 169 && octets[1] == (byte) 254;
} }
/** /**

View File

@ -763,7 +763,7 @@ public class IpAddressTest {
@Test @Test
public void testIsSelfAssignedIpv4() { public void testIsSelfAssignedIpv4() {
IpAddress normalIP = IpAddress.valueOf("10.0.0.1"); IpAddress normalIP = IpAddress.valueOf("10.0.0.1");
IpAddress selfAssignedIP = IpAddress.valueOf("169.1.2.3"); IpAddress selfAssignedIP = IpAddress.valueOf("169.254.2.3");
assertFalse(normalIP.isSelfAssigned()); assertFalse(normalIP.isSelfAssigned());
assertTrue(selfAssignedIP.isSelfAssigned()); assertTrue(selfAssignedIP.isSelfAssigned());
} }