[Winpcap-users] after 32 loops pcap_findalldevs() starts returning 0 adapters. Why?

Test santosh.payasi at bytechindia.com
Thu May 11 08:55:09 GMT 2006


Hi All, 

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.

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.

void main()

{

int ListCount;

HANDLE handleArray[12];

pcap_t *deviceArray[12];

char errbuffer[PCAP_ERRBUF_SIZE];

pcap_if_t *allDevs;

pcap_if_t *D;

int p=0;

//FILE *lf;

//lf = fopen("C:\\Santosh\\Test.txt", "a+");

//fflush(lf);

while(1)

{

Sleep(500); //Retrieve All Device List

if (pcap_findalldevs(&allDevs, errbuffer) == -1)

{

//If error occurs then Loop back

continue;

}

printf("\n Get List Device %d %s ",p,(allDevs==NULL)?"TRUE":"FALSE");

//fflush(lf);

ListCount = 0;

for(D=allDevs; D; D=D->next)

{

if (!(D->flags & PCAP_IF_LOOPBACK))

{

//if List of devices is more than 12 

if (ListCount==12)

continue;

{

//Open a device

if ((deviceArray[ListCount]=pcap_open_live(D->name, 65536, 0, 1000, errbuffer)) == NULL) 

{

//if device is disabled

printf("\n Disabled Device %d",ListCount);

// fflush(lf);

continue;

}

printf("\n Active Device %d",ListCount);

// fflush(lf);

//Get event Handle for the Adapter or Device

handleArray[ListCount++] = pcap_getevent(deviceArray[ListCount]); 

}

}

else

{

printf("\n Device %s \t%s",D->name,D->description);

//fflush(lf);

}

}

printf("\nPlease see CurrentADL = %d ", ListCount);

//fflush(lf);


for(p=0; p < ListCount; p++)

{

CloseHandle(handleArray[p]);

handleArray[p]=NULL;

deviceArray[p]=NULL;

//pcap_close(deviceArray[p]);

}

pcap_freealldevs(allDevs); 

}

}



santosh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20060511/40178bb3/attachment.htm


More information about the Winpcap-users mailing list