Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4505dd4f
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4505dd4f
编写于
5月 11, 2012
作者:
Y
youdwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7163874: InetAddress.isReachable should support pinging 0.0.0.0
Reviewed-by: alanb, chegar
上级
dea63d31
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
126 addition
and
10 deletion
+126
-10
src/share/native/java/net/net_util.h
src/share/native/java/net/net_util.h
+3
-0
src/solaris/native/java/net/Inet4AddressImpl.c
src/solaris/native/java/net/Inet4AddressImpl.c
+13
-6
src/solaris/native/java/net/Inet6AddressImpl.c
src/solaris/native/java/net/Inet6AddressImpl.c
+9
-4
src/solaris/native/java/net/net_util_md.c
src/solaris/native/java/net/net_util_md.c
+10
-0
test/java/net/Inet4Address/PingThis.java
test/java/net/Inet4Address/PingThis.java
+91
-0
未找到文件。
src/share/native/java/net/net_util.h
浏览文件 @
4505dd4f
...
...
@@ -139,6 +139,9 @@ NET_IPv4MappedToIPv4(jbyte* caddr);
int
NET_IsEqual
(
jbyte
*
caddr1
,
jbyte
*
caddr2
);
int
NET_IsZeroAddr
(
jbyte
*
caddr
);
/* Socket operations
*
* These work just like the JVM_* procedures, except that they may do some
...
...
src/solaris/native/java/net/Inet4AddressImpl.c
浏览文件 @
4505dd4f
...
...
@@ -671,12 +671,19 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
* We did receive something, but is it what we were expecting?
* I.E.: A ICMP_ECHOREPLY packet with the proper PID.
*/
if
(
icmplen
>=
8
&&
icmp
->
icmp_type
==
ICMP_ECHOREPLY
&&
(
ntohs
(
icmp
->
icmp_id
)
==
pid
)
&&
(
him
->
sin_addr
.
s_addr
==
sa_recv
.
sin_addr
.
s_addr
))
{
close
(
fd
);
return
JNI_TRUE
;
}
if
(
icmplen
>=
8
&&
icmp
->
icmp_type
==
ICMP_ECHOREPLY
&&
(
ntohs
(
icmp
->
icmp_id
)
==
pid
))
{
if
((
him
->
sin_addr
.
s_addr
==
sa_recv
.
sin_addr
.
s_addr
))
{
close
(
fd
);
return
JNI_TRUE
;
}
if
(
him
->
sin_addr
.
s_addr
==
0
)
{
close
(
fd
);
return
JNI_TRUE
;
}
}
}
}
while
(
tmout2
>
0
);
timeout
-=
1000
;
...
...
src/solaris/native/java/net/Inet6AddressImpl.c
浏览文件 @
4505dd4f
...
...
@@ -532,10 +532,15 @@ ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
* from the host that we are trying to determine is reachable.
*/
if
(
n
>=
8
&&
icmp6
->
icmp6_type
==
ICMP6_ECHO_REPLY
&&
(
ntohs
(
icmp6
->
icmp6_id
)
==
pid
)
&&
NET_IsEqual
(
caddr
,
recv_caddr
))
{
close
(
fd
);
return
JNI_TRUE
;
(
ntohs
(
icmp6
->
icmp6_id
)
==
pid
))
{
if
(
NET_IsEqual
(
caddr
,
recv_caddr
))
{
close
(
fd
);
return
JNI_TRUE
;
}
if
(
NET_IsZeroAddr
(
caddr
))
{
close
(
fd
);
return
JNI_TRUE
;
}
}
}
}
while
(
tmout2
>
0
);
...
...
src/solaris/native/java/net/net_util_md.c
浏览文件 @
4505dd4f
...
...
@@ -961,6 +961,16 @@ NET_IsEqual(jbyte* caddr1, jbyte* caddr2) {
return
1
;
}
int
NET_IsZeroAddr
(
jbyte
*
caddr
)
{
int
i
;
for
(
i
=
0
;
i
<
16
;
i
++
)
{
if
(
caddr
[
i
]
!=
0
)
{
return
0
;
}
}
return
1
;
}
/*
* Map the Java level socket option to the platform specific
* level and option name.
...
...
test/java/net/Inet4Address/PingThis.java
0 → 100644
浏览文件 @
4505dd4f
/*
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Portions Copyright (c) 2012 IBM Corporation
*/
/* @test
* @bug 7163874
* @summary InetAddress.isReachable is returning false
* for InetAdress 0.0.0.0 and ::0
* @run main PingThis
* @run main/othervm -Djava.net.preferIPv4Stack=true PingThis
*/
import
java.net.Inet6Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
public
class
PingThis
{
private
static
boolean
hasIPv6
()
throws
Exception
{
List
<
NetworkInterface
>
nics
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
());
for
(
NetworkInterface
nic
:
nics
)
{
List
<
InetAddress
>
addrs
=
Collections
.
list
(
nic
.
getInetAddresses
());
for
(
InetAddress
addr
:
addrs
)
{
if
(
addr
instanceof
Inet6Address
)
return
true
;
}
}
return
false
;
}
public
static
void
main
(
String
args
[])
throws
Exception
{
if
(
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
))
{
return
;
}
boolean
preferIPv4Stack
=
"true"
.
equals
(
System
.
getProperty
(
"java.net.preferIPv4Stack"
));
List
<
String
>
addrs
=
new
ArrayList
<
String
>();
InetAddress
inetAddress
=
null
;
addrs
.
add
(
"0.0.0.0"
);
if
(!
preferIPv4Stack
)
{
if
(
hasIPv6
())
{
addrs
.
add
(
"::0"
);
}
}
for
(
String
addr
:
addrs
)
{
inetAddress
=
InetAddress
.
getByName
(
addr
);
System
.
out
.
println
(
"The target ip is "
+
inetAddress
.
getHostAddress
());
boolean
isReachable
=
inetAddress
.
isReachable
(
3000
);
System
.
out
.
println
(
"the target is reachable: "
+
isReachable
);
if
(
isReachable
)
{
System
.
out
.
println
(
"Test passed "
);
}
else
{
System
.
out
.
println
(
"Test failed "
);
throw
new
Exception
(
"address "
+
inetAddress
.
getHostAddress
()
+
" can not be reachable!"
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录