Huw Davies : iphlpapi: Implement IcmpParseReplies().
Alexandre Julliard
julliard at winehq.org
Wed Oct 6 15:51:38 CDT 2021
Module: wine
Branch: master
Commit: f6ca752201b191326ce837edeae56792b5c23044
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f6ca752201b191326ce837edeae56792b5c23044
Author: Huw Davies <huw at codeweavers.com>
Date: Wed Oct 6 10:12:56 2021 +0100
iphlpapi: Implement IcmpParseReplies().
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/iphlpapi/iphlpapi.spec | 2 +-
dlls/iphlpapi/iphlpapi_main.c | 14 ++++++++++++
dlls/iphlpapi/tests/iphlpapi.c | 49 ++++++++++++++++++++++++++++++------------
3 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec
index 6c51548b6e3..ce188084c01 100644
--- a/dlls/iphlpapi/iphlpapi.spec
+++ b/dlls/iphlpapi/iphlpapi.spec
@@ -157,7 +157,7 @@
@ stdcall Icmp6SendEcho2(ptr ptr ptr ptr ptr ptr ptr long ptr ptr long long)
@ stdcall IcmpCloseHandle(ptr)
@ stdcall IcmpCreateFile()
-@ stub IcmpParseReplies
+@ stdcall IcmpParseReplies(ptr long)
@ stdcall IcmpSendEcho2Ex(ptr ptr ptr ptr long long ptr long ptr ptr long long)
@ stdcall IcmpSendEcho2(ptr ptr ptr ptr long ptr long ptr ptr long long)
@ stdcall IcmpSendEcho(ptr long ptr long ptr ptr long long)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index d52441f022a..9e525a2116c 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -2,6 +2,7 @@
* iphlpapi dll implementation
*
* Copyright (C) 2003,2006 Juan Lang
+ * Copyright 2021 Huw Davies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -4541,3 +4542,16 @@ DWORD WINAPI ParseNetworkString(const WCHAR *str, DWORD type,
return ERROR_INVALID_PARAMETER;
}
+
+/******************************************************************
+ * IcmpParseReplies (IPHLPAPI.@)
+ */
+DWORD WINAPI IcmpParseReplies( void *reply, DWORD reply_size )
+{
+ ICMP_ECHO_REPLY *icmp_reply = reply;
+ DWORD num_pkts = icmp_reply->Reserved;
+
+ icmp_reply->Reserved = 0;
+ if (!num_pkts) SetLastError( icmp_reply->Status );
+ return num_pkts;
+}
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index 223d6d270cb..080feb364f9 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -1043,20 +1043,40 @@ static void testIcmpSendEcho(void)
IcmpCloseHandle(icmp);
}
-/*
-still-to-be-tested NT4-onward functions:
-CreateIpForwardEntry
-DeleteIpForwardEntry
-CreateIpNetEntry
-DeleteIpNetEntry
-GetFriendlyIfIndex
-GetRTTAndHopCount
-SetIfEntry
-SetIpForwardEntry
-SetIpNetEntry
-SetIpStatistics
-SetIpTTL
-*/
+static void testIcmpParseReplies( void )
+{
+ ICMP_ECHO_REPLY reply = { 0 };
+ DWORD ret;
+
+ SetLastError( 0xdeadbeef );
+ ret = IcmpParseReplies( &reply, sizeof(reply) );
+ ok( ret == 0, "ret %d\n", ret );
+ ok( GetLastError() == 0, "gle %d\n", GetLastError() );
+
+ reply.Status = 12345;
+ SetLastError( 0xdeadbeef );
+ ret = IcmpParseReplies( &reply, sizeof(reply) );
+ ok( ret == 0, "ret %d\n", ret );
+ ok( GetLastError() == 12345, "gle %d\n", GetLastError() );
+ ok( reply.Status == 12345, "status %d\n", reply.Status );
+
+ reply.Reserved = 1;
+ SetLastError( 0xdeadbeef );
+ ret = IcmpParseReplies( &reply, sizeof(reply) );
+ ok( ret == 1, "ret %d\n", ret );
+ ok( GetLastError() == 0xdeadbeef, "gle %d\n", GetLastError() );
+ ok( reply.Status == 12345, "status %d\n", reply.Status );
+ ok( !reply.Reserved, "reserved %d\n", reply.Reserved );
+
+ reply.Reserved = 3;
+ SetLastError( 0xdeadbeef );
+ ret = IcmpParseReplies( &reply, sizeof(reply) );
+ ok( ret == 3, "ret %d\n", ret );
+ ok( GetLastError() == 0xdeadbeef, "gle %d\n", GetLastError() );
+ ok( reply.Status == 12345, "status %d\n", reply.Status );
+ ok( !reply.Reserved, "reserved %d\n", reply.Reserved );
+}
+
static void testWinNT4Functions(void)
{
testGetNumberOfInterfaces();
@@ -1076,6 +1096,7 @@ static void testWinNT4Functions(void)
testGetUdpTable();
testSetTcpEntry();
testIcmpSendEcho();
+ testIcmpParseReplies();
}
static void testGetInterfaceInfo(void)
More information about the wine-cvs
mailing list