< prev index next >

src/java.base/share/native/libnet/net_util.c

Print this page
*** 24,10 ***
--- 24,11 ---
   */
  
  #include "net_util.h"
  
  #include "java_net_InetAddress.h"
+ #include "java_net_spi_InetAddressResolver_LookupPolicy.h"
  
  int IPv4_supported();
  int IPv6_supported();
  int reuseport_supported();
  

*** 330,5 ***
--- 331,25 ---
      sum = (sum >> 16) + (sum & 0xffff);
      sum += (sum >> 16);
      answer = ~sum;
      return (answer);
  }
+ 
+ int lookupCharacteristicsToAddressFamily(int characteristics) {
+     int ipv4 = characteristics & java_net_spi_InetAddressResolver_LookupPolicy_IPV4;
+     int ipv6 = characteristics & java_net_spi_InetAddressResolver_LookupPolicy_IPV6;
+ 
+     if (ipv4 != 0 && ipv6 == 0) {
+         return AF_INET;
+     }
+ 
+     if (ipv4 == 0 && ipv6 != 0) {
+         return AF_INET6;
+     }
+     return AF_UNSPEC;
+ }
+ 
+ int addressesInSystemOrder(int characteristics) {
+     return (characteristics &
+            (java_net_spi_InetAddressResolver_LookupPolicy_IPV4_FIRST |
+             java_net_spi_InetAddressResolver_LookupPolicy_IPV6_FIRST)) == 0;
+ }
< prev index next >