kernel-pfroute: Check for RTM_IFANNOUNCE availability
authorMartin Willi <martin@revosec.ch>
Tue, 14 Oct 2014 09:40:43 +0000 (11:40 +0200)
committerMartin Willi <martin@revosec.ch>
Tue, 14 Oct 2014 14:33:10 +0000 (16:33 +0200)
This message is not available on OS X.

configure.ac
src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c

index dab78a9..7a3524a 100644 (file)
@@ -629,6 +629,18 @@ AC_COMPILE_IFELSE(
        [AC_MSG_RESULT([no])]
 )
 
+AC_MSG_CHECKING([for RTM_IFANNOUNCE])
+AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+               [[#include <sys/socket.h>
+                 #include <net/if.h>
+                 #include <net/route.h>]],
+               [[return RTM_IFANNOUNCE;]])],
+       [AC_MSG_RESULT([yes]);
+        AC_DEFINE([HAVE_RTM_IFANNOUNCE], [], [have PF_ROUTE RTM_IFANNOUNCE defined])],
+       [AC_MSG_RESULT([no])]
+)
+
 AC_MSG_CHECKING([for IPSEC_MODE_BEET])
 AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
index 8121969..26fae0d 100644 (file)
@@ -875,6 +875,8 @@ static void process_link(private_kernel_pfroute_net_t *this,
        }
 }
 
+#ifdef HAVE_RTM_IFANNOUNCE
+
 /**
  * Process an RTM_IFANNOUNCE message from the kernel
  */
@@ -906,6 +908,8 @@ static void process_announce(private_kernel_pfroute_net_t *this,
        this->lock->unlock(this->lock);
 }
 
+#endif /* HAVE_RTM_IFANNOUNCE */
+
 /**
  * Process an RTM_*ROUTE message from the kernel
  */
@@ -926,7 +930,9 @@ static bool receive_events(private_kernel_pfroute_net_t *this, int fd,
                        struct rt_msghdr rtm;
                        struct if_msghdr ifm;
                        struct ifa_msghdr ifam;
+#ifdef HAVE_RTM_IFANNOUNCE
                        struct if_announcemsghdr ifanm;
+#endif
                };
                char buf[sizeof(struct sockaddr_storage) * RTAX_MAX];
        } msg;
@@ -967,9 +973,11 @@ static bool receive_events(private_kernel_pfroute_net_t *this, int fd,
                case RTM_IFINFO:
                        hdrlen = sizeof(msg.ifm);
                        break;
+#ifdef HAVE_RTM_IFANNOUNCE
                case RTM_IFANNOUNCE:
                        hdrlen = sizeof(msg.ifanm);
                        break;
+#endif /* HAVE_RTM_IFANNOUNCE */
                case RTM_ADD:
                case RTM_DELETE:
                case RTM_GET:
@@ -992,9 +1000,11 @@ static bool receive_events(private_kernel_pfroute_net_t *this, int fd,
                case RTM_IFINFO:
                        process_link(this, &msg.ifm);
                        break;
+#ifdef HAVE_RTM_IFANNOUNCE
                case RTM_IFANNOUNCE:
                        process_announce(this, &msg.ifanm);
                        break;
+#endif /* HAVE_RTM_IFANNOUNCE */
                case RTM_ADD:
                case RTM_DELETE:
                        process_route(this, &msg.rtm);