From 3231f2df96705deea09c42525d6a64540d12ec0a Mon Sep 17 00:00:00 2001 From: Albert Zeyer Date: Mon, 30 May 2011 16:52:32 +0200 Subject: [PATCH] more cross platform check --- shairport.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shairport.c b/shairport.c index e27fb10d..bbc126ee 100644 --- a/shairport.c +++ b/shairport.c @@ -330,16 +330,16 @@ 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) + union { + struct sockaddr_in6 s; + unsigned char bin[sizeof(struct sockaddr_in6)]; + } addr; + memcpy(&addr.s, &s->sin6_addr, sizeof(struct sockaddr_in6)); + + if(memcmp(&addr.bin[0], "\x00\x00\x00\x00" "\x00\x00\x00\x00" "\xff\xff\x00\x00", 12) == 0) { // its ipv4... - memcpy(ipbin, &s->sin6_addr.__u6_addr.__u6_addr32[3], 4); + memcpy(ipbin, &addr.bin[12], 4); ipbinlen = 4; } else