<div>Hi,</div>
<div>Yes, WMI is very weird in some aspects that should normally be really really simple.</div>
<div>&nbsp;</div>
<div>The suggestion to ignore the #Number suffix is not very nice because this will make it impossible to have two identical adapters connected to a computer. As I said previously, this is exactly my case :-).</div>
<div>&nbsp;</div>
<div>
<div>A Win32_PnPEntity instance exists for&nbsp;every adapter, even for those that are not removable, even for legacy devices.</div>
<div>&nbsp;</div>
<div>There is no need for very complex handling of the cases when the adapter is added/removed.</div>
<div>Here&nbsp;is how I implemented it:</div>
<div>&nbsp;</div></div>
<div>1. Find the Index of the adapter, knowing only the ifname (GUID)</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT Index FROM Win32_NetworkAdapterConfiguration&nbsp;WHERE SettingID='{bla bla bla}'</div>
<div>&nbsp;&nbsp;&nbsp; This will always work, no fallback based on adapter description is needed.</div>
<div>&nbsp;</div>
<div>2. Register for async events on MSNdis_StatusMediaConnect, MSNdis_StatusMediaDisconnect, ... WITHOUT using a filter. The event will be filtered later when it is received.</div>
<div>&nbsp;</div>
<div>3. When the event is received, look for the Win32_PnPEntity with the Name equal to the InstanceName of the event, get its PNPDeviceId, get the Win32_NetworkAdapter which has this PNPDeviceId. Compare the Index attribute of the found Win32_NetworkAdapter with the index obtained in step 1. If they match, the event is for the right adapter, otherwise drop it.
</div>
<div>This works because the Index of an adapter is assigned to it when its driver is first installed on the system and it never changes, even if the device&nbsp;is unplugged/plugged or disabled/enabled.</div>
<div>&nbsp;</div>
<div>So this solution&nbsp;works even in&nbsp;the case when the adapter is removed/added but it is not as efficient as the one you implemented ;-).</div>
<div>&nbsp;</div>
<div>Anyway, I hope you will choose an approach that will support the 'two identical usb adapters scenario'. </div>
<div>&nbsp;</div>
<div>Thank you!</div>
<div>&nbsp;</div>
<div><span class="gmail_quote">On 8/22/06, <b class="gmail_sendername">Jouni Malinen</b> &lt;<a href="mailto:jkmaline@cc.hut.fi">jkmaline@cc.hut.fi</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On Tue, Aug 22, 2006 at 10:57:41AM +0300, Adrian Nistor wrote:<br>&gt; The idea to do the SELECTs in the opposite order and keep an
<br>&gt; InstanceName-to-GUID mapping is great. It will decrease the number of WMI<br>&gt; calls per event and save a lot of time as WMI is notably slow.<br><br>I think I'll keep it, but..<br><br>&gt; I could not find any relevant documentation regarding the source of the
<br>&gt; InstanceName from WMI. I did some investigation and found the weird<br>&gt; behaviour regarding USB adapters I described in the previous mail (it can be<br>&gt; seen also in the log file I sent). In the process, I also found that the
<br>&gt; InstanceName matches the Name from the Win32_PNPEntity instead.<br><br>That's getting somewhat complex. Well, I can easily add the use on<br>Win32_PnPEntity, but it sounds like that is not enough. There needs to<br>
be code for re-doing this whenever the adapter addition notification is<br>received. Since ndis_events.exe can be made to receive this, it should<br>be possible to take care of all this complexity there. Though, the<br>current model of filtering all notifications based on a fixed interface
<br>name is not going to work..<br><br>If the only thing changing is a number in the end of string, that can be<br>handled relatively easily by using LIKE 'prefix%' type matching. In<br>addition, I don't know whether Win32_PnPEntity is guaranteed to include
<br>all network adapters, so it might be good to default to using Name from<br>Win32_NetworkAdapter and only replace it if a better candidate is found<br>from Win32_PnPEntity. I really love WMI.. This has almost convinced me
<br>to write an own protocol driver for getting these events in a sane way..<br><br>--<br>Jouni Malinen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PGP id EFC895FA<br>_______________________________________________<br>HostAP mailing list
<br><a href="mailto:HostAP@shmoo.com">HostAP@shmoo.com</a><br><a href="http://lists.shmoo.com/mailman/listinfo/hostap">http://lists.shmoo.com/mailman/listinfo/hostap</a><br></blockquote></div><br>