Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-12-15 17:50:13 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-06-24 17:02:39 +0300
commitc356901f0d69b83107740bc0965960154b35e251 (patch)
tree13e95e05272391f8150dfa16eb53cfcdf9fc0b33 /winsup/cygwin/net.cc
parentbd4339e2a2905d6f62b9510067360badc27da591 (diff)
Rename if_indextoname to cygwin_if_indextoname (analag for if_nametoindex)
Just call OS functions
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc70
1 files changed, 4 insertions, 66 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 97885b13c..7834aae9d 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -2380,77 +2380,15 @@ get_ifconf (struct ifconf *ifc, int what)
}
extern "C" unsigned
-if_nametoindex (const char *name)
+cygwin_if_nametoindex (const char *name)
{
- PIP_ADAPTER_ADDRESSES pa0 = NULL, pap;
- unsigned index = 0;
-
- __try
- {
- if (get_adapters_addresses (&pa0, AF_UNSPEC))
- {
- char lname[IF_NAMESIZE], *c;
-
- lname[0] = '\0';
- strncat (lname, name, IF_NAMESIZE - 1);
- if (lname[0] == '{' && (c = strchr (lname, ':')))
- *c = '\0';
- for (pap = pa0; pap; pap = pap->Next)
- if (strcasematch (lname, pap->AdapterName))
- {
- index = pap->Ipv6IfIndex ?: pap->IfIndex;
- break;
- }
- free (pa0);
- }
- }
- __except (EFAULT)
- {
- index = 0;
- }
- __endtry
- return index;
+ return (unsigned) ::if_nametoindex (name);
}
extern "C" char *
-if_indextoname (unsigned ifindex, char *ifname)
+cygwin_if_indextoname (unsigned ifindex, char *ifname)
{
- PIP_ADAPTER_ADDRESSES pa0 = NULL, pap;
- char *name = NULL;
-
- __try
- {
- if (get_adapters_addresses (&pa0, AF_UNSPEC))
- {
- for (pap = pa0; pap; pap = pap->Next)
- if (ifindex == (pap->Ipv6IfIndex ?: pap->IfIndex))
- {
- /* Unfortunately the pre-Vista IPv6 stack has a distinct
- loopback device with the same Ipv6IfIndex as the IfIndex
- of the IPv4 loopback device, but with a different adapter
- name. For consistency with /proc/net/if_inet6, try to find
- the IPv6 loopback device and use that adapter name instead.
- We identify the loopback device by its IfIndex of 1. */
- if (pap->IfIndex == 1 && pap->Ipv6IfIndex == 0)
- for (PIP_ADAPTER_ADDRESSES pap2 = pa0;
- pap2;
- pap2 = pap2->Next)
- if (pap2->Ipv6IfIndex == 1)
- {
- pap = pap2;
- break;
- }
- name = strcpy (ifname, pap->AdapterName);
- break;
- }
- free (pa0);
- }
- else
- set_errno (ENXIO);
- }
- __except (EFAULT) {}
- __endtry
- return name;
+ return ::if_indextoname (ifindex, ifname);
}
extern "C" struct if_nameindex *