+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
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 */