iphlpapi: Implement IcmpParseReplies().

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-10-06 10:12:56 +01:00 committed by Alexandre Julliard
parent da81d63f6f
commit f6ca752201
3 changed files with 50 additions and 15 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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)