getifaddrs: Return pointer to extended interface info in ifa_data member

According to https://cygwin.com/ml/cygwin/2016-03/msg00124.html it's a
problem to collect friendlyname info using AF_INET6 sockets.  Fix problem
by exposing additional hardware info for all collected interfaces via the
pointer in the ifaddrs::ifa_data member.

	* include/ifaddrs.h (struct ifaddrs_hwdata): Define as struct of
	not yet exposed members of struct ifall, defined in net.cc.
	* net.cc (struct ifall): Replace hardware dta members with struct
	ifaddrs_hwdata.  Accommodate throughout.
	(get_ifs): Let ifaddrs ifa_data member point to ifall::ifa_hwdata
	member.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2016-03-10 18:00:00 +01:00
parent c86b2f8e93
commit 65231f415a
2 changed files with 36 additions and 22 deletions

View File

@@ -38,6 +38,19 @@ struct ifaddrs {
void *ifa_data;
};
#ifdef __CYGWIN__
#include <cygwin/if.h>
/* On Cygwin the ifa_data member points to this structure, independent of
the address family. */
struct ifaddrs_hwdata {
struct sockaddr ifa_hwaddr;
int ifa_metric;
int ifa_mtu;
int ifa_ifindex;
struct ifreq_frndlyname ifa_frndlyname;
};
#endif
/*
* This may have been defined in <net/if.h>. Note that if <net/if.h> is
* to be included it must be included before this header file.