Back to index

glibc  2.9
getsockname.c File Reference
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <hurd/socket.h>

Go to the source code of this file.


int __getsockname (int fd, __SOCKADDR_ARG addrarg, socklen_t *len)

Function Documentation

int __getsockname ( int  fd,
__SOCKADDR_ARG  addrarg,
socklen_t len 

Definition at line 28 of file getsockname.c.

  error_t err;
  struct sockaddr *addr = addrarg.__sockaddr__;
  char *buf = (char *) addr;
  mach_msg_type_number_t buflen = *len;
  int type;
  addr_port_t aport;

  if (err = HURD_DPORT_USE (fd, __socket_name (port, &aport)))
    return __hurd_dfail (fd, err);

  err = __socket_whatis_address (aport, &type, &buf, &buflen);
  __mach_port_deallocate (__mach_task_self (), aport);

  if (err)
    return __hurd_dfail (fd, err);

  if (*len > buflen)
    *len = buflen;
  if (buf != (char *) addr)
      memcpy (addr, buf, *len);
      __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);

  addr->sa_family = type;

  return 0;

Here is the call graph for this function: