[Winpcap-users] Re: Correct Initialization for winpcap

matt jaffa mjaffa at gmail.com
Wed Mar 29 23:23:03 GMT 2006


So what I am really asking is all about the pcap_findalldevs call. Is this a
neccessary call or is there another call I can use? Why was pcap_lookupdev()
depracated? Is there anyway to get the default adapter, active device on the
system?

Thanks,
Matt

On 3/28/06, matt jaffa <mjaffa at gmail.com> wrote:
>
>  Hi,
>
> I was wondering if how I was first initially using winpcap is the correct
> way of doing it.
> So I am looking up all the devices then creating a thread for each device
> to listen for packets on.
> Does this code look right?  (Code is below).
>
> Thanks,
> Matt
>
>
> pcap_if_t *alldevs;
>
> pcap_if_t *d;
>
> int i=0;
>
> char errbuf[PCAP_ERRBUF_SIZE];
>
>
>
> if(pcap_findalldevs(&alldevs, errbuf) == -1)    // This is where it hangs
> when are program is a service
>
> {
>
> fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
>
> return;
>
> }
>
> for(d=alldevs; d; d=d->next)
>
> {
>
> char *deviceName = new char[256];
>
> sprintf(deviceName, "%s", d->name);
>
> CreateThread(NULL, 0, &StartRoutine, deviceName, 0, NULL);     // Each of
> these threads listen for packets on each device
>
> }
>
> pcap_freealldevs(alldevs);
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20060329/e557e861/attachment.htm


More information about the Winpcap-users mailing list