From 6503c0ff04c6b5cc091a9f58b066cf338559ddf7 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Tue, 4 Jun 2024 09:18:00 +0800
Subject: [PATCH] ddsi_udp.c: use ip_mreqn where it is actually available

---
 src/core/ddsi/src/ddsi_udp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git src/core/ddsi/src/ddsi_udp.c src/core/ddsi/src/ddsi_udp.c
index 5ad3b4b8..8089682b 100644
--- src/core/ddsi/src/ddsi_udp.c
+++ src/core/ddsi/src/ddsi_udp.c
@@ -9,6 +9,11 @@
  *
  * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
  */
+
+#ifdef __APPLE__
+#include <AvailabilityMacros.h>
+#endif
+
 #include <assert.h>
 #include <string.h>
 #include "dds/ddsrt/atomics.h"
@@ -385,7 +390,9 @@
 
 static dds_return_t set_mc_options_transmit_ipv4_if (struct ddsi_domaingv const * const gv, struct nn_interface const * const intf, ddsrt_socket_t sock)
 {
-#if (defined(__linux) || defined(__APPLE__)) && !LWIP_SOCKET
+/* ip_mreqn is available on macOS 10.7+ */
+#if ((defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)) \
+  || defined(__linux)) && !LWIP_SOCKET
   if (gv->config.use_multicast_if_mreqn)
   {
     struct ip_mreqn mreqn;
