[Winpcap-users] RE: Opening a port multiple times and filters

Paul Rocca Paul.Rocca at audiosoft.co.uk
Fri Jan 11 11:11:34 GMT 2008


Thanks for the suggestion. I tried it, but it doesn't appear to have any
effect, I didn't think it would as I can start and stop threads  at different
times minutes apart and still see this behaviour.
 
Best Wishes
 
Paul
 
----- Original Message ----- 

Can you please try wrapping all the calls to pcap_compile() with a critical section or a mutex? That API is not thread safe i.e. if you happen to call that function concurrently from multiple threads, the result is undefined.

Have a nice day
GV

  ----- Original Message ----- 
  From: Paul Rocca 
  To: winpcap-users at winpcap.org <https://www.winpcap.org/mailman/listinfo/winpcap-users>  
  Sent: Tuesday, January 08, 2008 5:07 AM
  Subject: [Winpcap-users] Opening a port multiple times and filters


  I am wrining an app to capture various multicast streams to seperate files.
  In order to make my program easier to write I have 1 thread per stream, and
  open the NIC card multiple times and pull out the packets and filter them
  in my code using src/dst ip addresses. This appears to work great, but
  a bit CPU intensive. 
  I thought it might be easier then to use the winpcap filter function, so I wrote
  a bit of code to do this and that initially appeared to work great, BUT
  on further investigation, it would appear that winpcap only uses the last
  filter that was set with pcap_setfilter. i.e.
  if I have three threads and in in each one I open an instances of my port and
  in each thread set a filter on each one (eg thread 1 = 'dst ip 225.0.0.1', 
  thread 2 = 'dst ip 225.0.0.2', thread 3 = 'dst ip 225.0.0.3'), then start calling
  pcap_next_ex() in each thread, all three threads will only receive packets
  matching 'dst ip 225.0.0.3'

  Is this "as designed"?, any ideas for a workaround, or is it back to filtering
  in my software?

  TIA

  Paul

  _______________________________________________________________________
  This e-mail has been scanned for all viruses by Star Internet. The
  service is powered by MessageLabs.
  _______________________________________________________________________




_______________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs.
_______________________________________________________________________



More information about the Winpcap-users mailing list