Commit 1ae38f7b authored by Sebastian Dröge's avatar Sebastian Dröge 🍵
Browse files

ptp: Check for the actual API we use instead of just looking for __APPLE__

Should fix the build on FreeBSD, DragonFly and other BSDs.

https://bugzilla.gnome.org/show_bug.cgi?id=750530
parent 59d916a0
......@@ -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 <sys/ioctl.h>
#include <net/if.h>
]],
[[
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 <ifaddrs.h>
#include <net/if.h>
#include <net/if_dl.h>
]],
[[
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
......
......@@ -41,7 +41,7 @@
#include <netinet/in.h>
#include <string.h>
#ifdef __APPLE__
#ifdef HAVE_GETIFADDRS_AF_LINK
#include <ifaddrs.h>
#include <net/if_dl.h>
#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) {
......
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