<div>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?
<br> </div>
<div>Thanks,</div>
<div>Matt<br> </div>
<div><span class="gmail_quote">On 3/28/06, <b class="gmail_sendername">matt jaffa</b> <<a href="mailto:mjaffa@gmail.com">mjaffa@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div style="DIRECTION: ltr">
<div>Hi,</div>
<div> </div>
<div>I was wondering if how I was first initially using winpcap is the correct way of doing it.</div>
<div>So I am looking up all the devices then creating a thread for each device to listen for packets on.</div>
<div>Does this code look right? (Code is below).</div>
<div> </div>
<div>Thanks,</div>
<div>Matt</div>
<div> </div>
<div><font size="2">
<p>pcap_if_t *alldevs;</p>
<p>pcap_if_t *d;</p>
<p></p></font><font color="#0000ff" size="2">int</font><font size="2"> i=0;
<p></p></font><font color="#0000ff" size="2">char</font><font size="2"> errbuf[PCAP_ERRBUF_SIZE];
<p></p>
<p> </p>
<p></p></font><font color="#0000ff" size="2">if</font><font size="2">(pcap_findalldevs(&alldevs, errbuf) == -1) // This is where it hangs when are program is a service
<p>{</p>
<p>fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);</p>
<p></p></font><font color="#0000ff" size="2">return</font><font size="2">;
<p>}</p>
<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">char</font><font size="2"> *deviceName = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#0000ff" size="2">char</font><font size="2">[256];
<p>sprintf(deviceName, "%s", d->name);</p>
<p>CreateThread(NULL, 0, &StartRoutine, deviceName, 0, NULL); // Each of these threads listen for packets on each device</p>
<p>}</p>
<p>pcap_freealldevs(alldevs);</p></font></div></div></blockquote></div><br>