Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5d9e65ad
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看板
提交
5d9e65ad
编写于
9月 23, 2016
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8159410: InetAddress.isReachable returns true for non existing IP adresses
Reviewed-by: chegar, coffeys
上级
b6545e13
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
3 deletion
+47
-3
src/windows/native/java/net/Inet4AddressImpl.c
src/windows/native/java/net/Inet4AddressImpl.c
+47
-3
未找到文件。
src/windows/native/java/net/Inet4AddressImpl.c
浏览文件 @
5d9e65ad
...
...
@@ -33,6 +33,7 @@
#include <process.h>
#include <iphlpapi.h>
#include <icmpapi.h>
#include <WinError.h>
#include "java_net_InetAddress.h"
#include "java_net_Inet4AddressImpl.h"
...
...
@@ -481,7 +482,15 @@ ping4(JNIEnv *env,
DWORD
ReplySize
=
0
;
jboolean
ret
=
JNI_FALSE
;
ReplySize
=
sizeof
(
ICMP_ECHO_REPLY
)
+
sizeof
(
SendData
);
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa366051%28v=vs.85%29.aspx
ReplySize
=
sizeof
(
ICMP_ECHO_REPLY
)
// The buffer should be large enough
// to hold at least one ICMP_ECHO_REPLY
// structure
+
sizeof
(
SendData
)
// plus RequestSize bytes of data.
+
8
;
// This buffer should also be large enough
// to also hold 8 more bytes of data
// (the size of an ICMP error message)
ReplyBuffer
=
(
VOID
*
)
malloc
(
ReplySize
);
if
(
ReplyBuffer
==
NULL
)
{
IcmpCloseHandle
(
hIcmpFile
);
...
...
@@ -517,10 +526,45 @@ ping4(JNIEnv *env,
(
timeout
<
1000
)
?
1000
:
timeout
);
// DWORD Timeout
}
if
(
dwRetVal
!=
0
)
{
if
(
dwRetVal
==
0
)
{
// if the call failed
TCHAR
*
buf
;
DWORD
err
=
WSAGetLastError
();
switch
(
err
)
{
case
ERROR_NO_NETWORK
:
case
ERROR_NETWORK_UNREACHABLE
:
case
ERROR_HOST_UNREACHABLE
:
case
ERROR_PROTOCOL_UNREACHABLE
:
case
ERROR_PORT_UNREACHABLE
:
case
ERROR_REQUEST_ABORTED
:
case
ERROR_INCORRECT_ADDRESS
:
case
ERROR_HOST_DOWN
:
case
WSAEHOSTUNREACH
:
/* Host Unreachable */
case
WSAENETUNREACH
:
/* Network Unreachable */
case
WSAENETDOWN
:
/* Network is down */
case
WSAEPFNOSUPPORT
:
/* Protocol Family unsupported */
case
IP_REQ_TIMED_OUT
:
break
;
default:
FormatMessage
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
err
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
(
LPTSTR
)
&
buf
,
0
,
NULL
);
NET_ThrowNew
(
env
,
err
,
buf
);
LocalFree
(
buf
);
break
;
}
}
else
{
PICMP_ECHO_REPLY
pEchoReply
=
(
PICMP_ECHO_REPLY
)
ReplyBuffer
;
if
((
int
)
pEchoReply
->
RoundTripTime
<=
timeout
)
// This is to take into account the undocumented minimum
// timeout mentioned in the IcmpSendEcho call above.
// We perform an extra check to make sure that our
// roundtrip time was less than our desired timeout
// for cases where that timeout is < 1000ms.
if
(
pEchoReply
->
Status
==
IP_SUCCESS
&&
(
int
)
pEchoReply
->
RoundTripTime
<=
timeout
)
{
ret
=
JNI_TRUE
;
}
}
free
(
ReplyBuffer
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录