Hi,
I am writing a statistical protocol analyzer running under Windows with
WinPcap.
The problem is: The pcap_loop function for starting to capture the
packets wants a C style callback function, but I need that callback
function to have access to several class variables, so this callback
function should be a member function.
I know that it is not possible to use a member function directly,
because of the additional parameter, the pointer to the class.
I thought, maybe I could use boost::function and boost::bind, but I am
not sure if my solution is correct, so it would be very nice if some of
you guys could just look over it and tell me if this is a good way to do
this.
This is my code for starting the capture:
void MyClass::startCapturing()
{
boost::function < void (u_char *, const struct pcap_pkthdr *, const
u_char *) > f;
f = boost::bind(&MyClass::packetHandler, this, _1, _2, _3);
pcap_handler p = *(f.target