mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 20:20:48 +00:00
wpcap: Implement pcap_dispatch.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53104 Signed-off-by: Roman Pišl <rpisl@seznam.cz> Signed-off-by: André Zwing <nerv@dawncrow.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
569c27945e
commit
556077e674
|
@ -99,15 +99,6 @@ const char * CDECL pcap_datalink_val_to_name( int link )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CDECL pcap_dispatch( struct pcap *pcap, int count,
|
|
||||||
void (CALLBACK *callback)(unsigned char *, const struct pcap_pkthdr_win32 *, const unsigned char *),
|
|
||||||
unsigned char *user )
|
|
||||||
{
|
|
||||||
/* FIXME: reimplement on top of pcap_next_ex */
|
|
||||||
FIXME( "%p, %d, %p, %p: not implemented\n", pcap, count, callback, user );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDECL pcap_dump( unsigned char *user, const struct pcap_pkthdr_win32 *hdr, const unsigned char *packet )
|
void CDECL pcap_dump( unsigned char *user, const struct pcap_pkthdr_win32 *hdr, const unsigned char *packet )
|
||||||
{
|
{
|
||||||
struct dump_params params = { user, hdr, packet };
|
struct dump_params params = { user, hdr, packet };
|
||||||
|
@ -543,6 +534,38 @@ const unsigned char * CDECL pcap_next( struct pcap *pcap, struct pcap_pkthdr_win
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CDECL pcap_dispatch( struct pcap *pcap, int count,
|
||||||
|
void (CALLBACK *callback)(unsigned char *, const struct pcap_pkthdr_win32 *, const unsigned char *),
|
||||||
|
unsigned char *user )
|
||||||
|
{
|
||||||
|
int processed = 0;
|
||||||
|
TRACE( "%p, %d, %p, %p\n", pcap, count, callback, user );
|
||||||
|
|
||||||
|
while (processed < count)
|
||||||
|
{
|
||||||
|
struct pcap_pkthdr_win32 *hdr = NULL;
|
||||||
|
const unsigned char *data = NULL;
|
||||||
|
|
||||||
|
int ret = pcap_next_ex( pcap, &hdr, &data );
|
||||||
|
|
||||||
|
if (ret == 1)
|
||||||
|
processed++;
|
||||||
|
else if (ret == 0)
|
||||||
|
break;
|
||||||
|
else if (ret == -2)
|
||||||
|
{
|
||||||
|
if (processed == 0) return -2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
callback( user, hdr, data );
|
||||||
|
}
|
||||||
|
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
static char *strdupWA( const WCHAR *src )
|
static char *strdupWA( const WCHAR *src )
|
||||||
{
|
{
|
||||||
char *dst;
|
char *dst;
|
||||||
|
|
Loading…
Reference in a new issue