Commit 63f4962c authored by Klemens Nanni's avatar Klemens Nanni Committed by Olivier Crête

Use ifr_ifindex on Linux

parent 37f1e243
......@@ -373,7 +373,7 @@ get_local_ips_ioctl (gboolean include_loopback)
static guint
get_local_if_index_by_addr_ioctl (NiceAddress *addr)
{
#ifdef HAVE_IFR_INDEX
#if defined(HAVE_IFR_INDEX) || defined(HAVE_IFR_IFINDEX)
gint sockfd;
gint size = 0;
struct ifreq *ifr;
......@@ -417,10 +417,18 @@ get_local_if_index_by_addr_ioctl (NiceAddress *addr)
if (!nice_address_equal_no_port (myaddr, addr))
continue;
#if defined(HAVE_IFR_INDEX)
if (ifr->ifr_index == 0)
#else
if (ifr->ifr_ifindex == 0)
#endif
continue;
#if defined(HAVE_IFR_INDEX)
if_index = ifr->ifr_index;
#else
if_index = ifr->ifr_ifindex;
#endif
break;
}
......@@ -430,7 +438,8 @@ get_local_if_index_by_addr_ioctl (NiceAddress *addr)
return if_index;
#else
g_critical ("getifaddrs() should not fail on a platform that doesn't"
" include ifr_index in the struct ifreq. Please report the bug.");
" include ifr_index or ifr_ifindex in the struct ifreq."
" Please report the bug.");
return 0;
#endif
}
......
......@@ -119,10 +119,16 @@ foreach f : ['poll', 'getifaddrs']
endif
endforeach
# BSD and macOS
if cc.has_member('struct ifreq', 'ifr_index', prefix: '#include <net/if.h>')
cdata.set('HAVE_IFR_INDEX', 1)
endif
# Linux
if cc.has_member('struct ifreq', 'ifr_ifindex', prefix: '#include <net/if.h>')
cdata.set('HAVE_IFR_IFINDEX', 1)
endif
if cc.has_argument('-fno-strict-aliasing')
add_project_arguments('-fno-strict-aliasing', language: 'c')
endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment