From cb3bf49e323d629c4d147a41dda4e83764691c2b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 2 Mar 1999 00:04:32 +0000 Subject: 1999-03-01 Mark Kettenis * pf.c (S_socket_whatis_address): Implement. Since we cannot tell what our adress is, return an empty string as the file name. --- pflocal/pf.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'pflocal') diff --git a/pflocal/pf.c b/pflocal/pf.c index d404743d..71467ef7 100644 --- a/pflocal/pf.c +++ b/pflocal/pf.c @@ -1,6 +1,6 @@ /* Protocol family operations - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1999 Free Software Foundation, Inc. Written by Miles Bader @@ -18,8 +18,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include - #include #include "sock.h" @@ -96,10 +96,28 @@ S_socket_fabricate_address (mach_port_t pf, return 0; } +/* Implement socket_whatis_address as described in . + Since we cannot tell what our adress is, return an empty string as + the file name. This is primarily for the implementation of accept + and recvfrom. The functions getsockname and getpeername remain + unsupported for the local namespace. */ error_t S_socket_whatis_address (struct addr *addr, int *sockaddr_type, char **sockaddr, size_t *sockaddr_len) { - return EOPNOTSUPP; + socklen_t addr_len = (offsetof (struct sockaddr, sa_data) + 1); + + if (! addr) + return EOPNOTSUPP; + + *sockaddr_type = AF_LOCAL; + if (*sockaddr_len < addr_len) + vm_allocate (mach_task_self (), (vm_address_t *) sockaddr, addr_len, 1); + ((struct sockaddr *) *sockaddr)->sa_len = addr_len; + ((struct sockaddr *) *sockaddr)->sa_family = *sockaddr_type; + ((struct sockaddr *) *sockaddr)->sa_data[0] = 0; + *sockaddr_len = addr_len; + + return 0; } -- cgit v1.2.3