[gssdp] Use if_nametoindex if available
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gssdp] Use if_nametoindex if available
- Date: Sat, 2 Apr 2016 21:14:35 +0000 (UTC)
commit 8bdb91cf436e5bc0ac59cf1a7582947a0df61dd9
Author: Jens Georg <mail jensge org>
Date: Fri Feb 19 17:09:04 2016 +0100
Use if_nametoindex if available
Signed-off-by: Jens Georg <mail jensge org>
https://bugzilla.gnome.org/show_bug.cgi?id=762324
configure.ac | 12 ++++++++++++
libgssdp/gssdp-client.c | 5 ++++-
2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b0f72b9..8cfbfc5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,6 +133,18 @@ AC_CHECK_TYPE(struct in_pktinfo,
], [#include <netinet/ip.h>])
AM_CONDITIONAL([HAVE_PKTINFO], [test $HAVE_PKTINFO = yes], [])
+dnl Check for if_nametoindex
+AC_MSG_CHECKING([for if_nametoindex])
+AC_TRY_COMPILE([#include <net/if.h>],
+ [if_nametoindex("lo")],
+ [HAVE_IFNAMETOINDEX=yes
+ AC_DEFINE([HAVE_IFNAMETOINDEX], [1], [Whether we have if_nametoindex])
+ ],
+ [
+ HAVE_IFNAMETOINDEX=no
+ ])
+AC_MSG_RESULT([$HAVE_IFNAMETOINDEX])
+
dnl Check for SIOCGIFINDEX
AC_MSG_CHECKING([for SIOCGIFINDEX])
AC_TRY_COMPILE([#include <sys/ioctl.h>],
diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c
index ad46780..e5d0c01 100644
--- a/libgssdp/gssdp-client.c
+++ b/libgssdp/gssdp-client.c
@@ -1382,7 +1382,10 @@ extract_address_and_prefix (PIP_ADAPTER_UNICAST_ADDRESS adapter,
static int
query_ifindex (const char *iface_name)
{
-#ifdef HAVE_SIOCGIFINDEX
+#if defined(HAVE_IFNAMETOINDEX)
+ return if_nametoindex (iface_name);
+
+#elif defied(HAVE_SIOCGIFINDEX)
int fd;
int result;
struct ifreq ifr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]