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 Icmp6SendEcho2(ptr ptr ptr ptr ptr ptr ptr long ptr ptr long long)
@ stdcall IcmpCloseHandle(ptr) @ stdcall IcmpCloseHandle(ptr)
@ stdcall IcmpCreateFile() @ stdcall IcmpCreateFile()
@ stub IcmpParseReplies @ stdcall IcmpParseReplies(ptr long)
@ stdcall IcmpSendEcho2Ex(ptr ptr ptr ptr long long ptr long ptr ptr long 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 IcmpSendEcho2(ptr ptr ptr ptr long ptr long ptr ptr long long)
@ stdcall IcmpSendEcho(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 * iphlpapi dll implementation
* *
* Copyright (C) 2003,2006 Juan Lang * Copyright (C) 2003,2006 Juan Lang
* Copyright 2021 Huw Davies
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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; 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); IcmpCloseHandle(icmp);
} }
/* static void testIcmpParseReplies( void )
still-to-be-tested NT4-onward functions: {
CreateIpForwardEntry ICMP_ECHO_REPLY reply = { 0 };
DeleteIpForwardEntry DWORD ret;
CreateIpNetEntry
DeleteIpNetEntry SetLastError( 0xdeadbeef );
GetFriendlyIfIndex ret = IcmpParseReplies( &reply, sizeof(reply) );
GetRTTAndHopCount ok( ret == 0, "ret %d\n", ret );
SetIfEntry ok( GetLastError() == 0, "gle %d\n", GetLastError() );
SetIpForwardEntry
SetIpNetEntry reply.Status = 12345;
SetIpStatistics SetLastError( 0xdeadbeef );
SetIpTTL 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) static void testWinNT4Functions(void)
{ {
testGetNumberOfInterfaces(); testGetNumberOfInterfaces();
@ -1076,6 +1096,7 @@ static void testWinNT4Functions(void)
testGetUdpTable(); testGetUdpTable();
testSetTcpEntry(); testSetTcpEntry();
testIcmpSendEcho(); testIcmpSendEcho();
testIcmpParseReplies();
} }
static void testGetInterfaceInfo(void) static void testGetInterfaceInfo(void)