From e4884b5f216156ed5eeecbc49f80b0971fb544ef Mon Sep 17 00:00:00 2001 From: Max Lv Date: Mon, 20 Mar 2017 09:05:12 +0800 Subject: [PATCH] Fix IPV6_RECVORIGDSTADDR. #1368 --- src/udprelay.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/udprelay.c b/src/udprelay.c index 3c26eda4..571eb2c3 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -140,8 +140,20 @@ set_nosigpipe(int socket_fd) #endif #ifndef IP_RECVORIGDSTADDR +#ifdef IP_ORIGDSTADDR +#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR +#else #define IP_RECVORIGDSTADDR 20 #endif +#endif + +#ifndef IPV6_RECVORIGDSTADDR +#ifdef IPV6_ORIGDSTADDR +#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR +#else +#define IPV6_RECVORIGDSTADDR 74 +#endif +#endif static int get_dstaddr(struct msghdr *msg, struct sockaddr_storage *dstaddr) @@ -153,7 +165,7 @@ get_dstaddr(struct msghdr *msg, struct sockaddr_storage *dstaddr) memcpy(dstaddr, CMSG_DATA(cmsg), sizeof(struct sockaddr_in)); dstaddr->ss_family = AF_INET; return 0; - } else if (cmsg->cmsg_level == SOL_IPV6 && cmsg->cmsg_type == IP_RECVORIGDSTADDR) { + } else if (cmsg->cmsg_level == SOL_IPV6 && cmsg->cmsg_type == IPV6_RECVORIGDSTADDR) { memcpy(dstaddr, CMSG_DATA(cmsg), sizeof(struct sockaddr_in6)); dstaddr->ss_family = AF_INET6; return 0;