mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
Handle pretty printing of IPv6 socket names.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1013 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
519aa9b2ef
commit
7582f7493b
1 changed files with 17 additions and 0 deletions
|
|
@ -56,6 +56,13 @@
|
||||||
#ifdef HAVE_NETDB_H
|
#ifdef HAVE_NETDB_H
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_ARPA_INET_H
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_INET_NTOP
|
||||||
|
#include "inet_ntop.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "winsock.h"
|
#include "winsock.h"
|
||||||
|
|
||||||
|
|
@ -85,6 +92,7 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
|
||||||
union {
|
union {
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
struct sockaddr_in in;
|
struct sockaddr_in in;
|
||||||
|
struct sockaddr_in6 in6;
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
struct sockaddr_un un;
|
struct sockaddr_un un;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -103,6 +111,15 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
|
||||||
ip & 0xFF,
|
ip & 0xFF,
|
||||||
ntohs(sa.in.sin_port));
|
ntohs(sa.in.sin_port));
|
||||||
return;
|
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
|
#ifdef HAVE_SYS_UN_H
|
||||||
} else if (sa.sa.sa_family == AF_UNIX) {
|
} else if (sa.sa.sa_family == AF_UNIX) {
|
||||||
snprintf(c, l, "UNIX socket client");
|
snprintf(c, l, "UNIX socket client");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue