pkgsrc/net/samba/patches/patch-da
drochner c8fa83b3b6 fix the problems with SIOCGIFCONF and its wrong use here by adding
a getifaddrs-based implementation,
fix another botch in the patch for "configure",
bump PKGREVISION
2007-12-21 17:32:24 +00:00

47 lines
1.2 KiB
Text

$NetBSD: patch-da,v 1.1 2007/12/21 17:32:27 drochner Exp $
--- lib/interfaces.c.orig 2007-03-01 05:54:30.000000000 +0100
+++ lib/interfaces.c
@@ -343,6 +343,42 @@ static int _get_interfaces(struct iface_
#define _FOUND_IFACE_ANY
#endif /* HAVE_IFACE_AIX */
+#ifdef HAVE_IFACE_IFADDRS
+
+#include <ifaddrs.h>
+
+static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
+{
+ struct ifaddrs *ia;
+ int total;
+
+ if (getifaddrs(&ia) < 0)
+ return -1;
+
+ total = 0;
+ while (ia && total < max_interfaces) {
+ if (ia->ifa_addr->sa_family != AF_INET ||
+ !(ia->ifa_flags & IFF_UP)) {
+ ia = ia->ifa_next;
+ continue;
+ }
+ strncpy(ifaces[total].name, ia->ifa_name,
+ sizeof(ifaces[total].name) - 1);
+ ifaces[total].name[sizeof(ifaces[total].name) - 1] = 0;
+ ifaces[total].ip = ((struct sockaddr_in *)(ia->ifa_addr))
+ ->sin_addr;
+ ifaces[total].netmask = ((struct sockaddr_in *)(ia->ifa_netmask))
+ ->sin_addr;
+ total++;
+ ia = ia->ifa_next;
+ }
+
+ freeifaddrs(ia);
+ return total;
+}
+
+#define _FOUND_IFACE_ANY
+#endif /* HAVE_IFACE_IFADDRS */
#ifndef _FOUND_IFACE_ANY
static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
{