Owen Rudge : wsdapi: Add stub for Probe message parsing, prepare notification sink message.

Alexandre Julliard julliard at winehq.org
Thu Jun 14 16:53:23 CDT 2018


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

Author: Owen Rudge <orudge at codeweavers.com>
Date:   Wed Jun 13 19:11:22 2018 +0100

wsdapi: Add stub for Probe message parsing, prepare notification sink message.

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         | 60 ++++++++++++++++++++++++++++++++++++++++++-
 dlls/wsdapi/soap.c            |  6 +++++
 dlls/wsdapi/wsdapi_internal.h |  5 ++++
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/dlls/wsdapi/network.c b/dlls/wsdapi/network.c
index e91ab76..e124a5d 100644
--- a/dlls/wsdapi/network.c
+++ b/dlls/wsdapi/network.c
@@ -292,6 +292,64 @@ typedef struct listener_thread_params
     BOOL ipv6;
 } listener_thread_params;
 
+static HRESULT process_received_message(listener_thread_params *params, char *message, int message_len,
+    SOCKADDR_STORAGE *source_addr)
+{
+    IWSDUdpMessageParameters *msg_params = NULL;
+    IWSDUdpAddress *remote_addr = NULL;
+    struct notificationSink *sink;
+    WSD_SOAP_MESSAGE *msg = NULL;
+    int msg_type;
+    HRESULT ret;
+
+    ret = read_message(message, message_len, &msg, &msg_type);
+    if (FAILED(ret)) return ret;
+
+    switch (msg_type)
+    {
+        case MSGTYPE_PROBE:
+            TRACE("Received probe message\n");
+
+            ret = WSDCreateUdpMessageParameters(&msg_params);
+
+            if (FAILED(ret))
+            {
+                ERR("Unable to create IWSDUdpMessageParameters, not processing message.\n");
+                goto cleanup;
+            }
+
+            ret = WSDCreateUdpAddress(&remote_addr);
+
+            if (FAILED(ret))
+            {
+                ERR("Unable to create IWSDUdpAddress, not processing message.\n");
+                goto cleanup;
+            }
+
+            IWSDUdpAddress_SetSockaddr(remote_addr, source_addr);
+            IWSDUdpMessageParameters_SetRemoteAddress(msg_params, (IWSDAddress *)remote_addr);
+
+            EnterCriticalSection(&params->impl->notification_sink_critical_section);
+
+            LIST_FOR_EACH_ENTRY(sink, &params->impl->notificationSinks, struct notificationSink, entry)
+            {
+                IWSDiscoveryPublisherNotify_ProbeHandler(sink->notificationSink, msg, (IWSDMessageParameters *)msg_params);
+            }
+
+            LeaveCriticalSection(&params->impl->notification_sink_critical_section);
+
+            break;
+    }
+
+cleanup:
+    WSDFreeLinkedMemory(msg);
+
+    if (remote_addr != NULL) IWSDUdpAddress_Release(remote_addr);
+    if (msg_params != NULL) IWSDUdpMessageParameters_Release(msg_params);
+
+    return ret;
+}
+
 #define RECEIVE_BUFFER_SIZE        65536
 
 static DWORD WINAPI listening_thread(LPVOID params)
@@ -321,7 +379,7 @@ static DWORD WINAPI listening_thread(LPVOID params)
         }
         else
         {
-            /* TODO: Process received message */
+            process_received_message(parameter, buffer, bytes_received, &source_addr);
         }
     }
 
diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c
index d0fb0af..0d4a4a6 100644
--- a/dlls/wsdapi/soap.c
+++ b/dlls/wsdapi/soap.c
@@ -1080,3 +1080,9 @@ cleanup:
 
     return ret;
 }
+
+HRESULT read_message(const char *xml, int xml_length, WSD_SOAP_MESSAGE **out_msg, int *msg_type)
+{
+    /* TODO: Parse and read message */
+    return E_NOTIMPL;
+}
diff --git a/dlls/wsdapi/wsdapi_internal.h b/dlls/wsdapi/wsdapi_internal.h
index 3e5e163..dc4fc4d 100644
--- a/dlls/wsdapi/wsdapi_internal.h
+++ b/dlls/wsdapi/wsdapi_internal.h
@@ -72,6 +72,11 @@ HRESULT send_bye_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR id, ULONGLONG
 
 HRESULT register_namespaces(IWSDXMLContext *xml_context);
 
+HRESULT read_message(const char *xml, int xml_length, WSD_SOAP_MESSAGE **out_msg, int *msg_type);
+
+#define MSGTYPE_UNKNOWN     0
+#define MSGTYPE_PROBE       1
+
 /* xml.c */
 
 LPWSTR duplicate_string(void *parentMemoryBlock, LPCWSTR value);




More information about the wine-cvs mailing list