wpcap: Implement pcap_dump_open and pcap_dump.

Based off a patch by Jianqiu Zhang.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2018-04-08 23:17:19 +00:00 committed by Alexandre Julliard
parent e787791bed
commit d6fc811877
2 changed files with 46 additions and 2 deletions

View File

@ -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);
}

View File

@ -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