From 2c76375ca3a3b34a2b68f5ad38db9dd597589524 Mon Sep 17 00:00:00 2001 From: Yuval Tal Date: Sun, 29 May 2011 17:05:56 +0300 Subject: [PATCH 1/2] fix situation where ipv6 addresses are actually ipv4 addresses --- shairport.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/shairport.c b/shairport.c index 98407e26..82ee5b3e 100644 --- a/shairport.c +++ b/shairport.c @@ -329,8 +329,20 @@ void handleClient(int pSock, char *pPassword, char *pHWADDR) struct sockaddr_in6 *s = (struct sockaddr_in6 *)&addr; port = ntohs(s->sin6_port); inet_ntop(AF_INET6, &s->sin6_addr, ipstr, sizeof ipstr); - memcpy(ipbin, &s->sin6_addr, 16); - ipbinlen = 16; + + if (s->sin6_addr.__u6_addr.__u6_addr32[0] == 0 && + s->sin6_addr.__u6_addr.__u6_addr32[1] == 0 && + s->sin6_addr.__u6_addr.__u6_addr32[2] == 0xffff0000) + { + // its ipv4... + memcpy(ipbin, &s->sin6_addr.__u6_addr.__u6_addr32[3], 4); + ipbinlen = 4; + } + else + { + memcpy(ipbin, &s->sin6_addr, 16); + ipbinlen = 16; + } } slog(LOG_DEBUG_V, "Peer IP address: %s\n", ipstr); From 272c288dfe2c2e88806f22cdefb68b1587496df5 Mon Sep 17 00:00:00 2001 From: Yuval Tal Date: Sun, 29 May 2011 17:49:05 +0300 Subject: [PATCH 2/2] fix compilation on linux --- shairport.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shairport.c b/shairport.c index 82ee5b3e..6772a44f 100644 --- a/shairport.c +++ b/shairport.c @@ -330,6 +330,10 @@ void handleClient(int pSock, char *pPassword, char *pHWADDR) port = ntohs(s->sin6_port); inet_ntop(AF_INET6, &s->sin6_addr, ipstr, sizeof ipstr); +#ifndef __APPLE__ +#define __u6_addr __in6_u +#endif + if (s->sin6_addr.__u6_addr.__u6_addr32[0] == 0 && s->sin6_addr.__u6_addr.__u6_addr32[1] == 0 && s->sin6_addr.__u6_addr.__u6_addr32[2] == 0xffff0000)