wsdapi: Implement IWSDUdpAddress_SetTransportAddress.

Signed-off-by: Owen Rudge <orudge@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Owen Rudge 2017-06-26 22:35:54 +01:00 committed by Alexandre Julliard
parent 4373eb30a4
commit 4f1dca9db0
4 changed files with 36 additions and 10 deletions

View File

@ -1,6 +1,6 @@
MODULE = wsdapi.dll
IMPORTLIB = wsdapi
IMPORTS = user32
IMPORTS = user32 ws2_32
C_SRCS = \
address.c \

View File

@ -22,6 +22,8 @@
#define COBJMACROS
#include "winsock2.h"
#include "ws2tcpip.h"
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"
@ -32,6 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wsdapi);
typedef struct IWSDUdpAddressImpl {
IWSDUdpAddress IWSDUdpAddress_iface;
LONG ref;
SOCKADDR_STORAGE sockAddr;
} IWSDUdpAddressImpl;
static inline IWSDUdpAddressImpl *impl_from_IWSDUdpAddress(IWSDUdpAddress *iface)
@ -132,8 +135,31 @@ static HRESULT WINAPI IWSDUdpAddressImpl_GetTransportAddressEx(IWSDUdpAddress *T
static HRESULT WINAPI IWSDUdpAddressImpl_SetTransportAddress(IWSDUdpAddress *This, LPCWSTR pszAddress)
{
FIXME("(%p, %s)\n", This, debugstr_w(pszAddress));
return E_NOTIMPL;
IWSDUdpAddressImpl *impl = impl_from_IWSDUdpAddress(This);
ADDRINFOW *addrInfo = NULL;
ADDRINFOW hints;
int ret;
TRACE("(%p, %s)\n", impl, debugstr_w(pszAddress));
if (pszAddress == NULL)
return E_INVALIDARG;
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_UNSPEC;
ret = GetAddrInfoW(pszAddress, NULL, &hints, &addrInfo);
if (ret == 0)
{
ZeroMemory(&impl->sockAddr, sizeof(SOCKADDR_STORAGE));
memcpy(&impl->sockAddr, addrInfo->ai_addr, addrInfo->ai_addrlen);
}
if (addrInfo != NULL)
FreeAddrInfoW(addrInfo);
return HRESULT_FROM_WIN32(ret);
}
static HRESULT WINAPI IWSDUdpAddressImpl_SetSockaddr(IWSDUdpAddress *This, const SOCKADDR_STORAGE *pSockAddr)

View File

@ -98,15 +98,15 @@ static void GetSetTransportAddress_udp_tests(void)
/* Try setting a null address */
rc = IWSDUdpAddress_SetTransportAddress(udpAddress, NULL);
todo_wine ok(rc == E_INVALIDARG, "SetTransportAddress(NULL) returned unexpected result: %08x\n", rc);
ok(rc == E_INVALIDARG, "SetTransportAddress(NULL) returned unexpected result: %08x\n", rc);
/* Try setting an invalid address */
rc = IWSDUdpAddress_SetTransportAddress(udpAddress, invalidAddress);
todo_wine ok(rc == HRESULT_FROM_WIN32(WSAHOST_NOT_FOUND), "SetTransportAddress(invalidAddress) returned unexpected result: %08x\n", rc);
ok(rc == HRESULT_FROM_WIN32(WSAHOST_NOT_FOUND), "SetTransportAddress(invalidAddress) returned unexpected result: %08x\n", rc);
/* Try setting an IPv4 address */
rc = IWSDUdpAddress_SetTransportAddress(udpAddress, ipv4Address);
todo_wine ok(rc == S_OK, "SetTransportAddress(ipv4Address) failed: %08x\n", rc);
ok(rc == S_OK, "SetTransportAddress(ipv4Address) failed: %08x\n", rc);
rc = IWSDUdpAddress_GetTransportAddress(udpAddress, NULL);
todo_wine ok(rc == E_POINTER, "GetTransportAddress(NULL) returned unexpected result: %08x\n", rc);
@ -118,7 +118,7 @@ static void GetSetTransportAddress_udp_tests(void)
/* Try setting an IPv6 address */
rc = IWSDUdpAddress_SetTransportAddress(udpAddress, ipv6Address);
todo_wine ok(rc == S_OK, "SetTransportAddress(ipv6Address) failed: %08x\n", rc);
ok(rc == S_OK, "SetTransportAddress(ipv6Address) failed: %08x\n", rc);
rc = IWSDUdpAddress_GetTransportAddress(udpAddress, &returnedAddress);
todo_wine ok(rc == S_OK, "GetTransportAddress returned unexpected result: %08x\n", rc);
@ -264,7 +264,7 @@ static void GetSetSockaddr_udp_tests(void)
/* Try setting a transport address */
rc = IWSDUdpAddress_SetTransportAddress(udpAddress, expectedIpv6TransportAddr);
todo_wine ok(rc == S_OK, "SetTransportAddress failed: %08x\n", rc);
ok(rc == S_OK, "SetTransportAddress failed: %08x\n", rc);
/* A socket address should be returned */
rc = IWSDUdpAddress_GetSockaddr(udpAddress, &returnedStorage);

View File

@ -96,7 +96,7 @@ static void LocalAddress_tests(void)
ok(origUdpAddress != NULL, "WSDCreateUdpMessageParameters(NULL, &origUdpAddress) failed: origUdpAddress == NULL\n");
rc = IWSDUdpAddress_SetTransportAddress(origUdpAddress, address);
todo_wine ok(rc == S_OK, "SetTransportAddress failed: %08x\n", rc);
ok(rc == S_OK, "SetTransportAddress failed: %08x\n", rc);
rc = IWSDUdpMessageParameters_SetLocalAddress(udpMessageParams, (IWSDAddress *)origUdpAddress);
ok(rc == S_OK, "SetLocalAddress failed: %08x\n", rc);
@ -154,7 +154,7 @@ static void RemoteAddress_tests(void)
ok(origUdpAddress != NULL, "WSDCreateUdpMessageParameters(NULL, &origUdpAddress) failed: origUdpAddress == NULL\n");
rc = IWSDUdpAddress_SetTransportAddress(origUdpAddress, address);
todo_wine ok(rc == S_OK, "SetTransportAddress failed: %08x\n", rc);
ok(rc == S_OK, "SetTransportAddress failed: %08x\n", rc);
rc = IWSDUdpMessageParameters_SetRemoteAddress(udpMessageParams, (IWSDAddress *)origUdpAddress);
ok(rc == S_OK, "SetRemoteAddress failed: %08x\n", rc);