wpcap: Wrap native handles in a structure.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2021-10-04 14:36:39 +02:00 committed by Alexandre Julliard
parent d5c585c6aa
commit be9362190c
3 changed files with 222 additions and 201 deletions

View File

@ -27,6 +27,7 @@
#include <pcap/pcap.h>
#include <stdarg.h>
#include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
@ -40,39 +41,46 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
static const struct pcap_callbacks *callbacks;
static int CDECL wrap_activate( void *handle )
static int CDECL wrap_activate( struct pcap *pcap )
{
return pcap_activate( handle );
return pcap_activate( pcap->handle );
}
static void CDECL wrap_breakloop( void *handle )
static void CDECL wrap_breakloop( struct pcap *pcap )
{
return pcap_breakloop( handle );
return pcap_breakloop( pcap->handle );
}
static int CDECL wrap_can_set_rfmon( void *handle )
static int CDECL wrap_can_set_rfmon( struct pcap *pcap )
{
return pcap_can_set_rfmon( handle );
return pcap_can_set_rfmon( pcap->handle );
}
static void CDECL wrap_close( void *handle )
static void CDECL wrap_close( struct pcap *pcap )
{
pcap_close( handle );
pcap_close( pcap->handle );
free( pcap );
}
static int CDECL wrap_compile( void *handle, void *program, const char *buf, int optimize, unsigned int mask )
static int CDECL wrap_compile( struct pcap *pcap, void *program, const char *buf, int optimize, unsigned int mask )
{
return pcap_compile( handle, program, buf, optimize, mask );
return pcap_compile( pcap->handle, program, buf, optimize, mask );
}
static void * CDECL wrap_create( const char *src, char *errbuf )
static struct pcap * CDECL wrap_create( const char *src, char *errbuf )
{
return pcap_create( src, errbuf );
struct pcap *ret = malloc( sizeof(*ret) );
if (ret && !(ret->handle = pcap_create( src, errbuf )))
{
free( ret );
return NULL;
}
return ret;
}
static int CDECL wrap_datalink( void *handle )
static int CDECL wrap_datalink( struct pcap *pcap )
{
return pcap_datalink( handle );
return pcap_datalink( pcap->handle );
}
static int CDECL wrap_datalink_name_to_val( const char *name )
@ -96,7 +104,7 @@ static void wrap_pcap_handler( unsigned char *user, const struct pcap_pkthdr *hd
callbacks->handler( cb, hdr, packet );
}
static int CDECL wrap_dispatch( void *handle, int count,
static int CDECL wrap_dispatch( struct pcap *pcap, int count,
void (CALLBACK *callback)(unsigned char *, const void *, const unsigned char *),
unsigned char *user )
{
@ -105,9 +113,9 @@ static int CDECL wrap_dispatch( void *handle, int count,
struct handler_callback cb;
cb.callback = callback;
cb.user = user;
return pcap_dispatch( handle, count, wrap_pcap_handler, (unsigned char *)&cb );
return pcap_dispatch( pcap->handle, count, wrap_pcap_handler, (unsigned char *)&cb );
}
return pcap_dispatch( handle, count, NULL, user );
return pcap_dispatch( pcap->handle, count, NULL, user );
}
static void CDECL wrap_dump( unsigned char *user, const void *hdr, const unsigned char *packet )
@ -115,9 +123,9 @@ static void CDECL wrap_dump( unsigned char *user, const void *hdr, const unsigne
return pcap_dump( user, hdr, packet );
}
static void * CDECL wrap_dump_open( void *handle, const char *name )
static void * CDECL wrap_dump_open( struct pcap *pcap, const char *name )
{
return pcap_dump_open( handle, name );
return pcap_dump_open( pcap->handle, name );
}
static int CDECL wrap_findalldevs( struct pcap_if_hdr **devs, char *errbuf )
@ -149,19 +157,19 @@ static void CDECL wrap_freecode( void *program )
return pcap_freecode( program );
}
static int CDECL wrap_get_tstamp_precision( void *handle )
static int CDECL wrap_get_tstamp_precision( struct pcap *pcap )
{
return pcap_get_tstamp_precision( handle );
return pcap_get_tstamp_precision( pcap->handle );
}
static char * CDECL wrap_geterr( void *handle )
static char * CDECL wrap_geterr( struct pcap *pcap )
{
return pcap_geterr( handle );
return pcap_geterr( pcap->handle );
}
static int CDECL wrap_getnonblock( void *handle, char *errbuf )
static int CDECL wrap_getnonblock( struct pcap *pcap, char *errbuf )
{
return pcap_getnonblock( handle, errbuf );
return pcap_getnonblock( pcap->handle, errbuf );
}
static const char * CDECL wrap_lib_version( void )
@ -169,14 +177,14 @@ static const char * CDECL wrap_lib_version( void )
return pcap_lib_version();
}
static int CDECL wrap_list_datalinks( void *handle, int **buf )
static int CDECL wrap_list_datalinks( struct pcap *pcap, int **buf )
{
return pcap_list_datalinks( handle, buf );
return pcap_list_datalinks( pcap->handle, buf );
}
static int CDECL wrap_list_tstamp_types( void *handle, int **types )
static int CDECL wrap_list_tstamp_types( struct pcap *pcap, int **types )
{
return pcap_list_tstamp_types( handle, types );
return pcap_list_tstamp_types( pcap->handle, types );
}
static int CDECL wrap_lookupnet( const char *device, unsigned int *net, unsigned int *mask, char *errbuf )
@ -184,7 +192,7 @@ static int CDECL wrap_lookupnet( const char *device, unsigned int *net, unsigned
return pcap_lookupnet( device, net, mask, errbuf );
}
static int CDECL wrap_loop( void *handle, int count,
static int CDECL wrap_loop( struct pcap *pcap, int count,
void (CALLBACK *callback)(unsigned char *, const void *, const unsigned char *),
unsigned char *user )
{
@ -193,99 +201,105 @@ static int CDECL wrap_loop( void *handle, int count,
struct handler_callback cb;
cb.callback = callback;
cb.user = user;
return pcap_loop( handle, count, wrap_pcap_handler, (unsigned char *)&cb );
return pcap_loop( pcap->handle, count, wrap_pcap_handler, (unsigned char *)&cb );
}
return pcap_loop( handle, count, NULL, user );
return pcap_loop( pcap->handle, count, NULL, user );
}
static int CDECL wrap_major_version( void *handle )
static int CDECL wrap_major_version( struct pcap *pcap )
{
return pcap_major_version( handle );
return pcap_major_version( pcap->handle );
}
static int CDECL wrap_minor_version( void *handle )
static int CDECL wrap_minor_version( struct pcap *pcap )
{
return pcap_minor_version( handle );
return pcap_minor_version( pcap->handle );
}
static const unsigned char * CDECL wrap_next( void *handle, void *hdr )
static const unsigned char * CDECL wrap_next( struct pcap *pcap, void *hdr )
{
return pcap_next( handle, hdr );
return pcap_next( pcap->handle, hdr );
}
static int CDECL wrap_next_ex( void *handle, void **hdr, const unsigned char **data )
static int CDECL wrap_next_ex( struct pcap *pcap, void **hdr, const unsigned char **data )
{
return pcap_next_ex( handle, (struct pcap_pkthdr **)hdr, data );
return pcap_next_ex( pcap->handle, (struct pcap_pkthdr **)hdr, data );
}
static void * CDECL wrap_open_live( const char *source, int snaplen, int promisc, int to_ms, char *errbuf )
static struct pcap * CDECL wrap_open_live( const char *source, int snaplen, int promisc, int to_ms, char *errbuf )
{
return pcap_open_live( source, snaplen, promisc, to_ms, errbuf );
struct pcap *ret = malloc( sizeof(*ret) );
if (ret && !(ret->handle = pcap_open_live( source, snaplen, promisc, to_ms, errbuf )))
{
free( ret );
return NULL;
}
return ret;
}
static int CDECL wrap_sendpacket( void *handle, const unsigned char *buf, int size )
static int CDECL wrap_sendpacket( struct pcap *pcap, const unsigned char *buf, int size )
{
return pcap_sendpacket( handle, buf, size );
return pcap_sendpacket( pcap->handle, buf, size );
}
static int CDECL wrap_set_buffer_size( void *handle, int size )
static int CDECL wrap_set_buffer_size( struct pcap *pcap, int size )
{
return pcap_set_buffer_size( handle, size );
return pcap_set_buffer_size( pcap->handle, size );
}
static int CDECL wrap_set_datalink( void *handle, int link )
static int CDECL wrap_set_datalink( struct pcap *pcap, int link )
{
return pcap_set_datalink( handle, link );
return pcap_set_datalink( pcap->handle, link );
}
static int CDECL wrap_set_promisc( void *handle, int enable )
static int CDECL wrap_set_promisc( struct pcap *pcap, int enable )
{
return pcap_set_promisc( handle, enable );
return pcap_set_promisc( pcap->handle, enable );
}
static int CDECL wrap_set_rfmon( void *handle, int enable )
static int CDECL wrap_set_rfmon( struct pcap *pcap, int enable )
{
return pcap_set_rfmon( handle, enable );
return pcap_set_rfmon( pcap->handle, enable );
}
static int CDECL wrap_set_snaplen( void *handle, int len )
static int CDECL wrap_set_snaplen( struct pcap *pcap, int len )
{
return pcap_set_snaplen( handle, len );
return pcap_set_snaplen( pcap->handle, len );
}
static int CDECL wrap_set_timeout( void *handle, int timeout )
static int CDECL wrap_set_timeout( struct pcap *pcap, int timeout )
{
return pcap_set_timeout( handle, timeout );
return pcap_set_timeout( pcap->handle, timeout );
}
static int CDECL wrap_set_tstamp_precision( void *handle, int precision )
static int CDECL wrap_set_tstamp_precision( struct pcap *pcap, int precision )
{
return pcap_set_tstamp_precision( handle, precision );
return pcap_set_tstamp_precision( pcap->handle, precision );
}
static int CDECL wrap_set_tstamp_type( void *handle, int type )
static int CDECL wrap_set_tstamp_type( struct pcap *pcap, int type )
{
return pcap_set_tstamp_type( handle, type );
return pcap_set_tstamp_type( pcap->handle, type );
}
static int CDECL wrap_setfilter( void *handle, void *program )
static int CDECL wrap_setfilter( struct pcap *pcap, void *program )
{
return pcap_setfilter( handle, program );
return pcap_setfilter( pcap->handle, program );
}
static int CDECL wrap_setnonblock( void *handle, int nonblock, char *errbuf )
static int CDECL wrap_setnonblock( struct pcap *pcap, int nonblock, char *errbuf )
{
return pcap_setnonblock( handle, nonblock, errbuf );
return pcap_setnonblock( pcap->handle, nonblock, errbuf );
}
static int CDECL wrap_snapshot( void *handle )
static int CDECL wrap_snapshot( struct pcap *pcap )
{
return pcap_snapshot( handle );
return pcap_snapshot( pcap->handle );
}
static int CDECL wrap_stats( void *handle, void *stats )
static int CDECL wrap_stats( struct pcap *pcap, void *stats )
{
return pcap_stats( handle, stats );
return pcap_stats( pcap->handle, stats );
}
static const char * CDECL wrap_statustostr( int status )

View File

@ -23,6 +23,11 @@ struct pcap_if_hdr
char *name;
};
struct pcap
{
void *handle;
};
struct handler_callback
{
void (CALLBACK *callback)( unsigned char *, const void *, const unsigned char * );
@ -31,52 +36,54 @@ struct handler_callback
struct pcap_funcs
{
int (CDECL *activate)( void * );
void (CDECL *breakloop)( void * );
int (CDECL *can_set_rfmon)( void * );
void (CDECL *close)( void * );
int (CDECL *compile)( void *, void *, const char *, int, unsigned int );
void * (CDECL *create)( const char *, char * );
int (CDECL *datalink)( void * );
int (CDECL *activate)( struct pcap * );
void (CDECL *breakloop)( struct pcap * );
int (CDECL *can_set_rfmon)( struct pcap * );
void (CDECL *close)( struct pcap * );
int (CDECL *compile)( struct pcap *, void *, const char *, int, unsigned int );
struct pcap * (CDECL *create)( const char *, char * );
int (CDECL *datalink)( struct pcap * );
int (CDECL *datalink_name_to_val)( const char * );
const char * (CDECL *datalink_val_to_description)( int );
const char * (CDECL *datalink_val_to_name)( int );
int (CDECL *dispatch)( void *, int, void (CALLBACK *)(unsigned char *, const void *, const unsigned char *),
int (CDECL *dispatch)( struct pcap *, int,
void (CALLBACK *)(unsigned char *, const void *, const unsigned char *),
unsigned char * );
void (CDECL *dump)( unsigned char *, const void *, const unsigned char * );
void * (CDECL *dump_open)( void *, const char * );
void * (CDECL *dump_open)( struct pcap *, const char * );
int (CDECL *findalldevs)( struct pcap_if_hdr **, char * );
void (CDECL *free_datalinks)( int * );
void (CDECL *free_tstamp_types)( int * );
void (CDECL *freealldevs)( struct pcap_if_hdr * );
void (CDECL *freecode)( void * );
int (CDECL *get_tstamp_precision)( void * );
char * (CDECL *geterr)( void * );
int (CDECL *getnonblock)( void *, char * );
int (CDECL *get_tstamp_precision)( struct pcap * );
char * (CDECL *geterr)( struct pcap * );
int (CDECL *getnonblock)( struct pcap *, char * );
const char * (CDECL *lib_version)( void );
int (CDECL *list_datalinks)( void *, int ** );
int (CDECL *list_tstamp_types)( void *, int ** );
int (CDECL *list_datalinks)( struct pcap *, int ** );
int (CDECL *list_tstamp_types)( struct pcap *, int ** );
int (CDECL *lookupnet)( const char *, unsigned int *, unsigned int *, char * );
int (CDECL *loop)( void *, int, void (CALLBACK *)(unsigned char *, const void *, const unsigned char *),
int (CDECL *loop)( struct pcap *, int,
void (CALLBACK *)(unsigned char *, const void *, const unsigned char *),
unsigned char * );
int (CDECL *major_version)( void * );
int (CDECL *minor_version)( void * );
const unsigned char * (CDECL *next)( void *, void * );
int (CDECL *next_ex)( void *, void **, const unsigned char ** );
void * (CDECL *open_live)( const char *, int, int, int, char * );
int (CDECL *sendpacket)( void *, const unsigned char *, int );
int (CDECL *set_buffer_size)( void *, int );
int (CDECL *set_datalink)( void *, int );
int (CDECL *set_promisc)( void *, int );
int (CDECL *set_rfmon)( void *, int );
int (CDECL *set_snaplen)( void *, int );
int (CDECL *set_timeout)( void *, int );
int (CDECL *set_tstamp_precision)( void *, int );
int (CDECL *set_tstamp_type)( void *, int );
int (CDECL *setfilter)( void *, void * );
int (CDECL *setnonblock)( void *, int, char * );
int (CDECL *snapshot)( void * );
int (CDECL *stats)( void *, void * );
int (CDECL *major_version)( struct pcap * );
int (CDECL *minor_version)( struct pcap * );
const unsigned char * (CDECL *next)( struct pcap *, void * );
int (CDECL *next_ex)( struct pcap *, void **, const unsigned char ** );
struct pcap * (CDECL *open_live)( const char *, int, int, int, char * );
int (CDECL *sendpacket)( struct pcap *, const unsigned char *, int );
int (CDECL *set_buffer_size)( struct pcap *, int );
int (CDECL *set_datalink)( struct pcap *, int );
int (CDECL *set_promisc)( struct pcap *, int );
int (CDECL *set_rfmon)( struct pcap *, int );
int (CDECL *set_snaplen)( struct pcap *, int );
int (CDECL *set_timeout)( struct pcap *, int );
int (CDECL *set_tstamp_precision)( struct pcap *, int );
int (CDECL *set_tstamp_type)( struct pcap *, int );
int (CDECL *setfilter)( struct pcap *, void * );
int (CDECL *setnonblock)( struct pcap *, int, char * );
int (CDECL *snapshot)( struct pcap * );
int (CDECL *stats)( struct pcap *, void * );
const char * (CDECL *statustostr)( int );
int (CDECL *tstamp_type_name_to_val)( const char * );
const char * (CDECL *tstamp_type_val_to_description)( int );

View File

@ -33,46 +33,46 @@ WINE_DEFAULT_DEBUG_CHANNEL(wpcap);
const struct pcap_funcs *pcap_funcs = NULL;
int CDECL pcap_activate( void *handle )
int CDECL pcap_activate( struct pcap *pcap )
{
TRACE( "%p\n", handle );
return pcap_funcs->activate( handle );
TRACE( "%p\n", pcap );
return pcap_funcs->activate( pcap );
}
void CDECL pcap_breakloop( void *handle )
void CDECL pcap_breakloop( struct pcap *pcap )
{
TRACE( "%p\n", handle );
pcap_funcs->breakloop( handle );
TRACE( "%p\n", pcap );
pcap_funcs->breakloop( pcap );
}
int CDECL pcap_can_set_rfmon( void *handle )
int CDECL pcap_can_set_rfmon( struct pcap *pcap )
{
TRACE( "%p\n", handle );
return pcap_funcs->can_set_rfmon( handle );
TRACE( "%p\n", pcap );
return pcap_funcs->can_set_rfmon( pcap );
}
void CDECL pcap_close( void *handle )
void CDECL pcap_close( struct pcap *pcap )
{
TRACE( "%p\n", handle );
pcap_funcs->close( handle );
TRACE( "%p\n", pcap );
pcap_funcs->close( pcap );
}
int CDECL pcap_compile( void *handle, void *program, const char *buf, int optimize, unsigned int mask )
int CDECL pcap_compile( struct pcap *pcap, void *program, const char *buf, int optimize, unsigned int mask )
{
TRACE( "%p, %p, %s, %d, %u\n", handle, program, debugstr_a(buf), optimize, mask );
return pcap_funcs->compile( handle, program, buf, optimize, mask );
TRACE( "%p, %p, %s, %d, %u\n", pcap, program, debugstr_a(buf), optimize, mask );
return pcap_funcs->compile( pcap, program, buf, optimize, mask );
}
void * CDECL pcap_create( const char *src, char *errbuf )
struct pcap * CDECL pcap_create( const char *src, char *errbuf )
{
TRACE( "%s, %p\n", src, errbuf );
return pcap_funcs->create( src, errbuf );
}
int CDECL pcap_datalink( void *handle )
int CDECL pcap_datalink( struct pcap *pcap )
{
TRACE( "%p\n", handle );
return pcap_funcs->datalink( handle );
TRACE( "%p\n", pcap );
return pcap_funcs->datalink( pcap );
}
int CDECL pcap_datalink_name_to_val( const char *name )
@ -93,12 +93,12 @@ const char * CDECL pcap_datalink_val_to_name( int link )
return pcap_funcs->datalink_val_to_name( link );
}
int CDECL pcap_dispatch( void *handle, int count,
int CDECL pcap_dispatch( struct pcap *pcap, int count,
void (CALLBACK *callback)(unsigned char *, const void *, const unsigned char *),
unsigned char *user )
{
TRACE( "%p, %d, %p, %p\n", handle, count, callback, user );
return pcap_funcs->dispatch( handle, count, callback, user );
TRACE( "%p, %d, %p, %p\n", pcap, count, callback, user );
return pcap_funcs->dispatch( pcap, count, callback, user );
}
void CDECL pcap_dump( unsigned char *user, const void *hdr, const unsigned char *packet )
@ -118,13 +118,13 @@ static inline WCHAR *strdupAW( const char *str )
return ret;
}
void * CDECL pcap_dump_open( void *handle, const char *filename )
void * CDECL pcap_dump_open( struct pcap *pcap, const char *filename )
{
void *dumper;
WCHAR *filenameW;
char *unix_path;
TRACE( "%p, %s\n", handle, debugstr_a(filename) );
TRACE( "%p, %s\n", pcap, debugstr_a(filename) );
if (!(filenameW = strdupAW( filename ))) return NULL;
unix_path = wine_get_unix_file_name( filenameW );
@ -133,7 +133,7 @@ void * CDECL pcap_dump_open( void *handle, const char *filename )
TRACE( "unix_path %s\n", debugstr_a(unix_path) );
dumper = pcap_funcs->dump_open( handle, unix_path );
dumper = pcap_funcs->dump_open( pcap, unix_path );
RtlFreeHeap( GetProcessHeap(), 0, unix_path );
return dumper;
}
@ -174,28 +174,28 @@ void CDECL pcap_freecode( void *program )
pcap_funcs->freecode( program );
}
void * CDECL pcap_get_airpcap_handle( void *handle )
void * CDECL pcap_get_airpcap_handle( struct pcap *pcap )
{
TRACE( "%p\n", handle );
TRACE( "%p\n", pcap );
return NULL;
}
int CDECL pcap_get_tstamp_precision( void *handle )
int CDECL pcap_get_tstamp_precision( struct pcap *pcap )
{
TRACE( "%p\n", handle );
return pcap_funcs->get_tstamp_precision( handle );
TRACE( "%p\n", pcap );
return pcap_funcs->get_tstamp_precision( pcap );
}
char * CDECL pcap_geterr( void *handle )
char * CDECL pcap_geterr( struct pcap *pcap )
{
TRACE( "%p\n", handle );
return pcap_funcs->geterr( handle );
TRACE( "%p\n", pcap );
return pcap_funcs->geterr( pcap );
}
int CDECL pcap_getnonblock( void *handle, char *errbuf )
int CDECL pcap_getnonblock( struct pcap *pcap, char *errbuf )
{
TRACE( "%p, %p\n", handle, errbuf );
return pcap_funcs->getnonblock( handle, errbuf );
TRACE( "%p, %p\n", pcap, errbuf );
return pcap_funcs->getnonblock( pcap, errbuf );
}
static char lib_version[256];
@ -214,16 +214,16 @@ const char * CDECL pcap_lib_version( void )
return lib_version;
}
int CDECL pcap_list_datalinks( void *handle, int **buf )
int CDECL pcap_list_datalinks( struct pcap *pcap, int **buf )
{
TRACE( "%p, %p\n", handle, buf );
return pcap_funcs->list_datalinks( handle, buf );
TRACE( "%p, %p\n", pcap, buf );
return pcap_funcs->list_datalinks( pcap, buf );
}
int CDECL pcap_list_tstamp_types( void *handle, int **types )
int CDECL pcap_list_tstamp_types( struct pcap *pcap, int **types )
{
TRACE( "%p, %p\n", handle, types );
return pcap_funcs->list_tstamp_types( handle, types );
TRACE( "%p, %p\n", pcap, types );
return pcap_funcs->list_tstamp_types( pcap, types );
}
char * CDECL pcap_lookupdev( char *errbuf )
@ -248,46 +248,46 @@ int CDECL pcap_lookupnet( const char *device, unsigned int *net, unsigned int *m
return pcap_funcs->lookupnet( device, net, mask, errbuf );
}
int CDECL pcap_loop( void *handle, int count,
int CDECL pcap_loop( struct pcap *pcap, int count,
void (CALLBACK *callback)(unsigned char *, const void *, const unsigned char *),
unsigned char *user)
{
TRACE( "%p, %d, %p, %p\n", handle, count, callback, user );
return pcap_funcs->loop( handle, count, callback, user );
TRACE( "%p, %d, %p, %p\n", pcap, count, callback, user );
return pcap_funcs->loop( pcap, count, callback, user );
}
int CDECL pcap_major_version( void *handle )
int CDECL pcap_major_version( struct pcap *pcap )
{
TRACE( "%p\n", handle );
return pcap_funcs->major_version( handle );
TRACE( "%p\n", pcap );
return pcap_funcs->major_version( pcap );
}
int CDECL pcap_minor_version( void *handle )
int CDECL pcap_minor_version( struct pcap *pcap )
{
TRACE( "%p\n", handle );
return pcap_funcs->minor_version( handle );
TRACE( "%p\n", pcap );
return pcap_funcs->minor_version( pcap );
}
const unsigned char * CDECL pcap_next( void *handle, void *hdr )
const unsigned char * CDECL pcap_next( struct pcap *pcap, void *hdr )
{
TRACE( "%p, %p\n", handle, hdr );
return pcap_funcs->next( handle, hdr );
TRACE( "%p, %p\n", pcap, hdr );
return pcap_funcs->next( pcap, hdr );
}
int CDECL pcap_next_ex( void *handle, void **hdr, const unsigned char **data )
int CDECL pcap_next_ex( struct pcap *pcap, void **hdr, const unsigned char **data )
{
TRACE( "%p, %p, %p\n", handle, hdr, data );
return pcap_funcs->next_ex( handle, hdr, data );
TRACE( "%p, %p, %p\n", pcap, hdr, data );
return pcap_funcs->next_ex( pcap, hdr, data );
}
#define PCAP_OPENFLAG_PROMISCUOUS 1
void * CDECL pcap_open( const char *source, int snaplen, int flags, int timeout, void *auth, char *errbuf )
struct pcap * CDECL pcap_open( const char *source, int snaplen, int flags, int timeout, void *auth, char *errbuf )
{
FIXME( "%s, %d, %d, %d, %p, %p: partial stub\n", debugstr_a(source), snaplen, flags, timeout, auth, errbuf );
return pcap_funcs->open_live( source, snaplen, flags & PCAP_OPENFLAG_PROMISCUOUS, timeout, errbuf );
}
void * CDECL pcap_open_live( const char *source, int snaplen, int promisc, int to_ms, char *errbuf )
struct pcap * CDECL pcap_open_live( const char *source, int snaplen, int promisc, int to_ms, char *errbuf )
{
TRACE( "%s, %d, %d, %d, %p\n", debugstr_a(source), snaplen, promisc, to_ms, errbuf );
return pcap_funcs->open_live( source, snaplen, promisc, to_ms, errbuf );
@ -334,88 +334,88 @@ int CDECL pcap_parsesrcstr( const char *source, int *type, char *host, char *por
return 0;
}
int CDECL pcap_sendpacket( void *handle, const unsigned char *buf, int size )
int CDECL pcap_sendpacket( struct pcap *pcap, const unsigned char *buf, int size )
{
TRACE( "%p, %p, %d\n", handle, buf, size );
return pcap_funcs->sendpacket( handle, buf, size );
TRACE( "%p, %p, %d\n", pcap, buf, size );
return pcap_funcs->sendpacket( pcap, buf, size );
}
int CDECL pcap_set_buffer_size( void *handle, int size )
int CDECL pcap_set_buffer_size( struct pcap *pcap, int size )
{
TRACE( "%p, %d\n", handle, size );
return pcap_funcs->set_buffer_size( handle, size );
TRACE( "%p, %d\n", pcap, size );
return pcap_funcs->set_buffer_size( pcap, size );
}
int CDECL pcap_set_datalink( void *handle, int link )
int CDECL pcap_set_datalink( struct pcap *pcap, int link )
{
TRACE( "%p, %d\n", handle, link );
return pcap_funcs->set_datalink( handle, link );
TRACE( "%p, %d\n", pcap, link );
return pcap_funcs->set_datalink( pcap, link );
}
int CDECL pcap_set_promisc( void *handle, int enable )
int CDECL pcap_set_promisc( struct pcap *pcap, int enable )
{
TRACE( "%p, %d\n", handle, enable );
return pcap_funcs->set_promisc( handle, enable );
TRACE( "%p, %d\n", pcap, enable );
return pcap_funcs->set_promisc( pcap, enable );
}
int CDECL pcap_set_rfmon( void *handle, int enable )
int CDECL pcap_set_rfmon( struct pcap *pcap, int enable )
{
TRACE( "%p, %d\n", handle, enable );
return pcap_funcs->set_rfmon( handle, enable );
TRACE( "%p, %d\n", pcap, enable );
return pcap_funcs->set_rfmon( pcap, enable );
}
int CDECL pcap_set_snaplen( void *handle, int len )
int CDECL pcap_set_snaplen( struct pcap *pcap, int len )
{
TRACE( "%p, %d\n", handle, len );
return pcap_funcs->set_snaplen( handle, len );
TRACE( "%p, %d\n", pcap, len );
return pcap_funcs->set_snaplen( pcap, len );
}
int CDECL pcap_set_timeout( void *handle, int timeout )
int CDECL pcap_set_timeout( struct pcap *pcap, int timeout )
{
TRACE( "%p, %d\n", handle, timeout );
return pcap_funcs->set_timeout( handle, timeout );
TRACE( "%p, %d\n", pcap, timeout );
return pcap_funcs->set_timeout( pcap, timeout );
}
int CDECL pcap_set_tstamp_precision( void *handle, int precision )
int CDECL pcap_set_tstamp_precision( struct pcap *pcap, int precision )
{
TRACE( "%p, %d\n", handle, precision );
return pcap_funcs->set_tstamp_precision( handle, precision );
TRACE( "%p, %d\n", pcap, precision );
return pcap_funcs->set_tstamp_precision( pcap, precision );
}
int CDECL pcap_set_tstamp_type( void *handle, int type )
int CDECL pcap_set_tstamp_type( struct pcap *pcap, int type )
{
TRACE( "%p, %d\n", handle, type );
return pcap_funcs->set_tstamp_type( handle, type );
TRACE( "%p, %d\n", pcap, type );
return pcap_funcs->set_tstamp_type( pcap, type );
}
int CDECL pcap_setbuff( void *handle, int size )
int CDECL pcap_setbuff( struct pcap *pcap, int size )
{
FIXME( "%p, %d\n", handle, size );
FIXME( "%p, %d\n", pcap, size );
return 0;
}
int CDECL pcap_setfilter( void *handle, void *program )
int CDECL pcap_setfilter( struct pcap *pcap, void *program )
{
TRACE( "%p, %p\n", handle, program );
return pcap_funcs->setfilter( handle, program );
TRACE( "%p, %p\n", pcap, program );
return pcap_funcs->setfilter( pcap, program );
}
int CDECL pcap_setnonblock( void *handle, int nonblock, char *errbuf )
int CDECL pcap_setnonblock( struct pcap *pcap, int nonblock, char *errbuf )
{
TRACE( "%p, %d, %p\n", handle, nonblock, errbuf );
return pcap_funcs->setnonblock( handle, nonblock, errbuf );
TRACE( "%p, %d, %p\n", pcap, nonblock, errbuf );
return pcap_funcs->setnonblock( pcap, nonblock, errbuf );
}
int CDECL pcap_snapshot( void *handle )
int CDECL pcap_snapshot( struct pcap *pcap )
{
TRACE( "%p\n", handle );
return pcap_funcs->snapshot( handle );
TRACE( "%p\n", pcap );
return pcap_funcs->snapshot( pcap );
}
int CDECL pcap_stats( void *handle, void *stats )
int CDECL pcap_stats( struct pcap *pcap, void *stats )
{
TRACE( "%p, %p\n", handle, stats );
return pcap_funcs->stats( handle, stats );
TRACE( "%p, %p\n", pcap, stats );
return pcap_funcs->stats( pcap, stats );
}
const char * CDECL pcap_statustostr( int status )