author | kvn |
Tue, 28 Jan 2014 14:57:41 -0800 | |
changeset 22607 | ba232b417248 |
parent 22341 | 4689530d03b9 |
parent 22597 | 7515a991bb37 |
child 23015 | 73b21ab36615 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
13999
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#ifndef NET_UTILS_MD_H |
|
27 |
#define NET_UTILS_MD_H |
|
28 |
||
29 |
#include <sys/socket.h> |
|
30 |
#include <sys/types.h> |
|
31 |
#include <netdb.h> |
|
32 |
#include <netinet/in.h> |
|
33 |
#include <unistd.h> |
|
34 |
||
35 |
#ifndef USE_SELECT |
|
36 |
#include <sys/poll.h> |
|
37 |
#endif |
|
38 |
||
39 |
||
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
40 |
/* |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
41 |
AIX needs a workaround for I/O cancellation, see: |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
42 |
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/close.htm |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
43 |
... |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
44 |
The close subroutine is blocked until all subroutines which use the file |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
45 |
descriptor return to usr space. For example, when a thread is calling close |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
46 |
and another thread is calling select with the same file descriptor, the |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
47 |
close subroutine does not return until the select call returns. |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
48 |
... |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
49 |
*/ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
14342
diff
changeset
|
50 |
#if defined(__linux__) || defined(MACOSX) || defined (_AIX) |
2 | 51 |
extern int NET_Timeout(int s, long timeout); |
52 |
extern int NET_Read(int s, void* buf, size_t len); |
|
53 |
extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, |
|
54 |
struct sockaddr *from, int *fromlen); |
|
55 |
extern int NET_ReadV(int s, const struct iovec * vector, int count); |
|
56 |
extern int NET_Send(int s, void *msg, int len, unsigned int flags); |
|
57 |
extern int NET_SendTo(int s, const void *msg, int len, unsigned int |
|
58 |
flags, const struct sockaddr *to, int tolen); |
|
59 |
extern int NET_Writev(int s, const struct iovec * vector, int count); |
|
60 |
extern int NET_Connect(int s, struct sockaddr *addr, int addrlen); |
|
61 |
extern int NET_Accept(int s, struct sockaddr *addr, int *addrlen); |
|
62 |
extern int NET_SocketClose(int s); |
|
63 |
extern int NET_Dup2(int oldfd, int newfd); |
|
64 |
||
65 |
#ifdef USE_SELECT |
|
66 |
extern int NET_Select(int s, fd_set *readfds, fd_set *writefds, |
|
67 |
fd_set *exceptfds, struct timeval *timeout); |
|
68 |
#else |
|
69 |
extern int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout); |
|
70 |
#endif |
|
71 |
||
72 |
#else |
|
73 |
||
74 |
#define NET_Timeout JVM_Timeout |
|
75 |
#define NET_Read JVM_Read |
|
76 |
#define NET_RecvFrom JVM_RecvFrom |
|
77 |
#define NET_ReadV readv |
|
78 |
#define NET_Send JVM_Send |
|
79 |
#define NET_SendTo JVM_SendTo |
|
80 |
#define NET_WriteV writev |
|
81 |
#define NET_Connect JVM_Connect |
|
82 |
#define NET_Accept JVM_Accept |
|
83 |
#define NET_SocketClose JVM_SocketClose |
|
84 |
#define NET_Dup2 dup2 |
|
85 |
#define NET_Select select |
|
86 |
#define NET_Poll poll |
|
87 |
||
88 |
#endif |
|
89 |
||
90 |
#if defined(__linux__) && defined(AF_INET6) |
|
91 |
int getDefaultIPv6Interface(struct in6_addr *target_addr); |
|
92 |
#endif |
|
93 |
||
22341
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
14342
diff
changeset
|
94 |
#ifdef __solaris__ |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
14342
diff
changeset
|
95 |
extern int net_getParam(char *driver, char *param); |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
14342
diff
changeset
|
96 |
#endif |
2 | 97 |
|
98 |
/* needed from libsocket on Solaris 8 */ |
|
99 |
||
6670
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
100 |
typedef int (*getaddrinfo_f)(const char *nodename, const char *servname, |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
101 |
const struct addrinfo *hints, struct addrinfo **res); |
2 | 102 |
|
103 |
typedef void (*freeaddrinfo_f)(struct addrinfo *); |
|
104 |
||
6670
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
105 |
typedef const char * (*gai_strerror_f)(int ecode); |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
106 |
|
2 | 107 |
typedef int (*getnameinfo_f)(const struct sockaddr *, size_t, |
108 |
char *, size_t, char *, size_t, int); |
|
109 |
||
110 |
extern getaddrinfo_f getaddrinfo_ptr; |
|
111 |
extern freeaddrinfo_f freeaddrinfo_ptr; |
|
112 |
extern getnameinfo_f getnameinfo_ptr; |
|
113 |
||
6670
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
114 |
void ThrowUnknownHostExceptionWithGaiError(JNIEnv *env, |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
115 |
const char* hostname, |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
116 |
int gai_error); |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
117 |
|
2 | 118 |
#define NET_WAIT_READ 0x01 |
119 |
#define NET_WAIT_WRITE 0x02 |
|
120 |
#define NET_WAIT_CONNECT 0x04 |
|
121 |
||
122 |
extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout); |
|
123 |
||
124 |
/************************************************************************ |
|
125 |
* Macros and constants |
|
126 |
*/ |
|
127 |
||
128 |
/* |
|
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
129 |
* On 64-bit JDKs we use a much larger stack and heap buffer. |
2 | 130 |
*/ |
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
131 |
#ifdef _LP64 |
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
132 |
#define MAX_BUFFER_LEN 65536 |
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
133 |
#define MAX_HEAP_BUFFER_LEN 131072 |
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
134 |
#else |
2 | 135 |
#define MAX_BUFFER_LEN 8192 |
136 |
#define MAX_HEAP_BUFFER_LEN 65536 |
|
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
137 |
#endif |
2 | 138 |
|
139 |
#ifdef AF_INET6 |
|
140 |
||
141 |
#define SOCKADDR union { \ |
|
142 |
struct sockaddr_in him4; \ |
|
143 |
struct sockaddr_in6 him6; \ |
|
144 |
} |
|
145 |
||
146 |
#define SOCKADDR_LEN (ipv6_available() ? sizeof(SOCKADDR) : \ |
|
147 |
sizeof(struct sockaddr_in)) |
|
148 |
||
149 |
#else |
|
150 |
||
4814 | 151 |
#define SOCKADDR union { struct sockaddr_in him4; } |
2 | 152 |
#define SOCKADDR_LEN sizeof(SOCKADDR) |
153 |
||
154 |
#endif |
|
155 |
||
156 |
/************************************************************************ |
|
157 |
* Utilities |
|
158 |
*/ |
|
159 |
#ifdef __linux__ |
|
160 |
extern int kernelIsV24(); |
|
161 |
#endif |
|
162 |
||
163 |
void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name, |
|
164 |
const char *defaultDetail); |
|
165 |
||
166 |
||
167 |
#endif /* NET_UTILS_MD_H */ |