summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2014-05-23 10:01:21 +0200
committerMichael Adam <obnox@samba.org>2014-05-26 10:06:20 +0200
commit13ea22cdaac3b5855232f1f59d910b628847ffe2 (patch)
tree988bd6fe43dff04df27748669832c78e89dac890
parentf81b6e84d57a6d40dce96b49cf18d924ab282872 (diff)
downloadsocket_wrapper-13ea22cdaac3b5855232f1f59d910b628847ffe2.tar.gz
socket_wrapper-13ea22cdaac3b5855232f1f59d910b628847ffe2.tar.xz
socket_wrapper-13ea22cdaac3b5855232f1f59d910b628847ffe2.zip
swrap: Check if the in_pktinfo structure is available.
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r--ConfigureChecks.cmake1
-rw-r--r--config.h.cmake1
-rw-r--r--src/socket_wrapper.c2
-rw-r--r--tests/echo_srv.c2
4 files changed, 5 insertions, 1 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 2d4c409..3a31f50 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -82,6 +82,7 @@ endif (UNIX)
set(SWRAP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "socket_wrapper required system libraries")
# STRUCTS
+check_struct_has_member("struct in_pktinfo" ipi_addr "sys/types.h;sys/socket.h;netinet/in.h" HAVE_STRUCT_IN_PKTINFO)
set(CMAKE_REQUIRED_FLAGS -D_GNU_SOURCE)
check_struct_has_member("struct in6_pktinfo" ipi6_addr "sys/types.h;sys/socket.h;netinet/in.h" HAVE_STRUCT_IN6_PKTINFO)
set(CMAKE_REQUIRED_FLAGS)
diff --git a/config.h.cmake b/config.h.cmake
index 57a2f12..02c016e 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -22,6 +22,7 @@
/**************************** STRUCTS ****************************/
+#cmakedefine HAVE_STRUCT_IN_PKTINFO 1
#cmakedefine HAVE_STRUCT_IN6_PKTINFO 1
/************************ STRUCT MEMBERS *************************/
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index f5a7858..56d1d96 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3053,7 +3053,7 @@ static int swrap_msghdr_add_pktinfo(struct socket_info *si,
{
/* Add packet info */
switch (si->pktinfo) {
-#ifdef IP_PKTINFO
+#if defined(IP_PKTINFO) && defined(HAVE_STRUCT_IN_PKTINFO)
case AF_INET: {
struct sockaddr_in *sin;
struct in_pktinfo pkt;
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index 33f2ebd..a7b674d 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -59,7 +59,9 @@ union pktinfo {
#ifdef HAVE_STRUCT_IN6_PKTINFO
struct in6_pktinfo pkt6;
#endif
+#ifdef HAVE_STRUCT_IN_PKTINFO
struct in_pktinfo pkt4;
+#endif
char c;
};