Description: fix IPv6 ssmping server functionality for new kernels/glibc
 The original implementation used setsockopt with IPV6_PKTINFO to receive
 source/destination addresses, as defined in RFC 2292 (and glibc <= 2.4).
 .
 Unfortunately, it seems that RFC 3542 superseded RFC 2292 in a
 backwards-incompatible way, replacing the setsockopt argument with
 IPV6_RECVPKTINFO.
 .
 Fix this in a backwards-compatible way using #ifdefs; note that the other uses of 
 IPV6_PKTINFO in the code are valid and should stay that way
 .
 This fixes ssmping server functionality for IPv6.
Author: Faidon Liambotis <paravoid@debian.org>
Forwarded: no
Last-Update: 2011-12-05

--- dbeacon-0.3.9.3.orig/dbeacon_posix.cpp
+++ dbeacon-0.3.9.3/dbeacon_posix.cpp
@@ -252,12 +252,19 @@ bool SetHops(int sock, const address &ad
 }
 
 bool RequireToAddress(int sock, const address &addr) {
-#ifdef IPV6_PKTINFO
+#if defined(IPV6_RECVPKTINFO) || defined(IPV6_PKTINFO)
+	int on = 1;
+#endif
+
 	if (addr.family() == AF_INET6) {
-		int on = 1;
+#ifdef IPV6_RECVPKTINFO
+		/* RFC 3542 / glibc >= 2.5 */
+		return setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on)) == 0;
+#elif defined(IPV6_PKTINFO)
+		/* RFC 2292 / glibc <= 2.4 */
 		return setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &on, sizeof(on)) == 0;
-	}
 #endif
+	}
 
 	return true;
 }
