Commit f6ca7522 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

iphlpapi: Implement IcmpParseReplies().

parent da81d63f
......@@ -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)
......
......@@ -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;
}
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment