@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2023 Jonathan Schleifer + * Copyright (c) 2008-2024 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -225,13 +225,16 @@ # if defined(OF_HAVE_IPV6) && defined(HAVE_IF_NAMETOINDEX) if (address.sockaddr.in6.sin6_family == AF_INET6 && address.sockaddr.in6.sin6_addr.s6_addr[0] == 0xFE && (address.sockaddr.in6.sin6_addr.s6_addr[1] & 0xC0) == 0x80) { -# if defined(HAVE_INET6_GETSCOPEID) - inet6_getscopeid(&address.sockaddr.in6, - INET6_IS_ADDR_LINKLOCAL); +# if defined(__KAME__) +# define addr6 address.sockaddr.in6.sin6_addr.s6_addr + address.sockaddr.in6.sin6_scope_id = + (addr6[2] << 8) | addr6[3]; + addr6[2] = addr6[3] = 0; +# undef addr6 # elif defined(HAVE_IF_NAMETOINDEX) address.sockaddr.in6.sin6_scope_id = if_nametoindex( [name cStringWithEncoding: encoding]); # endif @@ -239,15 +242,18 @@ # endif [addresses addItem: &address]; next: -# ifdef _SIZEOF_ADDR_IFREQ - buffer += _SIZEOF_ADDR_IFREQ(*current); -# else - buffer += sizeof(struct ifreq); -# endif +# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN + if (current->ifr_addr.sa_len > sizeof(struct sockaddr)) + buffer += sizeof(struct ifreq) - + sizeof(struct sockaddr) + + current->ifr_addr.sa_len; + else +# endif + buffer += sizeof(struct ifreq); } } @finally { free(ifrs); closesocket(sock); }