+ IP_ADAPTER_ADDRESSES *pAddrList;
+ IP_ADAPTER_ADDRESSES *pAddrPtr;
+ BYTE bBuffer[8192];
+ ULONG dwSize;
+ ULONG dwStatus;
+ unsigned dwIndex = 0;
+
+ dwSize = (ULONG) sizeof (bBuffer);
+ pAddrList = (IP_ADAPTER_ADDRESSES *) &bBuffer[0];
+
+ dwStatus = GetAdaptersAddresses (
+ /* Family = */ AF_UNSPEC,
+ /* Flags = */ GAA_FLAG_SKIP_ANYCAST,
+ /* Reserved = */ NULL,
+ /* AdapterAddresses = */ pAddrList,
+ /* SizePointer = */ &dwSize);
+ if (dwStatus != ERROR_SUCCESS)
+ return (0);
+
+ for (pAddrPtr = pAddrList;
+ pAddrPtr != NULL;
+ pAddrPtr = pAddrPtr->Next)
+ {
+ if (strcmp (pszIfName, pAddrPtr->AdapterName) != 0)
+ continue;
+
+ dwIndex = (unsigned) pAddrPtr->IfIndex;
+ break;
+ }
+
+ return (dwIndex);
+} /* }}} unsigned if_nametoindex */
+#endif /* WIN32 */
+