Index: include/netdb.h diff -u include/netdb.h.orig include/netdb.h --- include/netdb.h.orig Tue May 3 01:00:51 2005 +++ include/netdb.h Wed May 4 03:19:39 2005 @@ -74,6 +74,11 @@ #define _SOCKLEN_T_DECLARED #endif +#ifndef _UINT32_T_DECLARED +typedef __uint32_t uint32_t; +#define _UINT32_T_DECLARED +#endif + #ifndef _PATH_HEQUIV # define _PATH_HEQUIV "/etc/hosts.equiv" #endif @@ -102,11 +107,29 @@ * Assumption here is that a network number * fits in an unsigned long -- probably a poor one. */ +/* + * Note: n_net 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 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. + */ struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net address type */ - unsigned long n_net; /* network # */ +#if defined(__sparc64__) + int __n_pad0; /* ABI compatibility */ +#endif + uint32_t n_net; /* network # */ +#if defined(__alpha__) || defined(__amd64__) || defined(__ia64__) || \ + defined(__x86_64__) + int __n_pad0; /* ABI compatibility */ +#endif }; struct servent { @@ -122,12 +145,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 RFC 3493 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. + */ 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(__amd64__) || defined(__ia64__) || \ + defined(__x86_64__) + 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 */ @@ -225,7 +266,7 @@ struct hostent *gethostent(void); struct hostent *getipnodebyaddr(const void *, size_t, int, int *); struct hostent *getipnodebyname(const char *, int, int, int *); -struct netent *getnetbyaddr(unsigned long, int); +struct netent *getnetbyaddr(uint32_t, int); struct netent *getnetbyname(const char *); struct netent *getnetent(void); int getnetgrent(char **, char **, char **); Index: lib/libc/net/getaddrinfo.c diff -u -p lib/libc/net/getaddrinfo.c.orig lib/libc/net/getaddrinfo.c --- lib/libc/net/getaddrinfo.c.orig Mon May 2 13:37:41 2005 +++ lib/libc/net/getaddrinfo.c Wed May 4 03:29:59 2005 @@ -135,7 +135,7 @@ TAILQ_HEAD(policyhead, policyqueue); static const struct afd { int a_af; int a_addrlen; - int a_socklen; + socklen_t a_socklen; int a_off; const char *a_addrany; const char *a_loopback; Index: lib/libc/net/getnetbydns.c diff -u -p lib/libc/net/getnetbydns.c.orig lib/libc/net/getnetbydns.c --- lib/libc/net/getnetbydns.c.orig Sat Apr 30 14:59:36 2005 +++ lib/libc/net/getnetbydns.c Wed May 4 03:09:46 2005 @@ -268,7 +268,7 @@ getnetanswer(querybuf *answer, int ansle 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 +276,9 @@ _dns_getnetbyaddr(void *rval, void *cb_d 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 *); @@ -331,12 +331,10 @@ _dns_getnetbyaddr(void *rval, void *cb_d 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; return NS_SUCCESS; } return NS_NOTFOUND; Index: lib/libc/net/getnetbyht.c diff -u -p lib/libc/net/getnetbyht.c.orig lib/libc/net/getnetbyht.c --- lib/libc/net/getnetbyht.c.orig Sat Apr 30 02:28:42 2005 +++ lib/libc/net/getnetbyht.c Wed May 4 03:12:47 2005 @@ -191,13 +191,13 @@ found: int _ht_getnetbyaddr(void *rval, void *cb_data, va_list ap) { - unsigned long net; + uint32_t net; int type; struct netent *ne; struct netent_data *ned; int error; - net = va_arg(ap, unsigned long); + net = va_arg(ap, uint32_t); type = va_arg(ap, int); ne = va_arg(ap, struct netent *); ned = va_arg(ap, struct netent_data *); Index: lib/libc/net/getnetbynis.c diff -u -p lib/libc/net/getnetbynis.c.orig lib/libc/net/getnetbynis.c --- lib/libc/net/getnetbynis.c.orig Sat Apr 30 02:29:19 2005 +++ lib/libc/net/getnetbynis.c Wed May 4 03:14:53 2005 @@ -149,22 +149,22 @@ _nis_getnetbyname(void *rval, void *cb_d } -int +int _nis_getnetbyaddr(void *rval, void *cb_data, va_list ap) { #ifdef YP - unsigned long addr; + uint32_t addr; int af; struct netent *ne; struct netent_data *ned; char *str, *cp; - unsigned long net2; + uint32_t net2; int nn; unsigned int netbr[4]; char buf[MAXDNAME]; int error; - addr = va_arg(ap, unsigned long); + addr = va_arg(ap, uint32_t); af = va_arg(ap, int); ne = va_arg(ap, struct netent *); ned = va_arg(ap, struct netent_data *); Index: lib/libc/net/getnetnamadr.c diff -u -p lib/libc/net/getnetnamadr.c.orig lib/libc/net/getnetnamadr.c --- lib/libc/net/getnetnamadr.c.orig Thu Apr 28 01:55:26 2005 +++ lib/libc/net/getnetnamadr.c Wed May 4 03:04:53 2005 @@ -120,7 +120,8 @@ getnetbyname_r(const char *name, struct } int -getnetbyaddr_r(u_long addr, int af, struct netent *ne, struct netent_data *ned) +getnetbyaddr_r(uint32_t addr, int af, struct netent *ne, + struct netent_data *ned) { int rval; @@ -164,7 +165,7 @@ getnetbyname(const char *name) } struct netent * -getnetbyaddr(u_long addr, int af) +getnetbyaddr(uint32_t addr, int af) { struct netdata *nd; Index: lib/libc/net/netdb_private.h diff -u lib/libc/net/netdb_private.h.orig lib/libc/net/netdb_private.h --- lib/libc/net/netdb_private.h.orig Wed May 4 03:18:26 2005 +++ lib/libc/net/netdb_private.h Wed May 4 03:21:32 2005 @@ -150,7 +150,7 @@ int gethostbyname2_r(const char *, int, struct hostent *, struct hostent_data *); int gethostent_r(struct hostent *, struct hostent_data *); -int getnetbyaddr_r(unsigned long addr, int af, struct netent *, +int getnetbyaddr_r(uint32_t addr, int af, struct netent *, struct netent_data *); int getnetbyname_r(const char *, struct netent *, struct netent_data *); int getnetent_r(struct netent *, struct netent_data *);