Commit 3b43fe09 authored by Martti Mela's avatar Martti Mela

su_localinfo.c: isolated IPv6 stuff with SU_HAVE_IN6s

darcs-hash:20070206154321-1b897-b8e04d1a65671a90bf1a132c8364f34afb189407.gz
parent bf6c39b2
......@@ -1045,7 +1045,9 @@ int bsd_localinfo(su_localinfo_t const hints[1],
{
struct ifaddrs *ifa, *results;
int error = 0;
#if SU_HAVE_IN6
int v4_mapped = (hints->li_flags & LI_V4MAPPED) != 0;
#endif
char *canonname = NULL;
if (getifaddrs(&results) < 0) {
......@@ -1057,7 +1059,10 @@ int bsd_localinfo(su_localinfo_t const hints[1],
for (ifa = results; ifa; ifa = ifa->ifa_next) {
su_localinfo_t *li;
su_sockaddr_t *su, su2[1];
su_sockaddr_t *su;
#if SU_HAVE_IN6
su_sockaddr_t su2[1];
#endif
socklen_t sulen;
int scope, flags = 0, gni_flags = 0, if_index = 0;
char const *ifname = 0;
......@@ -1075,15 +1080,19 @@ int bsd_localinfo(su_localinfo_t const hints[1],
if (su->su_family == AF_INET) {
sulen = sizeof(su->su_sin);
scope = li_scope4(su->su_sin.sin_addr.s_addr);
#if SU_HAVE_IN6
if (v4_mapped)
sulen = sizeof(su->su_sin6);
#endif
}
#if SU_HAVE_IN6
else if (su->su_family == AF_INET6) {
if (IN6_IS_ADDR_MULTICAST(&su->su_sin6.sin6_addr))
continue;
sulen = sizeof(su->su_sin6);
scope = li_scope6(&su->su_sin6.sin6_addr);
}
#endif
else
continue;
......@@ -1102,6 +1111,7 @@ int bsd_localinfo(su_localinfo_t const hints[1],
if (scope == LI_SCOPE_HOST || scope == LI_SCOPE_LINK)
gni_flags = NI_NUMERICHOST;
#if SU_HAVE_IN6
if (v4_mapped && su->su_family == AF_INET) {
/* Map IPv4 address to IPv6 address */
memset(su2, 0, sizeof(*su2));
......@@ -1110,6 +1120,7 @@ int bsd_localinfo(su_localinfo_t const hints[1],
((int32_t*)&su2->su_sin6.sin6_addr)[3] = su->su_sin.sin_addr.s_addr;
su = su2;
}
#endif
if ((error = li_name(hints, gni_flags, su, &canonname)) < 0)
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment