[PATCH 1/2] wpcap: Implement pcap_dump_open and pcap_dump(try 5)

André Hentschel nerv at dawncrow.de
Fri Feb 12 13:15:37 CST 2016


Hi,

great to see you continue your work :)
But you missed a lot of valuable hints from Sebastian in try 4 and 5
What I need to add is that I'd still like to see the pcap_close function in the same patch and a TRACE in pcap_dump.
In pcap_dump you could also remove the return as it is a void function, but the file isn't consistent in that regard anyway.
Thinking twice, the pcap_dump function should maybe be a seperate patch, while the pcap_close function really should go in this one.

Am 12.02.2016 um 17:14 schrieb Jianqiu Zhang:
> From 2c90ac326c3eb2d58c95a219616b6789e98499ef Mon Sep 17 00:00:00 2001
> From: Jianqiu Zhang <zhangjianqiu_133 at yeah.net>
> Date: Thu, 29 Oct 2015 15:33:28 +0800
> Subject: [PATCH 1/2] wpcap: Implement pcap_dump_open and pcap_dump
> 
> Signed-off-by: Jianqiu Zhang <zhangjianqiu_133 at yeah.net>
> ---
> 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 ae9e482..b3bb6a5 100644
> --- a/dlls/wpcap/wpcap.c
> +++ b/dlls/wpcap/wpcap.c
> @@ -18,10 +18,13 @@
>  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
>  */
> 
> +#include "ntstatus.h"
> +#define WIN32_NO_STATUS
> #include <pcap/pcap.h>
> #include "winsock2.h"
> #include "windef.h"
> #include "winbase.h"
> +#include "winternl.h"
> #include "wine/debug.h"
> 
> WINE_DEFAULT_DEBUG_CHANNEL(wpcap);
> @@ -339,3 +342,44 @@ 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)
> +{
> +    UNICODE_STRING nt_name, dospathW;
> +    ANSI_STRING fname_dos;
> +    ANSI_STRING fname_unix;
> +    pcap_dumper_t *dumper_data;
> +    NTSTATUS status;
> +    TRACE("(%p %s)\n", p, fname);
> +    RtlInitAnsiString(&fname_dos, fname);
> +    status = RtlAnsiStringToUnicodeString(&dospathW, &fname_dos, TRUE);
> +    if (status)
> +    {
> +        SetLastError(RtlNtStatusToDosError(status));
> +        return NULL;
> +    }
> +    if (!RtlDosPathNameToNtPathName_U(dospathW.Buffer, &nt_name, NULL, NULL))
> +    {
> +        RtlFreeUnicodeString(&dospathW);
> +        SetLastError(ERROR_PATH_NOT_FOUND);
> +        return NULL;
> +    }
> +    status = wine_nt_to_unix_file_name(&nt_name, &fname_unix, FILE_OPEN_IF, FALSE);
> +    if (status && status != STATUS_NO_SUCH_FILE)
> +    {
> +        RtlFreeUnicodeString(&dospathW);
> +        RtlFreeUnicodeString(&nt_name);
> +        SetLastError(RtlNtStatusToDosError(status));
> +        return NULL;
> +    }
> +    RtlFreeUnicodeString(&nt_name);
> +    RtlFreeUnicodeString(&dospathW);
> +    dumper_data = pcap_dump_open(p, fname_unix.Buffer);
> +    RtlFreeAnsiString(&fname_unix);
> +    return dumper_data;
> +}
> +
> +void CDECL wine_pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
> +{
> +    return pcap_dump(user, h, sp);
> +}
> diff --git a/dlls/wpcap/wpcap.spec b/dlls/wpcap/wpcap.spec
> index 66303b4..541fc49 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 ptr) 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
> -- 
> 2.7.1
> 
> 
> 




More information about the wine-devel mailing list