Commit 40f7680e authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Ignore sockaddr_{sin,sin6,sun}.{sin,sin6,sun}_len even on systems that define it

parent e6dc08b0
......@@ -739,7 +739,6 @@ ISC_IRS_GETNAMEINFOSOCKLEN
ISC_IRS_NEEDADDRINFO
ISC_PLATFORM_HAVETFO
ISC_PLATFORM_NEEDPORTT
ISC_PLATFORM_HAVESALEN
ISC_PLATFORM_HAVEIF_LADDRCONF
ISC_PLATFORM_HAVEIF_LADDRREQ
BIND9_CO_RULE
......@@ -17917,33 +17916,6 @@ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
 
 
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sa_len in struct sockaddr" >&5
$as_echo_n "checking for sa_len in struct sockaddr... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/socket.h>
int
main ()
{
struct sockaddr sa; sa.sa_len = 0; return (0);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
#
# Look for in_port_t.
#
......
......@@ -1977,17 +1977,6 @@ AC_TRY_LINK([
ISC_PLATFORM_HAVEIF_LADDRCONF="#undef ISC_PLATFORM_HAVEIF_LADDRCONF"])
AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRCONF)
AC_MSG_CHECKING(for sa_len in struct sockaddr)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>],
[struct sockaddr sa; sa.sa_len = 0; return (0);],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"],
[AC_MSG_RESULT(no)
ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN"])
AC_SUBST(ISC_PLATFORM_HAVESALEN)
#
# Look for in_port_t.
#
......
......@@ -30,12 +30,6 @@
*** Network.
***/
/*! \brief
* If sockaddrs on this system have an sa_len field, ISC_PLATFORM_HAVESALEN
* will be defined.
*/
@ISC_PLATFORM_HAVESALEN@
/*! \brief
* If this system needs in_port_t, ISC_PLATFORM_NEEDPORTT will be defined.
*/
......
......@@ -242,9 +242,6 @@ isc_sockaddr_any(isc_sockaddr_t *sockaddr)
{
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin.sin_family = AF_INET;
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
#endif
sockaddr->type.sin.sin_addr.s_addr = INADDR_ANY;
sockaddr->type.sin.sin_port = 0;
sockaddr->length = sizeof(sockaddr->type.sin);
......@@ -256,9 +253,6 @@ isc_sockaddr_any6(isc_sockaddr_t *sockaddr)
{
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin6.sin6_family = AF_INET6;
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
#endif
sockaddr->type.sin6.sin6_addr = in6addr_any;
sockaddr->type.sin6.sin6_port = 0;
sockaddr->length = sizeof(sockaddr->type.sin6);
......@@ -271,9 +265,6 @@ isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
{
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin.sin_family = AF_INET;
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
#endif
sockaddr->type.sin.sin_addr = *ina;
sockaddr->type.sin.sin_port = htons(port);
sockaddr->length = sizeof(sockaddr->type.sin);
......@@ -300,9 +291,6 @@ isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6,
{
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin6.sin6_family = AF_INET6;
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
#endif
sockaddr->type.sin6.sin6_addr = *ina6;
sockaddr->type.sin6.sin6_port = htons(port);
sockaddr->length = sizeof(sockaddr->type.sin6);
......@@ -315,9 +303,6 @@ isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
{
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin6.sin6_family = AF_INET6;
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
#endif
sockaddr->type.sin6.sin6_addr.s6_addr[10] = 0xff;
sockaddr->type.sin6.sin6_addr.s6_addr[11] = 0xff;
memmove(&sockaddr->type.sin6.sin6_addr.s6_addr[12], ina, 4);
......@@ -363,17 +348,11 @@ isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na,
switch (na->family) {
case AF_INET:
sockaddr->length = sizeof(sockaddr->type.sin);
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
#endif
sockaddr->type.sin.sin_addr = na->type.in;
sockaddr->type.sin.sin_port = htons(port);
break;
case AF_INET6:
sockaddr->length = sizeof(sockaddr->type.sin6);
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
#endif
memmove(&sockaddr->type.sin6.sin6_addr, &na->type.in6, 16);
sockaddr->type.sin6.sin6_scope_id = isc_netaddr_getzone(na);
sockaddr->type.sin6.sin6_port = htons(port);
......@@ -488,10 +467,6 @@ isc_sockaddr_frompath(isc_sockaddr_t *sockaddr, const char *path) {
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->length = sizeof(sockaddr->type.sunix);
sockaddr->type.sunix.sun_family = AF_UNIX;
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sunix.sun_len =
(unsigned char)sizeof(sockaddr->type.sunix);
#endif
strlcpy(sockaddr->type.sunix.sun_path, path,
sizeof(sockaddr->type.sunix.sun_path));
return (ISC_R_SUCCESS);
......
......@@ -738,19 +738,8 @@ internal_current(isc_interfaceiter_t *iter) {
*/
static isc_result_t
internal_next4(isc_interfaceiter_t *iter) {
#ifdef ISC_PLATFORM_HAVESALEN
struct ifreq *ifrp;
#endif
if (iter->pos < (unsigned int) iter->ifc.ifc_len) {
#ifdef ISC_PLATFORM_HAVESALEN
ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos);
if (ifrp->ifr_addr.sa_len > sizeof(struct sockaddr))
iter->pos += sizeof(ifrp->ifr_name) +
ifrp->ifr_addr.sa_len;
else
#endif
iter->pos += sizeof(struct ifreq);
} else {
......@@ -767,23 +756,13 @@ internal_next4(isc_interfaceiter_t *iter) {
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
static isc_result_t
internal_next6(isc_interfaceiter_t *iter) {
#ifdef ISC_PLATFORM_HAVESALEN
struct LIFREQ *ifrp;
#endif
if (iter->result6 != ISC_R_SUCCESS && iter->result6 != ISC_R_IGNORE)
return (iter->result6);
REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
#ifdef ISC_PLATFORM_HAVESALEN
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
if (ifrp->lifr_addr.sa_len > sizeof(struct sockaddr))
iter->pos6 += sizeof(ifrp->lifr_name) + ifrp->lifr_addr.sa_len;
else
#endif
iter->pos6 += sizeof(struct LIFREQ);
iter->pos6 += sizeof(struct LIFREQ);
if (iter->pos6 >= (unsigned int) iter->lifc.lifc_len)
return (ISC_R_NOMORE);
......
......@@ -209,14 +209,8 @@ internal_current(isc_interfaceiter_t *iter) {
dst_sa = sa;
break;
}
#ifdef ISC_PLATFORM_HAVESALEN
sa = (struct sockaddr *)((char*)(sa)
+ ROUNDUP(sa->sa_len));
#else
/* XXX untested. */
sa = (struct sockaddr *)((char*)(sa)
+ ROUNDUP(sizeof(struct sockaddr)));
#endif
}
if (addr_sa == NULL)
......
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