2014-08-07 00:15:00 +02:00
|
|
|
/*
|
|
|
|
* WPcap.dll Proxy.
|
|
|
|
*
|
2014-08-15 22:47:44 +02:00
|
|
|
* Copyright 2011, 2014 André Hentschel
|
2014-08-07 00:15:00 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
#include <stdarg.h>
|
2014-08-15 22:47:44 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2021-05-10 15:37:23 +02:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#define USE_WS_PREFIX
|
|
|
|
#include "winsock2.h"
|
|
|
|
|
2014-08-07 00:15:00 +02:00
|
|
|
#include "wine/debug.h"
|
2021-05-10 15:37:23 +02:00
|
|
|
#include "unixlib.h"
|
2014-08-07 00:15:00 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wpcap);
|
2021-05-10 15:37:23 +02:00
|
|
|
|
|
|
|
const struct pcap_funcs *pcap_funcs = NULL;
|
2015-08-31 20:52:13 +02:00
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_activate( void *handle )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
return pcap_funcs->activate( handle );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void CDECL pcap_breakloop( void *handle )
|
2014-08-15 21:55:13 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
pcap_funcs->breakloop( handle );
|
2014-08-15 21:55:13 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_can_set_rfmon( void *handle )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
return pcap_funcs->can_set_rfmon( handle );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void CDECL pcap_close( void *handle )
|
2014-08-18 23:55:15 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
pcap_funcs->close( handle );
|
2014-08-18 23:55:15 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_compile( void *handle, void *program, const char *buf, int optimize, unsigned int mask )
|
2014-08-12 00:34:45 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p, %s, %d, %u\n", handle, program, debugstr_a(buf), optimize, mask );
|
|
|
|
return pcap_funcs->compile( handle, program, buf, optimize, mask );
|
2014-08-12 00:34:45 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void * CDECL pcap_create( const char *src, char *errbuf )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%s, %p\n", src, errbuf );
|
|
|
|
return pcap_funcs->create( src, errbuf );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_datalink( void *handle )
|
2014-08-12 00:32:05 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
return pcap_funcs->datalink( handle );
|
2014-08-12 00:32:05 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_datalink_name_to_val( const char *name )
|
2014-08-18 23:55:47 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%s\n", debugstr_a(name) );
|
|
|
|
return pcap_funcs->datalink_name_to_val( name );
|
2014-08-18 23:55:47 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
const char * CDECL pcap_datalink_val_to_description( int link )
|
2014-08-18 23:56:28 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%d\n", link );
|
|
|
|
return pcap_funcs->datalink_val_to_description( link );
|
2014-08-18 23:56:28 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
const char * CDECL pcap_datalink_val_to_name( int link )
|
2014-08-18 23:55:01 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%d\n", link );
|
|
|
|
return pcap_funcs->datalink_val_to_name( link );
|
2014-08-18 23:55:01 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_dispatch( void *handle, int count,
|
|
|
|
void (CALLBACK *callback)(unsigned char *, const void *, const unsigned char *),
|
|
|
|
unsigned char *user )
|
2014-08-15 22:47:44 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %d, %p, %p\n", handle, count, callback, user );
|
|
|
|
return pcap_funcs->dispatch( handle, count, callback, user );
|
|
|
|
}
|
2014-08-15 22:47:44 +02:00
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void CDECL pcap_dump( unsigned char *user, const void *hdr, const unsigned char *packet )
|
2014-08-15 22:47:44 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p, %p\n", user, hdr, packet );
|
|
|
|
pcap_funcs->dump( user, hdr, packet );
|
2014-08-15 22:47:44 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:26 +02:00
|
|
|
static inline WCHAR *strdupAW( const char *str )
|
|
|
|
{
|
|
|
|
WCHAR *ret = NULL;
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
|
|
|
|
if ((ret = malloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void * CDECL pcap_dump_open( void *handle, const char *filename )
|
2014-08-15 22:47:44 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
void *dumper;
|
|
|
|
WCHAR *filenameW;
|
|
|
|
char *unix_path;
|
2014-08-15 22:47:44 +02:00
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %s\n", handle, debugstr_a(filename) );
|
2014-08-15 22:47:44 +02:00
|
|
|
|
2021-05-10 15:37:26 +02:00
|
|
|
if (!(filenameW = strdupAW( filename ))) return NULL;
|
2021-05-10 15:37:23 +02:00
|
|
|
unix_path = wine_get_unix_file_name( filenameW );
|
2021-05-10 15:37:26 +02:00
|
|
|
free( filenameW );
|
2021-05-10 15:37:23 +02:00
|
|
|
if (!unix_path) return NULL;
|
2014-08-15 22:47:44 +02:00
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "unix_path %s\n", debugstr_a(unix_path) );
|
2014-08-10 23:08:40 +02:00
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
dumper = pcap_funcs->dump_open( handle, unix_path );
|
2021-05-10 15:37:26 +02:00
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, unix_path );
|
2021-05-10 15:37:23 +02:00
|
|
|
return dumper;
|
|
|
|
}
|
2014-08-10 23:08:40 +02:00
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_findalldevs( struct pcap_if_hdr **devs, char *errbuf )
|
2021-05-10 15:37:23 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %p\n", devs, errbuf );
|
|
|
|
return pcap_funcs->findalldevs( devs, errbuf );
|
2014-08-10 23:08:40 +02:00
|
|
|
}
|
2014-08-07 00:15:00 +02:00
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_findalldevs_ex( char *source, void *auth, struct pcap_if_hdr **devs, char *errbuf )
|
2014-08-20 23:04:46 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
FIXME( "%s, %p, %p, %p: partial stub\n", debugstr_a(source), auth, devs, errbuf );
|
|
|
|
return pcap_funcs->findalldevs( devs, errbuf );
|
2014-08-20 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void CDECL pcap_free_datalinks( int *links )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p\n", links );
|
|
|
|
pcap_funcs->free_datalinks( links );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void CDECL pcap_free_tstamp_types( int *types )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p\n", types );
|
|
|
|
pcap_funcs->free_tstamp_types( types );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void CDECL pcap_freealldevs( struct pcap_if_hdr *devs )
|
2014-08-10 23:09:22 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", devs );
|
|
|
|
pcap_funcs->freealldevs( devs );
|
2014-08-10 23:09:22 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void CDECL pcap_freecode( void *program )
|
2014-08-15 21:53:51 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", program );
|
|
|
|
pcap_funcs->freecode( program );
|
2014-08-15 21:53:51 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void * CDECL pcap_get_airpcap_handle( void *handle )
|
2014-08-18 23:57:52 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", handle );
|
2014-08-18 23:57:52 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_get_tstamp_precision( void *handle )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
return pcap_funcs->get_tstamp_precision( handle );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
char * CDECL pcap_geterr( void *handle )
|
2014-08-12 00:28:59 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
return pcap_funcs->geterr( handle );
|
2014-08-12 00:28:59 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_getnonblock( void *handle, char *errbuf )
|
2014-08-19 00:00:00 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p\n", handle, errbuf );
|
|
|
|
return pcap_funcs->getnonblock( handle, errbuf );
|
2014-08-19 00:00:00 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
static char lib_version[256];
|
|
|
|
static BOOL WINAPI init_lib_version( INIT_ONCE *once, void *param, void **ctx )
|
2014-08-07 00:15:00 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
const char *str = pcap_funcs->lib_version();
|
|
|
|
if (strlen( str ) < sizeof(lib_version)) strcpy( lib_version, str );
|
|
|
|
return TRUE;
|
2014-08-07 00:15:00 +02:00
|
|
|
}
|
2014-08-10 23:08:20 +02:00
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
const char * CDECL pcap_lib_version( void )
|
2014-08-18 23:56:15 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
|
|
|
|
if (!lib_version[0]) InitOnceExecuteOnce( &once, init_lib_version, NULL, NULL );
|
|
|
|
TRACE( "%s\n", debugstr_a(lib_version) );
|
|
|
|
return lib_version;
|
2014-08-18 23:56:15 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_list_datalinks( void *handle, int **buf )
|
2021-05-10 15:37:23 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %p\n", handle, buf );
|
|
|
|
return pcap_funcs->list_datalinks( handle, buf );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_list_tstamp_types( void *handle, int **types )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %p\n", handle, types );
|
|
|
|
return pcap_funcs->list_tstamp_types( handle, types );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
char * CDECL pcap_lookupdev( char *errbuf )
|
2014-08-12 00:32:52 +02:00
|
|
|
{
|
2019-08-06 10:05:18 +02:00
|
|
|
static char *ret;
|
2021-05-10 15:37:23 +02:00
|
|
|
struct pcap_if_hdr *devs;
|
2019-08-06 10:05:18 +02:00
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", errbuf );
|
2019-08-06 10:05:18 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
if (pcap_funcs->findalldevs( &devs, errbuf ) == -1) return NULL;
|
2019-08-06 10:05:18 +02:00
|
|
|
if (!devs) return NULL;
|
2021-05-10 15:37:23 +02:00
|
|
|
if ((ret = malloc( strlen(devs->name) + 1 ))) strcpy( ret, devs->name );
|
|
|
|
pcap_funcs->freealldevs( devs );
|
2019-08-06 10:05:18 +02:00
|
|
|
}
|
|
|
|
return ret;
|
2014-08-12 00:32:52 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_lookupnet( const char *device, unsigned int *net, unsigned int *mask, char *errbuf )
|
2014-08-12 00:33:14 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%s, %p, %p, %p\n", debugstr_a(device), net, mask, errbuf );
|
|
|
|
return pcap_funcs->lookupnet( device, net, mask, errbuf );
|
2014-08-12 00:33:14 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_loop( void *handle, int count,
|
|
|
|
void (CALLBACK *callback)(unsigned char *, const void *, const unsigned char *),
|
|
|
|
unsigned char *user)
|
2014-08-15 22:48:14 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %d, %p, %p\n", handle, count, callback, user );
|
|
|
|
return pcap_funcs->loop( handle, count, callback, user );
|
2014-08-15 22:48:14 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_major_version( void *handle )
|
2014-08-10 23:08:20 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
return pcap_funcs->major_version( handle );
|
2014-08-10 23:08:20 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_minor_version( void *handle )
|
2014-08-10 23:08:20 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
return pcap_funcs->minor_version( handle );
|
2014-08-10 23:08:20 +02:00
|
|
|
}
|
2014-08-12 00:29:46 +02:00
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
const unsigned char * CDECL pcap_next( void *handle, void *hdr )
|
2014-08-19 00:00:15 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p\n", handle, hdr );
|
|
|
|
return pcap_funcs->next( handle, hdr );
|
2014-08-19 00:00:15 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_next_ex( void *handle, void **hdr, const unsigned char **data )
|
2014-08-19 00:00:31 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p, %p\n", handle, hdr, data );
|
|
|
|
return pcap_funcs->next_ex( handle, hdr, data );
|
2014-08-19 00:00:31 +02:00
|
|
|
}
|
|
|
|
|
2014-08-18 23:58:06 +02:00
|
|
|
#define PCAP_OPENFLAG_PROMISCUOUS 1
|
2021-05-10 15:37:27 +02:00
|
|
|
void * CDECL pcap_open( const char *source, int snaplen, int flags, int timeout, void *auth, char *errbuf )
|
2014-08-18 23:58:06 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
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 );
|
2014-08-18 23:58:06 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
void * CDECL pcap_open_live( const char *source, int snaplen, int promisc, int to_ms, char *errbuf )
|
2014-08-12 00:29:46 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
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 );
|
2014-08-12 00:29:46 +02:00
|
|
|
}
|
2014-08-12 00:30:47 +02:00
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
#define PCAP_SRC_FILE 2
|
|
|
|
#define PCAP_SRC_IFLOCAL 3
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_parsesrcstr( const char *source, int *type, char *host, char *port, char *name, char *errbuf )
|
2015-08-31 20:52:13 +02:00
|
|
|
{
|
|
|
|
int t = PCAP_SRC_IFLOCAL;
|
|
|
|
const char *p = source;
|
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
FIXME( "%s, %p, %p, %p, %p, %p: partial stub\n", debugstr_a(source), type, host, port, name, errbuf );
|
2015-08-31 20:52:13 +02:00
|
|
|
|
|
|
|
if (host)
|
|
|
|
*host = '\0';
|
|
|
|
if (port)
|
|
|
|
*port = '\0';
|
|
|
|
if (name)
|
|
|
|
*name = '\0';
|
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
if (!strncmp(p, "rpcap://", strlen("rpcap://")))
|
|
|
|
p += strlen("rpcap://");
|
|
|
|
else if (!strncmp(p, "file://", strlen("file://")))
|
2015-08-31 20:52:13 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
p += strlen("file://");
|
2015-08-31 20:52:13 +02:00
|
|
|
t = PCAP_SRC_FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type)
|
|
|
|
*type = t;
|
|
|
|
|
|
|
|
if (!*p)
|
|
|
|
{
|
|
|
|
if (errbuf)
|
|
|
|
sprintf(errbuf, "The name has not been specified in the source string.");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
strcpy(name, p);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_sendpacket( void *handle, const unsigned char *buf, int size )
|
2014-08-19 00:01:25 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p, %d\n", handle, buf, size );
|
|
|
|
return pcap_funcs->sendpacket( handle, buf, size );
|
2014-08-19 00:01:25 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_set_buffer_size( void *handle, int size )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %d\n", handle, size );
|
|
|
|
return pcap_funcs->set_buffer_size( handle, size );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_set_datalink( void *handle, int link )
|
2014-08-18 23:57:01 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %d\n", handle, link );
|
|
|
|
return pcap_funcs->set_datalink( handle, link );
|
2014-08-18 23:57:01 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_set_promisc( void *handle, int enable )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %d\n", handle, enable );
|
|
|
|
return pcap_funcs->set_promisc( handle, enable );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_set_rfmon( void *handle, int enable )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %d\n", handle, enable );
|
|
|
|
return pcap_funcs->set_rfmon( handle, enable );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_set_snaplen( void *handle, int len )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %d\n", handle, len );
|
|
|
|
return pcap_funcs->set_snaplen( handle, len );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_set_timeout( void *handle, int timeout )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %d\n", handle, timeout );
|
|
|
|
return pcap_funcs->set_timeout( handle, timeout );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_set_tstamp_precision( void *handle, int precision )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %d\n", handle, precision );
|
|
|
|
return pcap_funcs->set_tstamp_precision( handle, precision );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_set_tstamp_type( void *handle, int type )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%p, %d\n", handle, type );
|
|
|
|
return pcap_funcs->set_tstamp_type( handle, type );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_setbuff( void *handle, int size )
|
2014-08-12 00:31:25 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
FIXME( "%p, %d\n", handle, size );
|
2014-08-12 00:31:25 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_setfilter( void *handle, void *program )
|
2014-08-12 00:35:45 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p\n", handle, program );
|
|
|
|
return pcap_funcs->setfilter( handle, program );
|
2014-08-12 00:35:45 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_setnonblock( void *handle, int nonblock, char *errbuf )
|
2014-08-19 00:02:03 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %d, %p\n", handle, nonblock, errbuf );
|
|
|
|
return pcap_funcs->setnonblock( handle, nonblock, errbuf );
|
2014-08-19 00:02:03 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_snapshot( void *handle )
|
2014-08-15 21:54:03 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p\n", handle );
|
|
|
|
return pcap_funcs->snapshot( handle );
|
2014-08-15 21:54:03 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_stats( void *handle, void *stats )
|
2014-08-12 00:30:47 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p\n", handle, stats );
|
|
|
|
return pcap_funcs->stats( handle, stats );
|
2014-08-12 00:30:47 +02:00
|
|
|
}
|
2014-08-19 00:02:22 +02:00
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
const char * CDECL pcap_statustostr( int status )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%d\n", status );
|
|
|
|
return pcap_funcs->statustostr( status );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
int CDECL pcap_tstamp_type_name_to_val( const char *name )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%s\n", debugstr_a(name) );
|
|
|
|
return pcap_funcs->tstamp_type_name_to_val( name );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
const char * CDECL pcap_tstamp_type_val_to_description( int val )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%d\n", val );
|
|
|
|
return pcap_funcs->tstamp_type_val_to_description( val );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:27 +02:00
|
|
|
const char * CDECL pcap_tstamp_type_val_to_name( int val )
|
2021-05-10 15:37:24 +02:00
|
|
|
{
|
|
|
|
TRACE( "%d\n", val );
|
|
|
|
return pcap_funcs->tstamp_type_val_to_name( val );
|
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
int CDECL wsockinit( void )
|
2014-08-19 00:02:22 +02:00
|
|
|
{
|
|
|
|
WSADATA wsadata;
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "\n" );
|
|
|
|
if (WSAStartup( MAKEWORD(1, 1), &wsadata )) return -1;
|
2014-08-19 00:02:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2018-04-09 01:17:19 +02:00
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
static void CDECL pcap_handler_cb( struct handler_callback *cb, const void *hdr, const unsigned char *packet )
|
2018-04-09 01:17:19 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
TRACE( "%p, %p, %p\n", cb, hdr, packet );
|
|
|
|
cb->callback( cb->user, hdr, packet );
|
|
|
|
TRACE( "callback completed\n" );
|
2018-04-09 01:17:19 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:37:23 +02:00
|
|
|
const struct pcap_callbacks pcap_callbacks =
|
2018-04-09 01:17:19 +02:00
|
|
|
{
|
2021-05-10 15:37:23 +02:00
|
|
|
pcap_handler_cb
|
|
|
|
};
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, void *reserved )
|
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls( hinst );
|
|
|
|
if (__wine_init_unix_lib( hinst, reason, &pcap_callbacks, &pcap_funcs ))
|
|
|
|
ERR( "No pcap support, expect problems\n" );
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2018-04-09 01:17:19 +02:00
|
|
|
}
|