Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53104 Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/wpcap/wpcap.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c index b140deeb3d2..a295819f7fe 100644 --- a/dlls/wpcap/wpcap.c +++ b/dlls/wpcap/wpcap.c @@ -68,15 +68,6 @@ int CDECL pcap_compile( struct pcap *pcap, void *program, const char *buf, int o return PCAP_CALL( compile, ¶ms ); }
-struct pcap * CDECL pcap_create( const char *src, char *errbuf ) -{ - struct pcap *ret; - struct create_params params = { src, errbuf, &ret }; - TRACE( "%s, %p\n", src, errbuf ); - PCAP_CALL( create, ¶ms ); - return ret; -} - int CDECL pcap_datalink( struct pcap *pcap ) { TRACE( "%p\n", pcap ); @@ -579,6 +570,26 @@ static char *map_win32_device_name( const char *dev ) return ret; }
+struct pcap * CDECL pcap_create( const char *source, char *errbuf ) +{ + char *unix_dev; + struct pcap *ret; + TRACE( "%s, %p\n", source, errbuf ); + + if (!(unix_dev = map_win32_device_name( source ))) + { + if (errbuf) sprintf( errbuf, "Unable to open the adapter." ); + return NULL; + } + else + { + struct create_params params = { unix_dev, errbuf, &ret }; + PCAP_CALL( create, ¶ms ); + } + free( unix_dev ); + return ret; +} + static struct pcap *open_live( const char *source, int snaplen, int promisc, int timeout, char *errbuf ) { char *unix_dev;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53104 Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/wpcap/wpcap.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c index a295819f7fe..c5a4b391af5 100644 --- a/dlls/wpcap/wpcap.c +++ b/dlls/wpcap/wpcap.c @@ -99,15 +99,6 @@ const char * CDECL pcap_datalink_val_to_name( int link ) 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 ) { 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; }
+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 = 0; + const unsigned char *data = 0; + + 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 ) { char *dst;
Am 02.07.22 um 13:18 schrieb Roman Pišl:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53104 Signed-off-by: Roman Pišl rpisl@seznam.cz
dlls/wpcap/wpcap.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c index a295819f7fe..c5a4b391af5 100644 --- a/dlls/wpcap/wpcap.c +++ b/dlls/wpcap/wpcap.c @@ -99,15 +99,6 @@ const char * CDECL pcap_datalink_val_to_name( int link ) 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 ) { 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; }
+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 = 0;
const unsigned char *data = 0;
Initialize pointers with NULL instead of 0
Am 02.07.22 um 13:18 schrieb Roman Pišl:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53104 Signed-off-by: Roman Pišl rpisl@seznam.cz
dlls/wpcap/wpcap.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c index b140deeb3d2..a295819f7fe 100644 --- a/dlls/wpcap/wpcap.c +++ b/dlls/wpcap/wpcap.c @@ -68,15 +68,6 @@ int CDECL pcap_compile( struct pcap *pcap, void *program, const char *buf, int o return PCAP_CALL( compile, ¶ms ); }
-struct pcap * CDECL pcap_create( const char *src, char *errbuf ) -{
- struct pcap *ret;
- struct create_params params = { src, errbuf, &ret };
- TRACE( "%s, %p\n", src, errbuf );
- PCAP_CALL( create, ¶ms );
- return ret;
-}
- int CDECL pcap_datalink( struct pcap *pcap ) { TRACE( "%p\n", pcap );
@@ -579,6 +570,26 @@ static char *map_win32_device_name( const char *dev ) return ret; }
+struct pcap * CDECL pcap_create( const char *source, char *errbuf ) +{
- char *unix_dev;
- struct pcap *ret;
- TRACE( "%s, %p\n", source, errbuf );
- if (!(unix_dev = map_win32_device_name( source )))
- {
if (errbuf) sprintf( errbuf, "Unable to open the adapter." );
return NULL;
- }
- else
- {
struct create_params params = { unix_dev, errbuf, &ret };
PCAP_CALL( create, ¶ms );
- }
- free( unix_dev );
- return ret;
+}
- static struct pcap *open_live( const char *source, int snaplen, int promisc, int timeout, char *errbuf ) { char *unix_dev;
Signed-off-by: André Zwing nerv@dawncrow.de