diff --git a/dlls/wsdapi/network.c b/dlls/wsdapi/network.c index c7af2c3dfa3..ab290845834 100644 --- a/dlls/wsdapi/network.c +++ b/dlls/wsdapi/network.c @@ -558,6 +558,38 @@ cleanup: return (ret == ERROR_SUCCESS) && (valid_listeners > 0); } +HRESULT send_udp_unicast(char *data, int length, IWSDUdpAddress *remote_addr, int max_initial_delay) +{ + SOCKADDR_STORAGE address; + HRESULT ret; + SOCKET s; + + ZeroMemory(&address, sizeof(SOCKADDR_STORAGE)); + + ret = IWSDUdpAddress_GetSockaddr(remote_addr, &address); + + if (FAILED(ret)) + { + WARN("No sockaddr specified in send_udp_unicast\n"); + return ret; + } + + /* Create a socket and bind to the adapter address */ + s = socket(address.ss_family, SOCK_DGRAM, IPPROTO_UDP); + + if (s == INVALID_SOCKET) + { + int error = WSAGetLastError(); + WARN("Unable to create socket: %d\n", error); + return HRESULT_FROM_WIN32(error); + } + + send_message(s, data, length, &address, max_initial_delay, UNICAST_UDP_REPEAT); + closesocket(s); + + return S_OK; +} + void terminate_networking(IWSDiscoveryPublisherImpl *impl) { BOOL needsCleanup = impl->publisherStarted; diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c index 4469cefdb7b..45f0da90e0d 100644 --- a/dlls/wsdapi/soap.c +++ b/dlls/wsdapi/soap.c @@ -923,8 +923,8 @@ static HRESULT write_and_send_message(IWSDiscoveryPublisherImpl *impl, WSD_SOAP_ } else { - /* TODO: Send the message via UDP unicast */ - FIXME("TODO: Send the message via UDP unicast\n"); + /* Send the message via UDP unicast */ + ret = send_udp_unicast(full_xml, xml_length + xml_header_len + 1, remote_address, max_initial_delay); } heap_free(full_xml); diff --git a/dlls/wsdapi/tests/discovery.c b/dlls/wsdapi/tests/discovery.c index d231fd9b5fc..16cefd9609a 100644 --- a/dlls/wsdapi/tests/discovery.c +++ b/dlls/wsdapi/tests/discovery.c @@ -729,7 +729,7 @@ static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ProbeHandler(IWSDiscoveryP DeleteCriticalSection(&msg_storage->criticalSection); /* Verify we've received a message */ - todo_wine ok(msg_storage->messageCount >= 1, "No messages received\n"); + ok(msg_storage->messageCount >= 1, "No messages received\n"); sprintf(endpoint_reference_string, "%s" "RefPTest" @@ -767,16 +767,16 @@ static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ProbeHandler(IWSDiscoveryP heap_free(msg_storage->messages[i]); } - todo_wine ok(probe_matches_message_seen == TRUE, "Probe matches message not received\n"); - todo_wine ok(endpoint_reference_seen == TRUE, "EndpointReference not received\n"); - todo_wine ok(app_sequence_seen == TRUE, "AppSequence not received\n"); - todo_wine ok(metadata_version_seen == TRUE, "MetadataVersion not received\n"); - todo_wine ok(message_ok == TRUE, "ProbeMatches message metadata not received\n"); - todo_wine ok(any_header_seen == TRUE, "Custom header not received\n"); - todo_wine ok(wine_ns_seen == TRUE, "Wine namespace not received\n"); - todo_wine ok(body_probe_matches_seen == TRUE, "Body and Probe Matches elements not received\n"); - todo_wine ok(any_body_seen == TRUE, "Custom body element not received\n"); - todo_wine ok(types_seen == TRUE, "Types not received\n"); + ok(probe_matches_message_seen == TRUE, "Probe matches message not received\n"); + ok(endpoint_reference_seen == TRUE, "EndpointReference not received\n"); + ok(app_sequence_seen == TRUE, "AppSequence not received\n"); + ok(metadata_version_seen == TRUE, "MetadataVersion not received\n"); + ok(message_ok == TRUE, "ProbeMatches message metadata not received\n"); + ok(any_header_seen == TRUE, "Custom header not received\n"); + ok(wine_ns_seen == TRUE, "Wine namespace not received\n"); + ok(body_probe_matches_seen == TRUE, "Body and Probe Matches elements not received\n"); + ok(any_body_seen == TRUE, "Custom body element not received\n"); + ok(types_seen == TRUE, "Types not received\n"); after_matchprobe_test: heap_free(publisherIdW); diff --git a/dlls/wsdapi/wsdapi_internal.h b/dlls/wsdapi/wsdapi_internal.h index a2b89026b28..2bab54ffda6 100644 --- a/dlls/wsdapi/wsdapi_internal.h +++ b/dlls/wsdapi/wsdapi_internal.h @@ -67,6 +67,7 @@ typedef struct IWSDiscoveryPublisherImpl { BOOL init_networking(IWSDiscoveryPublisherImpl *impl); void terminate_networking(IWSDiscoveryPublisherImpl *impl); BOOL send_udp_multicast(IWSDiscoveryPublisherImpl *impl, char *data, int length, int max_initial_delay); +HRESULT send_udp_unicast(char *data, int length, IWSDUdpAddress *remote_addr, int max_initial_delay); /* soap.c */