From b8283c664e0bdb53275828196cef34811ea9694e Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 17 May 1996 18:21:41 +0000 Subject: [PATCH] Correctly implement getsockname(), so it does getsockname(), not getpeername(), and add the function getpeername(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@8040 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 6 ++++++ src/lib/krb5/os/macsock.c | 45 ++++++++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index bd007d9f1..37600779f 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,9 @@ +Thu Apr 18 16:24:44 1996 Theodore Y. Ts'o + + * macsock.c (getsockname, getpeername): Correctly implement + getsockname(), so it does getsockname(), not + getpeername(), and add the function getpeername(). + Sat May 11 10:08:15 1996 Ezra Peisach * configure.in: Need to include sys/types.h before regexp.h in diff --git a/src/lib/krb5/os/macsock.c b/src/lib/krb5/os/macsock.c index 00f4b7977..a8ce21b76 100644 --- a/src/lib/krb5/os/macsock.c +++ b/src/lib/krb5/os/macsock.c @@ -781,21 +781,46 @@ struct GetAddrParamBlock pb; int getsockname(s, name, namelen) - SOCKET s; - struct sockaddr_in *name; - int *namelen; + SOCKET s; + struct sockaddr_in *name; + int *namelen; { + struct hostent *hp; - if (s == NULL) - return(EINVAL); + hp = getmyipaddr(); - if (*namelen < sizeof(struct sockaddr_in)) - return(EINVAL); + if (hp == NULL) + return -1; - *namelen = sizeof(struct sockaddr_in); - *name = s->connect_addr; + if (*namelen < sizeof(struct sockaddr_in)) { + SOCKET_SET_ERRNO(EIO); + return -1; + } + + name->sin_family = hp->h_addrtype; + memcpy((char *)&name->sin_addr, hp->h_addr, hp->h_length); + + *namelen = sizeof(struct sockaddr_in); - return(0); + return (0); } +int +getpeername(s, name, namelen) + SOCKET s; + struct sockaddr_in *name; + int *namelen; +{ + + if (s == NULL) + return(EINVAL); + + if (*namelen < sizeof(struct sockaddr_in)) + return(EINVAL); + + *namelen = sizeof(struct sockaddr_in); + *name = s->connect_addr; + + return(0); +} #endif /* HAVE_MACSOCK_H */ -- 2.26.2