Commit d6fc8118 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

wpcap: Implement pcap_dump_open and pcap_dump.

Based off a patch by Jianqiu Zhang. Signed-off-by: 's avatarAlistair Leslie-Hughes <leslie_alistair@hotmail.com> Signed-off-by: 's avatarAndré Hentschel <nerv@dawncrow.de> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent e787791b
......@@ -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);
}
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment