hi all,


QUESTION 1
do you have any plans to release a multiprocessor version of the
winpcap/libpcap library?


QUESTION 2
this is pretty long, I hope somebody has enough patience to read it.
I'm using libpcap(win32 version) to dump some network traffic.

I start the capture like below:
"
m_pfp = pcap_open_live(m_szDevice, 1514, 1, 20, m_szErr) );
//obtain the subnet
pcap_lookupnet(m_szDevice, &m_SubNet, &m_NetMask, m_szErr);
//compile the filter
pcap_compile(m_pfp, &m_fcode, m_szFilter, 1, m_NetMask) <0 );
//set the filter
pcap_setfilter(m_pfp, &m_fcode) < 0 );
pcap_loop(m_pfp, 0, My_Sniffer::dispatcher_handler, NULL);
"

stop the capture:
"
if (m_pfp){
        pcap_close(m_pfp);
        m_pfp = NULL;
}
//!!!PROBLEM LINE!!!
m_dumpfile.close();//(m_dumpfile is an ofstream buffer)
"

the My_Sniffer::dispatcher_handler() callback does some processing on
packages and then dumps content in the m_dumfile buffer.

AND THE PROBLEM IS :
after the "m_dumpfile.close()" line, I get an "Access violation error"
which leads to a line like "dumpfile << "bla, bla"; " in my
dispatcher_handler callback function.

first thought was : the current dispatcher_handler() call did not
finished. 
so i tried to wait in the closing procedure.
new code looks like:
"
dispatcher_handler(...)
{
ResetEvent(m_hEvent);
...processing...
SetEvent(m_hEvent);
}

and the closing procedure is :
"
pcap_close();
WaitForSingleEvent(m_hEvent);
dumpfile.close();
"

but i still get the same error, which means the dispatcher_handler is 
called at least once AFTER pcap_close().
IS THIS TRUE? or is something wrong with my code?

If true, the only solutions I can think of are:
1. rewrite the pcap_close() function so it does not return until the
capture buffer is emptied.
2. signal an event when capture buffer is emptied.

Can you do this? or at least give me some hints where to do such
changes?( pcap_read() or pcap_loop() functions seem a good place for
solution 2)

Many thanks in advance!

Paul






 

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

Reply via email to