author | simonis |
Thu, 27 Feb 2014 10:53:07 +0100 | |
changeset 23028 | 0554f6183d11 |
parent 23015 | 73b21ab36615 |
child 23033 | 0cc7c83fde3c |
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 |
||
23015
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
39 |
int NET_Timeout(int s, long timeout); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
40 |
int NET_Read(int s, void* buf, size_t len); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
41 |
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
42 |
struct sockaddr *from, socklen_t *fromlen); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
43 |
int NET_ReadV(int s, const struct iovec * vector, int count); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
44 |
int NET_Send(int s, void *msg, int len, unsigned int flags); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
45 |
int NET_SendTo(int s, const void *msg, int len, unsigned int |
2 | 46 |
flags, const struct sockaddr *to, int tolen); |
23015
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
47 |
int NET_Writev(int s, const struct iovec * vector, int count); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
48 |
int NET_Connect(int s, struct sockaddr *addr, int addrlen); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
49 |
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
50 |
int NET_SocketClose(int s); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
51 |
int NET_Dup2(int oldfd, int newfd); |
23028
0554f6183d11
8035876: AIX build issues after '8034174: Remove use of JVM_* functions from java.net code'
simonis
parents:
23015
diff
changeset
|
52 |
#ifdef USE_SELECT |
2 | 53 |
extern int NET_Select(int s, fd_set *readfds, fd_set *writefds, |
54 |
fd_set *exceptfds, struct timeval *timeout); |
|
23028
0554f6183d11
8035876: AIX build issues after '8034174: Remove use of JVM_* functions from java.net code'
simonis
parents:
23015
diff
changeset
|
55 |
#else |
2 | 56 |
extern int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout); |
23028
0554f6183d11
8035876: AIX build issues after '8034174: Remove use of JVM_* functions from java.net code'
simonis
parents:
23015
diff
changeset
|
57 |
#endif |
2 | 58 |
|
23015
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
59 |
int NET_SocketAvailable(int s, jint *pbytes); |
2 | 60 |
|
61 |
#if defined(__linux__) && defined(AF_INET6) |
|
62 |
int getDefaultIPv6Interface(struct in6_addr *target_addr); |
|
63 |
#endif |
|
64 |
||
22341
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
14342
diff
changeset
|
65 |
#ifdef __solaris__ |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
14342
diff
changeset
|
66 |
extern int net_getParam(char *driver, char *param); |
4689530d03b9
8028293: Check local configuration for actual ephemeral port range
michaelm
parents:
14342
diff
changeset
|
67 |
#endif |
2 | 68 |
|
69 |
/* needed from libsocket on Solaris 8 */ |
|
70 |
||
6670
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
71 |
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
|
72 |
const struct addrinfo *hints, struct addrinfo **res); |
2 | 73 |
|
74 |
typedef void (*freeaddrinfo_f)(struct addrinfo *); |
|
75 |
||
6670
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
76 |
typedef const char * (*gai_strerror_f)(int ecode); |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
77 |
|
2 | 78 |
typedef int (*getnameinfo_f)(const struct sockaddr *, size_t, |
79 |
char *, size_t, char *, size_t, int); |
|
80 |
||
81 |
extern getaddrinfo_f getaddrinfo_ptr; |
|
82 |
extern freeaddrinfo_f freeaddrinfo_ptr; |
|
83 |
extern getnameinfo_f getnameinfo_ptr; |
|
84 |
||
6670
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
85 |
void ThrowUnknownHostExceptionWithGaiError(JNIEnv *env, |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
86 |
const char* hostname, |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
87 |
int gai_error); |
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
88 |
|
2 | 89 |
#define NET_WAIT_READ 0x01 |
90 |
#define NET_WAIT_WRITE 0x02 |
|
91 |
#define NET_WAIT_CONNECT 0x04 |
|
92 |
||
93 |
extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout); |
|
94 |
||
95 |
/************************************************************************ |
|
96 |
* Macros and constants |
|
97 |
*/ |
|
98 |
||
99 |
/* |
|
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
100 |
* On 64-bit JDKs we use a much larger stack and heap buffer. |
2 | 101 |
*/ |
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
102 |
#ifdef _LP64 |
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
103 |
#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
|
104 |
#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
|
105 |
#else |
2 | 106 |
#define MAX_BUFFER_LEN 8192 |
107 |
#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
|
108 |
#endif |
2 | 109 |
|
110 |
#ifdef AF_INET6 |
|
111 |
||
112 |
#define SOCKADDR union { \ |
|
113 |
struct sockaddr_in him4; \ |
|
114 |
struct sockaddr_in6 him6; \ |
|
115 |
} |
|
116 |
||
117 |
#define SOCKADDR_LEN (ipv6_available() ? sizeof(SOCKADDR) : \ |
|
118 |
sizeof(struct sockaddr_in)) |
|
119 |
||
120 |
#else |
|
121 |
||
4814 | 122 |
#define SOCKADDR union { struct sockaddr_in him4; } |
2 | 123 |
#define SOCKADDR_LEN sizeof(SOCKADDR) |
124 |
||
125 |
#endif |
|
126 |
||
127 |
/************************************************************************ |
|
128 |
* Utilities |
|
129 |
*/ |
|
130 |
#ifdef __linux__ |
|
131 |
extern int kernelIsV24(); |
|
132 |
#endif |
|
133 |
||
134 |
void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name, |
|
135 |
const char *defaultDetail); |
|
136 |
||
137 |
||
138 |
#endif /* NET_UTILS_MD_H */ |