diff options
author | ume <ume@FreeBSD.org> | 2005-05-15 20:15:15 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2005-05-15 20:15:15 +0000 |
commit | 7a6cd620d08df24bc7c27e2a13017a1f63f004b2 (patch) | |
tree | 309b5291b90b8bac584d010fde9db8ed4db9a767 /lib/libc/net/getnetbydns.c | |
parent | dd14237cdafb5e0124ab3277ac0ac8f9eaf03aa0 (diff) | |
download | FreeBSD-src-7a6cd620d08df24bc7c27e2a13017a1f63f004b2.zip FreeBSD-src-7a6cd620d08df24bc7c27e2a13017a1f63f004b2.tar.gz |
- The ai_addrlen of a struct addrinfo used to be a size_t, per
RFC 2553. In XNS5.2, and subsequently in POSIX-2001 and RFC
3493, it was changed to a socklen_t. And, the n_net of a
struct netent used to be an unsigned long integer. In XNS5,
and subsequently in POSIX-2001, it was changed to an uint32_t.
To accomodate for this while preserving ABI compatibility with
the old interface, we need to prepend or append 32 bits of
padding, depending on the (LP64) architecture's endianness.
- Correct 1st argument of getnetbyaddr() to uint32_t on 32
bit arch. Stay as is on 64 bit arch for ABI backward
compatibility for now.
Reviewed by: das, peter
MFC after: 2 weeks
Diffstat (limited to 'lib/libc/net/getnetbydns.c')
-rw-r--r-- | lib/libc/net/getnetbydns.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c index e4f0ae8..5eca268 100644 --- a/lib/libc/net/getnetbydns.c +++ b/lib/libc/net/getnetbydns.c @@ -259,6 +259,9 @@ getnetanswer(querybuf *answer, int anslen, int net_i, struct netent *ne, break; } ne->n_aliases++; +#if __LONG_BIT == 64 + ne->__n_pad0 = 0; /* ABI compatibility */ +#endif return 0; } h_errno = TRY_AGAIN; @@ -268,7 +271,7 @@ getnetanswer(querybuf *answer, int anslen, int net_i, struct netent *ne, int _dns_getnetbyaddr(void *rval, void *cb_data, va_list ap) { - unsigned long net; + uint32_t net; int net_type; struct netent *ne; struct netent_data *ned; @@ -276,9 +279,9 @@ _dns_getnetbyaddr(void *rval, void *cb_data, va_list ap) int nn, anslen, error; querybuf *buf; char qbuf[MAXDNAME]; - unsigned long net2; + uint32_t net2; - net = va_arg(ap, unsigned long); + net = va_arg(ap, uint32_t); net_type = va_arg(ap, int); ne = va_arg(ap, struct netent *); ned = va_arg(ap, struct netent_data *); @@ -327,12 +330,13 @@ _dns_getnetbyaddr(void *rval, void *cb_data, va_list ap) error = getnetanswer(buf, anslen, BYADDR, ne, ned); free(buf); if (error == 0) { - unsigned u_net = net; /* maybe net should be unsigned ? */ - /* Strip trailing zeros */ - while ((u_net & 0xff) == 0 && u_net != 0) - u_net >>= 8; - ne->n_net = u_net; + while ((net & 0xff) == 0 && net != 0) + net >>= 8; + ne->n_net = net; +#if __LONG_BIT == 64 + ne->__n_pad0 = 0; /* ABI compatibility */ +#endif return NS_SUCCESS; } return NS_NOTFOUND; |