diff --git a/configure.ac b/configure.ac index 71309c967d..3717518597 100644 --- a/configure.ac +++ b/configure.ac @@ -325,6 +325,44 @@ AC_PATH_PROG([SETCAP], [setcap], [no], [$PATH:/usr/bin:/bin:/usr/sbin:/sbin]) if test "x$HAVE_PTP" = "xyes"; then AC_DEFINE(HAVE_PTP, 1, [PTP support available]) +AC_MSG_CHECKING([for SIOCGIFCONF, SIOCGIFFLAGS and SIOCGIFHWADDR]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ + #include + #include + ]], + [[ + struct ifreq ifr; + struct ifconf ifc; + ioctl(0, SIOCGIFCONF, &ifc); + ioctl(0, SIOCGIFFLAGS, &ifr); + ioctl(0, SIOCGIFHWADDR, &ifr); + int dummy = ifr.ifr_hwaddr.sa_data[0]; + ]])], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SIOCGIFCONF_SIOCGIFFLAGS_SIOCGIFHWADDR, 1, [SIOCGIFCONF, SIOCGIFFLAGS and SIOCGIFHWADDR is available]) + ], [ + AC_MSG_RESULT(no) +]) + +AC_MSG_CHECKING([for getifaddrs() and AF_LINK]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ + #include + #include + #include + ]], + [[ + struct ifaddrs *ifaddr; + getifaddrs(&ifaddr); + int dummy = (ifaddr->ifa_flags & IFF_LOOPBACK) && ifaddr->ifa_addr->sa_family != AF_LINK; + ]])], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETIFADDRS_AF_LINK, 1, [getifaddrs() and AF_LINK is available]) + ], [ + AC_MSG_RESULT(no) + ]) + AC_MSG_CHECKING([how to install gst-ptp-helper]) if test "x$with_ptp_helper_permissions" = "xauto"; then if test "x$gst_ptp_have_cap" = "xyes" -a "x$SETCAP" != "xno"; then diff --git a/libs/gst/helpers/gst-ptp-helper.c b/libs/gst/helpers/gst-ptp-helper.c index 45a0206862..6c753dff73 100644 --- a/libs/gst/helpers/gst-ptp-helper.c +++ b/libs/gst/helpers/gst-ptp-helper.c @@ -41,7 +41,7 @@ #include #include -#ifdef __APPLE__ +#ifdef HAVE_GETIFADDRS_AF_LINK #include #include #endif @@ -240,7 +240,7 @@ setup_sockets (void) /* Probe all non-loopback interfaces */ if (!ifaces) { -#ifndef __APPLE__ +#if defined(HAVE_SIOCGIFCONF_SIOCGIFFLAGS_SIOCGIFHWADDR) struct ifreq ifr; struct ifconf ifc; gchar buf[8192]; @@ -269,7 +269,7 @@ setup_sockets (void) ifaces = probed_ifaces; } } -#else +#elif defined(HAVE_GETIFADDRS_AF_LINK) struct ifaddrs *ifaddr, *ifa; if (getifaddrs (&ifaddr) != -1) { @@ -291,6 +291,8 @@ setup_sockets (void) g_ptr_array_add (arr, NULL); ifaces = probed_ifaces = (gchar **) g_ptr_array_free (arr, FALSE); } +#else +#warning "Implement something to list all network interfaces" #endif } @@ -298,7 +300,7 @@ setup_sockets (void) if (clock_id == (guint64) - 1) { gboolean success = FALSE; -#ifndef __APPLE__ +#if defined(HAVE_SIOCGIFCONF_SIOCGIFFLAGS_SIOCGIFHWADDR) struct ifreq ifr; if (ifaces) { @@ -356,7 +358,7 @@ setup_sockets (void) } } } -#else +#elif defined(HAVE_GETIFADDRS_AF_LINK) struct ifaddrs *ifaddr, *ifa; if (getifaddrs (&ifaddr) != -1) { @@ -405,6 +407,8 @@ setup_sockets (void) freeifaddrs (ifaddr); } +#else +#warning "Implement something to get MAC addresses of network interfaces" #endif if (!success) {