author | clanger |
Wed, 02 Nov 2016 11:52:51 +0100 | |
changeset 41834 | 99c4f72c0a91 |
parent 41771 | 18c9669e76ca |
child 43100 | a7e3457672c7 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
36115 | 2 |
* Copyright (c) 1997, 2016, 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 |
||
41771
18c9669e76ca
8167481: cleanup of headers and includes for native libnet
clanger
parents:
41380
diff
changeset
|
29 |
#include <netdb.h> |
18c9669e76ca
8167481: cleanup of headers and includes for native libnet
clanger
parents:
41380
diff
changeset
|
30 |
#include <sys/poll.h> |
2 | 31 |
#include <sys/socket.h> |
32 |
||
23048 | 33 |
int NET_Timeout(int s, long timeout); |
40937
f72e61ec734b
8075484: SocketInputStream.socketRead0 can hang even with soTimeout set
vtewari
parents:
37676
diff
changeset
|
34 |
int NET_Timeout0(int s, long timeout, long currentTime); |
23015
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
35 |
int NET_Read(int s, void* buf, size_t len); |
40937
f72e61ec734b
8075484: SocketInputStream.socketRead0 can hang even with soTimeout set
vtewari
parents:
37676
diff
changeset
|
36 |
int NET_NonBlockingRead(int s, void* buf, size_t len); |
f72e61ec734b
8075484: SocketInputStream.socketRead0 can hang even with soTimeout set
vtewari
parents:
37676
diff
changeset
|
37 |
int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime); |
f72e61ec734b
8075484: SocketInputStream.socketRead0 can hang even with soTimeout set
vtewari
parents:
37676
diff
changeset
|
38 |
long NET_GetCurrentTime(); |
23015
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
39 |
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
|
40 |
struct sockaddr *from, socklen_t *fromlen); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
41 |
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
|
42 |
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
|
43 |
int NET_SendTo(int s, const void *msg, int len, unsigned int |
23033
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
44 |
flags, const struct sockaddr *to, int tolen); |
23015
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
int NET_SocketClose(int s); |
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
49 |
int NET_Dup2(int oldfd, int newfd); |
23033
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
50 |
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout); |
23015
73b21ab36615
8034174: Remove use of JVM_* functions from java.net code
chegar
parents:
22607
diff
changeset
|
51 |
int NET_SocketAvailable(int s, jint *pbytes); |
2 | 52 |
|
23033
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
53 |
void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env, |
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
54 |
const char* hostname, |
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
55 |
int gai_error); |
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
56 |
void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name, |
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
57 |
const char *defaultDetail); |
6670
ae13809f3ce7
6981157: Improve UnknownHostException with EAI error details and other cleanups
martin
parents:
5506
diff
changeset
|
58 |
|
41380
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
59 |
/************************************************************************ |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
60 |
* Macros and constants |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
61 |
*/ |
2 | 62 |
|
36115 | 63 |
/* Defines SO_REUSEPORT */ |
64 |
#ifndef SO_REUSEPORT |
|
65 |
#ifdef __linux__ |
|
66 |
#define SO_REUSEPORT 15 |
|
67 |
#elif __solaris__ |
|
68 |
#define SO_REUSEPORT 0x100e |
|
69 |
#elif defined(AIX) || defined(MACOSX) |
|
70 |
#define SO_REUSEPORT 0x0200 |
|
71 |
#else |
|
72 |
#define SO_REUSEPORT 0 |
|
73 |
#endif |
|
74 |
#endif |
|
75 |
||
2 | 76 |
/* |
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
77 |
* On 64-bit JDKs we use a much larger stack and heap buffer. |
2 | 78 |
*/ |
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
79 |
#ifdef _LP64 |
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
80 |
#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
|
81 |
#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
|
82 |
#else |
2 | 83 |
#define MAX_BUFFER_LEN 8192 |
84 |
#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
|
85 |
#endif |
2 | 86 |
|
41380
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
87 |
typedef union { |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
88 |
struct sockaddr sa; |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
89 |
struct sockaddr_in sa4; |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
90 |
struct sockaddr_in6 sa6; |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
91 |
} SOCKETADDRESS; |
2 | 92 |
|
93 |
/************************************************************************ |
|
94 |
* Utilities |
|
95 |
*/ |
|
23033
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
96 |
|
2 | 97 |
#ifdef __linux__ |
23033
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
98 |
int kernelIsV24(); |
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
99 |
int getDefaultIPv6Interface(struct in6_addr *target_addr); |
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
100 |
#endif |
2 | 101 |
|
23033
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
102 |
#ifdef __solaris__ |
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
103 |
int net_getParam(char *driver, char *param); |
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
104 |
#endif |
2 | 105 |
|
106 |
#endif /* NET_UTILS_MD_H */ |