Correctly implement getsockname(), so it does getsockname(), not
authorTheodore Tso <tytso@mit.edu>
Fri, 17 May 1996 18:21:41 +0000 (18:21 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 17 May 1996 18:21:41 +0000 (18:21 +0000)
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
src/lib/krb5/os/macsock.c

index bd007d9f1ba915d32be39ee2c70169483849792e..37600779fd7139c77951e4784a7df6eba6d802f4 100644 (file)
@@ -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
index 00f4b7977fd705bcd1c07c0db8a77ad27c867886..a8ce21b7623e197a8468c4882ef9011f64d0c65d 100644 (file)
@@ -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 */