blob: d51e3bfd52ca9665243d409153be833c043bc7f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
$NetBSD: patch-ao,v 1.1 2014/06/11 11:03:56 hauke Exp $
--- libatalk/util/getiface.c.orig 2005-01-31 14:50:54.000000000 -0500
+++ libatalk/util/getiface.c 2008-04-05 21:32:56.000000000 -0400
@@ -16,6 +16,10 @@
#include <stdint.h>
#endif
+#ifdef HAVE_GETIFADDRS
+#include <ifaddrs.h>
+#endif
+
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
@@ -74,6 +78,28 @@
*list = new;
return i;
+#elif defined(HAVE_GETIFADDRS)
+ struct ifaddrs *ifa, *a;
+ int i;
+ char **new;
+
+ if (!list)
+ return 0;
+ if (getifaddrs(&ifa) == -1)
+ return 0;
+ for (i = 0, a = ifa; a != NULL; a = a->ifa_next, i++)
+ continue;
+ new = malloc((i + 1) * sizeof(char *));
+ if (new == NULL) {
+ freeifaddrs(ifa);
+ return 0;
+ }
+ for (i = 0, a = ifa; a != NULL; a = a->ifa_next)
+ if (addname(new, &i, a->ifa_name) < 0)
+ break;
+ freeifaddrs(ifa);
+ *list = new;
+ return i;
#else
struct ifconf ifc;
struct ifreq ifrs[ 64 ], *ifr, *nextifr;
|