tcpdump mailing list archives
Re: Problems with libpcap and C++
From: Mike Kershaw <dragorn () nerv-un net>
Date: Wed, 14 Jun 2006 13:43:27 -0400
On Wed, Jun 14, 2006 at 04:48:02PM +0200, David Rosal wrote:
I'm writing a packet sniffer in C++ using libpcap-0.9.4. I've tried to use a class function member as a callback for pcap_loop(), but the compiler complains that arguments don't match. The code is something like this (I have simplified it): 8<----------------------------- class X { public: // This is the callback, defined below void dumper(u_char *u, const struct pcap_pkthdr *h, const u_char *p); };
To pass a C++ member function as a callback it must be static, or you must have mechanisms to allow you to pass an instantiated object as well. -m -- Mike Kershaw/Dragorn <dragorn () kismetwireless net> GPG Fingerprint: 3546 89DF 3C9D ED80 3381 A661 D7B2 8822 738B BDB1 "Yes, yes, LORD OF HUMANS! I will rule you ALL with an iron fist! YOU! OBEY THE FIST!" -- Invader Zim
Attachment:
_bin
Description:
Current thread:
- Problems with libpcap and C++ David Rosal (Jun 14)
- Re: Problems with libpcap and C++ Guy Harris (Jun 14)
- Re: Problems with libpcap and C++ Ury Segal (Jun 14)
- Re: Problems with libpcap and C++ David Rosal (Jun 14)
- Re: Problems with libpcap and C++ Mike Kershaw (Jun 14)