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

Gianluca Varenni gianluca.varenni at cacetech.com
Fri Jan 11 02:01:36 GMT 2008


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 
  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.
  _______________________________________________________________________



------------------------------------------------------------------------------


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20080111/6623903d/attachment.htm


More information about the Winpcap-users mailing list