-/* Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1993, 1994, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/socket.h>
#include <hurd.h>
#include <hurd/fd.h>
-#include <sys/socket.h>
#include <hurd/socket.h>
-#include <fcntl.h>
-#include <string.h>
/* Await a connection on socket FD.
When a connection arrives, open a new socket to communicate with it,
accept (fd, addrarg, addr_len)
int fd;
__SOCKADDR_ARG addrarg;
- size_t *addr_len;
+ socklen_t *addr_len;
{
error_t err;
socket_t new;
if (addr != NULL)
{
+ if (*addr_len > buflen)
+ *addr_len = buflen;
+
if (buf != (char *) addr)
{
- if (*addr_len < buflen)
- *addr_len = buflen;
memcpy (addr, buf, *addr_len);
__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
}
-/* Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1994, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <string.h>
#include <sys/socket.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <hurd/socket.h>
-#include <string.h>
/* Put the address of the peer connected to socket FD into *ADDR
(which is *LEN bytes long), and its actual length into *LEN. */
-
-/* XXX should be __getpeername ? */
int
getpeername (fd, addrarg, len)
int fd;
__SOCKADDR_ARG addrarg;
- size_t *len;
+ socklen_t *len;
{
error_t err;
mach_msg_type_number_t buflen = *len;
if (err)
return __hurd_dfail (fd, err);
+ if (*len > buflen)
+ *len = buflen;
+
if (buf != (char *) addr)
{
- if (*len < buflen)
- *len = buflen;
memcpy (addr, buf, *len);
__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
}
-/* Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1994, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <string.h>
#include <sys/socket.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <hurd/socket.h>
-#include <string.h>
/* Put the local address of FD into *ADDR and its length in *LEN. */
int
getsockname (fd, addrarg, len)
int fd;
__SOCKADDR_ARG addrarg;
- size_t *len;
+ socklen_t *len;
{
error_t err;
struct sockaddr *addr = addrarg.__sockaddr__;
if (err)
return __hurd_dfail (fd, err);
+ if (*len > buflen)
+ *len = buflen;
+
if (buf != (char *) addr)
{
- if (*len < buflen)
- *len = buflen;
memcpy (addr, buf, *len);
__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
}
-/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Boston, MA 02111-1307, USA. */
#include <errno.h>
+#include <string.h>
#include <sys/socket.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <hurd/socket.h>
-#include <string.h>
/* Read N bytes into BUF through socket FD from peer
at address ADDR (which is ADDR_LEN bytes long).
Returns the number read or -1 for errors. */
-
-/* XXX should be __recvfrom ? */
int
recvfrom (fd, buf, n, flags, addrarg, addr_len)
int fd;
size_t n;
int flags;
__SOCKADDR_ARG addrarg;
- size_t *addr_len;
+ socklen_t *addr_len;
{
error_t err;
mach_port_t addrport;
if (err)
return __hurd_dfail (fd, err);
+ if (*addr_len > buflen)
+ *addr_len = buflen;
+
if (buf != (char *) addr)
{
- if (*addr_len < buflen)
- *addr_len = buflen;
memcpy (addr, buf, *addr_len);
__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
}
-/* Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
#include <errno.h>
#include <sys/socket.h>
+#include <sys/un.h>
#include <hurd.h>
-#include <hurd/socket.h>
#include <hurd/fd.h>
-#include <sys/un.h>
#include <hurd/ifsock.h>
+#include <hurd/socket.h>
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
size_t n,
int flags,
const struct sockaddr_un *addr,
- size_t addr_len)
+ socklen_t addr_len)
{
addr_port_t aport;
error_t err;