<!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.2963" 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=s_rsy@yahoo.com href="mailto:s_rsy@yahoo.com">Ravi Sankar</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> Tuesday, October 10, 2006 4:44
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Winpcap-users] Different
Adaptor list when using initilize COMusing Mulitithreads....</DIV>
<DIV><BR></DIV>
<DIV>Hello All</DIV>
<DIV> </DIV>
<DIV>I am comming accross a strange behaviour in getting list of
adaptors.</DIV>
<DIV> </DIV>
<DIV>My code </DIV>
<DIV> </DIV>
<DIV>// Function to get list of adaptors</DIV><FONT size=2>
<DIV>pcap_if_t* GetAllDevices () {</DIV>
<DIV>pcap_if_t *l_pAllDevs;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2>
errbuf[PCAP_ERRBUF_SIZE];</DIV>
<DIV></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>
(pcap_findalldevs_ex (PCAP_SRC_IF_STRING, NULL, &l_pAllDevs, errbuf) ==
-1) {</DIV>
<DIV></FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> NULL;</DIV>
<DIV>} </DIV>
<DIV></FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2>
l_pAllDevs;</DIV>
<DIV>}</DIV></FONT>
<DIV> </DIV>
<DIV>// code which uses the above function to get list</DIV>
<DIV> </DIV><FONT size=2>
<DIV>pcap_if_t *l_Devices = NULL, *d = NULL;</DIV>
<DIV>CString l_strTemp;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> l_iCount =
1;</DIV>
<DIV>l_Devices = GetAllDevices ();</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>(d=l_Devices; d;
d=d->next)</DIV>
<DIV>{</DIV>
<DIV>l_strTemp.Format ("%d - %s", l_iCount++,
d->description);</DIV></FONT><FONT color=#000000 size=2>
<DIV>((CComboBox*)GetDlgItem (IDC_COMBO1))->AddString
(l_strTemp);</DIV></FONT><FONT size=2>
<DIV>}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>If I use the above code <STRONG>BEFORE </STRONG>calling </DIV><FONT
size=2>
<DIV>HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);</DIV>
<DIV> </DIV>
<DIV>I am getting 2 adaptors </DIV>
<DIV>1 - "Network adapter 'Generic dialup adapter' on local host"</DIV>
<DIV>2 - "Network adapter 'Broadcom NetXtreme Gigabit Ethernet Driver
(Microsoft's Packet Scheduler) ' on local host"</DIV>
<DIV> </DIV>
<DIV>same code if i call <STRONG>AFTER</STRONG> calling </DIV>
<DIV>HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);</DIV>
<DIV> </DIV>
<DIV>I am getting 1 adaptor </DIV>
<DIV>1 - "Network adapter 'Broadcom NetXtreme Gigabit Ethernet
Driver (Microsoft's Packet Scheduler) ' on local host"</DIV>
<DIV> </DIV>
<DIV>Rest of packet capturing is working fine, I am facing issue in
getting number of adaptors only. In My application I have to Initilize
COM with MULTITHREAD. i can not avoid that. </DIV>
<DIV> </DIV>
<DIV>My clarrifications</DIV>
<DIV>1) Can I use <FONT size=2>pcap_findalldevs_ex in MULTTHREADED
environment?</FONT></DIV>
<DIV> </DIV></BLOCKQUOTE>
<DIV>Yes, but if you initialize COM with the COINIT_MULTITHREADED threading
model you won't be able to capture from dialup/VPN adapters ("generic
dialup adapter"). The reason is that in order to capture from such adapters we
make use of a Microsoft COM component (NetMon) that is not compatible with the
MULTITHREADED threading model.</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV> </DIV><FONT size=2>
<DIV>2) what is this "Generic Dialup Adaptor"?</DIV>
<DIV> </DIV></BLOCKQUOTE>
<DIV>It's a generic adapter to capture from dialup/VPN. It's the only one that
allows you to capture the initial PPP handshake packets at the beginning of a
dialup connection.</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV> </DIV>
<DIV>3) It is good that I get only Ethernet adaptors in list. End user will
not get confused with other adaptors. It raises another doubt, whether it can
detect multiple Ethernet cards if present in a PC? (I don't have a PC where 2
Ethenet adaptors are used, so i could not test)</DIV>
<DIV> </DIV></BLOCKQUOTE>
<DIV>pcap_findalldevs(ex) will detect all the adapters in the system supported
by WinPcap. Remember that Ethernet is not the only supported type of adapters
(although it's the most common).</DIV>
<DIV> </DIV>
<DIV>Have a nice day</DIV>
<DIV>GV<BR></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"></FONT>
<DIV> </DIV>
<DIV>Thanks for your time,</DIV>
<DIV>Ravi </DIV></FONT></FONT>
<P></P><FONT size=2></FONT>
<HR SIZE=1>
Stay in the know. Pulse on the new Yahoo.com. <A
href="http://us.rd.yahoo.com/evt=42974/*http://www.yahoo.com/preview">Check it
out.</A>
<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>