AC_SUBST([LIBNL_CFLAGS])
AC_SUBST([LIBNL_LIBS])
+# Check for Linux vs. BSD ifreq members
+AC_CHECK_MEMBERS([struct ifreq.ifr_newname,
+ struct ifreq.ifr_ifindex,
+ struct ifreq.ifr_index],
+ [], [],
+ [#include <sys/socket.h>
+ #include <net/if.h>
+ ])
+
# Only COPYING.LIB is under version control, yet COPYING
# is included as part of the distribution tarball.
# Copy one to the other, but only if this is a srcdir-build.
/*
- * Copyright (C) 2007-2012 Red Hat, Inc.
+ * Copyright (C) 2007-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#ifdef __linux__
# include <linux/sockios.h>
# include <linux/if_vlan.h>
-#elif !defined(AF_PACKET)
+# define VIR_NETDEV_FAMILY AF_PACKET
+#elif defined(HAVE_STRUCT_IFREQ) && defined(AF_LOCAL)
+# define VIR_NETDEV_FAMILY AF_LOCAL
+#else
# undef HAVE_STRUCT_IFREQ
#endif
static int virNetDevSetupControl(const char *ifname,
struct ifreq *ifr)
{
- return virNetDevSetupControlFull(ifname, ifr, AF_PACKET, SOCK_DGRAM);
+ return virNetDevSetupControlFull(ifname, ifr, VIR_NETDEV_FAMILY, SOCK_DGRAM);
}
#endif
if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
return -1;
+# ifdef HAVE_STRUCT_IFREQ_IFR_NEWNAME
if (virStrcpyStatic(ifr.ifr_newname, newifname) == NULL) {
virReportSystemError(ERANGE,
_("Network interface name '%s' is too long"),
newifname);
goto cleanup;
}
+# else
+ ifr.ifr_data = (caddr_t)newifname;
+# endif
if (ioctl(fd, SIOCSIFNAME, &ifr)) {
virReportSystemError(errno,
{
int ret = -1;
struct ifreq ifreq;
- int fd = socket(PF_PACKET, SOCK_DGRAM, 0);
+ int fd = socket(VIR_NETDEV_FAMILY, SOCK_DGRAM, 0);
if (fd < 0) {
virReportSystemError(errno, "%s",
goto cleanup;
}
+# ifdef HAVE_STRUCT_IFREQ_IFR_INDEX
+ *ifindex = ifreq.ifr_index;
+# else
*ifindex = ifreq.ifr_ifindex;
+# endif
ret = 0;
cleanup:
*
* Returns 1 if the config matches, 0 if the config does not match, or interface does not exist, -1 on error
*/
-#if defined(HAVE_STRUCT_IFREQ)
+#if defined(SIOCGIFHWADDR) && defined(HAVE_STRUCT_IFREQ)
int virNetDevValidateConfig(const char *ifname,
const virMacAddrPtr macaddr, int ifindex)
{
VIR_FORCE_CLOSE(fd);
return ret;
}
-#else /* ! HAVE_STRUCT_IFREQ */
+#else
int virNetDevValidateConfig(const char *ifname ATTRIBUTE_UNUSED,
const virMacAddrPtr macaddr ATTRIBUTE_UNUSED,
int ifindex ATTRIBUTE_UNUSED)
_("Unable to check interface config on this platform"));
return -1;
}
-#endif /* ! HAVE_STRUCT_IFREQ */
+#endif
#ifdef __linux__