author | simonis |
Mon, 20 Jan 2014 09:24:25 +0100 | |
changeset 22604 | 9b394795e216 |
parent 22597 | 7515a991bb37 |
child 22605 | dba3d6b22818 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
2 |
* Copyright (c) 2001, 2013, 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 |
||
22604
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
26 |
#include <sys/poll.h> |
2 | 27 |
#include <sys/types.h> |
28 |
#include <sys/socket.h> |
|
29 |
#include <string.h> |
|
30 |
#include <netinet/in.h> |
|
31 |
#include <netinet/tcp.h> |
|
32 |
||
33 |
#include "jni.h" |
|
34 |
#include "jni_util.h" |
|
35 |
#include "jvm.h" |
|
36 |
#include "jlong.h" |
|
37 |
#include "sun_nio_ch_Net.h" |
|
38 |
#include "net_util.h" |
|
39 |
#include "net_util_md.h" |
|
40 |
#include "nio_util.h" |
|
41 |
#include "nio.h" |
|
14025
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
42 |
#include "sun_nio_ch_PollArrayWrapper.h" |
2 | 43 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
44 |
#ifdef _AIX |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
45 |
#include <sys/utsname.h> |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
46 |
#endif |
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
47 |
|
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
48 |
/** |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
49 |
* IP_MULTICAST_ALL supported since 2.6.31 but may not be available at |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
50 |
* build time. |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
51 |
*/ |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
52 |
#ifdef __linux__ |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
53 |
#ifndef IP_MULTICAST_ALL |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
54 |
#define IP_MULTICAST_ALL 49 |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
55 |
#endif |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
56 |
#endif |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
57 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
58 |
#if defined(_ALLBSD_SOURCE) || defined(_AIX) |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
59 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
60 |
#ifndef IP_BLOCK_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
61 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
62 |
#if defined(_AIX) |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
63 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
64 |
#define IP_BLOCK_SOURCE 58 /* Block data from a given source to a given group */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
65 |
#define IP_UNBLOCK_SOURCE 59 /* Unblock data from a given source to a given group */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
66 |
#define IP_ADD_SOURCE_MEMBERSHIP 60 /* Join a source-specific group */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
67 |
#define IP_DROP_SOURCE_MEMBERSHIP 61 /* Leave a source-specific group */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
68 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
69 |
#else |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
70 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
71 |
#define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
72 |
#define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
73 |
#define IP_BLOCK_SOURCE 72 /* block a source */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
74 |
#define IP_UNBLOCK_SOURCE 73 /* unblock a source */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
75 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
76 |
#endif /* _AIX */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
77 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
78 |
#endif /* IP_BLOCK_SOURCE */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
79 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
80 |
#ifndef MCAST_BLOCK_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
81 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
82 |
#if defined(_AIX) |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
83 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
84 |
#define MCAST_BLOCK_SOURCE 64 |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
85 |
#define MCAST_UNBLOCK_SOURCE 65 |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
86 |
#define MCAST_JOIN_SOURCE_GROUP 66 |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
87 |
#define MCAST_LEAVE_SOURCE_GROUP 67 |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
88 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
89 |
#else |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
90 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
91 |
#define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
92 |
#define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
93 |
#define MCAST_BLOCK_SOURCE 84 /* block a source */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
94 |
#define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
95 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
96 |
#endif /* _AIX */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
97 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
98 |
#endif /* MCAST_BLOCK_SOURCE */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
99 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
100 |
#ifndef IPV6_ADD_MEMBERSHIP |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
101 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
102 |
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
103 |
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
104 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
105 |
#endif /* IPV6_ADD_MEMBERSHIP */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
106 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
107 |
struct my_ip_mreq_source { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
108 |
struct in_addr imr_multiaddr; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
109 |
struct in_addr imr_interface; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
110 |
struct in_addr imr_sourceaddr; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
111 |
}; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
112 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
113 |
struct my_group_source_req { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
114 |
uint32_t gsr_interface; /* interface index */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
115 |
struct sockaddr_storage gsr_group; /* group address */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
116 |
struct sockaddr_storage gsr_source; /* source address */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
117 |
}; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
118 |
|
13363
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
119 |
#else /* _ALLBSD_SOURCE */ |
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
120 |
|
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
121 |
#define my_ip_mreq_source ip_mreq_source |
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
122 |
#define my_group_source_req group_source_req |
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
123 |
|
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
124 |
#endif |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
125 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
126 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
127 |
#define COPY_INET6_ADDRESS(env, source, target) \ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
128 |
(*env)->GetByteArrayRegion(env, source, 0, 16, target) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
129 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
130 |
/* |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
131 |
* Copy IPv6 group, interface index, and IPv6 source address |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
132 |
* into group_source_req structure. |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
133 |
*/ |
4814 | 134 |
#ifdef AF_INET6 |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
135 |
static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
136 |
jbyteArray source, struct my_group_source_req* req) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
137 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
138 |
struct sockaddr_in6* sin6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
139 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
140 |
req->gsr_interface = (uint32_t)index; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
141 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
142 |
sin6 = (struct sockaddr_in6*)&(req->gsr_group); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
143 |
sin6->sin6_family = AF_INET6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
144 |
COPY_INET6_ADDRESS(env, group, (jbyte*)&(sin6->sin6_addr)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
145 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
146 |
sin6 = (struct sockaddr_in6*)&(req->gsr_source); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
147 |
sin6->sin6_family = AF_INET6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
148 |
COPY_INET6_ADDRESS(env, source, (jbyte*)&(sin6->sin6_addr)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
149 |
} |
4814 | 150 |
#endif |
2 | 151 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
152 |
#ifdef _AIX |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
153 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
154 |
/* |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
155 |
* Checks whether or not "socket extensions for multicast source filters" is supported. |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
156 |
* Returns JNI_TRUE if it is supported, JNI_FALSE otherwise |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
157 |
*/ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
158 |
static jboolean isSourceFilterSupported(){ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
159 |
static jboolean alreadyChecked = JNI_FALSE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
160 |
static jboolean result = JNI_TRUE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
161 |
if (alreadyChecked != JNI_TRUE){ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
162 |
struct utsname uts; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
163 |
memset(&uts, 0, sizeof(uts)); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
164 |
strcpy(uts.sysname, "?"); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
165 |
const int utsRes = uname(&uts); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
166 |
int major = -1; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
167 |
int minor = -1; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
168 |
major = atoi(uts.version); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
169 |
minor = atoi(uts.release); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
170 |
if (strcmp(uts.sysname, "AIX") == 0) { |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
171 |
if (major < 6 || (major == 6 && minor < 1)) {// unsupported on aix < 6.1 |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
172 |
result = JNI_FALSE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
173 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
174 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
175 |
alreadyChecked = JNI_TRUE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
176 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
177 |
return result; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
178 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
179 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
180 |
#endif /* _AIX */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
181 |
|
2 | 182 |
JNIEXPORT void JNICALL |
183 |
Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz) |
|
184 |
{ |
|
185 |
/* Here because Windows native code does need to init IDs */ |
|
186 |
} |
|
187 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
188 |
JNIEXPORT jboolean JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
189 |
Java_sun_nio_ch_Net_isIPv6Available0(JNIEnv* env, jclass cl) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
190 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
191 |
return (ipv6_available()) ? JNI_TRUE : JNI_FALSE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
192 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
193 |
|
18192 | 194 |
JNIEXPORT jint JNICALL |
195 |
Java_sun_nio_ch_Net_isExclusiveBindAvailable(JNIEnv *env, jclass clazz) { |
|
196 |
return -1; |
|
197 |
} |
|
198 |
||
8788
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
199 |
JNIEXPORT jboolean JNICALL |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
200 |
Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0(JNIEnv* env, jclass cl) |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
201 |
{ |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
202 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
203 |
/* for now IPv6 sockets cannot join IPv4 multicast groups */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
204 |
return JNI_FALSE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
205 |
#else |
8788
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
206 |
return JNI_TRUE; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
207 |
#endif |
8788
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
208 |
} |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
209 |
|
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
210 |
JNIEXPORT jboolean JNICALL |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
211 |
Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl) |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
212 |
{ |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
213 |
#ifdef __solaris__ |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
214 |
return JNI_TRUE; |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
215 |
#else |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
216 |
return JNI_FALSE; |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
217 |
#endif |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
218 |
} |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
219 |
|
2 | 220 |
JNIEXPORT int JNICALL |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
221 |
Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
222 |
jboolean stream, jboolean reuse) |
2 | 223 |
{ |
224 |
int fd; |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
225 |
int type = (stream ? SOCK_STREAM : SOCK_DGRAM); |
4814 | 226 |
#ifdef AF_INET6 |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
227 |
int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET; |
4814 | 228 |
#else |
229 |
int domain = AF_INET; |
|
230 |
#endif |
|
2 | 231 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
232 |
fd = socket(domain, type, 0); |
2 | 233 |
if (fd < 0) { |
234 |
return handleSocketError(env, errno); |
|
235 |
} |
|
6299
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
236 |
|
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
237 |
#ifdef AF_INET6 |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
238 |
/* Disable IPV6_V6ONLY to ensure dual-socket support */ |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
239 |
if (domain == AF_INET6) { |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
240 |
int arg = 0; |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
241 |
if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg, |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
242 |
sizeof(int)) < 0) { |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
243 |
JNU_ThrowByNameWithLastError(env, |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
244 |
JNU_JAVANETPKG "SocketException", |
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
245 |
"Unable to set IPV6_V6ONLY"); |
6299
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
246 |
close(fd); |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
247 |
return -1; |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
248 |
} |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
249 |
} |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
250 |
#endif |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
251 |
|
2 | 252 |
if (reuse) { |
253 |
int arg = 1; |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
254 |
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
255 |
sizeof(arg)) < 0) { |
2 | 256 |
JNU_ThrowByNameWithLastError(env, |
257 |
JNU_JAVANETPKG "SocketException", |
|
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
258 |
"Unable to set SO_REUSEADDR"); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
259 |
close(fd); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
260 |
return -1; |
2 | 261 |
} |
262 |
} |
|
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
263 |
|
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
264 |
#if defined(__linux__) |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
265 |
if (type == SOCK_DGRAM) { |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
266 |
int arg = 0; |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
267 |
int level = (domain == AF_INET6) ? IPPROTO_IPV6 : IPPROTO_IP; |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
268 |
if ((setsockopt(fd, level, IP_MULTICAST_ALL, (char*)&arg, sizeof(arg)) < 0) && |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
269 |
(errno != ENOPROTOOPT)) { |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
270 |
JNU_ThrowByNameWithLastError(env, |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
271 |
JNU_JAVANETPKG "SocketException", |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
272 |
"Unable to set IP_MULTICAST_ALL"); |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
273 |
close(fd); |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
274 |
return -1; |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
275 |
} |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
276 |
} |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
277 |
#endif |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
278 |
|
4814 | 279 |
#if defined(__linux__) && defined(AF_INET6) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
280 |
/* By default, Linux uses the route default */ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
281 |
if (domain == AF_INET6 && type == SOCK_DGRAM) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
282 |
int arg = 1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
283 |
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &arg, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
284 |
sizeof(arg)) < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
285 |
JNU_ThrowByNameWithLastError(env, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
286 |
JNU_JAVANETPKG "SocketException", |
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
287 |
"Unable to set IPV6_MULTICAST_HOPS"); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
288 |
close(fd); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
289 |
return -1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
290 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
291 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
292 |
#endif |
2 | 293 |
return fd; |
294 |
} |
|
295 |
||
296 |
JNIEXPORT void JNICALL |
|
18192 | 297 |
Java_sun_nio_ch_Net_bind0(JNIEnv *env, jclass clazz, jobject fdo, jboolean preferIPv6, |
298 |
jboolean useExclBind, jobject iao, int port) |
|
2 | 299 |
{ |
300 |
SOCKADDR sa; |
|
301 |
int sa_len = SOCKADDR_LEN; |
|
302 |
int rv = 0; |
|
303 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
304 |
if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) { |
2 | 305 |
return; |
306 |
} |
|
307 |
||
308 |
rv = NET_Bind(fdval(env, fdo), (struct sockaddr *)&sa, sa_len); |
|
309 |
if (rv != 0) { |
|
310 |
handleSocketError(env, errno); |
|
311 |
} |
|
312 |
} |
|
313 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
314 |
JNIEXPORT void JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
315 |
Java_sun_nio_ch_Net_listen(JNIEnv *env, jclass cl, jobject fdo, jint backlog) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
316 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
317 |
if (listen(fdval(env, fdo), backlog) < 0) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
318 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
319 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
320 |
|
2 | 321 |
JNIEXPORT jint JNICALL |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
322 |
Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
323 |
jobject fdo, jobject iao, jint port) |
2 | 324 |
{ |
325 |
SOCKADDR sa; |
|
326 |
int sa_len = SOCKADDR_LEN; |
|
327 |
int rv; |
|
328 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
329 |
if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
330 |
&sa_len, preferIPv6) != 0) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
331 |
{ |
2 | 332 |
return IOS_THROWN; |
333 |
} |
|
334 |
||
335 |
rv = connect(fdval(env, fdo), (struct sockaddr *)&sa, sa_len); |
|
336 |
if (rv != 0) { |
|
337 |
if (errno == EINPROGRESS) { |
|
338 |
return IOS_UNAVAILABLE; |
|
339 |
} else if (errno == EINTR) { |
|
340 |
return IOS_INTERRUPTED; |
|
341 |
} |
|
342 |
return handleSocketError(env, errno); |
|
343 |
} |
|
344 |
return 1; |
|
345 |
} |
|
346 |
||
347 |
JNIEXPORT jint JNICALL |
|
348 |
Java_sun_nio_ch_Net_localPort(JNIEnv *env, jclass clazz, jobject fdo) |
|
349 |
{ |
|
350 |
SOCKADDR sa; |
|
895 | 351 |
socklen_t sa_len = SOCKADDR_LEN; |
2 | 352 |
if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) { |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
353 |
#ifdef _ALLBSD_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
354 |
/* |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
355 |
* XXXBSD: |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
356 |
* ECONNRESET is specific to the BSDs. We can not return an error, |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
357 |
* as the calling Java code with raise a java.lang.Error given the expectation |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
358 |
* that getsockname() will never fail. According to the Single UNIX Specification, |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
359 |
* it shouldn't fail. As such, we just fill in generic Linux-compatible values. |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
360 |
*/ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
361 |
if (errno == ECONNRESET) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
362 |
struct sockaddr_in *sin; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
363 |
sin = (struct sockaddr_in *) &sa; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
364 |
bzero(sin, sizeof(*sin)); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
365 |
sin->sin_len = sizeof(struct sockaddr_in); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
366 |
sin->sin_family = AF_INET; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
367 |
sin->sin_port = htonl(0); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
368 |
sin->sin_addr.s_addr = INADDR_ANY; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
369 |
} else { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
370 |
handleSocketError(env, errno); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
371 |
return -1; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
372 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
373 |
#else /* _ALLBSD_SOURCE */ |
2 | 374 |
handleSocketError(env, errno); |
375 |
return -1; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
376 |
#endif /* _ALLBSD_SOURCE */ |
2 | 377 |
} |
378 |
return NET_GetPortFromSockaddr((struct sockaddr *)&sa); |
|
379 |
} |
|
380 |
||
381 |
JNIEXPORT jobject JNICALL |
|
382 |
Java_sun_nio_ch_Net_localInetAddress(JNIEnv *env, jclass clazz, jobject fdo) |
|
383 |
{ |
|
384 |
SOCKADDR sa; |
|
895 | 385 |
socklen_t sa_len = SOCKADDR_LEN; |
2 | 386 |
int port; |
387 |
if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) { |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
388 |
#ifdef _ALLBSD_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
389 |
/* |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
390 |
* XXXBSD: |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
391 |
* ECONNRESET is specific to the BSDs. We can not return an error, |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
392 |
* as the calling Java code with raise a java.lang.Error with the expectation |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
393 |
* that getsockname() will never fail. According to the Single UNIX Specification, |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
394 |
* it shouldn't fail. As such, we just fill in generic Linux-compatible values. |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
395 |
*/ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
396 |
if (errno == ECONNRESET) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
397 |
struct sockaddr_in *sin; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
398 |
sin = (struct sockaddr_in *) &sa; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
399 |
bzero(sin, sizeof(*sin)); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
400 |
sin->sin_len = sizeof(struct sockaddr_in); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
401 |
sin->sin_family = AF_INET; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
402 |
sin->sin_port = htonl(0); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
403 |
sin->sin_addr.s_addr = INADDR_ANY; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
404 |
} else { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
405 |
handleSocketError(env, errno); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
406 |
return NULL; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
407 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
408 |
#else /* _ALLBSD_SOURCE */ |
2 | 409 |
handleSocketError(env, errno); |
410 |
return NULL; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
411 |
#endif /* _ALLBSD_SOURCE */ |
2 | 412 |
} |
413 |
return NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); |
|
414 |
} |
|
415 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
416 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
417 |
Java_sun_nio_ch_Net_getIntOption0(JNIEnv *env, jclass clazz, jobject fdo, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
418 |
jboolean mayNeedConversion, jint level, jint opt) |
2 | 419 |
{ |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
420 |
int result; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
421 |
struct linger linger; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
422 |
u_char carg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
423 |
void *arg; |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
424 |
socklen_t arglen; |
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
425 |
int n; |
2 | 426 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
427 |
/* Option value is an int except for a few specific cases */ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
428 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
429 |
arg = (void *)&result; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
430 |
arglen = sizeof(result); |
2 | 431 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
432 |
if (level == IPPROTO_IP && |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
433 |
(opt == IP_MULTICAST_TTL || opt == IP_MULTICAST_LOOP)) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
434 |
arg = (void*)&carg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
435 |
arglen = sizeof(carg); |
2 | 436 |
} |
437 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
438 |
if (level == SOL_SOCKET && opt == SO_LINGER) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
439 |
arg = (void *)&linger; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
440 |
arglen = sizeof(linger); |
2 | 441 |
} |
442 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
443 |
if (mayNeedConversion) { |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
444 |
n = NET_GetSockOpt(fdval(env, fdo), level, opt, arg, (int*)&arglen); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
445 |
} else { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
446 |
n = getsockopt(fdval(env, fdo), level, opt, arg, &arglen); |
2 | 447 |
} |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
448 |
if (n < 0) { |
2 | 449 |
JNU_ThrowByNameWithLastError(env, |
450 |
JNU_JAVANETPKG "SocketException", |
|
451 |
"sun.nio.ch.Net.getIntOption"); |
|
452 |
return -1; |
|
453 |
} |
|
454 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
455 |
if (level == IPPROTO_IP && |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
456 |
(opt == IP_MULTICAST_TTL || opt == IP_MULTICAST_LOOP)) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
457 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
458 |
return (jint)carg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
459 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
460 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
461 |
if (level == SOL_SOCKET && opt == SO_LINGER) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
462 |
return linger.l_onoff ? (jint)linger.l_linger : (jint)-1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
463 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
464 |
return (jint)result; |
2 | 465 |
} |
466 |
||
467 |
JNIEXPORT void JNICALL |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
468 |
Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
469 |
jboolean mayNeedConversion, jint level, jint opt, jint arg) |
2 | 470 |
{ |
471 |
int result; |
|
472 |
struct linger linger; |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
473 |
u_char carg; |
2 | 474 |
void *parg; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
475 |
socklen_t arglen; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
476 |
int n; |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
477 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
478 |
/* Option value is an int except for a few specific cases */ |
2 | 479 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
480 |
parg = (void*)&arg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
481 |
arglen = sizeof(arg); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
482 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
483 |
if (level == IPPROTO_IP && |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
484 |
(opt == IP_MULTICAST_TTL || opt == IP_MULTICAST_LOOP)) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
485 |
parg = (void*)&carg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
486 |
arglen = sizeof(carg); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
487 |
carg = (u_char)arg; |
2 | 488 |
} |
489 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
490 |
if (level == SOL_SOCKET && opt == SO_LINGER) { |
2 | 491 |
parg = (void *)&linger; |
492 |
arglen = sizeof(linger); |
|
493 |
if (arg >= 0) { |
|
494 |
linger.l_onoff = 1; |
|
495 |
linger.l_linger = arg; |
|
496 |
} else { |
|
497 |
linger.l_onoff = 0; |
|
498 |
linger.l_linger = 0; |
|
499 |
} |
|
500 |
} |
|
501 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
502 |
if (mayNeedConversion) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
503 |
n = NET_SetSockOpt(fdval(env, fdo), level, opt, parg, arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
504 |
} else { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
505 |
n = setsockopt(fdval(env, fdo), level, opt, parg, arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
506 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
507 |
if (n < 0) { |
2 | 508 |
JNU_ThrowByNameWithLastError(env, |
509 |
JNU_JAVANETPKG "SocketException", |
|
510 |
"sun.nio.ch.Net.setIntOption"); |
|
511 |
} |
|
512 |
} |
|
513 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
514 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
515 |
Java_sun_nio_ch_Net_joinOrDrop4(JNIEnv *env, jobject this, jboolean join, jobject fdo, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
516 |
jint group, jint interf, jint source) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
517 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
518 |
struct ip_mreq mreq; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
519 |
struct my_ip_mreq_source mreq_source; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
520 |
int opt, n, optlen; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
521 |
void* optval; |
2 | 522 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
523 |
if (source == 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
524 |
mreq.imr_multiaddr.s_addr = htonl(group); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
525 |
mreq.imr_interface.s_addr = htonl(interf); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
526 |
opt = (join) ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
527 |
optval = (void*)&mreq; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
528 |
optlen = sizeof(mreq); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
529 |
} else { |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
530 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
531 |
/* no IPv4 include-mode filtering for now */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
532 |
return IOS_UNAVAILABLE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
533 |
#else |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
534 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
535 |
#ifdef _AIX |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
536 |
/* check AIX for support of source filtering */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
537 |
if (isSourceFilterSupported() != JNI_TRUE){ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
538 |
return IOS_UNAVAILABLE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
539 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
540 |
#endif |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
541 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
542 |
mreq_source.imr_multiaddr.s_addr = htonl(group); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
543 |
mreq_source.imr_sourceaddr.s_addr = htonl(source); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
544 |
mreq_source.imr_interface.s_addr = htonl(interf); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
545 |
opt = (join) ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
546 |
optval = (void*)&mreq_source; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
547 |
optlen = sizeof(mreq_source); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
548 |
#endif |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
549 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
550 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
551 |
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
552 |
if (n < 0) { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
553 |
if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
554 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
555 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
556 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
557 |
return 0; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
558 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
559 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
560 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
561 |
Java_sun_nio_ch_Net_blockOrUnblock4(JNIEnv *env, jobject this, jboolean block, jobject fdo, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
562 |
jint group, jint interf, jint source) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
563 |
{ |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
564 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
565 |
/* no IPv4 exclude-mode filtering for now */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
566 |
return IOS_UNAVAILABLE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
567 |
#else |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
568 |
struct my_ip_mreq_source mreq_source; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
569 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
570 |
int opt = (block) ? IP_BLOCK_SOURCE : IP_UNBLOCK_SOURCE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
571 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
572 |
#ifdef _AIX |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
573 |
/* check AIX for support of source filtering */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
574 |
if (isSourceFilterSupported() != JNI_TRUE){ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
575 |
return IOS_UNAVAILABLE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
576 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
577 |
#endif |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
578 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
579 |
mreq_source.imr_multiaddr.s_addr = htonl(group); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
580 |
mreq_source.imr_sourceaddr.s_addr = htonl(source); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
581 |
mreq_source.imr_interface.s_addr = htonl(interf); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
582 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
583 |
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
584 |
(void*)&mreq_source, sizeof(mreq_source)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
585 |
if (n < 0) { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
586 |
if (block && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
587 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
588 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
589 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
590 |
return 0; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
591 |
#endif |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
592 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
593 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
594 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
595 |
Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobject fdo, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
596 |
jbyteArray group, jint index, jbyteArray source) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
597 |
{ |
4814 | 598 |
#ifdef AF_INET6 |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
599 |
struct ipv6_mreq mreq6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
600 |
struct my_group_source_req req; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
601 |
int opt, n, optlen; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
602 |
void* optval; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
603 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
604 |
if (source == NULL) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
605 |
COPY_INET6_ADDRESS(env, group, (jbyte*)&(mreq6.ipv6mr_multiaddr)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
606 |
mreq6.ipv6mr_interface = (int)index; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
607 |
opt = (join) ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
608 |
optval = (void*)&mreq6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
609 |
optlen = sizeof(mreq6); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
610 |
} else { |
13363
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
611 |
#ifdef MACOSX |
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
612 |
/* no IPv6 include-mode filtering for now */ |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
613 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
614 |
#else |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
615 |
initGroupSourceReq(env, group, index, source, &req); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
616 |
opt = (join) ? MCAST_JOIN_SOURCE_GROUP : MCAST_LEAVE_SOURCE_GROUP; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
617 |
optval = (void*)&req; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
618 |
optlen = sizeof(req); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
619 |
#endif |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
620 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
621 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
622 |
n = setsockopt(fdval(env,fdo), IPPROTO_IPV6, opt, optval, optlen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
623 |
if (n < 0) { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
624 |
if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
625 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
626 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
627 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
628 |
return 0; |
4814 | 629 |
#else |
630 |
JNU_ThrowInternalError(env, "Should not get here"); |
|
631 |
return IOS_THROWN; |
|
632 |
#endif /* AF_INET6 */ |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
633 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
634 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
635 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
636 |
Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, jobject fdo, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
637 |
jbyteArray group, jint index, jbyteArray source) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
638 |
{ |
4814 | 639 |
#ifdef AF_INET6 |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
640 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
641 |
/* no IPv6 exclude-mode filtering for now */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
642 |
return IOS_UNAVAILABLE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
643 |
#else |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
644 |
struct my_group_source_req req; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
645 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
646 |
int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
647 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
648 |
initGroupSourceReq(env, group, index, source, &req); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
649 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
650 |
n = setsockopt(fdval(env,fdo), IPPROTO_IPV6, opt, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
651 |
(void*)&req, sizeof(req)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
652 |
if (n < 0) { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
653 |
if (block && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
654 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
655 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
656 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
657 |
return 0; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
658 |
#endif |
4814 | 659 |
#else |
660 |
JNU_ThrowInternalError(env, "Should not get here"); |
|
661 |
return IOS_THROWN; |
|
662 |
#endif |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
663 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
664 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
665 |
JNIEXPORT void JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
666 |
Java_sun_nio_ch_Net_setInterface4(JNIEnv* env, jobject this, jobject fdo, jint interf) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
667 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
668 |
struct in_addr in; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
669 |
socklen_t arglen = sizeof(struct in_addr); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
670 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
671 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
672 |
in.s_addr = htonl(interf); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
673 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
674 |
n = setsockopt(fdval(env, fdo), IPPROTO_IP, IP_MULTICAST_IF, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
675 |
(void*)&(in.s_addr), arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
676 |
if (n < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
677 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
678 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
679 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
680 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
681 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
682 |
Java_sun_nio_ch_Net_getInterface4(JNIEnv* env, jobject this, jobject fdo) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
683 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
684 |
struct in_addr in; |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
685 |
socklen_t arglen = sizeof(struct in_addr); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
686 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
687 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
688 |
n = getsockopt(fdval(env, fdo), IPPROTO_IP, IP_MULTICAST_IF, (void*)&in, &arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
689 |
if (n < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
690 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
691 |
return -1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
692 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
693 |
return ntohl(in.s_addr); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
694 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
695 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
696 |
JNIEXPORT void JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
697 |
Java_sun_nio_ch_Net_setInterface6(JNIEnv* env, jobject this, jobject fdo, jint index) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
698 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
699 |
int value = (jint)index; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
700 |
socklen_t arglen = sizeof(value); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
701 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
702 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
703 |
n = setsockopt(fdval(env, fdo), IPPROTO_IPV6, IPV6_MULTICAST_IF, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
704 |
(void*)&(index), arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
705 |
if (n < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
706 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
707 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
708 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
709 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
710 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
711 |
Java_sun_nio_ch_Net_getInterface6(JNIEnv* env, jobject this, jobject fdo) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
712 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
713 |
int index; |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
714 |
socklen_t arglen = sizeof(index); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
715 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
716 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
717 |
n = getsockopt(fdval(env, fdo), IPPROTO_IPV6, IPV6_MULTICAST_IF, (void*)&index, &arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
718 |
if (n < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
719 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
720 |
return -1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
721 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
722 |
return (jint)index; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
723 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
724 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
725 |
JNIEXPORT void JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
726 |
Java_sun_nio_ch_Net_shutdown(JNIEnv *env, jclass cl, jobject fdo, jint jhow) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
727 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
728 |
int how = (jhow == sun_nio_ch_Net_SHUT_RD) ? SHUT_RD : |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
729 |
(jhow == sun_nio_ch_Net_SHUT_WR) ? SHUT_WR : SHUT_RDWR; |
3486
0e14ae32369e
4516760: (so) Intermittent SocketException: Transport endpoint is not connected (lnx)
alanb
parents:
1247
diff
changeset
|
730 |
if ((shutdown(fdval(env, fdo), how) < 0) && (errno != ENOTCONN)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
731 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
732 |
} |
2 | 733 |
|
14025
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
734 |
JNIEXPORT jint JNICALL |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
735 |
Java_sun_nio_ch_Net_poll(JNIEnv* env, jclass this, jobject fdo, jint events, jlong timeout) |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
736 |
{ |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
737 |
struct pollfd pfd; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
738 |
int rv; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
739 |
pfd.fd = fdval(env, fdo); |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
740 |
pfd.events = events; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
741 |
rv = poll(&pfd, 1, timeout); |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
742 |
|
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
743 |
if (rv >= 0) { |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
744 |
return pfd.revents; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
745 |
} else if (errno == EINTR) { |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
746 |
return IOS_INTERRUPTED; |
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
747 |
} else { |
14025
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
748 |
handleSocketError(env, errno); |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
749 |
return IOS_THROWN; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
750 |
} |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
751 |
} |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
752 |
|
22604
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
753 |
JNIEXPORT jshort JNICALL |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
754 |
Java_sun_nio_ch_Net_pollinValue(JNIEnv *env, jclass this) |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
755 |
{ |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
756 |
return (jshort)POLLIN; |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
757 |
} |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
758 |
|
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
759 |
JNIEXPORT jshort JNICALL |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
760 |
Java_sun_nio_ch_Net_polloutValue(JNIEnv *env, jclass this) |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
761 |
{ |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
762 |
return (jshort)POLLOUT; |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
763 |
} |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
764 |
|
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
765 |
JNIEXPORT jshort JNICALL |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
766 |
Java_sun_nio_ch_Net_pollerrValue(JNIEnv *env, jclass this) |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
767 |
{ |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
768 |
return (jshort)POLLERR; |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
769 |
} |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
770 |
|
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
771 |
JNIEXPORT jshort JNICALL |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
772 |
Java_sun_nio_ch_Net_pollhupValue(JNIEnv *env, jclass this) |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
773 |
{ |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
774 |
return (jshort)POLLHUP; |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
775 |
} |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
776 |
|
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
777 |
JNIEXPORT jshort JNICALL |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
778 |
Java_sun_nio_ch_Net_pollnvalValue(JNIEnv *env, jclass this) |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
779 |
{ |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
780 |
return (jshort)POLLNVAL; |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
781 |
} |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
782 |
|
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
783 |
JNIEXPORT jshort JNICALL |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
784 |
Java_sun_nio_ch_Net_pollconnValue(JNIEnv *env, jclass this) |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
785 |
{ |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
786 |
return (jshort)POLLOUT; |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
787 |
} |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
788 |
|
14025
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
789 |
|
2 | 790 |
/* Declared in nio_util.h */ |
791 |
||
792 |
jint |
|
793 |
handleSocketError(JNIEnv *env, jint errorValue) |
|
794 |
{ |
|
795 |
char *xn; |
|
796 |
switch (errorValue) { |
|
797 |
case EINPROGRESS: /* Non-blocking connect */ |
|
798 |
return 0; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
799 |
#ifdef EPROTO |
2 | 800 |
case EPROTO: |
801 |
xn = JNU_JAVANETPKG "ProtocolException"; |
|
802 |
break; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
803 |
#endif |
2 | 804 |
case ECONNREFUSED: |
805 |
xn = JNU_JAVANETPKG "ConnectException"; |
|
806 |
break; |
|
807 |
case ETIMEDOUT: |
|
808 |
xn = JNU_JAVANETPKG "ConnectException"; |
|
809 |
break; |
|
810 |
case EHOSTUNREACH: |
|
811 |
xn = JNU_JAVANETPKG "NoRouteToHostException"; |
|
812 |
break; |
|
813 |
case EADDRINUSE: /* Fall through */ |
|
814 |
case EADDRNOTAVAIL: |
|
815 |
xn = JNU_JAVANETPKG "BindException"; |
|
816 |
break; |
|
817 |
default: |
|
818 |
xn = JNU_JAVANETPKG "SocketException"; |
|
819 |
break; |
|
820 |
} |
|
821 |
errno = errorValue; |
|
822 |
JNU_ThrowByNameWithLastError(env, xn, "NioSocketError"); |
|
823 |
return IOS_THROWN; |
|
824 |
} |