<!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.2900.2802" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=mjaffa@gmail.com href="mailto:mjaffa@gmail.com">matt jaffa</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=winpcap-users@winpcap.org
href="mailto:winpcap-users@winpcap.org">winpcap-users@winpcap.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, March 29, 2006 3:23
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Winpcap-users] Re: Correct
Initialization for winpcap</DIV>
<DIV><FONT size=2></FONT><BR></DIV>
<DIV>So what I am really asking is all about the pcap_findalldevs call. Is
this a neccessary call or is </DIV>
<DIV><FONT size=2></FONT> </DIV></BLOCKQUOTE>
<DIV><FONT size=2>Yes, if you want to know the list of available
adapters.</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT size=2></FONT> </DIV>
<DIV>there another call I can use? Why was pcap_lookupdev() depracated?
</DIV>
<DIV> </DIV></BLOCKQUOTE>
<DIV><FONT size=2>Because it is broken: first of all it's not thread safe at all
(it returns an internal static buffer allocated by wpcap.dll), and it has a
different behavior on windows vs. other platforms (if I remember well, on all
the other platforms except windows it returns the first adapter, only).
findalldevs returns more information like the IP addresses and the description
of each adapter, if available.</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT size=2></FONT> </DIV>
<DIV>Is there anyway to get the default adapter, active device on the system?
</DIV>
<DIV><FONT size=2></FONT> </DIV></BLOCKQUOTE>
<DIV><FONT size=2>No. You need to use either pcap_findalldevs of pcap_lookupdev,
which end up in calling PacketGetAdapterNames. I think there's some bug (or in
any case strange behavior) in PacketGetAdapterNames that causes the problems you
are encountering. Can you provide us some code that we can use to debug the
issue? </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Have a nice day</FONT></DIV>
<DIV><FONT size=2>GV</FONT><FONT size=2></FONT><FONT
size=2></FONT><BR> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<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>
<P>
<HR>
<P></P>_______________________________________________<BR>Winpcap-users
mailing
list<BR>Winpcap-users@winpcap.org<BR>https://www.winpcap.org/mailman/listinfo/winpcap-users<BR></BLOCKQUOTE></BODY></HTML>