I need to change the filter condition dynamically.  So I have another
thread that changes filter expression.

This code works fine on Windows changing the filter condition.  On LINUX
if I change a filter condition no packages come anymore through
pcap_next.


Will it help to use pcap_loop instead of pcap_next (pcap_next_ex on
Windows)? 

Thank you
 

Alex



while((res = pcap_next_ex( m_adhandle, &header, &pkt_data)) >= 0){

                              bpf_u_int32 NetMask=0xffffff;

                              struct bpf_program fcode;

                              if(pcap_compile(m_adhandle, &fcode,
packet_filter, 0, NetMask) <0 )

{

if (changeFilter)

{

            if(pcap_compile(m_adhandle, &fcode, packet_filter, 0,
NetMask) <0 )

            {

                  fprintf(stderr,"\nUnable to compile the packet filter.
Check the syntax.\n");

                                                                  return
-1;

            }

   

      //set the filter

if(pcap_setfilter(m_adhandle, &fcode)<0)

{

                  fprintf(stderr,"\nError setting the filter.\n");

                  return -1;

            }

      }

        

if(res == 0)

            /* Timeout elapsed */

            continue;

      packet_handler(header, pkt_data);

 }





==================================================================
 This is the WinPcap users list. It is archived at
 http://www.mail-archive.com/[EMAIL PROTECTED]/

 To unsubscribe use 
 mailto: [EMAIL PROTECTED]
==================================================================

Reply via email to