author | clanger |
Fri, 13 Jan 2017 13:12:21 +0100 | |
changeset 43100 | a7e3457672c7 |
parent 41834 | 99c4f72c0a91 |
child 44916 | 54d70322b32c |
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 |
||
41380
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
33 |
/************************************************************************ |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
34 |
* Macros and constants |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
35 |
*/ |
2 | 36 |
|
36115 | 37 |
/* Defines SO_REUSEPORT */ |
38 |
#ifndef SO_REUSEPORT |
|
39 |
#ifdef __linux__ |
|
40 |
#define SO_REUSEPORT 15 |
|
41 |
#elif __solaris__ |
|
42 |
#define SO_REUSEPORT 0x100e |
|
43 |
#elif defined(AIX) || defined(MACOSX) |
|
44 |
#define SO_REUSEPORT 0x0200 |
|
45 |
#else |
|
46 |
#define SO_REUSEPORT 0 |
|
47 |
#endif |
|
48 |
#endif |
|
49 |
||
2 | 50 |
/* |
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
51 |
* On 64-bit JDKs we use a much larger stack and heap buffer. |
2 | 52 |
*/ |
2938
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
53 |
#ifdef _LP64 |
b3338e271fcb
6807602: Increase MAX_BUFFER_LEN and MAX_HEAP_BUFFER_LEN on 64-bit Solaris and Linux
chegar
parents:
2
diff
changeset
|
54 |
#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
|
55 |
#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
|
56 |
#else |
2 | 57 |
#define MAX_BUFFER_LEN 8192 |
58 |
#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
|
59 |
#endif |
2 | 60 |
|
41380
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
61 |
typedef union { |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
62 |
struct sockaddr sa; |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
63 |
struct sockaddr_in sa4; |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
64 |
struct sockaddr_in6 sa6; |
c27cf95dd7e6
8167295: Further cleanup to the native parts of libnet/libnio
clanger
parents:
40937
diff
changeset
|
65 |
} SOCKETADDRESS; |
2 | 66 |
|
67 |
/************************************************************************ |
|
43100 | 68 |
* Functions |
2 | 69 |
*/ |
23033
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
70 |
|
43100 | 71 |
int NET_Timeout(int s, long timeout); |
72 |
int NET_Timeout0(int s, long timeout, long currentTime); |
|
73 |
int NET_Read(int s, void* buf, size_t len); |
|
74 |
int NET_NonBlockingRead(int s, void* buf, size_t len); |
|
75 |
int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime); |
|
76 |
long NET_GetCurrentTime(); |
|
77 |
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, |
|
78 |
struct sockaddr *from, socklen_t *fromlen); |
|
79 |
int NET_ReadV(int s, const struct iovec * vector, int count); |
|
80 |
int NET_Send(int s, void *msg, int len, unsigned int flags); |
|
81 |
int NET_SendTo(int s, const void *msg, int len, unsigned int |
|
82 |
flags, const struct sockaddr *to, int tolen); |
|
83 |
int NET_Writev(int s, const struct iovec * vector, int count); |
|
84 |
int NET_Connect(int s, struct sockaddr *addr, int addrlen); |
|
85 |
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen); |
|
86 |
int NET_SocketClose(int s); |
|
87 |
int NET_Dup2(int oldfd, int newfd); |
|
88 |
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout); |
|
89 |
int NET_SocketAvailable(int s, jint *pbytes); |
|
90 |
||
91 |
void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env, |
|
92 |
const char* hostname, |
|
93 |
int gai_error); |
|
94 |
void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name, |
|
95 |
const char *defaultDetail); |
|
96 |
void NET_SetTrafficClass(SOCKETADDRESS *sa, int trafficClass); |
|
97 |
||
2 | 98 |
#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
|
99 |
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
|
100 |
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
|
101 |
#endif |
2 | 102 |
|
23033
0cc7c83fde3c
8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
simonis
parents:
23028
diff
changeset
|
103 |
#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
|
104 |
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
|
105 |
#endif |
2 | 106 |
|
107 |
#endif /* NET_UTILS_MD_H */ |