/[classpath]/classpath/java/net/InetAddress.java
ViewVC logotype

Diff of /classpath/java/net/InetAddress.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.31.2.2 by gnu_andrew, Sun Jan 16 02:14:48 2005 UTC revision 1.31.2.3 by gnu_andrew, Sun Jan 16 15:15:12 2005 UTC
# Line 227  public class InetAddress implements Seri Line 227  public class InetAddress implements Seri
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    }    }
# Line 253  public class InetAddress implements Seri Line 253  public class InetAddress implements Seri
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    /**    /**
# Line 278  public class InetAddress implements Seri Line 278  public class InetAddress implements Seri
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 ?
# Line 310  public class InetAddress implements Seri Line 309  public class InetAddress implements Seri
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     */     */
# Line 323  public class InetAddress implements Seri Line 322  public class InetAddress implements Seri
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     */     */
# Line 334  public class InetAddress implements Seri Line 333  public class InetAddress implements Seri
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     */     */
# Line 351  public class InetAddress implements Seri Line 352  public class InetAddress implements Seri
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     */     */
# Line 474  public class InetAddress implements Seri Line 475  public class InetAddress implements Seri
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    }    }
# Line 802  public class InetAddress implements Seri Line 803  public class InetAddress implements Seri
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     *     *
# Line 847  public class InetAddress implements Seri Line 848  public class InetAddress implements Seri
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    }    }

Legend:
Removed from v.1.31.2.2  
changed lines
  Added in v.1.31.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26