Alistair Leslie-Hughes : wpcap: Implement pcap_dump_open and pcap_dump.

Alexandre Julliard julliard at winehq.org
Tue Apr 10 17:24:29 CDT 2018


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

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Sun Apr  8 23:17:19 2018 +0000

wpcap: Implement pcap_dump_open and pcap_dump.

Based off a patch by Jianqiu Zhang.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: André Hentschel <nerv at dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wpcap/wpcap.c    | 44 ++++++++++++++++++++++++++++++++++++++++++++
 dlls/wpcap/wpcap.spec |  4 ++--
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c
index fe46903..e7908cd 100644
--- a/dlls/wpcap/wpcap.c
+++ b/dlls/wpcap/wpcap.c
@@ -27,6 +27,7 @@
 #include "winsock2.h"
 #include "windef.h"
 #include "winbase.h"
+#include "wine/heap.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(wpcap);
@@ -45,6 +46,22 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
 #define PCAP_SRC_IFLOCAL        3
 #endif
 
+static inline WCHAR *heap_strdupAtoW(const char *str)
+{
+    LPWSTR ret = NULL;
+
+    if(str) {
+        DWORD len;
+
+        len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+        ret = heap_alloc(len*sizeof(WCHAR));
+        if(ret)
+            MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
+    }
+
+    return ret;
+}
+
 void CDECL wine_pcap_breakloop(pcap_t *p)
 {
     TRACE("(%p)\n", p);
@@ -341,3 +358,30 @@ int CDECL wine_wsockinit(void)
     if (WSAStartup(MAKEWORD(1,1), &wsadata)) return -1;
     return 0;
 }
+
+pcap_dumper_t* CDECL wine_pcap_dump_open(pcap_t *p, const char *fname)
+{
+    pcap_dumper_t *dumper;
+    WCHAR *fnameW = heap_strdupAtoW(fname);
+    char *unix_path;
+
+    TRACE("(%p %s)\n", p, debugstr_a(fname));
+
+    unix_path = wine_get_unix_file_name(fnameW);
+    heap_free(fnameW);
+    if(!unix_path)
+        return NULL;
+
+    TRACE("unix_path %s\n", debugstr_a(unix_path));
+
+    dumper = pcap_dump_open(p, unix_path);
+    heap_free(unix_path);
+
+    return dumper;
+}
+
+void CDECL wine_pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
+{
+    TRACE("(%p %p %p)\n", user, h, sp);
+    return pcap_dump(user, h, sp);
+}
diff --git a/dlls/wpcap/wpcap.spec b/dlls/wpcap/wpcap.spec
index 66303b4..ffb6ed1 100644
--- a/dlls/wpcap/wpcap.spec
+++ b/dlls/wpcap/wpcap.spec
@@ -16,12 +16,12 @@
 @ cdecl pcap_datalink_val_to_description(long) wine_pcap_datalink_val_to_description
 @ cdecl pcap_datalink_val_to_name(long) wine_pcap_datalink_val_to_name
 @ cdecl pcap_dispatch(ptr long ptr ptr) wine_pcap_dispatch
-@ stub pcap_dump
+@ cdecl pcap_dump(ptr ptr str) wine_pcap_dump
 @ stub pcap_dump_close
 @ stub pcap_dump_file
 @ stub pcap_dump_flush
 @ stub pcap_dump_ftell
-@ stub pcap_dump_open
+@ cdecl pcap_dump_open(ptr str) wine_pcap_dump_open
 @ stub pcap_file
 @ stub pcap_fileno
 @ cdecl pcap_findalldevs(ptr ptr) wine_pcap_findalldevs




More information about the wine-cvs mailing list