From c93cea7ea643f74fe36f1b6c06a9f9a59e10c950 Mon Sep 17 00:00:00 2001 From: Ted Percival Date: Fri, 4 Dec 2009 13:50:29 -0700 Subject: [PATCH] Fix roken getifaddrs for IPv4 & IPv6 on HP-UX & Solaris HP-UX only returns IPv6 addresses using SIOCGLIFCONF, SIOCGIFCONF has to be used for IPv4 addresses. Solaris uses the same code as described in the comments, which should correctly detect all addresses when running in a zone. This adds the code that went missing from commit e20183da. Signed-off-by: Love Hornquist Astrand --- lib/roken/getifaddrs.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/roken/getifaddrs.c b/lib/roken/getifaddrs.c index 019a43342..1e0583b7d 100644 --- a/lib/roken/getifaddrs.c +++ b/lib/roken/getifaddrs.c @@ -1039,7 +1039,7 @@ getlifaddrs2(struct ifaddrs **ifap, goto error_out; } #ifndef __hpux - ifconf.lifc_family = AF_UNSPEC; + ifconf.lifc_family = af; ifconf.lifc_flags = 0; #endif ifconf.lifc_len = buf_size; @@ -1154,6 +1154,27 @@ getlifaddrs2(struct ifaddrs **ifap, } #endif /* defined(HAVE_IPV6) && defined(SIOCGLIFCONF) && defined(SIOCGLIFFLAGS) */ +/** + * Join two struct ifaddrs lists by appending supp to base. + * Either may be NULL. The new list head (usually base) will be + * returned. + */ +static struct ifaddrs * +append_ifaddrs(struct ifaddrs *base, struct ifaddrs *supp) { + if (!base) + return supp; + + if (!supp) + return base; + + while (base->ifa_next) + base = base->ifa_next; + + base->ifa_next = supp; + + return base; +} + ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_getifaddrs(struct ifaddrs **ifap) {