From e339c07d0b6cbb00a0fc600e592a8e288250e772 Mon Sep 17 00:00:00 2001 From: Sven de Marothy Date: Wed, 19 Jul 2006 16:21:20 +0000 Subject: 2006-07-19 Sven de Marothy * java/net/Inet6Address.java: (getScopedId, getScopedInterface): New methods. --- java/net/Inet6Address.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'java/net/Inet6Address.java') diff --git a/java/net/Inet6Address.java b/java/net/Inet6Address.java index 6f41b792b..8d834a6fd 100644 --- a/java/net/Inet6Address.java +++ b/java/net/Inet6Address.java @@ -242,6 +242,7 @@ public final class Inet6Address extends InetAddress * Creates a scoped Inet6Address where the scope has an integer id. * * @throws UnkownHostException if the address is an invalid number of bytes. + * @since 1.5 */ public static Inet6Address getByAddress(String host, byte[] addr, int scopeId) @@ -261,6 +262,7 @@ public final class Inet6Address extends InetAddress * NetworkInterface. * * @throws UnkownHostException if the address is an invalid number of bytes. + * @since 1.5 */ public static Inet6Address getByAddress(String host, byte[] addr, NetworkInterface nif) @@ -275,6 +277,36 @@ public final class Inet6Address extends InetAddress return ip; } + /** + * Returns the NetworkInterface of the address scope + * if it is a scoped address and the scope is given in the form of a + * NetworkInterface. + * (I.e. the address was created using the + * getByAddress(String, byte[], NetworkInterface) method) + * Otherwise this method returns null. + * @since 1.5 + */ + public NetworkInterface getScopedInterface() + { + return nif; + } + + /** + * Returns the scope ID of the address scope if it is a scoped adress using + * an integer to identify the scope. + * + * Otherwise this method returns 0. + * @since 1.5 + */ + public int getScopeId() + { + // check scope_id_set because some JDK-serialized objects seem to have + // scope_id set to a nonzero value even when scope_id_set == false + if( scope_id_set ) + return scope_id; + return 0; + } + /** * Returns the IP address string in textual presentation */ -- cgit v1.2.1