summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormillert <>2005-06-08 18:32:34 +0000
committermillert <>2005-06-08 18:32:34 +0000
commitdfecb282049a7216c16a21f3f0b92747fdef5d87 (patch)
tree1940d0b5ce3e497aa61924e3e901f9c2be26f55e /src
parent8c92dcededfd6dda22940bfc0c6e29b294b73938 (diff)
downloadopenbsd-dfecb282049a7216c16a21f3f0b92747fdef5d87.tar.gz
openbsd-dfecb282049a7216c16a21f3f0b92747fdef5d87.tar.bz2
openbsd-dfecb282049a7216c16a21f3f0b92747fdef5d87.zip
Make gethostbyaddr() prototype match POSIX. This means len is now
unsigned but there is no ABI change. OK deraadt@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/net/gethostbyname.34
-rw-r--r--src/lib/libc/net/gethostnamadr.c27
2 files changed, 15 insertions, 16 deletions
diff --git a/src/lib/libc/net/gethostbyname.3 b/src/lib/libc/net/gethostbyname.3
index 51377dbc21..c2db100c9b 100644
--- a/src/lib/libc/net/gethostbyname.3
+++ b/src/lib/libc/net/gethostbyname.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: gethostbyname.3,v 1.22 2004/03/14 18:05:37 jmc Exp $ 1.\" $OpenBSD: gethostbyname.3,v 1.23 2005/06/08 18:32:34 millert Exp $
2.\" 2.\"
3.\" Copyright (c) 1983, 1987, 1991, 1993 3.\" Copyright (c) 1983, 1987, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
@@ -48,7 +48,7 @@
48.Ft struct hostent * 48.Ft struct hostent *
49.Fn gethostbyname2 "const char *name" "int af" 49.Fn gethostbyname2 "const char *name" "int af"
50.Ft struct hostent * 50.Ft struct hostent *
51.Fn gethostbyaddr "const char *addr" "int len" "int af" 51.Fn gethostbyaddr "const void *addr" "socklen_t len" "int af"
52.Ft struct hostent * 52.Ft struct hostent *
53.Fn gethostent void 53.Fn gethostent void
54.Ft void 54.Ft void
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c
index f0be24143c..b036efe2d1 100644
--- a/src/lib/libc/net/gethostnamadr.c
+++ b/src/lib/libc/net/gethostnamadr.c
@@ -48,7 +48,7 @@
48 */ 48 */
49 49
50#if defined(LIBC_SCCS) && !defined(lint) 50#if defined(LIBC_SCCS) && !defined(lint)
51static const char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.62 2005/05/02 17:38:41 moritz Exp $"; 51static const char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.63 2005/06/08 18:32:34 millert Exp $";
52#endif /* LIBC_SCCS and not lint */ 52#endif /* LIBC_SCCS and not lint */
53 53
54#include <sys/param.h> 54#include <sys/param.h>
@@ -640,7 +640,7 @@ gethostbyname2(const char *name, int af)
640} 640}
641 641
642struct hostent * 642struct hostent *
643gethostbyaddr(const char *addr, int len, int af) 643gethostbyaddr(const void *addr, socklen_t len, int af)
644{ 644{
645 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); 645 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res);
646 const u_char *uaddr = (const u_char *)addr; 646 const u_char *uaddr = (const u_char *)addr;
@@ -650,8 +650,8 @@ gethostbyaddr(const char *addr, int len, int af)
650 char qbuf[MAXDNAME+1], *qp, *ep; 650 char qbuf[MAXDNAME+1], *qp, *ep;
651 char lookups[MAXDNSLUS]; 651 char lookups[MAXDNSLUS];
652 struct hostent *res; 652 struct hostent *res;
653 extern struct hostent *_gethtbyaddr(const char *, int, int); 653 extern struct hostent *_gethtbyaddr(const void *, socklen_t, int);
654 extern struct hostent *_yp_gethtbyaddr(const char *); 654 extern struct hostent *_yp_gethtbyaddr(const void *);
655 655
656 if (_res_init(0) == -1) { 656 if (_res_init(0) == -1) {
657 res = _gethtbyaddr(addr, len, af); 657 res = _gethtbyaddr(addr, len, af);
@@ -668,7 +668,6 @@ gethostbyaddr(const char *addr, int len, int af)
668 (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)uaddr) || 668 (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)uaddr) ||
669 IN6_IS_ADDR_V4COMPAT((struct in6_addr *)uaddr))) { 669 IN6_IS_ADDR_V4COMPAT((struct in6_addr *)uaddr))) {
670 /* Unmap. */ 670 /* Unmap. */
671 addr += IN6ADDRSZ - INADDRSZ;
672 uaddr += IN6ADDRSZ - INADDRSZ; 671 uaddr += IN6ADDRSZ - INADDRSZ;
673 af = AF_INET; 672 af = AF_INET;
674 len = INADDRSZ; 673 len = INADDRSZ;
@@ -724,7 +723,7 @@ gethostbyaddr(const char *addr, int len, int af)
724 case 'y': 723 case 'y':
725 /* YP only supports AF_INET. */ 724 /* YP only supports AF_INET. */
726 if (af == AF_INET) 725 if (af == AF_INET)
727 hp = _yp_gethtbyaddr(addr); 726 hp = _yp_gethtbyaddr(uaddr);
728 break; 727 break;
729#endif 728#endif
730 case 'b': 729 case 'b':
@@ -748,7 +747,7 @@ gethostbyaddr(const char *addr, int len, int af)
748 free(buf); 747 free(buf);
749 hp->h_addrtype = af; 748 hp->h_addrtype = af;
750 hp->h_length = len; 749 hp->h_length = len;
751 bcopy(addr, host_addr, len); 750 bcopy(uaddr, host_addr, len);
752 h_addr_ptrs[0] = (char *)host_addr; 751 h_addr_ptrs[0] = (char *)host_addr;
753 h_addr_ptrs[1] = NULL; 752 h_addr_ptrs[1] = NULL;
754 if (af == AF_INET && (_resp->options & RES_USE_INET6)) { 753 if (af == AF_INET && (_resp->options & RES_USE_INET6)) {
@@ -760,7 +759,7 @@ gethostbyaddr(const char *addr, int len, int af)
760 h_errno = NETDB_SUCCESS; 759 h_errno = NETDB_SUCCESS;
761 break; 760 break;
762 case 'f': 761 case 'f':
763 hp = _gethtbyaddr(addr, len, af); 762 hp = _gethtbyaddr(uaddr, len, af);
764 break; 763 break;
765 } 764 }
766 } 765 }
@@ -906,7 +905,7 @@ _gethtbyname2(const char *name, int af)
906} 905}
907 906
908struct hostent * 907struct hostent *
909_gethtbyaddr(const char *addr, int len, int af) 908_gethtbyaddr(const void *addr, socklen_t len, int af)
910{ 909{
911 struct hostent *p; 910 struct hostent *p;
912 911
@@ -997,9 +996,10 @@ done:
997} 996}
998 997
999struct hostent * 998struct hostent *
1000_yp_gethtbyaddr(const char *addr) 999_yp_gethtbyaddr(const void *addr)
1001{ 1000{
1002 struct hostent *hp = (struct hostent *)NULL; 1001 struct hostent *hp = NULL;
1002 const u_char *uaddr = (const u_char *)addr;
1003 static char *__ypcurrent; 1003 static char *__ypcurrent;
1004 int __ypcurrentlen, r; 1004 int __ypcurrentlen, r;
1005 char name[sizeof("xxx.xxx.xxx.xxx")]; 1005 char name[sizeof("xxx.xxx.xxx.xxx")];
@@ -1008,9 +1008,8 @@ _yp_gethtbyaddr(const char *addr)
1008 if (_yp_check(&__ypdomain) == 0) 1008 if (_yp_check(&__ypdomain) == 0)
1009 return (hp); 1009 return (hp);
1010 } 1010 }
1011 snprintf(name, sizeof name, "%u.%u.%u.%u", 1011 snprintf(name, sizeof name, "%u.%u.%u.%u", (uaddr[0] & 0xff),
1012 ((unsigned)addr[0] & 0xff), ((unsigned)addr[1] & 0xff), 1012 (uaddr[1] & 0xff), (uaddr[2] & 0xff), (uaddr[3] & 0xff));
1013 ((unsigned)addr[2] & 0xff), ((unsigned)addr[3] & 0xff));
1014 if (__ypcurrent) 1013 if (__ypcurrent)
1015 free(__ypcurrent); 1014 free(__ypcurrent);
1016 __ypcurrent = NULL; 1015 __ypcurrent = NULL;