Owen Rudge : wsdapi: Send Probe Matches message via UDP unicast.

Alexandre Julliard julliard at winehq.org
Thu Sep 20 13:45:32 CDT 2018


Module: wine
Branch: master
Commit: ed3670eef01ade33fe57f82ccfa962a0ed04c7ec
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ed3670eef01ade33fe57f82ccfa962a0ed04c7ec

Author: Owen Rudge <orudge at codeweavers.com>
Date:   Wed Sep 19 21:29:10 2018 +0100

wsdapi: Send Probe Matches message via UDP unicast.

Signed-off-by: Owen Rudge <orudge at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wsdapi/network.c         | 32 ++++++++++++++++++++++++++++++++
 dlls/wsdapi/soap.c            |  4 ++--
 dlls/wsdapi/tests/discovery.c | 22 +++++++++++-----------
 dlls/wsdapi/wsdapi_internal.h |  1 +
 4 files changed, 46 insertions(+), 13 deletions(-)

diff --git a/dlls/wsdapi/network.c b/dlls/wsdapi/network.c
index c7af2c3..ab29084 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 4469cef..45f0da9 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 d231fd9..16cefd9 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, "<wsa:EndpointReference><wsa:Address>%s</wsa:Address>"
                     "<wsa:ReferenceParameters><wine:Beer>RefPTest</wine:Beer></wsa:ReferenceParameters>"
@@ -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 a2b8902..2bab54f 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 */
 




More information about the wine-cvs mailing list