Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/java/net/net_util_md.h
32287 views
/*1* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef NET_UTILS_MD_H26#define NET_UTILS_MD_H2728#include <sys/socket.h>29#include <sys/types.h>30#include <netdb.h>31#include <netinet/in.h>32#include <unistd.h>3334#ifndef USE_SELECT35#include <sys/poll.h>36#endif373839/*40AIX needs a workaround for I/O cancellation, see:41http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/close.htm42...43The close subroutine is blocked until all subroutines which use the file44descriptor return to usr space. For example, when a thread is calling close45and another thread is calling select with the same file descriptor, the46close subroutine does not return until the select call returns.47...48*/49#if !defined(__solaris__)50extern int NET_Timeout(int s, long timeout);51extern int NET_Timeout0(int s, long timeout, long currentTime);52extern int NET_Read(int s, void* buf, size_t len);53extern int NET_NonBlockingRead(int s, void* buf, size_t len);54extern int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);55extern long NET_GetCurrentTime();56extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,57struct sockaddr *from, int *fromlen);58extern int NET_ReadV(int s, const struct iovec * vector, int count);59extern int NET_Send(int s, void *msg, int len, unsigned int flags);60extern int NET_SendTo(int s, const void *msg, int len, unsigned int61flags, const struct sockaddr *to, int tolen);62extern int NET_Writev(int s, const struct iovec * vector, int count);63extern int NET_Connect(int s, struct sockaddr *addr, int addrlen);64extern int NET_Accept(int s, struct sockaddr *addr, int *addrlen);65extern int NET_SocketClose(int s);66extern int NET_Dup2(int oldfd, int newfd);6768#ifdef USE_SELECT69extern int NET_Select(int s, fd_set *readfds, fd_set *writefds,70fd_set *exceptfds, struct timeval *timeout);71#else72extern int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);73#endif7475#else7677#define NET_Timeout JVM_Timeout78#define NET_Read JVM_Read79#define NET_RecvFrom JVM_RecvFrom80#define NET_ReadV readv81#define NET_Send JVM_Send82#define NET_SendTo JVM_SendTo83#define NET_WriteV writev84#define NET_Connect JVM_Connect85#define NET_Accept JVM_Accept86#define NET_SocketClose JVM_SocketClose87#define NET_Dup2 dup288#define NET_Select select89#define NET_Poll poll9091#endif9293#if defined(__linux__) && defined(AF_INET6)94int getDefaultIPv6Interface(struct in6_addr *target_addr);95#endif9697#ifdef __solaris__98extern int net_getParam(char *driver, char *param);99100#ifndef SO_FLOW_SLA101#define SO_FLOW_SLA 0x1018102103#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4104#pragma pack(4)105#endif106107/*108* Used with the setsockopt(SO_FLOW_SLA, ...) call to set109* per socket service level properties.110* When the application uses per-socket API, we will enforce the properties111* on both outbound and inbound packets.112*113* For now, only priority and maxbw are supported in SOCK_FLOW_PROP_VERSION1.114*/115typedef struct sock_flow_props_s {116int sfp_version;117uint32_t sfp_mask;118int sfp_priority; /* flow priority */119uint64_t sfp_maxbw; /* bandwidth limit in bps */120int sfp_status; /* flow create status for getsockopt */121} sock_flow_props_t;122123#define SOCK_FLOW_PROP_VERSION1 1124125/* bit mask values for sfp_mask */126#define SFP_MAXBW 0x00000001 /* Flow Bandwidth Limit */127#define SFP_PRIORITY 0x00000008 /* Flow priority */128129/* possible values for sfp_priority */130#define SFP_PRIO_NORMAL 1131#define SFP_PRIO_HIGH 2132133#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4134#pragma pack()135#endif /* _LONG_LONG_ALIGNMENT */136137#endif /* SO_FLOW_SLA */138#endif /* __solaris__ */139140void ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,141const char* hostname,142int gai_error);143144#define NET_WAIT_READ 0x01145#define NET_WAIT_WRITE 0x02146#define NET_WAIT_CONNECT 0x04147148extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);149150/************************************************************************151* Macros and constants152*/153154/*155* On 64-bit JDKs we use a much larger stack and heap buffer.156*/157#ifdef _LP64158#define MAX_BUFFER_LEN 65536159#define MAX_HEAP_BUFFER_LEN 131072160#else161#define MAX_BUFFER_LEN 8192162#define MAX_HEAP_BUFFER_LEN 65536163#endif164165#ifdef AF_INET6166167#define SOCKADDR union { \168struct sockaddr_in him4; \169struct sockaddr_in6 him6; \170}171172#define SOCKADDR_LEN (ipv6_available() ? sizeof(SOCKADDR) : \173sizeof(struct sockaddr_in))174175#else176177#define SOCKADDR union { struct sockaddr_in him4; }178#define SOCKADDR_LEN sizeof(SOCKADDR)179180#endif181182/************************************************************************183* Utilities184*/185#ifdef __linux__186extern int kernelIsV24();187#endif188189void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,190const char *defaultDetail);191192193#endif /* NET_UTILS_MD_H */194195196