summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5/os
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1996-05-17 18:21:41 +0000
committerTheodore Tso <tytso@mit.edu>1996-05-17 18:21:41 +0000
commitb8283c664e0bdb53275828196cef34811ea9694e (patch)
tree1daedfe999e6c5dde74299e1aa9c6f30821280c2 /src/lib/krb5/os
parentbe61d9661ba9f960790e6d995bcbbdaaa5100f93 (diff)
downloadkrb5-b8283c664e0bdb53275828196cef34811ea9694e.tar.gz
krb5-b8283c664e0bdb53275828196cef34811ea9694e.tar.xz
krb5-b8283c664e0bdb53275828196cef34811ea9694e.zip
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
Diffstat (limited to 'src/lib/krb5/os')
-rw-r--r--src/lib/krb5/os/ChangeLog6
-rw-r--r--src/lib/krb5/os/macsock.c45
2 files changed, 41 insertions, 10 deletions
diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog
index bd007d9f1b..37600779fd 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 <tytso@mit.edu>
+
+ * 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 <epeisach@kangaroo.mit.edu>
* 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 00f4b7977f..a8ce21b762 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 */