<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi All, </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>We are using WinPcap 3.0 to create an application,
the problem wwhich we are encountering is after 32 loops pcap_findalldevs()
starts returning 0 adapters.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>We are simply counting the available adapters after
1/2 seconds . Following is the code which we are using.Kindly advise why after
approx 32 loops it starts returning 0 adapters.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT color=#0000ff size=2>
<P>void</FONT><FONT size=2> main()</P>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> ListCount;</P>
<P>HANDLE handleArray[12];</P>
<P>pcap_t *deviceArray[12];</P>
<P></FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2>
errbuffer[PCAP_ERRBUF_SIZE];</P>
<P>pcap_if_t *allDevs;</P>
<P>pcap_if_t *D;</P>
<P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> p=0;</P>
<P></FONT><FONT color=#008000 size=2>//FILE *lf;</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//lf = fopen("C:\\Santosh\\Test.txt",
"a+");</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//fflush(lf);</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>while</FONT><FONT size=2>(1)</P>
<P>{</P>
<P>Sleep(500); </FONT><FONT color=#008000 size=2>//Retrieve All Device
List</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>
(pcap_findalldevs(&allDevs, errbuffer) == -1)</P>
<P>{</P>
<P></FONT><FONT color=#008000 size=2>//If error occurs then Loop
back</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>continue</FONT><FONT size=2>;</P>
<P>}</P>
<P>printf(</FONT><FONT color=#800000 size=2>"\n Get List Device %d %s
"</FONT><FONT size=2>,p,(allDevs==NULL)?</FONT><FONT color=#800000
size=2>"TRUE"</FONT><FONT size=2>:</FONT><FONT color=#800000
size=2>"FALSE"</FONT><FONT size=2>);</P>
<P></FONT><FONT color=#008000 size=2>//fflush(lf);</P></FONT><FONT size=2>
<P>ListCount = 0;</P>
<P></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>(D=allDevs; D;
D=D->next)</P>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (!(D->flags &
PCAP_IF_LOOPBACK))</P>
<P>{</P>
<P></FONT><FONT color=#008000 size=2>//if List of devices is more than 12
</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (ListCount==12)</P>
<P></FONT><FONT color=#0000ff size=2>continue</FONT><FONT size=2>;</P>
<P>{</P>
<P></FONT><FONT color=#008000 size=2>//Open a device</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>
((deviceArray[ListCount]=pcap_open_live(D->name, 65536, 0, 1000, errbuffer))
== NULL) </P>
<P>{</P>
<P></FONT><FONT color=#008000 size=2>//if device is disabled</P></FONT><FONT
size=2>
<P>printf(</FONT><FONT color=#800000 size=2>"\n Disabled Device %d"</FONT><FONT
size=2>,ListCount);</P>
<P></FONT><FONT color=#008000 size=2>// fflush(lf);</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>continue</FONT><FONT size=2>;</P>
<P>}</P>
<P>printf(</FONT><FONT color=#800000 size=2>"\n Active Device %d"</FONT><FONT
size=2>,ListCount);</P>
<P></FONT><FONT color=#008000 size=2>// fflush(lf);</P></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2>//Get event Handle for the Adapter or
Device</P></FONT><FONT size=2>
<P>handleArray[ListCount++] = pcap_getevent(deviceArray[ListCount]); </P>
<P>}</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2>else</P></FONT><FONT size=2>
<P>{</P>
<P>printf(</FONT><FONT color=#800000 size=2>"\n Device %s \t%s"</FONT><FONT
size=2>,D->name,D->description);</P>
<P></FONT><FONT color=#008000 size=2>//fflush(lf);</P></FONT><FONT size=2>
<P>}</P>
<P>}</P>
<P>printf(</FONT><FONT color=#800000 size=2>"\nPlease see CurrentADL = %d
"</FONT><FONT size=2>, ListCount);</P>
<P></FONT><FONT color=#008000 size=2>//fflush(lf);</P></FONT><FONT size=2>
<P></P>
<P></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>(p=0; p <
ListCount; p++)</P>
<P>{</P>
<P>CloseHandle(handleArray[p]);</P>
<P>handleArray[p]=NULL;</P>
<P>deviceArray[p]=NULL;</P>
<P></FONT><FONT color=#008000
size=2>//pcap_close(deviceArray[p]);</P></FONT><FONT size=2>
<P>}</P>
<P>pcap_freealldevs(allDevs); </P>
<P>}</P>
<P>}</P>
<P> </P>
<P><FONT face=Arial>santosh</FONT></P></FONT></DIV></BODY></HTML>