LoadDLLfunc (GetTcpTable, iphlpapi)
LoadDLLfunc (GetTcp6Table, iphlpapi)
LoadDLLfunc (GetUdpTable, iphlpapi)
-LoadDLLfunc (if_indextoname, iphlpapi)
-LoadDLLfunc (if_nametoindex, iphlpapi)
LoadDLLfuncEx2 (DiscardVirtualMemory, kernel32, 1, 127)
LoadDLLfuncEx (ClosePseudoConsole, kernel32, 1)
extern "C" unsigned
cygwin_if_nametoindex (const char *name)
{
- return (unsigned) ::if_nametoindex (name);
+ PIP_ADAPTER_ADDRESSES pa0 = NULL, pap;
+ if (get_adapters_addresses (&pa0, AF_UNSPEC))
+ for (pap = pa0; pap; pap = pap->Next)
+ if (strcmp (name, pap->AdapterName) == 0)
+ {
+ free (pa0);
+ return pap->IfIndex;
+ }
+ if (pa0)
+ free (pa0);
+ return 0;
}
extern "C" char *
cygwin_if_indextoname (unsigned ifindex, char *ifname)
{
- return ::if_indextoname (ifindex, ifname);
+ if (ifindex == 0 || ifname == NULL)
+ {
+ set_errno (ENXIO);
+ return NULL;
+ }
+ PIP_ADAPTER_ADDRESSES pa0 = NULL, pap;
+ if (get_adapters_addresses (&pa0, AF_UNSPEC))
+ for (pap = pa0; pap; pap = pap->Next)
+ if (ifindex == pap->IfIndex)
+ {
+ strcpy (ifname, pap->AdapterName);
+ free (pa0);
+ return ifname;
+ }
+ if (pa0)
+ free (pa0);
+ set_errno (ENXIO);
+ return NULL;
}
extern "C" struct if_nameindex *
- Fix exit code for non-cygwin process running in console. The bug
was introduced in 3.5.0.
+
+- Make the interface names handled by if_nametoindex() and if_indextoname()
+ consistent with that of if_nameindex().