Commit faf354cd authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

iphlpapi: Implement ParseNetworkString for IPv4 addresses and services.

parent 8599d8e5
......@@ -243,7 +243,7 @@
@ stdcall NotifyUnicastIpAddressChange(long ptr ptr long ptr)
#@ stub NTPTimeToNTFileTime
#@ stub NTTimeToNTPTime
#@ stub ParseNetworkString
@ stdcall ParseNetworkString(wstr long ptr ptr ptr)
@ stub _PfAddFiltersToInterface@24
@ stub _PfAddGlobalFilterToInterface@8
@ stdcall _PfBindInterfaceToIPAddress@12(long long ptr) PfBindInterfaceToIPAddress
......
......@@ -46,6 +46,7 @@
#include "winsock2.h"
#include "winternl.h"
#include "ws2ipdef.h"
#include "windns.h"
#include "iphlpapi.h"
#include "ifenum.h"
#include "ipstats.h"
......@@ -54,6 +55,7 @@
#include "ifdef.h"
#include "netioapi.h"
#include "tcpestats.h"
#include "ip2string.h"
#include "wine/debug.h"
#include "wine/unicode.h"
......@@ -3333,3 +3335,62 @@ DWORD WINAPI GetBestRoute2(NET_LUID *luid, NET_IFINDEX index,
return ERROR_NOT_SUPPORTED;
}
/******************************************************************
* ParseNetworkString (IPHLPAPI.@)
*/
DWORD WINAPI ParseNetworkString(const WCHAR *str, DWORD type,
NET_ADDRESS_INFO *info, USHORT *port, BYTE *prefix_len)
{
IN_ADDR temp_addr4;
USHORT temp_port = 0;
NTSTATUS status;
TRACE("(%s, %d, %p, %p, %p)\n", debugstr_w(str), type, info, port, prefix_len);
if (!str)
return ERROR_INVALID_PARAMETER;
if (type & NET_STRING_IPV4_ADDRESS)
{
status = RtlIpv4StringToAddressExW(str, TRUE, &temp_addr4, &temp_port);
if (SUCCEEDED(status) && !temp_port)
{
if (info)
{
info->Format = NET_ADDRESS_IPV4;
info->u.Ipv4Address.sin_addr = temp_addr4;
info->u.Ipv4Address.sin_port = 0;
}
if (port) *port = 0;
if (prefix_len) *prefix_len = 255;
return ERROR_SUCCESS;
}
}
if (type & NET_STRING_IPV4_SERVICE)
{
status = RtlIpv4StringToAddressExW(str, TRUE, &temp_addr4, &temp_port);
if (SUCCEEDED(status) && temp_port)
{
if (info)
{
info->Format = NET_ADDRESS_IPV4;
info->u.Ipv4Address.sin_addr = temp_addr4;
info->u.Ipv4Address.sin_port = temp_port;
}
if (port) *port = ntohs(temp_port);
if (prefix_len) *prefix_len = 255;
return ERROR_SUCCESS;
}
}
if (info) info->Format = NET_ADDRESS_FORMAT_UNSPECIFIED;
if (type & ~(NET_STRING_IPV4_ADDRESS|NET_STRING_IPV4_SERVICE))
{
FIXME("Unimplemented type 0x%x\n", type);
return ERROR_NOT_SUPPORTED;
}
return ERROR_INVALID_PARAMETER;
}
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