[Winpcap-users] pcap_next_ex() not receiving packets

Ryan Fowler ryan.fowler at thomsonreuters.com
Wed Jul 2 07:14:15 GMT 2008


The filter is "ether dst FF:02:FF:FF:FF:FF".  But setting to promiscuous
mode solved it.

 

Thanks,

Ryan

 

PS. Now I just need to read more about promiscuous mode so I don't make
that mistake again...

 

From: winpcap-users-bounces at winpcap.org
[mailto:winpcap-users-bounces at winpcap.org] On Behalf Of Gianluca Varenni
Sent: 01 July 2008 17:44
To: winpcap-users at winpcap.org
Subject: Re: [Winpcap-users] pcap_next_ex() not receiving packets

 

Which capture filter do you use? Also, do you capture any packet if you
set promiscuous mode on (setting the promiscuous parameter of
pcap_open_live to 1)?

 

Have a nice day

GV

	----- Original Message ----- 

	From: Ryan Fowler <mailto:ryan.fowler at thomsonreuters.com>  

	To: winpcap-users at winpcap.org 

	Sent: Tuesday, July 01, 2008 6:47 AM

	Subject: [Winpcap-users] pcap_next_ex() not receiving packets

	 

	Hi,

	 

	I am trying to receive packets using pcap_next_ex(), but for
some reason I keep getting a timeout.  I know that packets are coming
into the machine because I can see them via WinDump.  The odd part is
that when I run WinDump concurrently with my test application, I start
to see packets in the test app (as well as in WinDump).  But without
WinDump, I get no packets on the test app at all.

	 

	I am guessing that there is something I need to do to "start"
the packet driver capturing, although I thought that's what
pcap_open_live does, so I'm not quite sure on that.

	 

	My code so far is a fairly liberal sampling of the pktdump_ex
example:

	 

	      /* Open the adapter */

	      if ((m_pSessionHandle =
pcap_open_live(m_pReceiveDevice->name,    // name of the device

	                                    65536,      // 65536 means
the whole packet will be captured.

	                                    0,    // non promiscuous
mode (nonzero means promiscuous)

	                                    1000,       // read timeout

	                                    errbuf      // error
buffer)) == NULL)

	                  {

	                        // Error code

	                  }

	 

	      std::cout << "Filter: " << m_strFilter << std::endl;

	      if ( !m_strFilter.empty() )

	      {

	            bpf_u_int32 NetMask = 0;

	            struct bpf_program fcode;

	 

	            //compile the filter

	            if(pcap_compile(m_pSessionHandle, &fcode,
const_cast<char*>(m_strFilter.c_str()), 1, NetMask) < 0)

	            {

	                  // Error code

	            }

	 

	            //set the filter

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

	            {

	                  // Error code

	            }

	      }

	 

	      /* At this point, we don't need the device list any more.
Free it */

	      pcap_freealldevs(alldevs);

	 

	And later on:

	 

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

	      {

	            if(res == 0)

	            {

	                  /* Timeout elapsed */

	                  OutputDebugString(L"No packets!\n");

	                  continue;

	            }

	//...

	      }

	 

	 

	Ryan Fowler
	Software Engineer

	Thomson Reuters 

	
________________________________


	_______________________________________________
	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/20080702/51272ac1/attachment-0001.htm


More information about the Winpcap-users mailing list