author | simonis |
Mon, 20 Jan 2014 17:16:05 +0100 | |
changeset 22605 | dba3d6b22818 |
parent 22604 | 9b394795e216 |
child 22607 | ba232b417248 |
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 |
|
22605
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
107 |
#if defined(_AIX) |
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
108 |
|
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
109 |
struct my_ip_mreq_source { |
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
110 |
struct in_addr imr_multiaddr; |
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
111 |
struct in_addr imr_sourceaddr; |
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
112 |
struct in_addr imr_interface; |
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
113 |
}; |
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
114 |
|
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
115 |
#else |
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
116 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
117 |
struct my_ip_mreq_source { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
118 |
struct in_addr imr_multiaddr; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
119 |
struct in_addr imr_interface; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
120 |
struct in_addr imr_sourceaddr; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
121 |
}; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
122 |
|
22605
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
123 |
#endif /* _AIX */ |
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
124 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
125 |
struct my_group_source_req { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
126 |
uint32_t gsr_interface; /* interface index */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
127 |
struct sockaddr_storage gsr_group; /* group address */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
128 |
struct sockaddr_storage gsr_source; /* source address */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
129 |
}; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
130 |
|
13363
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
131 |
#else /* _ALLBSD_SOURCE */ |
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
132 |
|
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
133 |
#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
|
134 |
#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
|
135 |
|
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
136 |
#endif |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
137 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
138 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
139 |
#define COPY_INET6_ADDRESS(env, source, target) \ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
140 |
(*env)->GetByteArrayRegion(env, source, 0, 16, target) |
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 |
/* |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
143 |
* Copy IPv6 group, interface index, and IPv6 source address |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
144 |
* into group_source_req structure. |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
145 |
*/ |
4814 | 146 |
#ifdef AF_INET6 |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
147 |
static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
148 |
jbyteArray source, struct my_group_source_req* req) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
149 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
150 |
struct sockaddr_in6* sin6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
151 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
152 |
req->gsr_interface = (uint32_t)index; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
153 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
154 |
sin6 = (struct sockaddr_in6*)&(req->gsr_group); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
155 |
sin6->sin6_family = AF_INET6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
156 |
COPY_INET6_ADDRESS(env, group, (jbyte*)&(sin6->sin6_addr)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
157 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
158 |
sin6 = (struct sockaddr_in6*)&(req->gsr_source); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
159 |
sin6->sin6_family = AF_INET6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
160 |
COPY_INET6_ADDRESS(env, source, (jbyte*)&(sin6->sin6_addr)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
161 |
} |
4814 | 162 |
#endif |
2 | 163 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
164 |
#ifdef _AIX |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
165 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
166 |
/* |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
167 |
* 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
|
168 |
* 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
|
169 |
*/ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
170 |
static jboolean isSourceFilterSupported(){ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
171 |
static jboolean alreadyChecked = JNI_FALSE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
172 |
static jboolean result = JNI_TRUE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
173 |
if (alreadyChecked != JNI_TRUE){ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
174 |
struct utsname uts; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
175 |
memset(&uts, 0, sizeof(uts)); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
176 |
strcpy(uts.sysname, "?"); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
177 |
const int utsRes = uname(&uts); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
178 |
int major = -1; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
179 |
int minor = -1; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
180 |
major = atoi(uts.version); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
181 |
minor = atoi(uts.release); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
182 |
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
|
183 |
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
|
184 |
result = JNI_FALSE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
185 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
186 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
187 |
alreadyChecked = JNI_TRUE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
188 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
189 |
return result; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
190 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
191 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
192 |
#endif /* _AIX */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
193 |
|
2 | 194 |
JNIEXPORT void JNICALL |
195 |
Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz) |
|
196 |
{ |
|
197 |
/* Here because Windows native code does need to init IDs */ |
|
198 |
} |
|
199 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
200 |
JNIEXPORT jboolean JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
201 |
Java_sun_nio_ch_Net_isIPv6Available0(JNIEnv* env, jclass cl) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
202 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
203 |
return (ipv6_available()) ? JNI_TRUE : JNI_FALSE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
204 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
205 |
|
18192 | 206 |
JNIEXPORT jint JNICALL |
207 |
Java_sun_nio_ch_Net_isExclusiveBindAvailable(JNIEnv *env, jclass clazz) { |
|
208 |
return -1; |
|
209 |
} |
|
210 |
||
8788
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
211 |
JNIEXPORT jboolean JNICALL |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
212 |
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
|
213 |
{ |
22605
dba3d6b22818
8031581: PPC64: Addons and fixes for AIX to pass the jdk regression tests
simonis
parents:
22604
diff
changeset
|
214 |
#if defined(MACOSX) || defined(_AIX) |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
215 |
/* for now IPv6 sockets cannot join IPv4 multicast groups */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
216 |
return JNI_FALSE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
217 |
#else |
8788
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
218 |
return JNI_TRUE; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
219 |
#endif |
8788
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
220 |
} |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
221 |
|
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
222 |
JNIEXPORT jboolean JNICALL |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
223 |
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
|
224 |
{ |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
225 |
#ifdef __solaris__ |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
226 |
return JNI_TRUE; |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
227 |
#else |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
228 |
return JNI_FALSE; |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
229 |
#endif |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
230 |
} |
b98f18278dc4
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
alanb
parents:
7668
diff
changeset
|
231 |
|
2 | 232 |
JNIEXPORT int JNICALL |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
233 |
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
|
234 |
jboolean stream, jboolean reuse) |
2 | 235 |
{ |
236 |
int fd; |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
237 |
int type = (stream ? SOCK_STREAM : SOCK_DGRAM); |
4814 | 238 |
#ifdef AF_INET6 |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
239 |
int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET; |
4814 | 240 |
#else |
241 |
int domain = AF_INET; |
|
242 |
#endif |
|
2 | 243 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
244 |
fd = socket(domain, type, 0); |
2 | 245 |
if (fd < 0) { |
246 |
return handleSocketError(env, errno); |
|
247 |
} |
|
6299
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 |
#ifdef AF_INET6 |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
250 |
/* 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
|
251 |
if (domain == AF_INET6) { |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
252 |
int arg = 0; |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
253 |
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
|
254 |
sizeof(int)) < 0) { |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
255 |
JNU_ThrowByNameWithLastError(env, |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
256 |
JNU_JAVANETPKG "SocketException", |
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
257 |
"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
|
258 |
close(fd); |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
259 |
return -1; |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
260 |
} |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
261 |
} |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
262 |
#endif |
a44d48dbcd50
6882910: Unexplained lack of IP4 network ability when transparent IP6 to IP4 is disabled.
chegar
parents:
5506
diff
changeset
|
263 |
|
2 | 264 |
if (reuse) { |
265 |
int arg = 1; |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
266 |
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
267 |
sizeof(arg)) < 0) { |
2 | 268 |
JNU_ThrowByNameWithLastError(env, |
269 |
JNU_JAVANETPKG "SocketException", |
|
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
270 |
"Unable to set SO_REUSEADDR"); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
271 |
close(fd); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
272 |
return -1; |
2 | 273 |
} |
274 |
} |
|
18535
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 |
#if defined(__linux__) |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
277 |
if (type == SOCK_DGRAM) { |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
278 |
int arg = 0; |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
279 |
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
|
280 |
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
|
281 |
(errno != ENOPROTOOPT)) { |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
282 |
JNU_ThrowByNameWithLastError(env, |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
283 |
JNU_JAVANETPKG "SocketException", |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
284 |
"Unable to set IP_MULTICAST_ALL"); |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
285 |
close(fd); |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
286 |
return -1; |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
287 |
} |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
288 |
} |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
289 |
#endif |
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
290 |
|
4814 | 291 |
#if defined(__linux__) && defined(AF_INET6) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
292 |
/* By default, Linux uses the route default */ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
293 |
if (domain == AF_INET6 && type == SOCK_DGRAM) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
294 |
int arg = 1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
295 |
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &arg, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
296 |
sizeof(arg)) < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
297 |
JNU_ThrowByNameWithLastError(env, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
298 |
JNU_JAVANETPKG "SocketException", |
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
299 |
"Unable to set IPV6_MULTICAST_HOPS"); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
300 |
close(fd); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
301 |
return -1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
302 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
303 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
304 |
#endif |
2 | 305 |
return fd; |
306 |
} |
|
307 |
||
308 |
JNIEXPORT void JNICALL |
|
18192 | 309 |
Java_sun_nio_ch_Net_bind0(JNIEnv *env, jclass clazz, jobject fdo, jboolean preferIPv6, |
310 |
jboolean useExclBind, jobject iao, int port) |
|
2 | 311 |
{ |
312 |
SOCKADDR sa; |
|
313 |
int sa_len = SOCKADDR_LEN; |
|
314 |
int rv = 0; |
|
315 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
316 |
if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) { |
2 | 317 |
return; |
318 |
} |
|
319 |
||
320 |
rv = NET_Bind(fdval(env, fdo), (struct sockaddr *)&sa, sa_len); |
|
321 |
if (rv != 0) { |
|
322 |
handleSocketError(env, errno); |
|
323 |
} |
|
324 |
} |
|
325 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
326 |
JNIEXPORT void JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
327 |
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
|
328 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
329 |
if (listen(fdval(env, fdo), backlog) < 0) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
330 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
331 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
332 |
|
2 | 333 |
JNIEXPORT jint JNICALL |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
334 |
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
|
335 |
jobject fdo, jobject iao, jint port) |
2 | 336 |
{ |
337 |
SOCKADDR sa; |
|
338 |
int sa_len = SOCKADDR_LEN; |
|
339 |
int rv; |
|
340 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
341 |
if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
342 |
&sa_len, preferIPv6) != 0) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
343 |
{ |
2 | 344 |
return IOS_THROWN; |
345 |
} |
|
346 |
||
347 |
rv = connect(fdval(env, fdo), (struct sockaddr *)&sa, sa_len); |
|
348 |
if (rv != 0) { |
|
349 |
if (errno == EINPROGRESS) { |
|
350 |
return IOS_UNAVAILABLE; |
|
351 |
} else if (errno == EINTR) { |
|
352 |
return IOS_INTERRUPTED; |
|
353 |
} |
|
354 |
return handleSocketError(env, errno); |
|
355 |
} |
|
356 |
return 1; |
|
357 |
} |
|
358 |
||
359 |
JNIEXPORT jint JNICALL |
|
360 |
Java_sun_nio_ch_Net_localPort(JNIEnv *env, jclass clazz, jobject fdo) |
|
361 |
{ |
|
362 |
SOCKADDR sa; |
|
895 | 363 |
socklen_t sa_len = SOCKADDR_LEN; |
2 | 364 |
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
|
365 |
#ifdef _ALLBSD_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
366 |
/* |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
367 |
* XXXBSD: |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
368 |
* 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
|
369 |
* 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
|
370 |
* 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
|
371 |
* 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
|
372 |
*/ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
373 |
if (errno == ECONNRESET) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
374 |
struct sockaddr_in *sin; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
375 |
sin = (struct sockaddr_in *) &sa; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
376 |
bzero(sin, sizeof(*sin)); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
377 |
sin->sin_len = sizeof(struct sockaddr_in); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
378 |
sin->sin_family = AF_INET; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
379 |
sin->sin_port = htonl(0); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
380 |
sin->sin_addr.s_addr = INADDR_ANY; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
381 |
} else { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
382 |
handleSocketError(env, errno); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
383 |
return -1; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
384 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
385 |
#else /* _ALLBSD_SOURCE */ |
2 | 386 |
handleSocketError(env, errno); |
387 |
return -1; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
388 |
#endif /* _ALLBSD_SOURCE */ |
2 | 389 |
} |
390 |
return NET_GetPortFromSockaddr((struct sockaddr *)&sa); |
|
391 |
} |
|
392 |
||
393 |
JNIEXPORT jobject JNICALL |
|
394 |
Java_sun_nio_ch_Net_localInetAddress(JNIEnv *env, jclass clazz, jobject fdo) |
|
395 |
{ |
|
396 |
SOCKADDR sa; |
|
895 | 397 |
socklen_t sa_len = SOCKADDR_LEN; |
2 | 398 |
int port; |
399 |
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
|
400 |
#ifdef _ALLBSD_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
401 |
/* |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
402 |
* XXXBSD: |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
403 |
* 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
|
404 |
* 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
|
405 |
* 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
|
406 |
* 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
|
407 |
*/ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
408 |
if (errno == ECONNRESET) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
409 |
struct sockaddr_in *sin; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
410 |
sin = (struct sockaddr_in *) &sa; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
411 |
bzero(sin, sizeof(*sin)); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
412 |
sin->sin_len = sizeof(struct sockaddr_in); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
413 |
sin->sin_family = AF_INET; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
414 |
sin->sin_port = htonl(0); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
415 |
sin->sin_addr.s_addr = INADDR_ANY; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
416 |
} else { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
417 |
handleSocketError(env, errno); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
418 |
return NULL; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
419 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
420 |
#else /* _ALLBSD_SOURCE */ |
2 | 421 |
handleSocketError(env, errno); |
422 |
return NULL; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
423 |
#endif /* _ALLBSD_SOURCE */ |
2 | 424 |
} |
425 |
return NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); |
|
426 |
} |
|
427 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
428 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
429 |
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
|
430 |
jboolean mayNeedConversion, jint level, jint opt) |
2 | 431 |
{ |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
432 |
int result; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
433 |
struct linger linger; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
434 |
u_char carg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
435 |
void *arg; |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
436 |
socklen_t arglen; |
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
437 |
int n; |
2 | 438 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
439 |
/* 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
|
440 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
441 |
arg = (void *)&result; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
442 |
arglen = sizeof(result); |
2 | 443 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
444 |
if (level == IPPROTO_IP && |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
445 |
(opt == IP_MULTICAST_TTL || opt == IP_MULTICAST_LOOP)) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
446 |
arg = (void*)&carg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
447 |
arglen = sizeof(carg); |
2 | 448 |
} |
449 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
450 |
if (level == SOL_SOCKET && opt == SO_LINGER) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
451 |
arg = (void *)&linger; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
452 |
arglen = sizeof(linger); |
2 | 453 |
} |
454 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
455 |
if (mayNeedConversion) { |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
456 |
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
|
457 |
} else { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
458 |
n = getsockopt(fdval(env, fdo), level, opt, arg, &arglen); |
2 | 459 |
} |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
460 |
if (n < 0) { |
2 | 461 |
JNU_ThrowByNameWithLastError(env, |
462 |
JNU_JAVANETPKG "SocketException", |
|
463 |
"sun.nio.ch.Net.getIntOption"); |
|
464 |
return -1; |
|
465 |
} |
|
466 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
467 |
if (level == IPPROTO_IP && |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
468 |
(opt == IP_MULTICAST_TTL || opt == IP_MULTICAST_LOOP)) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
469 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
470 |
return (jint)carg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
471 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
472 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
473 |
if (level == SOL_SOCKET && opt == SO_LINGER) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
474 |
return linger.l_onoff ? (jint)linger.l_linger : (jint)-1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
475 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
476 |
return (jint)result; |
2 | 477 |
} |
478 |
||
479 |
JNIEXPORT void JNICALL |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
480 |
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
|
481 |
jboolean mayNeedConversion, jint level, jint opt, jint arg) |
2 | 482 |
{ |
483 |
int result; |
|
484 |
struct linger linger; |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
485 |
u_char carg; |
2 | 486 |
void *parg; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
487 |
socklen_t arglen; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
488 |
int n; |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
489 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
490 |
/* Option value is an int except for a few specific cases */ |
2 | 491 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
492 |
parg = (void*)&arg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
493 |
arglen = sizeof(arg); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
494 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
495 |
if (level == IPPROTO_IP && |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
496 |
(opt == IP_MULTICAST_TTL || opt == IP_MULTICAST_LOOP)) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
497 |
parg = (void*)&carg; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
498 |
arglen = sizeof(carg); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
499 |
carg = (u_char)arg; |
2 | 500 |
} |
501 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
502 |
if (level == SOL_SOCKET && opt == SO_LINGER) { |
2 | 503 |
parg = (void *)&linger; |
504 |
arglen = sizeof(linger); |
|
505 |
if (arg >= 0) { |
|
506 |
linger.l_onoff = 1; |
|
507 |
linger.l_linger = arg; |
|
508 |
} else { |
|
509 |
linger.l_onoff = 0; |
|
510 |
linger.l_linger = 0; |
|
511 |
} |
|
512 |
} |
|
513 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
514 |
if (mayNeedConversion) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
515 |
n = NET_SetSockOpt(fdval(env, fdo), level, opt, parg, arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
516 |
} else { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
517 |
n = setsockopt(fdval(env, fdo), level, opt, parg, arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
518 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
519 |
if (n < 0) { |
2 | 520 |
JNU_ThrowByNameWithLastError(env, |
521 |
JNU_JAVANETPKG "SocketException", |
|
522 |
"sun.nio.ch.Net.setIntOption"); |
|
523 |
} |
|
524 |
} |
|
525 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
526 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
527 |
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
|
528 |
jint group, jint interf, jint source) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
529 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
530 |
struct ip_mreq mreq; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
531 |
struct my_ip_mreq_source mreq_source; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
532 |
int opt, n, optlen; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
533 |
void* optval; |
2 | 534 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
535 |
if (source == 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
536 |
mreq.imr_multiaddr.s_addr = htonl(group); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
537 |
mreq.imr_interface.s_addr = htonl(interf); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
538 |
opt = (join) ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
539 |
optval = (void*)&mreq; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
540 |
optlen = sizeof(mreq); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
541 |
} else { |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
542 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
543 |
/* no IPv4 include-mode filtering for now */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
544 |
return IOS_UNAVAILABLE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
545 |
#else |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
546 |
|
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
547 |
#ifdef _AIX |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
548 |
/* 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
|
549 |
if (isSourceFilterSupported() != JNI_TRUE){ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
550 |
return IOS_UNAVAILABLE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
551 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
552 |
#endif |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
553 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
554 |
mreq_source.imr_multiaddr.s_addr = htonl(group); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
555 |
mreq_source.imr_sourceaddr.s_addr = htonl(source); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
556 |
mreq_source.imr_interface.s_addr = htonl(interf); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
557 |
opt = (join) ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
558 |
optval = (void*)&mreq_source; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
559 |
optlen = sizeof(mreq_source); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
560 |
#endif |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
561 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
562 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
563 |
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
564 |
if (n < 0) { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
565 |
if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
566 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
567 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
568 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
569 |
return 0; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
570 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
571 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
572 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
573 |
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
|
574 |
jint group, jint interf, jint source) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
575 |
{ |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
576 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
577 |
/* no IPv4 exclude-mode filtering for now */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
578 |
return IOS_UNAVAILABLE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
579 |
#else |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
580 |
struct my_ip_mreq_source mreq_source; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
581 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
582 |
int opt = (block) ? IP_BLOCK_SOURCE : IP_UNBLOCK_SOURCE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
583 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
584 |
#ifdef _AIX |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
585 |
/* 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
|
586 |
if (isSourceFilterSupported() != JNI_TRUE){ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
587 |
return IOS_UNAVAILABLE; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
588 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
589 |
#endif |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
590 |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
591 |
mreq_source.imr_multiaddr.s_addr = htonl(group); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
592 |
mreq_source.imr_sourceaddr.s_addr = htonl(source); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
593 |
mreq_source.imr_interface.s_addr = htonl(interf); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
594 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
595 |
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
596 |
(void*)&mreq_source, sizeof(mreq_source)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
597 |
if (n < 0) { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
598 |
if (block && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
599 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
600 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
601 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
602 |
return 0; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
603 |
#endif |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
604 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
605 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
606 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
607 |
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
|
608 |
jbyteArray group, jint index, jbyteArray source) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
609 |
{ |
4814 | 610 |
#ifdef AF_INET6 |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
611 |
struct ipv6_mreq mreq6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
612 |
struct my_group_source_req req; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
613 |
int opt, n, optlen; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
614 |
void* optval; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
615 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
616 |
if (source == NULL) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
617 |
COPY_INET6_ADDRESS(env, group, (jbyte*)&(mreq6.ipv6mr_multiaddr)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
618 |
mreq6.ipv6mr_interface = (int)index; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
619 |
opt = (join) ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
620 |
optval = (void*)&mreq6; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
621 |
optlen = sizeof(mreq6); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
622 |
} else { |
13363
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
623 |
#ifdef MACOSX |
065e0e3545a3
6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
alanb
parents:
12047
diff
changeset
|
624 |
/* no IPv6 include-mode filtering for now */ |
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 |
#else |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
627 |
initGroupSourceReq(env, group, index, source, &req); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
628 |
opt = (join) ? MCAST_JOIN_SOURCE_GROUP : MCAST_LEAVE_SOURCE_GROUP; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
629 |
optval = (void*)&req; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
630 |
optlen = sizeof(req); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
631 |
#endif |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
632 |
} |
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 |
n = setsockopt(fdval(env,fdo), IPPROTO_IPV6, opt, optval, optlen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
635 |
if (n < 0) { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
636 |
if (join && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
637 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
638 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
639 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
640 |
return 0; |
4814 | 641 |
#else |
642 |
JNU_ThrowInternalError(env, "Should not get here"); |
|
643 |
return IOS_THROWN; |
|
644 |
#endif /* AF_INET6 */ |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
645 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
646 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
647 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
648 |
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
|
649 |
jbyteArray group, jint index, jbyteArray source) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
650 |
{ |
4814 | 651 |
#ifdef AF_INET6 |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
652 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
653 |
/* no IPv6 exclude-mode filtering for now */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
654 |
return IOS_UNAVAILABLE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
655 |
#else |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
656 |
struct my_group_source_req req; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
657 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
658 |
int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
659 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
660 |
initGroupSourceReq(env, group, index, source, &req); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
661 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
662 |
n = setsockopt(fdval(env,fdo), IPPROTO_IPV6, opt, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
663 |
(void*)&req, sizeof(req)); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
664 |
if (n < 0) { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
18535
diff
changeset
|
665 |
if (block && (errno == ENOPROTOOPT || errno == EOPNOTSUPP)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
666 |
return IOS_UNAVAILABLE; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
667 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
668 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
669 |
return 0; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
670 |
#endif |
4814 | 671 |
#else |
672 |
JNU_ThrowInternalError(env, "Should not get here"); |
|
673 |
return IOS_THROWN; |
|
674 |
#endif |
|
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
675 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
676 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
677 |
JNIEXPORT void JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
678 |
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
|
679 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
680 |
struct in_addr in; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
681 |
socklen_t arglen = sizeof(struct in_addr); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
682 |
int n; |
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 |
in.s_addr = htonl(interf); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
685 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
686 |
n = setsockopt(fdval(env, fdo), IPPROTO_IP, IP_MULTICAST_IF, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
687 |
(void*)&(in.s_addr), arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
688 |
if (n < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
689 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
690 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
691 |
} |
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 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
694 |
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
|
695 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
696 |
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
|
697 |
socklen_t arglen = sizeof(struct in_addr); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
698 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
699 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
700 |
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
|
701 |
if (n < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
702 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
703 |
return -1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
704 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
705 |
return ntohl(in.s_addr); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
706 |
} |
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 |
JNIEXPORT void JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
709 |
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
|
710 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
711 |
int value = (jint)index; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
712 |
socklen_t arglen = sizeof(value); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
713 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
714 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
715 |
n = setsockopt(fdval(env, fdo), IPPROTO_IPV6, IPV6_MULTICAST_IF, |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
716 |
(void*)&(index), arglen); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
717 |
if (n < 0) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
718 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
719 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
720 |
} |
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 |
JNIEXPORT jint JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
723 |
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
|
724 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
725 |
int index; |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6299
diff
changeset
|
726 |
socklen_t arglen = sizeof(index); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
727 |
int n; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
728 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
729 |
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
|
730 |
if (n < 0) { |
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 |
return -1; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
733 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
734 |
return (jint)index; |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
735 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
736 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
737 |
JNIEXPORT void JNICALL |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
738 |
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
|
739 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
740 |
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
|
741 |
(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
|
742 |
if ((shutdown(fdval(env, fdo), how) < 0) && (errno != ENOTCONN)) |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
743 |
handleSocketError(env, errno); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
895
diff
changeset
|
744 |
} |
2 | 745 |
|
14025
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
746 |
JNIEXPORT jint JNICALL |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
747 |
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
|
748 |
{ |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
749 |
struct pollfd pfd; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
750 |
int rv; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
751 |
pfd.fd = fdval(env, fdo); |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
752 |
pfd.events = events; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
753 |
rv = poll(&pfd, 1, timeout); |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
754 |
|
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
755 |
if (rv >= 0) { |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
756 |
return pfd.revents; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
757 |
} else if (errno == EINTR) { |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
758 |
return IOS_INTERRUPTED; |
18535
71b74ae0ab8a
8014377: (dc) DatagramChannel should set IP_MULTICAST_ALL=0 (lnx)
alanb
parents:
18192
diff
changeset
|
759 |
} else { |
14025
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
760 |
handleSocketError(env, errno); |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
761 |
return IOS_THROWN; |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
762 |
} |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
763 |
} |
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
764 |
|
22604
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_pollinValue(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)POLLIN; |
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_polloutValue(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)POLLOUT; |
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_pollerrValue(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)POLLERR; |
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_pollhupValue(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)POLLHUP; |
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 |
|
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
789 |
JNIEXPORT jshort JNICALL |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
790 |
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
|
791 |
{ |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
792 |
return (jshort)POLLNVAL; |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
793 |
} |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
794 |
|
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
795 |
JNIEXPORT jshort JNICALL |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
796 |
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
|
797 |
{ |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
798 |
return (jshort)POLLOUT; |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
799 |
} |
9b394795e216
8031997: PPC64: Make the various POLL constants system dependant
simonis
parents:
22597
diff
changeset
|
800 |
|
14025
fbebe005a3ee
7184932: Remove the temporary Selector usage in the NIO socket adapters
robm
parents:
13363
diff
changeset
|
801 |
|
2 | 802 |
/* Declared in nio_util.h */ |
803 |
||
804 |
jint |
|
805 |
handleSocketError(JNIEnv *env, jint errorValue) |
|
806 |
{ |
|
807 |
char *xn; |
|
808 |
switch (errorValue) { |
|
809 |
case EINPROGRESS: /* Non-blocking connect */ |
|
810 |
return 0; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
811 |
#ifdef EPROTO |
2 | 812 |
case EPROTO: |
813 |
xn = JNU_JAVANETPKG "ProtocolException"; |
|
814 |
break; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
815 |
#endif |
2 | 816 |
case ECONNREFUSED: |
817 |
xn = JNU_JAVANETPKG "ConnectException"; |
|
818 |
break; |
|
819 |
case ETIMEDOUT: |
|
820 |
xn = JNU_JAVANETPKG "ConnectException"; |
|
821 |
break; |
|
822 |
case EHOSTUNREACH: |
|
823 |
xn = JNU_JAVANETPKG "NoRouteToHostException"; |
|
824 |
break; |
|
825 |
case EADDRINUSE: /* Fall through */ |
|
826 |
case EADDRNOTAVAIL: |
|
827 |
xn = JNU_JAVANETPKG "BindException"; |
|
828 |
break; |
|
829 |
default: |
|
830 |
xn = JNU_JAVANETPKG "SocketException"; |
|
831 |
break; |
|
832 |
} |
|
833 |
errno = errorValue; |
|
834 |
JNU_ThrowByNameWithLastError(env, xn, "NioSocketError"); |
|
835 |
return IOS_THROWN; |
|
836 |
} |