![]() ![]() | ![]() |
File: [cvs.NetBSD.org] / pkgsrc / net / samba30 / patches / Attic / patch-da (download)
Revision 1.1.1.1 (vendor branch), Thu Dec 15 22:23:24 2011 UTC (11 years, 1 month ago) by asau
Reimport Samba 3.0.37 from net/samba as net/samba30 as part of Samba packages rotation. |
$NetBSD: patch-da,v 1.1.1.1 2011/12/15 22:23:24 asau 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) {