227 |
{ |
{ |
228 |
// Mask against high order bits of 1110 |
// Mask against high order bits of 1110 |
229 |
if (addr.length == 4) |
if (addr.length == 4) |
230 |
return (addr[0] & 0xF0) == 0xE0; |
return (addr[0] & 0xf0) == 0xe0; |
231 |
|
|
232 |
return false; |
return false; |
233 |
} |
} |
253 |
{ |
{ |
254 |
// This is the IPv4 implementation. |
// This is the IPv4 implementation. |
255 |
// Any class derived from InetAddress should override this. |
// Any class derived from InetAddress should override this. |
256 |
return addr[0] == 0x7F; |
return (addr[0] & 0xff) == 0x7f; |
257 |
} |
} |
258 |
|
|
259 |
/** |
/** |
278 |
{ |
{ |
279 |
// This is the IPv4 implementation. |
// This is the IPv4 implementation. |
280 |
// Any class derived from InetAddress should override this. |
// Any class derived from InetAddress should override this. |
281 |
|
|
282 |
// 10.0.0.0/8 |
// 10.0.0.0/8 |
283 |
if (addr[0] == 0x0A) |
if ((addr[0] & 0xff) == 0x0a) |
284 |
return true; |
return true; |
285 |
|
|
|
// XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here: |
|
|
// it says 172.16.0.0 - 172.255.255.255 are site local addresses |
|
286 |
// 172.16.0.0/12 |
// 172.16.0.0/12 |
287 |
if (addr[0] == 0xAC && (addr[1] & 0xF0) == 0x01) |
if ((addr[0] & 0xff) == 0xac && (addr[1] & 0xf0) == 0x10) |
288 |
return true; |
return true; |
289 |
|
|
290 |
// 192.168.0.0/16 |
// 192.168.0.0/16 |
291 |
if (addr[0] == 0xC0 && addr[1] == 0xA8) |
if ((addr[0] & 0xff) == 0xc0 && (addr[1] & 0xff) == 0xa8) |
292 |
return true; |
return true; |
293 |
|
|
294 |
// XXX: Do we need to check more addresses here ? |
// XXX: Do we need to check more addresses here ? |
309 |
} |
} |
310 |
|
|
311 |
/** |
/** |
312 |
* Utility reoutine to check if InetAddress is a node local multicast address |
* Utility routine to check if InetAddress is a node local multicast address. |
313 |
* |
* |
314 |
* @since 1.4 |
* @since 1.4 |
315 |
*/ |
*/ |
322 |
} |
} |
323 |
|
|
324 |
/** |
/** |
325 |
* Utility reoutine to check if InetAddress is a link local multicast address |
* Utility routine to check if InetAddress is a link local multicast address. |
326 |
* |
* |
327 |
* @since 1.4 |
* @since 1.4 |
328 |
*/ |
*/ |
333 |
if (! isMulticastAddress()) |
if (! isMulticastAddress()) |
334 |
return false; |
return false; |
335 |
|
|
336 |
return (addr[0] == 0xE0 && addr[1] == 0x00 && addr[2] == 0x00); |
return ((addr[0] & 0xff) == 0xe0 |
337 |
|
&& (addr[1] & 0xff) == 0x00 |
338 |
|
&& (addr[2] & 0xff) == 0x00); |
339 |
} |
} |
340 |
|
|
341 |
/** |
/** |
342 |
* Utility routine to check if InetAddress is a site local multicast address |
* Utility routine to check if InetAddress is a site local multicast address. |
343 |
* |
* |
344 |
* @since 1.4 |
* @since 1.4 |
345 |
*/ |
*/ |
352 |
} |
} |
353 |
|
|
354 |
/** |
/** |
355 |
* Utility reoutine to check if InetAddress is a organization local |
* Utility routine to check if InetAddress is a organization local |
356 |
* multicast address |
* multicast address. |
357 |
* |
* |
358 |
* @since 1.4 |
* @since 1.4 |
359 |
*/ |
*/ |
475 |
int i = len > 4 ? len - 4 : 0; |
int i = len > 4 ? len - 4 : 0; |
476 |
|
|
477 |
for (; i < len; i++) |
for (; i < len; i++) |
478 |
hash = (hash << 8) | (addr[i] & 0xFF); |
hash = (hash << 8) | (addr[i] & 0xff); |
479 |
|
|
480 |
return hash; |
return hash; |
481 |
} |
} |
803 |
* This method returns the hostname for a given IP address. It will |
* This method returns the hostname for a given IP address. It will |
804 |
* throw an UnknownHostException if the hostname cannot be determined. |
* throw an UnknownHostException if the hostname cannot be determined. |
805 |
* |
* |
806 |
* @param ip The IP address as a int array |
* @param ip The IP address as a byte array |
807 |
* |
* |
808 |
* @return The hostname |
* @return The hostname |
809 |
* |
* |
848 |
int i = len - 4; |
int i = len - 4; |
849 |
|
|
850 |
for (; i < len; i++) |
for (; i < len; i++) |
851 |
address = address << 8 | (((int) addr[i]) & 0xFF); |
address = address << 8 | (addr[i] & 0xff); |
852 |
|
|
853 |
oos.defaultWriteObject(); |
oos.defaultWriteObject(); |
854 |
} |
} |