#endif
#include <net/if.h>
+#ifdef HAVE_NET_IF_MEDIA_H
+ #include <net/if_media.h>
+#endif
#include <arpa/inet.h>
#endif /* G_OS_UNIX */
{
GList *ips = NULL;
struct ifaddrs *ifa, *results;
+ int sockfd = -1;
GList *loopbacks = NULL;
#ifdef IGNORED_IFACE_PREFIX
const gchar **prefix;
continue;
#endif
+#ifdef HAVE_NET_IF_MEDIA_H
+ {
+ struct ifmediareq ifmr;
+
+ if (sockfd == -1)
+ sockfd = socket (AF_INET, SOCK_DGRAM, 0);
+
+ memset (&ifmr, 0, sizeof (ifmr));
+ g_strlcpy (ifmr.ifm_name, ifa->ifa_name, sizeof (ifmr.ifm_name));
+
+ if (ioctl (sockfd, SIOCGIFMEDIA, &ifmr) == 0 &&
+ (ifmr.ifm_status & IFM_AVALID) != 0 &&
+ (ifmr.ifm_status & IFM_ACTIVE) == 0) {
+ continue;
+ }
+ }
+#endif
+
/* Convert to a string. */
addr_string = sockaddr_to_string (ifa->ifa_addr);
if (addr_string == NULL) {
ips = add_ip_to_list (ips, addr_string, FALSE);
}
+ if (sockfd != -1)
+ close (sockfd);
+
freeifaddrs (results);
if (loopbacks)
description: 'Public library function implementation')
# headers
-foreach h : ['arpa/inet.h', 'net/in.h', 'netdb.h', 'ifaddrs.h', 'unistd.h']
+foreach h : ['arpa/inet.h', 'net/in.h', 'net/if_media.h', 'netdb.h', 'ifaddrs.h', 'unistd.h']
if cc.has_header(h)
define = 'HAVE_' + h.underscorify().to_upper()
cdata.set(define, 1)