< prev index next >

test/lib/jdk/test/lib/NetworkConfiguration.java

Print this page
rev 59103 : imported patch hotspot


  51 public class NetworkConfiguration {
  52 
  53     private Map<NetworkInterface,List<Inet4Address>> ip4Interfaces;
  54     private Map<NetworkInterface,List<Inet6Address>> ip6Interfaces;
  55     private final boolean isIPv6Available;
  56     private boolean has_testableipv6address = false;
  57     private boolean has_sitelocaladdress = false;
  58     private boolean has_linklocaladdress = false;
  59     private boolean has_globaladdress = false;
  60 
  61     private NetworkConfiguration(
  62             Map<NetworkInterface,List<Inet4Address>> ip4Interfaces,
  63             Map<NetworkInterface,List<Inet6Address>> ip6Interfaces) {
  64         this.ip4Interfaces = ip4Interfaces;
  65         this.ip6Interfaces = ip6Interfaces;
  66 
  67         // initialize properties that can be queried
  68         isIPv6Available = !ip6Interfaces().collect(Collectors.toList()).isEmpty();
  69         ip6Interfaces().forEach(nif -> {
  70             ip6Addresses(nif)
  71                 // On Solaris or AIX, a configuration with only local or loopback
  72                 // addresses does not fully enable IPv6 operations.
  73                 // E.g. IPv6 multicasting does not work.
  74                 // So, don't set has_testableipv6address if we only find these.
  75                 .filter(addr -> Platform.isSolaris() || Platform.isAix() ?
  76                     !(addr.isAnyLocalAddress() || addr.isLoopbackAddress()) : true)
  77                 .forEach(ia -> {
  78                     has_testableipv6address = true;
  79                     if (ia.isLinkLocalAddress()) has_linklocaladdress = true;
  80                     if (ia.isSiteLocalAddress()) has_sitelocaladdress = true;
  81 
  82                     if (!ia.isLinkLocalAddress() &&
  83                         !ia.isSiteLocalAddress() &&
  84                         !ia.isLoopbackAddress()) {
  85                         has_globaladdress = true;
  86                     }
  87                 });
  88         });
  89     }
  90 
  91     private static boolean isIPv6LinkLocal(InetAddress a) {
  92         return Inet6Address.class.isInstance(a) && a.isLinkLocalAddress();
  93     }
  94 
  95     public static boolean isTestable(NetworkInterface nif) {




  51 public class NetworkConfiguration {
  52 
  53     private Map<NetworkInterface,List<Inet4Address>> ip4Interfaces;
  54     private Map<NetworkInterface,List<Inet6Address>> ip6Interfaces;
  55     private final boolean isIPv6Available;
  56     private boolean has_testableipv6address = false;
  57     private boolean has_sitelocaladdress = false;
  58     private boolean has_linklocaladdress = false;
  59     private boolean has_globaladdress = false;
  60 
  61     private NetworkConfiguration(
  62             Map<NetworkInterface,List<Inet4Address>> ip4Interfaces,
  63             Map<NetworkInterface,List<Inet6Address>> ip6Interfaces) {
  64         this.ip4Interfaces = ip4Interfaces;
  65         this.ip6Interfaces = ip6Interfaces;
  66 
  67         // initialize properties that can be queried
  68         isIPv6Available = !ip6Interfaces().collect(Collectors.toList()).isEmpty();
  69         ip6Interfaces().forEach(nif -> {
  70             ip6Addresses(nif)
  71                 // On AIX, a configuration with only local or loopback
  72                 // addresses does not fully enable IPv6 operations.
  73                 // E.g. IPv6 multicasting does not work.
  74                 // So, don't set has_testableipv6address if we only find these.
  75                 .filter(addr -> Platform.isAix() ?
  76                     !(addr.isAnyLocalAddress() || addr.isLoopbackAddress()) : true)
  77                 .forEach(ia -> {
  78                     has_testableipv6address = true;
  79                     if (ia.isLinkLocalAddress()) has_linklocaladdress = true;
  80                     if (ia.isSiteLocalAddress()) has_sitelocaladdress = true;
  81 
  82                     if (!ia.isLinkLocalAddress() &&
  83                         !ia.isSiteLocalAddress() &&
  84                         !ia.isLoopbackAddress()) {
  85                         has_globaladdress = true;
  86                     }
  87                 });
  88         });
  89     }
  90 
  91     private static boolean isIPv6LinkLocal(InetAddress a) {
  92         return Inet6Address.class.isInstance(a) && a.isLinkLocalAddress();
  93     }
  94 
  95     public static boolean isTestable(NetworkInterface nif) {


< prev index next >