From 4d73fa23b36fc2a0328f1213dcb3b4874ae9b0a7 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Mon, 28 Dec 2015 15:18:09 +0000 Subject: [PATCH 1/2] Prefer to use a public ipv6 number where privacy extensions are enabled --- rtp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rtp.c b/rtp.c index 78a19a36..0e4f1aaf 100644 --- a/rtp.c +++ b/rtp.c @@ -41,6 +41,10 @@ #include "player.h" #include "rtp.h" +#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN +#include +#endif + typedef struct { uint32_t seconds; uint32_t fraction; @@ -524,6 +528,19 @@ static int bind_port(SOCKADDR *remote, int *sock) { die("failed to get usable addrinfo?! %s.", gai_strerror(ret)); *sock = socket(remote->SAFAMILY, SOCK_DGRAM, IPPROTO_UDP); + + #ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN + #ifdef AF_INET6 + // now, if we are on IPv6, prefer a public ipv6 address + if (remote->SAFAMILY==AF_INET6) { + int value = IPV6_PREFER_SRC_PUBLIC; + ret = setsockopt(*sock, IPPROTO_IPV6, IPV6_ADDR_PREFERENCES, &value, sizeof(value)); + if (ret<0) + die("error: could not select a preference for public IPv6 address"); + } + #endif + #endif + ret = bind(*sock, info->ai_addr, info->ai_addrlen); freeaddrinfo(info); From b8b5b7fa1ef949698a24bdc6ccaa094999056b70 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Mon, 28 Dec 2015 20:38:51 +0000 Subject: [PATCH 2/2] Restore ability to compile in FreeBSD --- common.h | 7 ++++++- rtp.c | 4 ++-- shairport.c | 12 ++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/common.h b/common.h index 01ce9de0..4f67cd47 100644 --- a/common.h +++ b/common.h @@ -2,7 +2,6 @@ #define _COMMON_H #include -#include #include #include @@ -33,6 +32,12 @@ #define SAFAMILY sa_family #endif +enum endian_type { + SS_LITTLE_ENDIAN = 0, + SS_PDP_ENDIAN, + SS_BIG_ENDIAN, +} endian_type; + enum stuffing_type { ST_basic = 0, ST_soxr, diff --git a/rtp.c b/rtp.c index 0e4f1aaf..328b9f41 100644 --- a/rtp.c +++ b/rtp.c @@ -41,7 +41,7 @@ #include "player.h" #include "rtp.h" -#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN +#if defined(__linux__) #include #endif @@ -529,7 +529,7 @@ static int bind_port(SOCKADDR *remote, int *sock) { *sock = socket(remote->SAFAMILY, SOCK_DGRAM, IPPROTO_UDP); - #ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN + #if defined(__linux__) #ifdef AF_INET6 // now, if we are on IPv6, prefer a public ipv6 address if (remote->SAFAMILY==AF_INET6) { diff --git a/shairport.c b/shairport.c index 20fce74b..e6286891 100644 --- a/shairport.c +++ b/shairport.c @@ -655,11 +655,11 @@ int main(int argc, char **argv) { xn.arr[3] = 0x11; /* Highest-address byte */ if (xn.u32==0x11223344) - endianness = __LITTLE_ENDIAN; + endianness = SS_LITTLE_ENDIAN; else if (xn.u32==0x33441122) - endianness = __PDP_ENDIAN; + endianness = SS_PDP_ENDIAN; else if (xn.u32==0x44332211) - endianness = __BIG_ENDIAN; + endianness = SS_BIG_ENDIAN; else die("Can not recognise the endianness of the processor."); strcpy(configuration_file_path, "/etc/"); @@ -854,13 +854,13 @@ int main(int argc, char **argv) { daemon_log(LOG_NOTICE, "startup"); switch (endianness) { - case __LITTLE_ENDIAN: + case SS_LITTLE_ENDIAN: debug(2,"The processor is running little-endian."); break; - case __BIG_ENDIAN: + case SS_BIG_ENDIAN: debug(2,"The processor is running big-endian."); break; - case __PDP_ENDIAN: + case SS_PDP_ENDIAN: debug(2,"The processor is running pdp-endian."); break; }