summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkleink <kleink@NetBSD.org>2002-05-14 13:45:13 +0000
committerkleink <kleink@NetBSD.org>2002-05-14 13:45:13 +0000
commit06d36d9eee000064134e4e81e67bd8f972f5332c (patch)
tree20779f067edac8e3d53e77a9f588a6ee0b5ed73a
parent14389c7b500dfcba674438e2ead6b45aa28d057b (diff)
struct addrinfo.ai_addrlen used to be a size_t, per RFC 2553.
In XNS5.2, and subsequently in POSIX-2001 and draft-ietf-ipngwg-rfc2553bis-02 it was changed to a socklen_t. To accomodate for this while preserving binary compatibility with the old interface, prepend or append 32 bits of padding, depending on the (LP64 data model) architecture's endianness. This should be deleted the next time the libc major number is incremented.
-rw-r--r--include/netdb.h39
-rw-r--r--lib/libc/net/getaddrinfo.c7
2 files changed, 33 insertions, 13 deletions
diff --git a/include/netdb.h b/include/netdb.h
index 1ea85d613e9..e5e79cc08c1 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -1,4 +1,4 @@
-/* $NetBSD: netdb.h,v 1.22 2002/05/10 22:02:11 kleink Exp $ */
+/* $NetBSD: netdb.h,v 1.23 2002/05/14 13:45:13 kleink Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -89,9 +89,18 @@
#define _NETDB_H_
#include <machine/ansi.h>
+#include <sys/ansi.h>
#include <sys/cdefs.h>
#include <inttypes.h>
+/*
+ * Data types
+ */
+#ifndef socklen_t
+typedef __socklen_t socklen_t;
+#define socklen_t __socklen_t
+#endif
+
#ifdef _BSD_SIZE_T_
typedef _BSD_SIZE_T_ size_t;
#undef _BSD_SIZE_T_
@@ -145,13 +154,30 @@ struct protoent {
int p_proto; /* protocol # */
};
+/*
+ * Note: ai_addrlen used to be a size_t, per RFC 2553.
+ * In XNS5.2, and subsequently in POSIX-2001 and
+ * draft-ietf-ipngwg-rfc2553bis-02.txt it was changed to a socklen_t.
+ * To accomodate for this while preserving binary compatibility with the
+ * old interface, we prepend or append 32 bits of padding, depending on
+ * the (LP64) architecture's endianness.
+ *
+ * This should be deleted the next time the libc major number is
+ * incremented.
+ */
#if !defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE - 0) >= 520
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
+#if defined(__sparc64__)
+ int __ai_pad0;
+#endif
+ socklen_t ai_addrlen; /* length of ai_addr */
+#if defined(__alpha__) || (defined(__i386__) && defined(_LP64))
+ int __ai_pad0;
+#endif
char *ai_canonname; /* canonical name for hostname */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
@@ -250,15 +276,6 @@ struct addrinfo {
#endif
#endif /* !_XOPEN_SOURCE || (_XOPEN_SOURCE - 0) >= 520 */
-/*
- * Data types
- */
-#include <sys/ansi.h>
-#ifndef socklen_t
-typedef __socklen_t socklen_t;
-#define socklen_t __socklen_t
-#endif
-
__BEGIN_DECLS
void endhostent __P((void));
void endnetent __P((void));
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index eba3c2e229c..28c2b6db091 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getaddrinfo.c,v 1.54 2001/08/20 02:33:31 itojun Exp $ */
+/* $NetBSD: getaddrinfo.c,v 1.55 2002/05/14 13:45:14 kleink Exp $ */
/* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */
/*
@@ -79,7 +79,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getaddrinfo.c,v 1.54 2001/08/20 02:33:31 itojun Exp $");
+__RCSID("$NetBSD: getaddrinfo.c,v 1.55 2002/05/14 13:45:14 kleink Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -911,6 +911,9 @@ get_ai(pai, afd, addr)
memset(ai->ai_addr, 0, (size_t)afd->a_socklen);
ai->ai_addr->sa_len = afd->a_socklen;
ai->ai_addrlen = afd->a_socklen;
+#if defined (__alpha__) || (defined(__i386__) && defined(_LP64)) || defined(__sparc64__)
+ ai->__ai_pad0 = 0;
+#endif
ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
p = (char *)(void *)(ai->ai_addr);
memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen);