summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2006-06-13 09:33:04 +0000
committerPierre Ossman <ossman@cendio.se>2006-06-13 09:33:04 +0000
commit7582f7493b4103dcc1442c511d856cb616409078 (patch)
treeff48db3de8719e3f26ef15dd201d1d782ddf170d /src
parent519aa9b2ef4ec1fdbbc746f753240113423e1b21 (diff)
Handle pretty printing of IPv6 socket names.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1013 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src')
-rw-r--r--src/polypcore/socket-util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/polypcore/socket-util.c b/src/polypcore/socket-util.c
index aefcb5ef..3cd205db 100644
--- a/src/polypcore/socket-util.c
+++ b/src/polypcore/socket-util.c
@@ -56,6 +56,13 @@
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+#ifndef HAVE_INET_NTOP
+#include "inet_ntop.h"
+#endif
#include "winsock.h"
@@ -85,6 +92,7 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
union {
struct sockaddr sa;
struct sockaddr_in in;
+ struct sockaddr_in6 in6;
#ifdef HAVE_SYS_UN_H
struct sockaddr_un un;
#endif
@@ -103,6 +111,15 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
ip & 0xFF,
ntohs(sa.in.sin_port));
return;
+ } else if (sa.sa.sa_family == AF_INET6) {
+ char buf[INET6_ADDRSTRLEN];
+ const char *res;
+
+ res = inet_ntop(AF_INET6, &sa.in6.sin6_addr, buf, sizeof(buf));
+ if (res) {
+ snprintf(c, l, "TCP/IP client from [%s]:%u", buf, ntohs(sa.in6.sin6_port));
+ return;
+ }
#ifdef HAVE_SYS_UN_H
} else if (sa.sa.sa_family == AF_UNIX) {
snprintf(c, l, "UNIX socket client");