jdk/src/java.base/windows/native/libnet/net_util_md.c
changeset 27178 885f4428b501
parent 26458 d6a5aed9204b
child 36115 0676e37a0b9c
equal deleted inserted replaced
27177:3717db2c3bfe 27178:885f4428b501
    26 #include <winsock2.h>
    26 #include <winsock2.h>
    27 #include <ws2tcpip.h>
    27 #include <ws2tcpip.h>
    28 
    28 
    29 #include "net_util.h"
    29 #include "net_util.h"
    30 #include "jni.h"
    30 #include "jni.h"
       
    31 
       
    32 // Taken from mstcpip.h in Windows SDK 8.0 or newer.
       
    33 #define SIO_LOOPBACK_FAST_PATH              _WSAIOW(IOC_VENDOR,16)
    31 
    34 
    32 #ifndef IPTOS_TOS_MASK
    35 #ifndef IPTOS_TOS_MASK
    33 #define IPTOS_TOS_MASK 0x1e
    36 #define IPTOS_TOS_MASK 0x1e
    34 #endif
    37 #endif
    35 #ifndef IPTOS_PREC_MASK
    38 #ifndef IPTOS_PREC_MASK
   842         closesocket(fd);
   845         closesocket(fd);
   843         return route.sin6_scope_id;
   846         return route.sin6_scope_id;
   844     }
   847     }
   845 }
   848 }
   846 
   849 
       
   850 /**
       
   851  * Enables SIO_LOOPBACK_FAST_PATH
       
   852  */
       
   853 JNIEXPORT jint JNICALL
       
   854 NET_EnableFastTcpLoopback(int fd) {
       
   855     int enabled = 1;
       
   856     DWORD result_byte_count = -1;
       
   857     int result = WSAIoctl(fd,
       
   858                           SIO_LOOPBACK_FAST_PATH,
       
   859                           &enabled,
       
   860                           sizeof(enabled),
       
   861                           NULL,
       
   862                           0,
       
   863                           &result_byte_count,
       
   864                           NULL,
       
   865                           NULL);
       
   866     return result == SOCKET_ERROR ? WSAGetLastError() : 0;
       
   867 }
       
   868 
   847 /* If address types is IPv6, then IPv6 must be available. Otherwise
   869 /* If address types is IPv6, then IPv6 must be available. Otherwise
   848  * no address can be generated. In the case of an IPv4 Inetaddress this
   870  * no address can be generated. In the case of an IPv4 Inetaddress this
   849  * method will return an IPv4 mapped address where IPv6 is available and
   871  * method will return an IPv4 mapped address where IPv6 is available and
   850  * v4MappedAddress is TRUE. Otherwise it will return a sockaddr_in
   872  * v4MappedAddress is TRUE. Otherwise it will return a sockaddr_in
   851  * structure for an IPv4 InetAddress.
   873  * structure for an IPv4 InetAddress.