diff --git a/configure.ac b/configure.ac index 91bb331aef..d553ff3532 100644 --- a/configure.ac +++ b/configure.ac @@ -1018,6 +1018,34 @@ [], [AC_DEFINE([HAVE_LIBNET_CAPABILITIES],[1], (libnet_have_capabilities_patch))], [AC_DEFINE([HAVE_LIBNET_CAPABILITIES],[1], (libnet_have_capabilities_patch))]) + + + # check if the argument to libnet_init is char* or const char* + AC_MSG_CHECKING([libnet_init dev type]) + STORECFLAGS="${CFLAGS}" + if test `basename $CC` = "clang"; then + CFLAGS="${CFLAGS} -Werror=incompatible-pointer-types" + else + CFLAGS="${CFLAGS} -Werror" + fi + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [ + #include + #include + ], + [[ + const char dev[32] = ""; + char ebuf[LIBNET_ERRBUF_SIZE]; + (void)libnet_init(LIBNET_LINK, dev, ebuf); + ]])], + [libnet_init_const="yes"], + [libnet_init_const="no"]) + AC_MSG_RESULT($libnet_init_const) + if test "x$libnet_init_const" = "xyes"; then + AC_DEFINE([HAVE_LIBNET_INIT_CONST], [1], [libnet_init takes const argument]) + fi + CFLAGS="${STORECFLAGS}" fi else AC_MSG_RESULT(no) diff --git a/src/respond-reject-libnet11.c b/src/respond-reject-libnet11.c index c52e340c5b..ae238db873 100644 --- a/src/respond-reject-libnet11.c +++ b/src/respond-reject-libnet11.c @@ -51,6 +51,12 @@ #ifdef HAVE_LIBNET11 +#ifndef HAVE_LIBNET_INIT_CONST +#define LIBNET_INIT_CAST (char *) +#else +#define LIBNET_INIT_CAST +#endif + /** set to true in main if we're setting caps. We need it here if we're using * reject rules as libnet 1.1 is not compatible with caps. */ extern int sc_set_caps; @@ -91,7 +97,7 @@ int RejectSendLibnet11L3IPv4TCP(ThreadVars *tv, Packet *p, void *data, int dir) devname = p->livedev->dev; SCLogDebug("Will emit reject packet on dev %s", devname); } - if ((c = libnet_init(LIBNET_RAW4, devname, ebuf)) == NULL) { + if ((c = libnet_init(LIBNET_RAW4, LIBNET_INIT_CAST devname, ebuf)) == NULL) { SCLogError(SC_ERR_LIBNET_INIT,"libnet_init failed: %s", ebuf); return 1; } @@ -216,7 +222,7 @@ int RejectSendLibnet11L3IPv4ICMP(ThreadVars *tv, Packet *p, void *data, int dir) if (IS_SURI_HOST_MODE_SNIFFER_ONLY(host_mode) && (p->livedev)) { devname = p->livedev->dev; } - if ((c = libnet_init(LIBNET_RAW4, devname, ebuf)) == NULL) { + if ((c = libnet_init(LIBNET_RAW4, LIBNET_INIT_CAST devname, ebuf)) == NULL) { SCLogError(SC_ERR_LIBNET_INIT,"libnet_inint failed: %s", ebuf); return 1; } @@ -302,7 +308,7 @@ int RejectSendLibnet11L3IPv6TCP(ThreadVars *tv, Packet *p, void *data, int dir) if (IS_SURI_HOST_MODE_SNIFFER_ONLY(host_mode) && (p->livedev)) { devname = p->livedev->dev; } - if ((c = libnet_init(LIBNET_RAW6, devname, ebuf)) == NULL) { + if ((c = libnet_init(LIBNET_RAW6, LIBNET_INIT_CAST devname, ebuf)) == NULL) { SCLogError(SC_ERR_LIBNET_INIT,"libnet_init failed: %s", ebuf); return 1; } @@ -428,7 +434,7 @@ int RejectSendLibnet11L3IPv6ICMP(ThreadVars *tv, Packet *p, void *data, int dir) if (IS_SURI_HOST_MODE_SNIFFER_ONLY(host_mode) && (p->livedev)) { devname = p->livedev->dev; } - if ((c = libnet_init(LIBNET_RAW6, devname, ebuf)) == NULL) { + if ((c = libnet_init(LIBNET_RAW6, LIBNET_INIT_CAST devname, ebuf)) == NULL) { SCLogError(SC_ERR_LIBNET_INIT,"libnet_inint failed: %s", ebuf); return 1; }