version 1.70, 2014/01/19 04:17:29 |
version 1.71, 2014/07/15 15:54:14 |
|
|
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
|
#include <sys/un.h> |
|
|
#include <netinet/in.h> |
#include <netinet/in.h> |
|
|
|
|
< 0) |
< 0) |
return NULL; |
return NULL; |
} |
} |
|
|
|
if (addr.ss_family == AF_UNIX) { |
|
/* Get the Unix domain socket path. */ |
|
return xstrdup(((struct sockaddr_un *)&addr)->sun_path); |
|
} |
|
|
/* Get the address in ascii. */ |
/* Get the address in ascii. */ |
if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop, |
if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop, |
sizeof(ntop), NULL, 0, flags)) != 0) { |
sizeof(ntop), NULL, 0, flags)) != 0) { |
|
|
return -1; |
return -1; |
} |
} |
} |
} |
|
|
|
/* Unix domain sockets don't have a port number. */ |
|
if (from.ss_family == AF_UNIX) |
|
return 0; |
|
|
/* Return port number. */ |
/* Return port number. */ |
if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, |
if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, |
strport, sizeof(strport), NI_NUMERICSERV)) != 0) |
strport, sizeof(strport), NI_NUMERICSERV)) != 0) |