Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src struct addrinfo.ai_addrlen used to be a size_t, per RFC 2553.
details: https://anonhg.NetBSD.org/src/rev/a34a96d528e4
branches: trunk
changeset: 526938:a34a96d528e4
user: kleink <kleink%NetBSD.org@localhost>
date: Tue May 14 13:45:13 2002 +0000
description:
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.
diffstat:
include/netdb.h | 39 ++++++++++++++++++++++++++++-----------
lib/libc/net/getaddrinfo.c | 7 +++++--
2 files changed, 33 insertions(+), 13 deletions(-)
diffs (104 lines):
diff -r a49b97636bc7 -r a34a96d528e4 include/netdb.h
--- a/include/netdb.h Tue May 14 12:05:35 2002 +0000
+++ b/include/netdb.h Tue May 14 13:45:13 2002 +0000
@@ -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 @@
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 @@
#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 -r a49b97636bc7 -r a34a96d528e4 lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c Tue May 14 12:05:35 2002 +0000
+++ b/lib/libc/net/getaddrinfo.c Tue May 14 13:45:13 2002 +0000
@@ -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 @@
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);
Home |
Main Index |
Thread Index |
Old Index