[Winpcap-users] Different Adaptor list when using initilize COMusing Mulitithreads....

Gianluca Varenni gianluca.varenni at cacetech.com
Tue Oct 10 14:36:50 GMT 2006


  ----- Original Message ----- 
  From: Ravi Sankar 
  To: winpcap-users at winpcap.org 
  Sent: Tuesday, October 10, 2006 4:44 AM
  Subject: [Winpcap-users] Different Adaptor list when using initilize COMusing Mulitithreads....


  Hello All

  I am comming accross a strange behaviour in getting list of adaptors.

  My code 

  // Function to get list of adaptors
  pcap_if_t* GetAllDevices () {
  pcap_if_t *l_pAllDevs;
  char errbuf[PCAP_ERRBUF_SIZE];
  if (pcap_findalldevs_ex (PCAP_SRC_IF_STRING, NULL, &l_pAllDevs, errbuf) == -1) {
  return NULL;
  } 
  return l_pAllDevs;
  }

  // code which uses the above function to get list

  pcap_if_t *l_Devices = NULL, *d = NULL;
  CString l_strTemp;
  int l_iCount = 1;
  l_Devices = GetAllDevices ();
  for(d=l_Devices; d; d=d->next)
  {
  l_strTemp.Format ("%d - %s", l_iCount++, d->description);
  ((CComboBox*)GetDlgItem (IDC_COMBO1))->AddString (l_strTemp);
  }



  If I use the above code BEFORE calling 
  HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);

  I am getting 2 adaptors 
  1 - "Network adapter 'Generic dialup adapter' on local host"
  2 - "Network adapter 'Broadcom NetXtreme Gigabit Ethernet Driver (Microsoft's Packet Scheduler) ' on local host"

  same code if i call AFTER calling 
  HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);

  I am getting 1 adaptor 
  1 - "Network adapter 'Broadcom NetXtreme Gigabit Ethernet Driver (Microsoft's Packet Scheduler) ' on local host"

  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. 

  My clarrifications
  1) Can I use pcap_findalldevs_ex in MULTTHREADED environment?

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.

  2) what is this "Generic Dialup Adaptor"?

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.

  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)

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).

Have a nice day
GV


  Thanks for your time,
  Ravi 


------------------------------------------------------------------------------
  Stay in the know. Pulse on the new Yahoo.com. Check it out. 


------------------------------------------------------------------------------


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20061010/44a11f5b/attachment.htm


More information about the Winpcap-users mailing list