tcpdump mailing list archives
Re: pcap_loop
From: Michael Krüger <mickrulist () voipfuture com>
Date: Tue, 3 Jun 2008 13:57:21 +0200
Am Dienstag, 3. Juni 2008 10:13:49 schrieb m. kh:
HI
how to use a the last argument of pcap_loop ?
in my program i use :
u_char *user;
user="the message ";
pcap_loop(handle, -1, (pcap_handler) callback , user);
but not succe ,help me
give me example ?
Well this is very useful if you use C++ class instances. In that case you are able to pass the class instance pointer
to the method, so that a specific class instance is called by the pcap_loop method.
CMyConsumer consumer;
...
pcap_loop(handle, -1, (pcap_handler) callback , &consumer);
...
The consumer class needs to have a static member like processData... which does take the packet data as well as the
user parameter:
...
// this is within the pcap_handler method
CMyConsumer::processData(user /*which is the user data*/, pcap_t* data /*which is the packet data*/
...
The static processData method can now invoke a instance private method of the class to process the data:
void CMyConsumer::processData(void* instance, pcap_t* data)
{
((CMyConsumer* )instance)->processInternal(data);
...
}
Regards,
Michael
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- pcap_loop m. kh (Jun 03)
- Re: pcap_loop Michael Krüger (Jun 03)
- Re: pcap_loop khaled (Jun 03)
- Re: pcap_loop Guy Harris (Jun 03)
- Re: pcap_loop khaled (Jun 03)
- Re: pcap_loop Eloy Paris (Jun 03)
- Re: pcap_loop Michael Krüger (Jun 03)
